Magellan Linux

Contents of /trunk/kernel-alx/patches-5.4/0110-5.4.11-all-fixes.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3491 - (show annotations) (download)
Mon May 11 14:36:14 2020 UTC (4 years ago) by niro
File size: 203262 byte(s)
-linux-5.4.11
1 diff --git a/Makefile b/Makefile
2 index 726bb3dacd5b..e8963f623568 100644
3 --- a/Makefile
4 +++ b/Makefile
5 @@ -1,7 +1,7 @@
6 # SPDX-License-Identifier: GPL-2.0
7 VERSION = 5
8 PATCHLEVEL = 4
9 -SUBLEVEL = 10
10 +SUBLEVEL = 11
11 EXTRAVERSION =
12 NAME = Kleptomaniac Octopus
13
14 diff --git a/arch/arm/boot/dts/am335x-sancloud-bbe.dts b/arch/arm/boot/dts/am335x-sancloud-bbe.dts
15 index 8678e6e35493..e5fdb7abb0d5 100644
16 --- a/arch/arm/boot/dts/am335x-sancloud-bbe.dts
17 +++ b/arch/arm/boot/dts/am335x-sancloud-bbe.dts
18 @@ -108,7 +108,7 @@
19
20 &cpsw_emac0 {
21 phy-handle = <&ethphy0>;
22 - phy-mode = "rgmii-txid";
23 + phy-mode = "rgmii-id";
24 };
25
26 &i2c0 {
27 diff --git a/arch/arm/boot/dts/am437x-gp-evm.dts b/arch/arm/boot/dts/am437x-gp-evm.dts
28 index cae4500194fe..811c8cae315b 100644
29 --- a/arch/arm/boot/dts/am437x-gp-evm.dts
30 +++ b/arch/arm/boot/dts/am437x-gp-evm.dts
31 @@ -86,7 +86,7 @@
32 };
33
34 lcd0: display {
35 - compatible = "osddisplays,osd057T0559-34ts", "panel-dpi";
36 + compatible = "osddisplays,osd070t1718-19ts", "panel-dpi";
37 label = "lcd";
38
39 backlight = <&lcd_bl>;
40 diff --git a/arch/arm/boot/dts/am43x-epos-evm.dts b/arch/arm/boot/dts/am43x-epos-evm.dts
41 index 95314121d111..078cb473fa7d 100644
42 --- a/arch/arm/boot/dts/am43x-epos-evm.dts
43 +++ b/arch/arm/boot/dts/am43x-epos-evm.dts
44 @@ -42,7 +42,7 @@
45 };
46
47 lcd0: display {
48 - compatible = "osddisplays,osd057T0559-34ts", "panel-dpi";
49 + compatible = "osddisplays,osd070t1718-19ts", "panel-dpi";
50 label = "lcd";
51
52 backlight = <&lcd_bl>;
53 diff --git a/arch/arm/boot/dts/bcm-cygnus.dtsi b/arch/arm/boot/dts/bcm-cygnus.dtsi
54 index 2dac3efc7640..1bc45cfd5453 100644
55 --- a/arch/arm/boot/dts/bcm-cygnus.dtsi
56 +++ b/arch/arm/boot/dts/bcm-cygnus.dtsi
57 @@ -174,8 +174,8 @@
58 mdio: mdio@18002000 {
59 compatible = "brcm,iproc-mdio";
60 reg = <0x18002000 0x8>;
61 - #size-cells = <1>;
62 - #address-cells = <0>;
63 + #size-cells = <0>;
64 + #address-cells = <1>;
65 status = "disabled";
66
67 gphy0: ethernet-phy@0 {
68 diff --git a/arch/arm/boot/dts/bcm283x.dtsi b/arch/arm/boot/dts/bcm283x.dtsi
69 index 2d191fcbc2cc..90125ce19a1b 100644
70 --- a/arch/arm/boot/dts/bcm283x.dtsi
71 +++ b/arch/arm/boot/dts/bcm283x.dtsi
72 @@ -40,7 +40,7 @@
73
74 trips {
75 cpu-crit {
76 - temperature = <80000>;
77 + temperature = <90000>;
78 hysteresis = <0>;
79 type = "critical";
80 };
81 diff --git a/arch/arm/boot/dts/bcm5301x.dtsi b/arch/arm/boot/dts/bcm5301x.dtsi
82 index 372dc1eb88a0..2d9b4dd05830 100644
83 --- a/arch/arm/boot/dts/bcm5301x.dtsi
84 +++ b/arch/arm/boot/dts/bcm5301x.dtsi
85 @@ -353,8 +353,8 @@
86 mdio: mdio@18003000 {
87 compatible = "brcm,iproc-mdio";
88 reg = <0x18003000 0x8>;
89 - #size-cells = <1>;
90 - #address-cells = <0>;
91 + #size-cells = <0>;
92 + #address-cells = <1>;
93 };
94
95 mdio-bus-mux@18003000 {
96 diff --git a/arch/arm/boot/dts/imx6ul-14x14-evk.dtsi b/arch/arm/boot/dts/imx6ul-14x14-evk.dtsi
97 index c2a9dd57e56a..aa86341adaaa 100644
98 --- a/arch/arm/boot/dts/imx6ul-14x14-evk.dtsi
99 +++ b/arch/arm/boot/dts/imx6ul-14x14-evk.dtsi
100 @@ -215,7 +215,7 @@
101 flash0: n25q256a@0 {
102 #address-cells = <1>;
103 #size-cells = <1>;
104 - compatible = "micron,n25q256a";
105 + compatible = "micron,n25q256a", "jedec,spi-nor";
106 spi-max-frequency = <29000000>;
107 spi-rx-bus-width = <4>;
108 spi-tx-bus-width = <4>;
109 diff --git a/arch/arm/configs/exynos_defconfig b/arch/arm/configs/exynos_defconfig
110 index 08db1c83eb2d..736ed7a7bcf8 100644
111 --- a/arch/arm/configs/exynos_defconfig
112 +++ b/arch/arm/configs/exynos_defconfig
113 @@ -348,6 +348,7 @@ CONFIG_PRINTK_TIME=y
114 CONFIG_DYNAMIC_DEBUG=y
115 CONFIG_DEBUG_INFO=y
116 CONFIG_MAGIC_SYSRQ=y
117 +CONFIG_DEBUG_FS=y
118 CONFIG_DEBUG_KERNEL=y
119 CONFIG_SOFTLOCKUP_DETECTOR=y
120 # CONFIG_DETECT_HUNG_TASK is not set
121 diff --git a/arch/arm/configs/imx_v6_v7_defconfig b/arch/arm/configs/imx_v6_v7_defconfig
122 index 0f7381ee0c37..dabb80453249 100644
123 --- a/arch/arm/configs/imx_v6_v7_defconfig
124 +++ b/arch/arm/configs/imx_v6_v7_defconfig
125 @@ -460,6 +460,7 @@ CONFIG_FONT_8x8=y
126 CONFIG_FONT_8x16=y
127 CONFIG_PRINTK_TIME=y
128 CONFIG_MAGIC_SYSRQ=y
129 +CONFIG_DEBUG_FS=y
130 # CONFIG_SCHED_DEBUG is not set
131 CONFIG_PROVE_LOCKING=y
132 # CONFIG_DEBUG_BUGVERBOSE is not set
133 diff --git a/arch/arm/configs/omap2plus_defconfig b/arch/arm/configs/omap2plus_defconfig
134 index 40d7f1a4fc45..4ec69fb8a698 100644
135 --- a/arch/arm/configs/omap2plus_defconfig
136 +++ b/arch/arm/configs/omap2plus_defconfig
137 @@ -552,5 +552,6 @@ CONFIG_DEBUG_INFO=y
138 CONFIG_DEBUG_INFO_SPLIT=y
139 CONFIG_DEBUG_INFO_DWARF4=y
140 CONFIG_MAGIC_SYSRQ=y
141 +CONFIG_DEBUG_FS=y
142 CONFIG_SCHEDSTATS=y
143 # CONFIG_DEBUG_BUGVERBOSE is not set
144 diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c
145 index 354e0e7025ae..1da11bdb1dfb 100644
146 --- a/arch/arm/mach-vexpress/spc.c
147 +++ b/arch/arm/mach-vexpress/spc.c
148 @@ -551,8 +551,9 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
149
150 static int __init ve_spc_clk_init(void)
151 {
152 - int cpu;
153 + int cpu, cluster;
154 struct clk *clk;
155 + bool init_opp_table[MAX_CLUSTERS] = { false };
156
157 if (!info)
158 return 0; /* Continue only if SPC is initialised */
159 @@ -578,8 +579,17 @@ static int __init ve_spc_clk_init(void)
160 continue;
161 }
162
163 + cluster = topology_physical_package_id(cpu_dev->id);
164 + if (init_opp_table[cluster])
165 + continue;
166 +
167 if (ve_init_opp_table(cpu_dev))
168 pr_warn("failed to initialise cpu%d opp table\n", cpu);
169 + else if (dev_pm_opp_set_sharing_cpus(cpu_dev,
170 + topology_core_cpumask(cpu_dev->id)))
171 + pr_warn("failed to mark OPPs shared for cpu%d\n", cpu);
172 + else
173 + init_opp_table[cluster] = true;
174 }
175
176 platform_device_register_simple("vexpress-spc-cpufreq", -1, NULL, 0);
177 diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
178 index 72b9a75976a1..bb960fe2bb64 100644
179 --- a/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
180 +++ b/arch/arm64/boot/dts/freescale/fsl-ls1028a.dtsi
181 @@ -102,7 +102,7 @@
182
183 reboot {
184 compatible ="syscon-reboot";
185 - regmap = <&dcfg>;
186 + regmap = <&rst>;
187 offset = <0xb0>;
188 mask = <0x02>;
189 };
190 @@ -161,6 +161,12 @@
191 big-endian;
192 };
193
194 + rst: syscon@1e60000 {
195 + compatible = "syscon";
196 + reg = <0x0 0x1e60000 0x0 0x10000>;
197 + little-endian;
198 + };
199 +
200 scfg: syscon@1fc0000 {
201 compatible = "fsl,ls1028a-scfg", "syscon";
202 reg = <0x0 0x1fc0000 0x0 0x10000>;
203 @@ -567,7 +573,7 @@
204 0x00010004 0x0000003d
205 0x00010005 0x00000045
206 0x00010006 0x0000004d
207 - 0x00010007 0x00000045
208 + 0x00010007 0x00000055
209 0x00010008 0x0000005e
210 0x00010009 0x00000066
211 0x0001000a 0x0000006e
212 diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
213 index 93f34b4eca25..96f576e9ea46 100644
214 --- a/arch/arm64/kernel/cpu_errata.c
215 +++ b/arch/arm64/kernel/cpu_errata.c
216 @@ -575,6 +575,7 @@ static const struct midr_range spectre_v2_safe_list[] = {
217 MIDR_ALL_VERSIONS(MIDR_CORTEX_A53),
218 MIDR_ALL_VERSIONS(MIDR_CORTEX_A55),
219 MIDR_ALL_VERSIONS(MIDR_BRAHMA_B53),
220 + MIDR_ALL_VERSIONS(MIDR_HISI_TSV110),
221 { /* sentinel */ }
222 };
223
224 diff --git a/arch/mips/net/ebpf_jit.c b/arch/mips/net/ebpf_jit.c
225 index a2405d5f7d1e..561154cbcc40 100644
226 --- a/arch/mips/net/ebpf_jit.c
227 +++ b/arch/mips/net/ebpf_jit.c
228 @@ -604,6 +604,7 @@ static void emit_const_to_reg(struct jit_ctx *ctx, int dst, u64 value)
229 static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx)
230 {
231 int off, b_off;
232 + int tcc_reg;
233
234 ctx->flags |= EBPF_SEEN_TC;
235 /*
236 @@ -616,14 +617,14 @@ static int emit_bpf_tail_call(struct jit_ctx *ctx, int this_idx)
237 b_off = b_imm(this_idx + 1, ctx);
238 emit_instr(ctx, bne, MIPS_R_AT, MIPS_R_ZERO, b_off);
239 /*
240 - * if (--TCC < 0)
241 + * if (TCC-- < 0)
242 * goto out;
243 */
244 /* Delay slot */
245 - emit_instr(ctx, daddiu, MIPS_R_T5,
246 - (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4, -1);
247 + tcc_reg = (ctx->flags & EBPF_TCC_IN_V1) ? MIPS_R_V1 : MIPS_R_S4;
248 + emit_instr(ctx, daddiu, MIPS_R_T5, tcc_reg, -1);
249 b_off = b_imm(this_idx + 1, ctx);
250 - emit_instr(ctx, bltz, MIPS_R_T5, b_off);
251 + emit_instr(ctx, bltz, tcc_reg, b_off);
252 /*
253 * prog = array->ptrs[index];
254 * if (prog == NULL)
255 diff --git a/arch/parisc/include/asm/cmpxchg.h b/arch/parisc/include/asm/cmpxchg.h
256 index f627c37dad9c..ab5c215cf46c 100644
257 --- a/arch/parisc/include/asm/cmpxchg.h
258 +++ b/arch/parisc/include/asm/cmpxchg.h
259 @@ -44,8 +44,14 @@ __xchg(unsigned long x, __volatile__ void *ptr, int size)
260 ** if (((unsigned long)p & 0xf) == 0)
261 ** return __ldcw(p);
262 */
263 -#define xchg(ptr, x) \
264 - ((__typeof__(*(ptr)))__xchg((unsigned long)(x), (ptr), sizeof(*(ptr))))
265 +#define xchg(ptr, x) \
266 +({ \
267 + __typeof__(*(ptr)) __ret; \
268 + __typeof__(*(ptr)) _x_ = (x); \
269 + __ret = (__typeof__(*(ptr))) \
270 + __xchg((unsigned long)_x_, (ptr), sizeof(*(ptr))); \
271 + __ret; \
272 +})
273
274 /* bug catcher for when unsupported size is used - won't link */
275 extern void __cmpxchg_called_with_bad_pointer(void);
276 diff --git a/arch/parisc/include/asm/kexec.h b/arch/parisc/include/asm/kexec.h
277 index a99ea747d7ed..87e174006995 100644
278 --- a/arch/parisc/include/asm/kexec.h
279 +++ b/arch/parisc/include/asm/kexec.h
280 @@ -2,8 +2,6 @@
281 #ifndef _ASM_PARISC_KEXEC_H
282 #define _ASM_PARISC_KEXEC_H
283
284 -#ifdef CONFIG_KEXEC
285 -
286 /* Maximum physical address we can use pages from */
287 #define KEXEC_SOURCE_MEMORY_LIMIT (-1UL)
288 /* Maximum address we can reach in physical address mode */
289 @@ -32,6 +30,4 @@ static inline void crash_setup_regs(struct pt_regs *newregs,
290
291 #endif /* __ASSEMBLY__ */
292
293 -#endif /* CONFIG_KEXEC */
294 -
295 #endif /* _ASM_PARISC_KEXEC_H */
296 diff --git a/arch/parisc/kernel/Makefile b/arch/parisc/kernel/Makefile
297 index 2663c8f8be11..068d90950d93 100644
298 --- a/arch/parisc/kernel/Makefile
299 +++ b/arch/parisc/kernel/Makefile
300 @@ -37,5 +37,5 @@ obj-$(CONFIG_FUNCTION_GRAPH_TRACER) += ftrace.o
301 obj-$(CONFIG_JUMP_LABEL) += jump_label.o
302 obj-$(CONFIG_KGDB) += kgdb.o
303 obj-$(CONFIG_KPROBES) += kprobes.o
304 -obj-$(CONFIG_KEXEC) += kexec.o relocate_kernel.o
305 +obj-$(CONFIG_KEXEC_CORE) += kexec.o relocate_kernel.o
306 obj-$(CONFIG_KEXEC_FILE) += kexec_file.o
307 diff --git a/arch/parisc/kernel/drivers.c b/arch/parisc/kernel/drivers.c
308 index 3b330e58a4f0..a6c9f49c6612 100644
309 --- a/arch/parisc/kernel/drivers.c
310 +++ b/arch/parisc/kernel/drivers.c
311 @@ -810,7 +810,7 @@ EXPORT_SYMBOL(device_to_hwpath);
312 static void walk_native_bus(unsigned long io_io_low, unsigned long io_io_high,
313 struct device *parent);
314
315 -static void walk_lower_bus(struct parisc_device *dev)
316 +static void __init walk_lower_bus(struct parisc_device *dev)
317 {
318 unsigned long io_io_low, io_io_high;
319
320 diff --git a/arch/powerpc/include/asm/spinlock.h b/arch/powerpc/include/asm/spinlock.h
321 index e9a960e28f3c..d6102e34eb21 100644
322 --- a/arch/powerpc/include/asm/spinlock.h
323 +++ b/arch/powerpc/include/asm/spinlock.h
324 @@ -15,6 +15,7 @@
325 *
326 * (the type definitions are in asm/spinlock_types.h)
327 */
328 +#include <linux/jump_label.h>
329 #include <linux/irqflags.h>
330 #ifdef CONFIG_PPC64
331 #include <asm/paca.h>
332 @@ -36,10 +37,12 @@
333 #endif
334
335 #ifdef CONFIG_PPC_PSERIES
336 +DECLARE_STATIC_KEY_FALSE(shared_processor);
337 +
338 #define vcpu_is_preempted vcpu_is_preempted
339 static inline bool vcpu_is_preempted(int cpu)
340 {
341 - if (!firmware_has_feature(FW_FEATURE_SPLPAR))
342 + if (!static_branch_unlikely(&shared_processor))
343 return false;
344 return !!(be32_to_cpu(lppaca_of(cpu).yield_count) & 1);
345 }
346 diff --git a/arch/powerpc/mm/mem.c b/arch/powerpc/mm/mem.c
347 index d30a2e6e68b4..9f5b32163bda 100644
348 --- a/arch/powerpc/mm/mem.c
349 +++ b/arch/powerpc/mm/mem.c
350 @@ -282,6 +282,14 @@ void __init mem_init(void)
351 BUILD_BUG_ON(MMU_PAGE_COUNT > 16);
352
353 #ifdef CONFIG_SWIOTLB
354 + /*
355 + * Some platforms (e.g. 85xx) limit DMA-able memory way below
356 + * 4G. We force memblock to bottom-up mode to ensure that the
357 + * memory allocated in swiotlb_init() is DMA-able.
358 + * As it's the last memblock allocation, no need to reset it
359 + * back to to-down.
360 + */
361 + memblock_set_bottom_up(true);
362 swiotlb_init(0);
363 #endif
364
365 diff --git a/arch/powerpc/platforms/pseries/setup.c b/arch/powerpc/platforms/pseries/setup.c
366 index 0a40201f315f..0c8421dd01ab 100644
367 --- a/arch/powerpc/platforms/pseries/setup.c
368 +++ b/arch/powerpc/platforms/pseries/setup.c
369 @@ -74,6 +74,9 @@
370 #include "pseries.h"
371 #include "../../../../drivers/pci/pci.h"
372
373 +DEFINE_STATIC_KEY_FALSE(shared_processor);
374 +EXPORT_SYMBOL_GPL(shared_processor);
375 +
376 int CMO_PrPSP = -1;
377 int CMO_SecPSP = -1;
378 unsigned long CMO_PageSize = (ASM_CONST(1) << IOMMU_PAGE_SHIFT_4K);
379 @@ -758,6 +761,10 @@ static void __init pSeries_setup_arch(void)
380
381 if (firmware_has_feature(FW_FEATURE_LPAR)) {
382 vpa_init(boot_cpuid);
383 +
384 + if (lppaca_shared_proc(get_lppaca()))
385 + static_branch_enable(&shared_processor);
386 +
387 ppc_md.power_save = pseries_lpar_idle;
388 ppc_md.enable_pmcs = pseries_lpar_enable_pmcs;
389 #ifdef CONFIG_PCI_IOV
390 diff --git a/arch/riscv/net/bpf_jit_comp.c b/arch/riscv/net/bpf_jit_comp.c
391 index 5451ef3845f2..7fbf56aab661 100644
392 --- a/arch/riscv/net/bpf_jit_comp.c
393 +++ b/arch/riscv/net/bpf_jit_comp.c
394 @@ -631,14 +631,14 @@ static int emit_bpf_tail_call(int insn, struct rv_jit_context *ctx)
395 return -1;
396 emit(rv_bgeu(RV_REG_A2, RV_REG_T1, off >> 1), ctx);
397
398 - /* if (--TCC < 0)
399 + /* if (TCC-- < 0)
400 * goto out;
401 */
402 emit(rv_addi(RV_REG_T1, tcc, -1), ctx);
403 off = (tc_ninsn - (ctx->ninsns - start_insn)) << 2;
404 if (is_13b_check(off, insn))
405 return -1;
406 - emit(rv_blt(RV_REG_T1, RV_REG_ZERO, off >> 1), ctx);
407 + emit(rv_blt(tcc, RV_REG_ZERO, off >> 1), ctx);
408
409 /* prog = array->ptrs[index];
410 * if (!prog)
411 diff --git a/arch/s390/purgatory/Makefile b/arch/s390/purgatory/Makefile
412 index bc0d7a0d0394..9de56065f28c 100644
413 --- a/arch/s390/purgatory/Makefile
414 +++ b/arch/s390/purgatory/Makefile
415 @@ -15,8 +15,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS
416 $(obj)/mem.o: $(srctree)/arch/s390/lib/mem.S FORCE
417 $(call if_changed_rule,as_o_S)
418
419 -$(obj)/string.o: $(srctree)/arch/s390/lib/string.c FORCE
420 - $(call if_changed_rule,cc_o_c)
421 +KCOV_INSTRUMENT := n
422 +GCOV_PROFILE := n
423 +UBSAN_SANITIZE := n
424 +KASAN_SANITIZE := n
425
426 KBUILD_CFLAGS := -fno-strict-aliasing -Wall -Wstrict-prototypes
427 KBUILD_CFLAGS += -Wno-pointer-sign -Wno-sign-compare
428 diff --git a/arch/s390/purgatory/string.c b/arch/s390/purgatory/string.c
429 new file mode 100644
430 index 000000000000..c98c22a72db7
431 --- /dev/null
432 +++ b/arch/s390/purgatory/string.c
433 @@ -0,0 +1,3 @@
434 +// SPDX-License-Identifier: GPL-2.0
435 +#define __HAVE_ARCH_MEMCMP /* arch function */
436 +#include "../lib/string.c"
437 diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c
438 index 7b21455d7504..e622158f5659 100644
439 --- a/arch/x86/events/core.c
440 +++ b/arch/x86/events/core.c
441 @@ -375,7 +375,7 @@ int x86_add_exclusive(unsigned int what)
442 * LBR and BTS are still mutually exclusive.
443 */
444 if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt)
445 - return 0;
446 + goto out;
447
448 if (!atomic_inc_not_zero(&x86_pmu.lbr_exclusive[what])) {
449 mutex_lock(&pmc_reserve_mutex);
450 @@ -387,6 +387,7 @@ int x86_add_exclusive(unsigned int what)
451 mutex_unlock(&pmc_reserve_mutex);
452 }
453
454 +out:
455 atomic_inc(&active_events);
456 return 0;
457
458 @@ -397,11 +398,15 @@ fail_unlock:
459
460 void x86_del_exclusive(unsigned int what)
461 {
462 + atomic_dec(&active_events);
463 +
464 + /*
465 + * See the comment in x86_add_exclusive().
466 + */
467 if (x86_pmu.lbr_pt_coexist && what == x86_lbr_exclusive_pt)
468 return;
469
470 atomic_dec(&x86_pmu.lbr_exclusive[what]);
471 - atomic_dec(&active_events);
472 }
473
474 int x86_setup_perfctr(struct perf_event *event)
475 @@ -1641,9 +1646,12 @@ static struct attribute_group x86_pmu_format_group __ro_after_init = {
476
477 ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr, char *page)
478 {
479 - struct perf_pmu_events_attr *pmu_attr = \
480 + struct perf_pmu_events_attr *pmu_attr =
481 container_of(attr, struct perf_pmu_events_attr, attr);
482 - u64 config = x86_pmu.event_map(pmu_attr->id);
483 + u64 config = 0;
484 +
485 + if (pmu_attr->id < x86_pmu.max_events)
486 + config = x86_pmu.event_map(pmu_attr->id);
487
488 /* string trumps id */
489 if (pmu_attr->event_str)
490 @@ -1712,6 +1720,9 @@ is_visible(struct kobject *kobj, struct attribute *attr, int idx)
491 {
492 struct perf_pmu_events_attr *pmu_attr;
493
494 + if (idx >= x86_pmu.max_events)
495 + return 0;
496 +
497 pmu_attr = container_of(attr, struct perf_pmu_events_attr, attr.attr);
498 /* str trumps id */
499 return pmu_attr->event_str || x86_pmu.event_map(idx) ? attr->mode : 0;
500 diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c
501 index 606711f5ebf8..2f9ec14be3b1 100644
502 --- a/arch/x86/kernel/early-quirks.c
503 +++ b/arch/x86/kernel/early-quirks.c
504 @@ -714,6 +714,8 @@ static struct chipset early_qrk[] __initdata = {
505 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
506 { PCI_VENDOR_ID_INTEL, 0x3ec4,
507 PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
508 + { PCI_VENDOR_ID_INTEL, 0x8a12,
509 + PCI_CLASS_BRIDGE_HOST, PCI_ANY_ID, 0, force_disable_hpet},
510 { PCI_VENDOR_ID_BROADCOM, 0x4331,
511 PCI_CLASS_NETWORK_OTHER, PCI_ANY_ID, 0, apple_airport_reset},
512 {}
513 diff --git a/arch/x86/platform/efi/quirks.c b/arch/x86/platform/efi/quirks.c
514 index 3b9fd679cea9..aefe845dff59 100644
515 --- a/arch/x86/platform/efi/quirks.c
516 +++ b/arch/x86/platform/efi/quirks.c
517 @@ -260,10 +260,6 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
518 return;
519 }
520
521 - /* No need to reserve regions that will never be freed. */
522 - if (md.attribute & EFI_MEMORY_RUNTIME)
523 - return;
524 -
525 size += addr % EFI_PAGE_SIZE;
526 size = round_up(size, EFI_PAGE_SIZE);
527 addr = round_down(addr, EFI_PAGE_SIZE);
528 @@ -293,6 +289,8 @@ void __init efi_arch_mem_reserve(phys_addr_t addr, u64 size)
529 early_memunmap(new, new_size);
530
531 efi_memmap_install(new_phys, num_entries);
532 + e820__range_update(addr, size, E820_TYPE_RAM, E820_TYPE_RESERVED);
533 + e820__update_table(e820_table);
534 }
535
536 /*
537 diff --git a/block/blk-core.c b/block/blk-core.c
538 index d5e668ec751b..1075aaff606d 100644
539 --- a/block/blk-core.c
540 +++ b/block/blk-core.c
541 @@ -886,11 +886,14 @@ generic_make_request_checks(struct bio *bio)
542 }
543
544 /*
545 - * For a REQ_NOWAIT based request, return -EOPNOTSUPP
546 - * if queue is not a request based queue.
547 + * Non-mq queues do not honor REQ_NOWAIT, so complete a bio
548 + * with BLK_STS_AGAIN status in order to catch -EAGAIN and
549 + * to give a chance to the caller to repeat request gracefully.
550 */
551 - if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q))
552 - goto not_supported;
553 + if ((bio->bi_opf & REQ_NOWAIT) && !queue_is_mq(q)) {
554 + status = BLK_STS_AGAIN;
555 + goto end_io;
556 + }
557
558 if (should_fail_bio(bio))
559 goto end_io;
560 diff --git a/block/blk-flush.c b/block/blk-flush.c
561 index 1eec9cbe5a0a..b1f0a1ac505c 100644
562 --- a/block/blk-flush.c
563 +++ b/block/blk-flush.c
564 @@ -69,6 +69,7 @@
565 #include <linux/blkdev.h>
566 #include <linux/gfp.h>
567 #include <linux/blk-mq.h>
568 +#include <linux/lockdep.h>
569
570 #include "blk.h"
571 #include "blk-mq.h"
572 @@ -492,6 +493,9 @@ struct blk_flush_queue *blk_alloc_flush_queue(struct request_queue *q,
573 INIT_LIST_HEAD(&fq->flush_queue[1]);
574 INIT_LIST_HEAD(&fq->flush_data_in_flight);
575
576 + lockdep_register_key(&fq->key);
577 + lockdep_set_class(&fq->mq_flush_lock, &fq->key);
578 +
579 return fq;
580
581 fail_rq:
582 @@ -506,6 +510,7 @@ void blk_free_flush_queue(struct blk_flush_queue *fq)
583 if (!fq)
584 return;
585
586 + lockdep_unregister_key(&fq->key);
587 kfree(fq->flush_rq);
588 kfree(fq);
589 }
590 diff --git a/block/blk-map.c b/block/blk-map.c
591 index 3a62e471d81b..b0790268ed9d 100644
592 --- a/block/blk-map.c
593 +++ b/block/blk-map.c
594 @@ -151,7 +151,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq,
595 return 0;
596
597 unmap_rq:
598 - __blk_rq_unmap_user(bio);
599 + blk_rq_unmap_user(bio);
600 fail:
601 rq->bio = NULL;
602 return ret;
603 diff --git a/block/blk.h b/block/blk.h
604 index 47fba9362e60..ffea1691470e 100644
605 --- a/block/blk.h
606 +++ b/block/blk.h
607 @@ -30,6 +30,7 @@ struct blk_flush_queue {
608 * at the same time
609 */
610 struct request *orig_rq;
611 + struct lock_class_key key;
612 spinlock_t mq_flush_lock;
613 };
614
615 diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c
616 index 2b6670daf7fc..34bd9bf4e68a 100644
617 --- a/drivers/bus/ti-sysc.c
618 +++ b/drivers/bus/ti-sysc.c
619 @@ -1594,6 +1594,10 @@ static int sysc_reset(struct sysc *ddata)
620 sysc_val |= sysc_mask;
621 sysc_write(ddata, sysc_offset, sysc_val);
622
623 + if (ddata->cfg.srst_udelay)
624 + usleep_range(ddata->cfg.srst_udelay,
625 + ddata->cfg.srst_udelay * 2);
626 +
627 if (ddata->clk_enable_quirk)
628 ddata->clk_enable_quirk(ddata);
629
630 diff --git a/drivers/char/tpm/tpm_ftpm_tee.c b/drivers/char/tpm/tpm_ftpm_tee.c
631 index 6640a14dbe48..22bf553ccf9d 100644
632 --- a/drivers/char/tpm/tpm_ftpm_tee.c
633 +++ b/drivers/char/tpm/tpm_ftpm_tee.c
634 @@ -32,7 +32,7 @@ static const uuid_t ftpm_ta_uuid =
635 0x82, 0xCB, 0x34, 0x3F, 0xB7, 0xF3, 0x78, 0x96);
636
637 /**
638 - * ftpm_tee_tpm_op_recv - retrieve fTPM response.
639 + * ftpm_tee_tpm_op_recv() - retrieve fTPM response.
640 * @chip: the tpm_chip description as specified in driver/char/tpm/tpm.h.
641 * @buf: the buffer to store data.
642 * @count: the number of bytes to read.
643 @@ -61,7 +61,7 @@ static int ftpm_tee_tpm_op_recv(struct tpm_chip *chip, u8 *buf, size_t count)
644 }
645
646 /**
647 - * ftpm_tee_tpm_op_send - send TPM commands through the TEE shared memory.
648 + * ftpm_tee_tpm_op_send() - send TPM commands through the TEE shared memory.
649 * @chip: the tpm_chip description as specified in driver/char/tpm/tpm.h
650 * @buf: the buffer to send.
651 * @len: the number of bytes to send.
652 @@ -208,7 +208,7 @@ static int ftpm_tee_match(struct tee_ioctl_version_data *ver, const void *data)
653 }
654
655 /**
656 - * ftpm_tee_probe - initialize the fTPM
657 + * ftpm_tee_probe() - initialize the fTPM
658 * @pdev: the platform_device description.
659 *
660 * Return:
661 @@ -298,7 +298,7 @@ out_tee_session:
662 }
663
664 /**
665 - * ftpm_tee_remove - remove the TPM device
666 + * ftpm_tee_remove() - remove the TPM device
667 * @pdev: the platform_device description.
668 *
669 * Return:
670 @@ -328,6 +328,19 @@ static int ftpm_tee_remove(struct platform_device *pdev)
671 return 0;
672 }
673
674 +/**
675 + * ftpm_tee_shutdown() - shutdown the TPM device
676 + * @pdev: the platform_device description.
677 + */
678 +static void ftpm_tee_shutdown(struct platform_device *pdev)
679 +{
680 + struct ftpm_tee_private *pvt_data = dev_get_drvdata(&pdev->dev);
681 +
682 + tee_shm_free(pvt_data->shm);
683 + tee_client_close_session(pvt_data->ctx, pvt_data->session);
684 + tee_client_close_context(pvt_data->ctx);
685 +}
686 +
687 static const struct of_device_id of_ftpm_tee_ids[] = {
688 { .compatible = "microsoft,ftpm" },
689 { }
690 @@ -341,6 +354,7 @@ static struct platform_driver ftpm_tee_driver = {
691 },
692 .probe = ftpm_tee_probe,
693 .remove = ftpm_tee_remove,
694 + .shutdown = ftpm_tee_shutdown,
695 };
696
697 module_platform_driver(ftpm_tee_driver);
698 diff --git a/drivers/clk/at91/at91sam9260.c b/drivers/clk/at91/at91sam9260.c
699 index 0aabe49aed09..a9d4234758d7 100644
700 --- a/drivers/clk/at91/at91sam9260.c
701 +++ b/drivers/clk/at91/at91sam9260.c
702 @@ -348,7 +348,7 @@ static void __init at91sam926x_pmc_setup(struct device_node *np,
703 return;
704 mainxtal_name = of_clk_get_parent_name(np, i);
705
706 - regmap = syscon_node_to_regmap(np);
707 + regmap = device_node_to_regmap(np);
708 if (IS_ERR(regmap))
709 return;
710
711 diff --git a/drivers/clk/at91/at91sam9rl.c b/drivers/clk/at91/at91sam9rl.c
712 index 0ac34cdaa106..77fe83a73bf4 100644
713 --- a/drivers/clk/at91/at91sam9rl.c
714 +++ b/drivers/clk/at91/at91sam9rl.c
715 @@ -83,7 +83,7 @@ static void __init at91sam9rl_pmc_setup(struct device_node *np)
716 return;
717 mainxtal_name = of_clk_get_parent_name(np, i);
718
719 - regmap = syscon_node_to_regmap(np);
720 + regmap = device_node_to_regmap(np);
721 if (IS_ERR(regmap))
722 return;
723
724 diff --git a/drivers/clk/at91/at91sam9x5.c b/drivers/clk/at91/at91sam9x5.c
725 index 0855f3a80cc7..086cf0b4955c 100644
726 --- a/drivers/clk/at91/at91sam9x5.c
727 +++ b/drivers/clk/at91/at91sam9x5.c
728 @@ -146,7 +146,7 @@ static void __init at91sam9x5_pmc_setup(struct device_node *np,
729 return;
730 mainxtal_name = of_clk_get_parent_name(np, i);
731
732 - regmap = syscon_node_to_regmap(np);
733 + regmap = device_node_to_regmap(np);
734 if (IS_ERR(regmap))
735 return;
736
737 diff --git a/drivers/clk/at91/pmc.c b/drivers/clk/at91/pmc.c
738 index 0b03cfae3a9d..b71515acdec1 100644
739 --- a/drivers/clk/at91/pmc.c
740 +++ b/drivers/clk/at91/pmc.c
741 @@ -275,7 +275,7 @@ static int __init pmc_register_ops(void)
742
743 np = of_find_matching_node(NULL, sama5d2_pmc_dt_ids);
744
745 - pmcreg = syscon_node_to_regmap(np);
746 + pmcreg = device_node_to_regmap(np);
747 if (IS_ERR(pmcreg))
748 return PTR_ERR(pmcreg);
749
750 diff --git a/drivers/clk/at91/sama5d2.c b/drivers/clk/at91/sama5d2.c
751 index 0de1108737db..ff7e3f727082 100644
752 --- a/drivers/clk/at91/sama5d2.c
753 +++ b/drivers/clk/at91/sama5d2.c
754 @@ -162,7 +162,7 @@ static void __init sama5d2_pmc_setup(struct device_node *np)
755 return;
756 mainxtal_name = of_clk_get_parent_name(np, i);
757
758 - regmap = syscon_node_to_regmap(np);
759 + regmap = device_node_to_regmap(np);
760 if (IS_ERR(regmap))
761 return;
762
763 diff --git a/drivers/clk/at91/sama5d4.c b/drivers/clk/at91/sama5d4.c
764 index 25b156d4e645..a6dee4a3b6e4 100644
765 --- a/drivers/clk/at91/sama5d4.c
766 +++ b/drivers/clk/at91/sama5d4.c
767 @@ -136,7 +136,7 @@ static void __init sama5d4_pmc_setup(struct device_node *np)
768 return;
769 mainxtal_name = of_clk_get_parent_name(np, i);
770
771 - regmap = syscon_node_to_regmap(np);
772 + regmap = device_node_to_regmap(np);
773 if (IS_ERR(regmap))
774 return;
775
776 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c
777 index 1c677d7f7f53..27a95c86a80b 100644
778 --- a/drivers/clk/clk.c
779 +++ b/drivers/clk/clk.c
780 @@ -3231,6 +3231,34 @@ static inline void clk_debug_unregister(struct clk_core *core)
781 }
782 #endif
783
784 +static void clk_core_reparent_orphans_nolock(void)
785 +{
786 + struct clk_core *orphan;
787 + struct hlist_node *tmp2;
788 +
789 + /*
790 + * walk the list of orphan clocks and reparent any that newly finds a
791 + * parent.
792 + */
793 + hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
794 + struct clk_core *parent = __clk_init_parent(orphan);
795 +
796 + /*
797 + * We need to use __clk_set_parent_before() and _after() to
798 + * to properly migrate any prepare/enable count of the orphan
799 + * clock. This is important for CLK_IS_CRITICAL clocks, which
800 + * are enabled during init but might not have a parent yet.
801 + */
802 + if (parent) {
803 + /* update the clk tree topology */
804 + __clk_set_parent_before(orphan, parent);
805 + __clk_set_parent_after(orphan, parent, NULL);
806 + __clk_recalc_accuracies(orphan);
807 + __clk_recalc_rates(orphan, 0);
808 + }
809 + }
810 +}
811 +
812 /**
813 * __clk_core_init - initialize the data structures in a struct clk_core
814 * @core: clk_core being initialized
815 @@ -3241,8 +3269,6 @@ static inline void clk_debug_unregister(struct clk_core *core)
816 static int __clk_core_init(struct clk_core *core)
817 {
818 int ret;
819 - struct clk_core *orphan;
820 - struct hlist_node *tmp2;
821 unsigned long rate;
822
823 if (!core)
824 @@ -3389,27 +3415,8 @@ static int __clk_core_init(struct clk_core *core)
825 clk_enable_unlock(flags);
826 }
827
828 - /*
829 - * walk the list of orphan clocks and reparent any that newly finds a
830 - * parent.
831 - */
832 - hlist_for_each_entry_safe(orphan, tmp2, &clk_orphan_list, child_node) {
833 - struct clk_core *parent = __clk_init_parent(orphan);
834 + clk_core_reparent_orphans_nolock();
835
836 - /*
837 - * We need to use __clk_set_parent_before() and _after() to
838 - * to properly migrate any prepare/enable count of the orphan
839 - * clock. This is important for CLK_IS_CRITICAL clocks, which
840 - * are enabled during init but might not have a parent yet.
841 - */
842 - if (parent) {
843 - /* update the clk tree topology */
844 - __clk_set_parent_before(orphan, parent);
845 - __clk_set_parent_after(orphan, parent, NULL);
846 - __clk_recalc_accuracies(orphan);
847 - __clk_recalc_rates(orphan, 0);
848 - }
849 - }
850
851 kref_init(&core->ref);
852 out:
853 @@ -4160,6 +4167,13 @@ int clk_notifier_unregister(struct clk *clk, struct notifier_block *nb)
854 EXPORT_SYMBOL_GPL(clk_notifier_unregister);
855
856 #ifdef CONFIG_OF
857 +static void clk_core_reparent_orphans(void)
858 +{
859 + clk_prepare_lock();
860 + clk_core_reparent_orphans_nolock();
861 + clk_prepare_unlock();
862 +}
863 +
864 /**
865 * struct of_clk_provider - Clock provider registration structure
866 * @link: Entry in global list of clock providers
867 @@ -4255,6 +4269,8 @@ int of_clk_add_provider(struct device_node *np,
868 mutex_unlock(&of_clk_mutex);
869 pr_debug("Added clock from %pOF\n", np);
870
871 + clk_core_reparent_orphans();
872 +
873 ret = of_clk_set_defaults(np, true);
874 if (ret < 0)
875 of_clk_del_provider(np);
876 @@ -4290,6 +4306,8 @@ int of_clk_add_hw_provider(struct device_node *np,
877 mutex_unlock(&of_clk_mutex);
878 pr_debug("Added clk_hw provider from %pOF\n", np);
879
880 + clk_core_reparent_orphans();
881 +
882 ret = of_clk_set_defaults(np, true);
883 if (ret < 0)
884 of_clk_del_provider(np);
885 diff --git a/drivers/firmware/efi/earlycon.c b/drivers/firmware/efi/earlycon.c
886 index c9a0efca17b0..d4077db6dc97 100644
887 --- a/drivers/firmware/efi/earlycon.c
888 +++ b/drivers/firmware/efi/earlycon.c
889 @@ -13,18 +13,57 @@
890
891 #include <asm/early_ioremap.h>
892
893 +static const struct console *earlycon_console __initdata;
894 static const struct font_desc *font;
895 static u32 efi_x, efi_y;
896 static u64 fb_base;
897 static pgprot_t fb_prot;
898 +static void *efi_fb;
899 +
900 +/*
901 + * EFI earlycon needs to use early_memremap() to map the framebuffer.
902 + * But early_memremap() is not usable for 'earlycon=efifb keep_bootcon',
903 + * memremap() should be used instead. memremap() will be available after
904 + * paging_init() which is earlier than initcall callbacks. Thus adding this
905 + * early initcall function early_efi_map_fb() to map the whole EFI framebuffer.
906 + */
907 +static int __init efi_earlycon_remap_fb(void)
908 +{
909 + /* bail if there is no bootconsole or it has been disabled already */
910 + if (!earlycon_console || !(earlycon_console->flags & CON_ENABLED))
911 + return 0;
912 +
913 + if (pgprot_val(fb_prot) == pgprot_val(PAGE_KERNEL))
914 + efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WB);
915 + else
916 + efi_fb = memremap(fb_base, screen_info.lfb_size, MEMREMAP_WC);
917 +
918 + return efi_fb ? 0 : -ENOMEM;
919 +}
920 +early_initcall(efi_earlycon_remap_fb);
921 +
922 +static int __init efi_earlycon_unmap_fb(void)
923 +{
924 + /* unmap the bootconsole fb unless keep_bootcon has left it enabled */
925 + if (efi_fb && !(earlycon_console->flags & CON_ENABLED))
926 + memunmap(efi_fb);
927 + return 0;
928 +}
929 +late_initcall(efi_earlycon_unmap_fb);
930
931 static __ref void *efi_earlycon_map(unsigned long start, unsigned long len)
932 {
933 + if (efi_fb)
934 + return efi_fb + start;
935 +
936 return early_memremap_prot(fb_base + start, len, pgprot_val(fb_prot));
937 }
938
939 static __ref void efi_earlycon_unmap(void *addr, unsigned long len)
940 {
941 + if (efi_fb)
942 + return;
943 +
944 early_memunmap(addr, len);
945 }
946
947 @@ -201,6 +240,7 @@ static int __init efi_earlycon_setup(struct earlycon_device *device,
948 efi_earlycon_scroll_up();
949
950 device->con->write = efi_earlycon_write;
951 + earlycon_console = device->con;
952 return 0;
953 }
954 EARLYCON_DECLARE(efifb, efi_earlycon_setup);
955 diff --git a/drivers/firmware/efi/libstub/gop.c b/drivers/firmware/efi/libstub/gop.c
956 index 0101ca4c13b1..b7bf1e993b8b 100644
957 --- a/drivers/firmware/efi/libstub/gop.c
958 +++ b/drivers/firmware/efi/libstub/gop.c
959 @@ -83,30 +83,6 @@ setup_pixel_info(struct screen_info *si, u32 pixels_per_scan_line,
960 }
961 }
962
963 -static efi_status_t
964 -__gop_query32(efi_system_table_t *sys_table_arg,
965 - struct efi_graphics_output_protocol_32 *gop32,
966 - struct efi_graphics_output_mode_info **info,
967 - unsigned long *size, u64 *fb_base)
968 -{
969 - struct efi_graphics_output_protocol_mode_32 *mode;
970 - efi_graphics_output_protocol_query_mode query_mode;
971 - efi_status_t status;
972 - unsigned long m;
973 -
974 - m = gop32->mode;
975 - mode = (struct efi_graphics_output_protocol_mode_32 *)m;
976 - query_mode = (void *)(unsigned long)gop32->query_mode;
977 -
978 - status = __efi_call_early(query_mode, (void *)gop32, mode->mode, size,
979 - info);
980 - if (status != EFI_SUCCESS)
981 - return status;
982 -
983 - *fb_base = mode->frame_buffer_base;
984 - return status;
985 -}
986 -
987 static efi_status_t
988 setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
989 efi_guid_t *proto, unsigned long size, void **gop_handle)
990 @@ -119,7 +95,7 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
991 u64 fb_base;
992 struct efi_pixel_bitmask pixel_info;
993 int pixel_format;
994 - efi_status_t status = EFI_NOT_FOUND;
995 + efi_status_t status;
996 u32 *handles = (u32 *)(unsigned long)gop_handle;
997 int i;
998
999 @@ -128,6 +104,7 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
1000
1001 nr_gops = size / sizeof(u32);
1002 for (i = 0; i < nr_gops; i++) {
1003 + struct efi_graphics_output_protocol_mode_32 *mode;
1004 struct efi_graphics_output_mode_info *info = NULL;
1005 efi_guid_t conout_proto = EFI_CONSOLE_OUT_DEVICE_GUID;
1006 bool conout_found = false;
1007 @@ -145,9 +122,11 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
1008 if (status == EFI_SUCCESS)
1009 conout_found = true;
1010
1011 - status = __gop_query32(sys_table_arg, gop32, &info, &size,
1012 - &current_fb_base);
1013 - if (status == EFI_SUCCESS && (!first_gop || conout_found) &&
1014 + mode = (void *)(unsigned long)gop32->mode;
1015 + info = (void *)(unsigned long)mode->info;
1016 + current_fb_base = mode->frame_buffer_base;
1017 +
1018 + if ((!first_gop || conout_found) &&
1019 info->pixel_format != PIXEL_BLT_ONLY) {
1020 /*
1021 * Systems that use the UEFI Console Splitter may
1022 @@ -175,7 +154,7 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
1023
1024 /* Did we find any GOPs? */
1025 if (!first_gop)
1026 - goto out;
1027 + return EFI_NOT_FOUND;
1028
1029 /* EFI framebuffer */
1030 si->orig_video_isVGA = VIDEO_TYPE_EFI;
1031 @@ -197,32 +176,8 @@ setup_gop32(efi_system_table_t *sys_table_arg, struct screen_info *si,
1032 si->lfb_size = si->lfb_linelength * si->lfb_height;
1033
1034 si->capabilities |= VIDEO_CAPABILITY_SKIP_QUIRKS;
1035 -out:
1036 - return status;
1037 -}
1038 -
1039 -static efi_status_t
1040 -__gop_query64(efi_system_table_t *sys_table_arg,
1041 - struct efi_graphics_output_protocol_64 *gop64,
1042 - struct efi_graphics_output_mode_info **info,
1043 - unsigned long *size, u64 *fb_base)
1044 -{
1045 - struct efi_graphics_output_protocol_mode_64 *mode;
1046 - efi_graphics_output_protocol_query_mode query_mode;
1047 - efi_status_t status;
1048 - unsigned long m;
1049 -
1050 - m = gop64->mode;
1051 - mode = (struct efi_graphics_output_protocol_mode_64 *)m;
1052 - query_mode = (void *)(unsigned long)gop64->query_mode;
1053 -
1054 - status = __efi_call_early(query_mode, (void *)gop64, mode->mode, size,
1055 - info);
1056 - if (status != EFI_SUCCESS)
1057 - return status;
1058
1059 - *fb_base = mode->frame_buffer_base;
1060 - return status;
1061 + return EFI_SUCCESS;
1062 }
1063
1064 static efi_status_t
1065 @@ -237,7 +192,7 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
1066 u64 fb_base;
1067 struct efi_pixel_bitmask pixel_info;
1068 int pixel_format;
1069 - efi_status_t status = EFI_NOT_FOUND;
1070 + efi_status_t status;
1071 u64 *handles = (u64 *)(unsigned long)gop_handle;
1072 int i;
1073
1074 @@ -246,6 +201,7 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
1075
1076 nr_gops = size / sizeof(u64);
1077 for (i = 0; i < nr_gops; i++) {
1078 + struct efi_graphics_output_protocol_mode_64 *mode;
1079 struct efi_graphics_output_mode_info *info = NULL;
1080 efi_guid_t conout_proto = EFI_CONSOLE_OUT_DEVICE_GUID;
1081 bool conout_found = false;
1082 @@ -263,9 +219,11 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
1083 if (status == EFI_SUCCESS)
1084 conout_found = true;
1085
1086 - status = __gop_query64(sys_table_arg, gop64, &info, &size,
1087 - &current_fb_base);
1088 - if (status == EFI_SUCCESS && (!first_gop || conout_found) &&
1089 + mode = (void *)(unsigned long)gop64->mode;
1090 + info = (void *)(unsigned long)mode->info;
1091 + current_fb_base = mode->frame_buffer_base;
1092 +
1093 + if ((!first_gop || conout_found) &&
1094 info->pixel_format != PIXEL_BLT_ONLY) {
1095 /*
1096 * Systems that use the UEFI Console Splitter may
1097 @@ -293,7 +251,7 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
1098
1099 /* Did we find any GOPs? */
1100 if (!first_gop)
1101 - goto out;
1102 + return EFI_NOT_FOUND;
1103
1104 /* EFI framebuffer */
1105 si->orig_video_isVGA = VIDEO_TYPE_EFI;
1106 @@ -315,8 +273,8 @@ setup_gop64(efi_system_table_t *sys_table_arg, struct screen_info *si,
1107 si->lfb_size = si->lfb_linelength * si->lfb_height;
1108
1109 si->capabilities |= VIDEO_CAPABILITY_SKIP_QUIRKS;
1110 -out:
1111 - return status;
1112 +
1113 + return EFI_SUCCESS;
1114 }
1115
1116 /*
1117 diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
1118 index 80ea49f570f4..43ffec3a6fbb 100644
1119 --- a/drivers/gpio/gpiolib-of.c
1120 +++ b/drivers/gpio/gpiolib-of.c
1121 @@ -23,6 +23,29 @@
1122 #include "gpiolib.h"
1123 #include "gpiolib-of.h"
1124
1125 +/**
1126 + * of_gpio_spi_cs_get_count() - special GPIO counting for SPI
1127 + * Some elder GPIO controllers need special quirks. Currently we handle
1128 + * the Freescale GPIO controller with bindings that doesn't use the
1129 + * established "cs-gpios" for chip selects but instead rely on
1130 + * "gpios" for the chip select lines. If we detect this, we redirect
1131 + * the counting of "cs-gpios" to count "gpios" transparent to the
1132 + * driver.
1133 + */
1134 +int of_gpio_spi_cs_get_count(struct device *dev, const char *con_id)
1135 +{
1136 + struct device_node *np = dev->of_node;
1137 +
1138 + if (!IS_ENABLED(CONFIG_SPI_MASTER))
1139 + return 0;
1140 + if (!con_id || strcmp(con_id, "cs"))
1141 + return 0;
1142 + if (!of_device_is_compatible(np, "fsl,spi") &&
1143 + !of_device_is_compatible(np, "aeroflexgaisler,spictrl"))
1144 + return 0;
1145 + return of_gpio_named_count(np, "gpios");
1146 +}
1147 +
1148 /*
1149 * This is used by external users of of_gpio_count() from <linux/of_gpio.h>
1150 *
1151 @@ -35,6 +58,10 @@ int of_gpio_get_count(struct device *dev, const char *con_id)
1152 char propname[32];
1153 unsigned int i;
1154
1155 + ret = of_gpio_spi_cs_get_count(dev, con_id);
1156 + if (ret > 0)
1157 + return ret;
1158 +
1159 for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
1160 if (con_id)
1161 snprintf(propname, sizeof(propname), "%s-%s",
1162 diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1163 index 7ae087b0504d..88b6fcaa20be 100644
1164 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1165 +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c
1166 @@ -1313,6 +1313,7 @@ static int gsc_remove(struct platform_device *pdev)
1167 {
1168 struct device *dev = &pdev->dev;
1169
1170 + component_del(dev, &gsc_component_ops);
1171 pm_runtime_dont_use_autosuspend(dev);
1172 pm_runtime_disable(dev);
1173
1174 diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c
1175 index f321279baf9e..51456e7f264f 100644
1176 --- a/drivers/iommu/dma-iommu.c
1177 +++ b/drivers/iommu/dma-iommu.c
1178 @@ -19,6 +19,7 @@
1179 #include <linux/iova.h>
1180 #include <linux/irq.h>
1181 #include <linux/mm.h>
1182 +#include <linux/mutex.h>
1183 #include <linux/pci.h>
1184 #include <linux/scatterlist.h>
1185 #include <linux/vmalloc.h>
1186 @@ -43,7 +44,6 @@ struct iommu_dma_cookie {
1187 dma_addr_t msi_iova;
1188 };
1189 struct list_head msi_page_list;
1190 - spinlock_t msi_lock;
1191
1192 /* Domain for flush queue callback; NULL if flush queue not in use */
1193 struct iommu_domain *fq_domain;
1194 @@ -62,7 +62,6 @@ static struct iommu_dma_cookie *cookie_alloc(enum iommu_dma_cookie_type type)
1195
1196 cookie = kzalloc(sizeof(*cookie), GFP_KERNEL);
1197 if (cookie) {
1198 - spin_lock_init(&cookie->msi_lock);
1199 INIT_LIST_HEAD(&cookie->msi_page_list);
1200 cookie->type = type;
1201 }
1202 @@ -1150,7 +1149,7 @@ static struct iommu_dma_msi_page *iommu_dma_get_msi_page(struct device *dev,
1203 if (msi_page->phys == msi_addr)
1204 return msi_page;
1205
1206 - msi_page = kzalloc(sizeof(*msi_page), GFP_ATOMIC);
1207 + msi_page = kzalloc(sizeof(*msi_page), GFP_KERNEL);
1208 if (!msi_page)
1209 return NULL;
1210
1211 @@ -1180,7 +1179,7 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
1212 struct iommu_domain *domain = iommu_get_domain_for_dev(dev);
1213 struct iommu_dma_cookie *cookie;
1214 struct iommu_dma_msi_page *msi_page;
1215 - unsigned long flags;
1216 + static DEFINE_MUTEX(msi_prepare_lock); /* see below */
1217
1218 if (!domain || !domain->iova_cookie) {
1219 desc->iommu_cookie = NULL;
1220 @@ -1190,13 +1189,13 @@ int iommu_dma_prepare_msi(struct msi_desc *desc, phys_addr_t msi_addr)
1221 cookie = domain->iova_cookie;
1222
1223 /*
1224 - * We disable IRQs to rule out a possible inversion against
1225 - * irq_desc_lock if, say, someone tries to retarget the affinity
1226 - * of an MSI from within an IPI handler.
1227 + * In fact the whole prepare operation should already be serialised by
1228 + * irq_domain_mutex further up the callchain, but that's pretty subtle
1229 + * on its own, so consider this locking as failsafe documentation...
1230 */
1231 - spin_lock_irqsave(&cookie->msi_lock, flags);
1232 + mutex_lock(&msi_prepare_lock);
1233 msi_page = iommu_dma_get_msi_page(dev, msi_addr, domain);
1234 - spin_unlock_irqrestore(&cookie->msi_lock, flags);
1235 + mutex_unlock(&msi_prepare_lock);
1236
1237 msi_desc_set_iommu_cookie(desc, msi_page);
1238
1239 diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c
1240 index 41c605b0058f..c7a914b9bbbc 100644
1241 --- a/drivers/iommu/iova.c
1242 +++ b/drivers/iommu/iova.c
1243 @@ -233,7 +233,7 @@ static DEFINE_MUTEX(iova_cache_mutex);
1244
1245 struct iova *alloc_iova_mem(void)
1246 {
1247 - return kmem_cache_alloc(iova_cache, GFP_ATOMIC);
1248 + return kmem_cache_zalloc(iova_cache, GFP_ATOMIC);
1249 }
1250 EXPORT_SYMBOL(alloc_iova_mem);
1251
1252 diff --git a/drivers/misc/habanalabs/command_submission.c b/drivers/misc/habanalabs/command_submission.c
1253 index a9ac045dcfde..447f307ef4d6 100644
1254 --- a/drivers/misc/habanalabs/command_submission.c
1255 +++ b/drivers/misc/habanalabs/command_submission.c
1256 @@ -777,8 +777,9 @@ int hl_cs_wait_ioctl(struct hl_fpriv *hpriv, void *data)
1257 memset(args, 0, sizeof(*args));
1258
1259 if (rc < 0) {
1260 - dev_err(hdev->dev, "Error %ld on waiting for CS handle %llu\n",
1261 - rc, seq);
1262 + dev_err_ratelimited(hdev->dev,
1263 + "Error %ld on waiting for CS handle %llu\n",
1264 + rc, seq);
1265 if (rc == -ERESTARTSYS) {
1266 args->out.status = HL_WAIT_CS_STATUS_INTERRUPTED;
1267 rc = -EINTR;
1268 diff --git a/drivers/misc/habanalabs/context.c b/drivers/misc/habanalabs/context.c
1269 index 17db7b3dfb4c..2df6fb87e7ff 100644
1270 --- a/drivers/misc/habanalabs/context.c
1271 +++ b/drivers/misc/habanalabs/context.c
1272 @@ -176,7 +176,7 @@ struct dma_fence *hl_ctx_get_fence(struct hl_ctx *ctx, u64 seq)
1273 spin_lock(&ctx->cs_lock);
1274
1275 if (seq >= ctx->cs_sequence) {
1276 - dev_notice(hdev->dev,
1277 + dev_notice_ratelimited(hdev->dev,
1278 "Can't wait on seq %llu because current CS is at seq %llu\n",
1279 seq, ctx->cs_sequence);
1280 spin_unlock(&ctx->cs_lock);
1281 diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c
1282 index 6fba14b81f90..fe3574a83b7c 100644
1283 --- a/drivers/misc/habanalabs/goya/goya.c
1284 +++ b/drivers/misc/habanalabs/goya/goya.c
1285 @@ -2171,7 +2171,7 @@ static int goya_push_linux_to_device(struct hl_device *hdev)
1286
1287 static int goya_pldm_init_cpu(struct hl_device *hdev)
1288 {
1289 - u32 val, unit_rst_val;
1290 + u32 unit_rst_val;
1291 int rc;
1292
1293 /* Must initialize SRAM scrambler before pushing u-boot to SRAM */
1294 @@ -2179,14 +2179,14 @@ static int goya_pldm_init_cpu(struct hl_device *hdev)
1295
1296 /* Put ARM cores into reset */
1297 WREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL, CPU_RESET_ASSERT);
1298 - val = RREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL);
1299 + RREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL);
1300
1301 /* Reset the CA53 MACRO */
1302 unit_rst_val = RREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N);
1303 WREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N, CA53_RESET);
1304 - val = RREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N);
1305 + RREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N);
1306 WREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N, unit_rst_val);
1307 - val = RREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N);
1308 + RREG32(mmPSOC_GLOBAL_CONF_UNIT_RST_N);
1309
1310 rc = goya_push_uboot_to_device(hdev);
1311 if (rc)
1312 @@ -2207,7 +2207,7 @@ static int goya_pldm_init_cpu(struct hl_device *hdev)
1313 /* Release ARM core 0 from reset */
1314 WREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL,
1315 CPU_RESET_CORE0_DEASSERT);
1316 - val = RREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL);
1317 + RREG32(mmCPU_CA53_CFG_ARM_RST_CONTROL);
1318
1319 return 0;
1320 }
1321 @@ -2475,13 +2475,12 @@ err:
1322 static int goya_hw_init(struct hl_device *hdev)
1323 {
1324 struct asic_fixed_properties *prop = &hdev->asic_prop;
1325 - u32 val;
1326 int rc;
1327
1328 dev_info(hdev->dev, "Starting initialization of H/W\n");
1329
1330 /* Perform read from the device to make sure device is up */
1331 - val = RREG32(mmPCIE_DBI_DEVICE_ID_VENDOR_ID_REG);
1332 + RREG32(mmPCIE_DBI_DEVICE_ID_VENDOR_ID_REG);
1333
1334 /*
1335 * Let's mark in the H/W that we have reached this point. We check
1336 @@ -2533,7 +2532,7 @@ static int goya_hw_init(struct hl_device *hdev)
1337 goto disable_queues;
1338
1339 /* Perform read from the device to flush all MSI-X configuration */
1340 - val = RREG32(mmPCIE_DBI_DEVICE_ID_VENDOR_ID_REG);
1341 + RREG32(mmPCIE_DBI_DEVICE_ID_VENDOR_ID_REG);
1342
1343 return 0;
1344
1345 diff --git a/drivers/misc/ocxl/context.c b/drivers/misc/ocxl/context.c
1346 index 994563a078eb..de8a66b9d76b 100644
1347 --- a/drivers/misc/ocxl/context.c
1348 +++ b/drivers/misc/ocxl/context.c
1349 @@ -10,18 +10,17 @@ int ocxl_context_alloc(struct ocxl_context **context, struct ocxl_afu *afu,
1350 int pasid;
1351 struct ocxl_context *ctx;
1352
1353 - *context = kzalloc(sizeof(struct ocxl_context), GFP_KERNEL);
1354 - if (!*context)
1355 + ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
1356 + if (!ctx)
1357 return -ENOMEM;
1358
1359 - ctx = *context;
1360 -
1361 ctx->afu = afu;
1362 mutex_lock(&afu->contexts_lock);
1363 pasid = idr_alloc(&afu->contexts_idr, ctx, afu->pasid_base,
1364 afu->pasid_base + afu->pasid_max, GFP_KERNEL);
1365 if (pasid < 0) {
1366 mutex_unlock(&afu->contexts_lock);
1367 + kfree(ctx);
1368 return pasid;
1369 }
1370 afu->pasid_count++;
1371 @@ -43,6 +42,7 @@ int ocxl_context_alloc(struct ocxl_context **context, struct ocxl_afu *afu,
1372 * duration of the life of the context
1373 */
1374 ocxl_afu_get(afu);
1375 + *context = ctx;
1376 return 0;
1377 }
1378 EXPORT_SYMBOL_GPL(ocxl_context_alloc);
1379 diff --git a/drivers/net/dsa/mv88e6xxx/global1.c b/drivers/net/dsa/mv88e6xxx/global1.c
1380 index 25ec4c0ac589..8a903624fdd7 100644
1381 --- a/drivers/net/dsa/mv88e6xxx/global1.c
1382 +++ b/drivers/net/dsa/mv88e6xxx/global1.c
1383 @@ -332,6 +332,11 @@ int mv88e6390_g1_set_cpu_port(struct mv88e6xxx_chip *chip, int port)
1384 {
1385 u16 ptr = MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST;
1386
1387 + /* Use the default high priority for management frames sent to
1388 + * the CPU.
1389 + */
1390 + port |= MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST_MGMTPRI;
1391 +
1392 return mv88e6390_g1_monitor_write(chip, ptr, port);
1393 }
1394
1395 diff --git a/drivers/net/dsa/mv88e6xxx/global1.h b/drivers/net/dsa/mv88e6xxx/global1.h
1396 index 0870fcc8bfc8..0ae96a1e919b 100644
1397 --- a/drivers/net/dsa/mv88e6xxx/global1.h
1398 +++ b/drivers/net/dsa/mv88e6xxx/global1.h
1399 @@ -210,6 +210,7 @@
1400 #define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_INGRESS_DEST 0x2000
1401 #define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_EGRESS_DEST 0x2100
1402 #define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST 0x3000
1403 +#define MV88E6390_G1_MONITOR_MGMT_CTL_PTR_CPU_DEST_MGMTPRI 0x00e0
1404 #define MV88E6390_G1_MONITOR_MGMT_CTL_DATA_MASK 0x00ff
1405
1406 /* Offset 0x1C: Global Control 2 */
1407 diff --git a/drivers/net/dsa/mv88e6xxx/port.c b/drivers/net/dsa/mv88e6xxx/port.c
1408 index 15ef81654b67..330c41e87171 100644
1409 --- a/drivers/net/dsa/mv88e6xxx/port.c
1410 +++ b/drivers/net/dsa/mv88e6xxx/port.c
1411 @@ -393,7 +393,7 @@ phy_interface_t mv88e6390x_port_max_speed_mode(int port)
1412 }
1413
1414 static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1415 - phy_interface_t mode)
1416 + phy_interface_t mode, bool force)
1417 {
1418 u8 lane;
1419 u16 cmode;
1420 @@ -427,8 +427,8 @@ static int mv88e6xxx_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1421 cmode = 0;
1422 }
1423
1424 - /* cmode doesn't change, nothing to do for us */
1425 - if (cmode == chip->ports[port].cmode)
1426 + /* cmode doesn't change, nothing to do for us unless forced */
1427 + if (cmode == chip->ports[port].cmode && !force)
1428 return 0;
1429
1430 lane = mv88e6xxx_serdes_get_lane(chip, port);
1431 @@ -484,7 +484,7 @@ int mv88e6390x_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1432 if (port != 9 && port != 10)
1433 return -EOPNOTSUPP;
1434
1435 - return mv88e6xxx_port_set_cmode(chip, port, mode);
1436 + return mv88e6xxx_port_set_cmode(chip, port, mode, false);
1437 }
1438
1439 int mv88e6390_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1440 @@ -504,7 +504,7 @@ int mv88e6390_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1441 break;
1442 }
1443
1444 - return mv88e6xxx_port_set_cmode(chip, port, mode);
1445 + return mv88e6xxx_port_set_cmode(chip, port, mode, false);
1446 }
1447
1448 static int mv88e6341_port_set_cmode_writable(struct mv88e6xxx_chip *chip,
1449 @@ -555,7 +555,7 @@ int mv88e6341_port_set_cmode(struct mv88e6xxx_chip *chip, int port,
1450 if (err)
1451 return err;
1452
1453 - return mv88e6xxx_port_set_cmode(chip, port, mode);
1454 + return mv88e6xxx_port_set_cmode(chip, port, mode, true);
1455 }
1456
1457 int mv88e6185_port_get_cmode(struct mv88e6xxx_chip *chip, int port, u8 *cmode)
1458 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1459 index 8b08cb18e363..3f63ffd7561b 100644
1460 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1461 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
1462 @@ -1109,7 +1109,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
1463 for (i = 0; i < E1H_FUNC_MAX / 2; i++) {
1464 u32 func_config =
1465 MF_CFG_RD(bp,
1466 - func_mf_config[BP_PORT(bp) + 2 * i].
1467 + func_mf_config[BP_PATH(bp) + 2 * i].
1468 config);
1469 func_num +=
1470 ((func_config & FUNC_MF_CFG_FUNC_HIDE) ? 0 : 1);
1471 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1472 index 192ff8d5da32..cff64e43bdd8 100644
1473 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1474 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
1475 @@ -9976,10 +9976,18 @@ static void bnx2x_recovery_failed(struct bnx2x *bp)
1476 */
1477 static void bnx2x_parity_recover(struct bnx2x *bp)
1478 {
1479 - bool global = false;
1480 u32 error_recovered, error_unrecovered;
1481 - bool is_parity;
1482 + bool is_parity, global = false;
1483 +#ifdef CONFIG_BNX2X_SRIOV
1484 + int vf_idx;
1485 +
1486 + for (vf_idx = 0; vf_idx < bp->requested_nr_virtfn; vf_idx++) {
1487 + struct bnx2x_virtf *vf = BP_VF(bp, vf_idx);
1488
1489 + if (vf)
1490 + vf->state = VF_LOST;
1491 + }
1492 +#endif
1493 DP(NETIF_MSG_HW, "Handling parity\n");
1494 while (1) {
1495 switch (bp->recovery_state) {
1496 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
1497 index b6ebd92ec565..3a716c015415 100644
1498 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
1499 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.h
1500 @@ -139,6 +139,7 @@ struct bnx2x_virtf {
1501 #define VF_ACQUIRED 1 /* VF acquired, but not initialized */
1502 #define VF_ENABLED 2 /* VF Enabled */
1503 #define VF_RESET 3 /* VF FLR'd, pending cleanup */
1504 +#define VF_LOST 4 /* Recovery while VFs are loaded */
1505
1506 bool flr_clnup_stage; /* true during flr cleanup */
1507 bool malicious; /* true if FW indicated so, until FLR */
1508 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
1509 index 0752b7fa4d9c..ea0e9394f898 100644
1510 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
1511 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_vfpf.c
1512 @@ -2107,6 +2107,18 @@ static void bnx2x_vf_mbx_request(struct bnx2x *bp, struct bnx2x_virtf *vf,
1513 {
1514 int i;
1515
1516 + if (vf->state == VF_LOST) {
1517 + /* Just ack the FW and return if VFs are lost
1518 + * in case of parity error. VFs are supposed to be timedout
1519 + * on waiting for PF response.
1520 + */
1521 + DP(BNX2X_MSG_IOV,
1522 + "VF 0x%x lost, not handling the request\n", vf->abs_vfid);
1523 +
1524 + storm_memset_vf_mbx_ack(bp, vf->abs_vfid);
1525 + return;
1526 + }
1527 +
1528 /* check if tlv type is known */
1529 if (bnx2x_tlv_supported(mbx->first_tlv.tl.type)) {
1530 /* Lock the per vf op mutex and note the locker's identity.
1531 diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
1532 index 0f10a272827c..f496b248bda3 100644
1533 --- a/drivers/net/ethernet/cadence/macb_main.c
1534 +++ b/drivers/net/ethernet/cadence/macb_main.c
1535 @@ -4027,7 +4027,7 @@ static int fu540_c000_clk_init(struct platform_device *pdev, struct clk **pclk,
1536 mgmt->rate = 0;
1537 mgmt->hw.init = &init;
1538
1539 - *tx_clk = clk_register(NULL, &mgmt->hw);
1540 + *tx_clk = devm_clk_register(&pdev->dev, &mgmt->hw);
1541 if (IS_ERR(*tx_clk))
1542 return PTR_ERR(*tx_clk);
1543
1544 @@ -4361,7 +4361,6 @@ err_out_free_netdev:
1545
1546 err_disable_clocks:
1547 clk_disable_unprepare(tx_clk);
1548 - clk_unregister(tx_clk);
1549 clk_disable_unprepare(hclk);
1550 clk_disable_unprepare(pclk);
1551 clk_disable_unprepare(rx_clk);
1552 @@ -4397,7 +4396,6 @@ static int macb_remove(struct platform_device *pdev)
1553 pm_runtime_dont_use_autosuspend(&pdev->dev);
1554 if (!pm_runtime_suspended(&pdev->dev)) {
1555 clk_disable_unprepare(bp->tx_clk);
1556 - clk_unregister(bp->tx_clk);
1557 clk_disable_unprepare(bp->hclk);
1558 clk_disable_unprepare(bp->pclk);
1559 clk_disable_unprepare(bp->rx_clk);
1560 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
1561 index ae6a47dd7dc9..fb8ade9a05a9 100644
1562 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
1563 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c
1564 @@ -2996,6 +2996,9 @@ static int sge_queue_entries(const struct adapter *adap)
1565 int tot_uld_entries = 0;
1566 int i;
1567
1568 + if (!is_uld(adap))
1569 + goto lld_only;
1570 +
1571 mutex_lock(&uld_mutex);
1572 for (i = 0; i < CXGB4_TX_MAX; i++)
1573 tot_uld_entries += sge_qinfo_uld_txq_entries(adap, i);
1574 @@ -3006,6 +3009,7 @@ static int sge_queue_entries(const struct adapter *adap)
1575 }
1576 mutex_unlock(&uld_mutex);
1577
1578 +lld_only:
1579 return DIV_ROUND_UP(adap->sge.ethqsets, 4) +
1580 tot_uld_entries +
1581 DIV_ROUND_UP(MAX_CTRL_QUEUES, 4) + 1;
1582 diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
1583 index 4bb30761abfc..8336f4cbaf95 100644
1584 --- a/drivers/net/ethernet/freescale/fec_main.c
1585 +++ b/drivers/net/ethernet/freescale/fec_main.c
1586 @@ -2199,8 +2199,14 @@ static void fec_enet_get_regs(struct net_device *ndev,
1587 {
1588 struct fec_enet_private *fep = netdev_priv(ndev);
1589 u32 __iomem *theregs = (u32 __iomem *)fep->hwp;
1590 + struct device *dev = &fep->pdev->dev;
1591 u32 *buf = (u32 *)regbuf;
1592 u32 i, off;
1593 + int ret;
1594 +
1595 + ret = pm_runtime_get_sync(dev);
1596 + if (ret < 0)
1597 + return;
1598
1599 regs->version = fec_enet_register_version;
1600
1601 @@ -2216,6 +2222,9 @@ static void fec_enet_get_regs(struct net_device *ndev,
1602 off >>= 2;
1603 buf[off] = readl(&theregs[off]);
1604 }
1605 +
1606 + pm_runtime_mark_last_busy(dev);
1607 + pm_runtime_put_autosuspend(dev);
1608 }
1609
1610 static int fec_enet_get_ts_info(struct net_device *ndev,
1611 diff --git a/drivers/net/ethernet/intel/i40e/i40e.h b/drivers/net/ethernet/intel/i40e/i40e.h
1612 index 2af9f6308f84..401304d4d553 100644
1613 --- a/drivers/net/ethernet/intel/i40e/i40e.h
1614 +++ b/drivers/net/ethernet/intel/i40e/i40e.h
1615 @@ -1151,7 +1151,7 @@ void i40e_set_fec_in_flags(u8 fec_cfg, u32 *flags);
1616
1617 static inline bool i40e_enabled_xdp_vsi(struct i40e_vsi *vsi)
1618 {
1619 - return !!vsi->xdp_prog;
1620 + return !!READ_ONCE(vsi->xdp_prog);
1621 }
1622
1623 int i40e_create_queue_channel(struct i40e_vsi *vsi, struct i40e_channel *ch);
1624 diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
1625 index 339925af0206..4960c9c3e773 100644
1626 --- a/drivers/net/ethernet/intel/i40e/i40e_main.c
1627 +++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
1628 @@ -6804,8 +6804,8 @@ void i40e_down(struct i40e_vsi *vsi)
1629 for (i = 0; i < vsi->num_queue_pairs; i++) {
1630 i40e_clean_tx_ring(vsi->tx_rings[i]);
1631 if (i40e_enabled_xdp_vsi(vsi)) {
1632 - /* Make sure that in-progress ndo_xdp_xmit
1633 - * calls are completed.
1634 + /* Make sure that in-progress ndo_xdp_xmit and
1635 + * ndo_xsk_wakeup calls are completed.
1636 */
1637 synchronize_rcu();
1638 i40e_clean_tx_ring(vsi->xdp_rings[i]);
1639 @@ -12526,8 +12526,12 @@ static int i40e_xdp_setup(struct i40e_vsi *vsi,
1640
1641 old_prog = xchg(&vsi->xdp_prog, prog);
1642
1643 - if (need_reset)
1644 + if (need_reset) {
1645 + if (!prog)
1646 + /* Wait until ndo_xsk_wakeup completes. */
1647 + synchronize_rcu();
1648 i40e_reset_and_rebuild(pf, true, true);
1649 + }
1650
1651 for (i = 0; i < vsi->num_queue_pairs; i++)
1652 WRITE_ONCE(vsi->rx_rings[i]->xdp_prog, vsi->xdp_prog);
1653 diff --git a/drivers/net/ethernet/intel/i40e/i40e_xsk.c b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1654 index d07e1a890428..f73cd917c44f 100644
1655 --- a/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1656 +++ b/drivers/net/ethernet/intel/i40e/i40e_xsk.c
1657 @@ -787,8 +787,12 @@ int i40e_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
1658 {
1659 struct i40e_netdev_priv *np = netdev_priv(dev);
1660 struct i40e_vsi *vsi = np->vsi;
1661 + struct i40e_pf *pf = vsi->back;
1662 struct i40e_ring *ring;
1663
1664 + if (test_bit(__I40E_CONFIG_BUSY, pf->state))
1665 + return -ENETDOWN;
1666 +
1667 if (test_bit(__I40E_VSI_DOWN, vsi->state))
1668 return -ENETDOWN;
1669
1670 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1671 index 1a7203fede12..c6404abf2dd1 100644
1672 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1673 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
1674 @@ -10248,7 +10248,12 @@ static int ixgbe_xdp_setup(struct net_device *dev, struct bpf_prog *prog)
1675
1676 /* If transitioning XDP modes reconfigure rings */
1677 if (need_reset) {
1678 - int err = ixgbe_setup_tc(dev, adapter->hw_tcs);
1679 + int err;
1680 +
1681 + if (!prog)
1682 + /* Wait until ndo_xsk_wakeup completes. */
1683 + synchronize_rcu();
1684 + err = ixgbe_setup_tc(dev, adapter->hw_tcs);
1685
1686 if (err) {
1687 rcu_assign_pointer(adapter->xdp_prog, old_prog);
1688 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
1689 index d6feaacfbf89..b43be9f14105 100644
1690 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
1691 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_xsk.c
1692 @@ -709,10 +709,14 @@ int ixgbe_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
1693 if (qid >= adapter->num_xdp_queues)
1694 return -ENXIO;
1695
1696 - if (!adapter->xdp_ring[qid]->xsk_umem)
1697 + ring = adapter->xdp_ring[qid];
1698 +
1699 + if (test_bit(__IXGBE_TX_DISABLED, &ring->state))
1700 + return -ENETDOWN;
1701 +
1702 + if (!ring->xsk_umem)
1703 return -ENXIO;
1704
1705 - ring = adapter->xdp_ring[qid];
1706 if (!napi_if_scheduled_mark_missed(&ring->q_vector->napi)) {
1707 u64 eics = BIT_ULL(ring->q_vector->v_idx);
1708
1709 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en.h b/drivers/net/ethernet/mellanox/mlx5/core/en.h
1710 index 2c16add0b642..9c8427698238 100644
1711 --- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
1712 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
1713 @@ -760,7 +760,7 @@ enum {
1714 MLX5E_STATE_OPENED,
1715 MLX5E_STATE_DESTROYING,
1716 MLX5E_STATE_XDP_TX_ENABLED,
1717 - MLX5E_STATE_XDP_OPEN,
1718 + MLX5E_STATE_XDP_ACTIVE,
1719 };
1720
1721 struct mlx5e_rqt {
1722 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
1723 index 68d593074f6c..d48292ccda29 100644
1724 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
1725 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/fs.h
1726 @@ -122,6 +122,22 @@ enum {
1727 #endif
1728 };
1729
1730 +#define MLX5E_TTC_NUM_GROUPS 3
1731 +#define MLX5E_TTC_GROUP1_SIZE (BIT(3) + MLX5E_NUM_TUNNEL_TT)
1732 +#define MLX5E_TTC_GROUP2_SIZE BIT(1)
1733 +#define MLX5E_TTC_GROUP3_SIZE BIT(0)
1734 +#define MLX5E_TTC_TABLE_SIZE (MLX5E_TTC_GROUP1_SIZE +\
1735 + MLX5E_TTC_GROUP2_SIZE +\
1736 + MLX5E_TTC_GROUP3_SIZE)
1737 +
1738 +#define MLX5E_INNER_TTC_NUM_GROUPS 3
1739 +#define MLX5E_INNER_TTC_GROUP1_SIZE BIT(3)
1740 +#define MLX5E_INNER_TTC_GROUP2_SIZE BIT(1)
1741 +#define MLX5E_INNER_TTC_GROUP3_SIZE BIT(0)
1742 +#define MLX5E_INNER_TTC_TABLE_SIZE (MLX5E_INNER_TTC_GROUP1_SIZE +\
1743 + MLX5E_INNER_TTC_GROUP2_SIZE +\
1744 + MLX5E_INNER_TTC_GROUP3_SIZE)
1745 +
1746 #ifdef CONFIG_MLX5_EN_RXNFC
1747
1748 struct mlx5e_ethtool_table {
1749 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
1750 index 1d6b58860da6..3a975641f902 100644
1751 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
1752 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/health.c
1753 @@ -197,9 +197,10 @@ int mlx5e_health_report(struct mlx5e_priv *priv,
1754 struct devlink_health_reporter *reporter, char *err_str,
1755 struct mlx5e_err_ctx *err_ctx)
1756 {
1757 - if (!reporter) {
1758 - netdev_err(priv->netdev, err_str);
1759 + netdev_err(priv->netdev, err_str);
1760 +
1761 + if (!reporter)
1762 return err_ctx->recover(&err_ctx->ctx);
1763 - }
1764 +
1765 return devlink_health_report(reporter, err_str, err_ctx);
1766 }
1767 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
1768 index 36ac1e3816b9..d7587f40ecae 100644
1769 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
1770 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xdp.h
1771 @@ -75,12 +75,18 @@ int mlx5e_xdp_xmit(struct net_device *dev, int n, struct xdp_frame **frames,
1772 static inline void mlx5e_xdp_tx_enable(struct mlx5e_priv *priv)
1773 {
1774 set_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
1775 +
1776 + if (priv->channels.params.xdp_prog)
1777 + set_bit(MLX5E_STATE_XDP_ACTIVE, &priv->state);
1778 }
1779
1780 static inline void mlx5e_xdp_tx_disable(struct mlx5e_priv *priv)
1781 {
1782 + if (priv->channels.params.xdp_prog)
1783 + clear_bit(MLX5E_STATE_XDP_ACTIVE, &priv->state);
1784 +
1785 clear_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
1786 - /* let other device's napi(s) see our new state */
1787 + /* Let other device's napi(s) and XSK wakeups see our new state. */
1788 synchronize_rcu();
1789 }
1790
1791 @@ -89,19 +95,9 @@ static inline bool mlx5e_xdp_tx_is_enabled(struct mlx5e_priv *priv)
1792 return test_bit(MLX5E_STATE_XDP_TX_ENABLED, &priv->state);
1793 }
1794
1795 -static inline void mlx5e_xdp_set_open(struct mlx5e_priv *priv)
1796 -{
1797 - set_bit(MLX5E_STATE_XDP_OPEN, &priv->state);
1798 -}
1799 -
1800 -static inline void mlx5e_xdp_set_closed(struct mlx5e_priv *priv)
1801 -{
1802 - clear_bit(MLX5E_STATE_XDP_OPEN, &priv->state);
1803 -}
1804 -
1805 -static inline bool mlx5e_xdp_is_open(struct mlx5e_priv *priv)
1806 +static inline bool mlx5e_xdp_is_active(struct mlx5e_priv *priv)
1807 {
1808 - return test_bit(MLX5E_STATE_XDP_OPEN, &priv->state);
1809 + return test_bit(MLX5E_STATE_XDP_ACTIVE, &priv->state);
1810 }
1811
1812 static inline void mlx5e_xmit_xdp_doorbell(struct mlx5e_xdpsq *sq)
1813 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
1814 index 631af8dee517..c28cbae42331 100644
1815 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
1816 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/setup.c
1817 @@ -144,6 +144,7 @@ void mlx5e_close_xsk(struct mlx5e_channel *c)
1818 {
1819 clear_bit(MLX5E_CHANNEL_STATE_XSK, c->state);
1820 napi_synchronize(&c->napi);
1821 + synchronize_rcu(); /* Sync with the XSK wakeup. */
1822
1823 mlx5e_close_rq(&c->xskrq);
1824 mlx5e_close_cq(&c->xskrq.cq);
1825 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c
1826 index 87827477d38c..fe2d596cb361 100644
1827 --- a/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c
1828 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en/xsk/tx.c
1829 @@ -14,7 +14,7 @@ int mlx5e_xsk_wakeup(struct net_device *dev, u32 qid, u32 flags)
1830 struct mlx5e_channel *c;
1831 u16 ix;
1832
1833 - if (unlikely(!mlx5e_xdp_is_open(priv)))
1834 + if (unlikely(!mlx5e_xdp_is_active(priv)))
1835 return -ENETDOWN;
1836
1837 if (unlikely(!mlx5e_qid_get_ch_if_in_group(params, qid, MLX5E_RQ_GROUP_XSK, &ix)))
1838 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
1839 index 15b7f0f1427c..73d3dc07331f 100644
1840 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
1841 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_fs.c
1842 @@ -904,22 +904,6 @@ del_rules:
1843 return err;
1844 }
1845
1846 -#define MLX5E_TTC_NUM_GROUPS 3
1847 -#define MLX5E_TTC_GROUP1_SIZE (BIT(3) + MLX5E_NUM_TUNNEL_TT)
1848 -#define MLX5E_TTC_GROUP2_SIZE BIT(1)
1849 -#define MLX5E_TTC_GROUP3_SIZE BIT(0)
1850 -#define MLX5E_TTC_TABLE_SIZE (MLX5E_TTC_GROUP1_SIZE +\
1851 - MLX5E_TTC_GROUP2_SIZE +\
1852 - MLX5E_TTC_GROUP3_SIZE)
1853 -
1854 -#define MLX5E_INNER_TTC_NUM_GROUPS 3
1855 -#define MLX5E_INNER_TTC_GROUP1_SIZE BIT(3)
1856 -#define MLX5E_INNER_TTC_GROUP2_SIZE BIT(1)
1857 -#define MLX5E_INNER_TTC_GROUP3_SIZE BIT(0)
1858 -#define MLX5E_INNER_TTC_TABLE_SIZE (MLX5E_INNER_TTC_GROUP1_SIZE +\
1859 - MLX5E_INNER_TTC_GROUP2_SIZE +\
1860 - MLX5E_INNER_TTC_GROUP3_SIZE)
1861 -
1862 static int mlx5e_create_ttc_table_groups(struct mlx5e_ttc_table *ttc,
1863 bool use_ipv)
1864 {
1865 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1866 index 6abd4ed5b69b..29a5a8c894e3 100644
1867 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1868 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
1869 @@ -3002,12 +3002,9 @@ void mlx5e_timestamp_init(struct mlx5e_priv *priv)
1870 int mlx5e_open_locked(struct net_device *netdev)
1871 {
1872 struct mlx5e_priv *priv = netdev_priv(netdev);
1873 - bool is_xdp = priv->channels.params.xdp_prog;
1874 int err;
1875
1876 set_bit(MLX5E_STATE_OPENED, &priv->state);
1877 - if (is_xdp)
1878 - mlx5e_xdp_set_open(priv);
1879
1880 err = mlx5e_open_channels(priv, &priv->channels);
1881 if (err)
1882 @@ -3022,8 +3019,6 @@ int mlx5e_open_locked(struct net_device *netdev)
1883 return 0;
1884
1885 err_clear_state_opened_flag:
1886 - if (is_xdp)
1887 - mlx5e_xdp_set_closed(priv);
1888 clear_bit(MLX5E_STATE_OPENED, &priv->state);
1889 return err;
1890 }
1891 @@ -3055,8 +3050,6 @@ int mlx5e_close_locked(struct net_device *netdev)
1892 if (!test_bit(MLX5E_STATE_OPENED, &priv->state))
1893 return 0;
1894
1895 - if (priv->channels.params.xdp_prog)
1896 - mlx5e_xdp_set_closed(priv);
1897 clear_bit(MLX5E_STATE_OPENED, &priv->state);
1898
1899 netif_carrier_off(priv->netdev);
1900 @@ -4373,16 +4366,6 @@ static int mlx5e_xdp_allowed(struct mlx5e_priv *priv, struct bpf_prog *prog)
1901 return 0;
1902 }
1903
1904 -static int mlx5e_xdp_update_state(struct mlx5e_priv *priv)
1905 -{
1906 - if (priv->channels.params.xdp_prog)
1907 - mlx5e_xdp_set_open(priv);
1908 - else
1909 - mlx5e_xdp_set_closed(priv);
1910 -
1911 - return 0;
1912 -}
1913 -
1914 static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
1915 {
1916 struct mlx5e_priv *priv = netdev_priv(netdev);
1917 @@ -4422,7 +4405,7 @@ static int mlx5e_xdp_set(struct net_device *netdev, struct bpf_prog *prog)
1918 mlx5e_set_rq_type(priv->mdev, &new_channels.params);
1919 old_prog = priv->channels.params.xdp_prog;
1920
1921 - err = mlx5e_safe_switch_channels(priv, &new_channels, mlx5e_xdp_update_state);
1922 + err = mlx5e_safe_switch_channels(priv, &new_channels, NULL);
1923 if (err)
1924 goto unlock;
1925 } else {
1926 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1927 index 814a4ba4e7fa..947122c68493 100644
1928 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1929 +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c
1930 @@ -586,7 +586,7 @@ static void mlx5e_hairpin_set_ttc_params(struct mlx5e_hairpin *hp,
1931 for (tt = 0; tt < MLX5E_NUM_INDIR_TIRS; tt++)
1932 ttc_params->indir_tirn[tt] = hp->indir_tirn[tt];
1933
1934 - ft_attr->max_fte = MLX5E_NUM_TT;
1935 + ft_attr->max_fte = MLX5E_TTC_TABLE_SIZE;
1936 ft_attr->level = MLX5E_TC_TTC_FT_LEVEL;
1937 ft_attr->prio = MLX5E_TC_PRIO;
1938 }
1939 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
1940 index 50ab88d80033..051ab845b501 100644
1941 --- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
1942 +++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
1943 @@ -1197,6 +1197,12 @@ static int mlx5_load_one(struct mlx5_core_dev *dev, bool boot)
1944 if (err)
1945 goto err_load;
1946
1947 + if (boot) {
1948 + err = mlx5_devlink_register(priv_to_devlink(dev), dev->device);
1949 + if (err)
1950 + goto err_devlink_reg;
1951 + }
1952 +
1953 if (mlx5_device_registered(dev)) {
1954 mlx5_attach_device(dev);
1955 } else {
1956 @@ -1214,6 +1220,9 @@ out:
1957 return err;
1958
1959 err_reg_dev:
1960 + if (boot)
1961 + mlx5_devlink_unregister(priv_to_devlink(dev));
1962 +err_devlink_reg:
1963 mlx5_unload(dev);
1964 err_load:
1965 if (boot)
1966 @@ -1353,10 +1362,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1967
1968 request_module_nowait(MLX5_IB_MOD);
1969
1970 - err = mlx5_devlink_register(devlink, &pdev->dev);
1971 - if (err)
1972 - goto clean_load;
1973 -
1974 err = mlx5_crdump_enable(dev);
1975 if (err)
1976 dev_err(&pdev->dev, "mlx5_crdump_enable failed with error code %d\n", err);
1977 @@ -1364,9 +1369,6 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *id)
1978 pci_save_state(pdev);
1979 return 0;
1980
1981 -clean_load:
1982 - mlx5_unload_one(dev, true);
1983 -
1984 err_load_one:
1985 mlx5_pci_close(dev);
1986 pci_init_err:
1987 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
1988 index bd1699e62142..e1a647dde978 100644
1989 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
1990 +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_rule.c
1991 @@ -209,7 +209,7 @@ static void dr_rule_rehash_copy_ste_ctrl(struct mlx5dr_matcher *matcher,
1992 /* We need to copy the refcount since this ste
1993 * may have been traversed several times
1994 */
1995 - refcount_set(&new_ste->refcount, refcount_read(&cur_ste->refcount));
1996 + new_ste->refcount = cur_ste->refcount;
1997
1998 /* Link old STEs rule_mem list to the new ste */
1999 mlx5dr_rule_update_rule_member(cur_ste, new_ste);
2000 @@ -638,6 +638,9 @@ static int dr_rule_add_member(struct mlx5dr_rule_rx_tx *nic_rule,
2001 if (!rule_mem)
2002 return -ENOMEM;
2003
2004 + INIT_LIST_HEAD(&rule_mem->list);
2005 + INIT_LIST_HEAD(&rule_mem->use_ste_list);
2006 +
2007 rule_mem->ste = ste;
2008 list_add_tail(&rule_mem->list, &nic_rule->rule_members_list);
2009
2010 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
2011 index 3cbf74b44d1f..2739ed2a2911 100644
2012 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
2013 +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste.c
2014 @@ -340,7 +340,7 @@ static void dr_ste_replace(struct mlx5dr_ste *dst, struct mlx5dr_ste *src)
2015 if (dst->next_htbl)
2016 dst->next_htbl->pointing_ste = dst;
2017
2018 - refcount_set(&dst->refcount, refcount_read(&src->refcount));
2019 + dst->refcount = src->refcount;
2020
2021 INIT_LIST_HEAD(&dst->rule_list);
2022 list_splice_tail_init(&src->rule_list, &dst->rule_list);
2023 @@ -557,7 +557,7 @@ bool mlx5dr_ste_is_not_valid_entry(u8 *p_hw_ste)
2024
2025 bool mlx5dr_ste_not_used_ste(struct mlx5dr_ste *ste)
2026 {
2027 - return !refcount_read(&ste->refcount);
2028 + return !ste->refcount;
2029 }
2030
2031 /* Init one ste as a pattern for ste data array */
2032 @@ -681,14 +681,14 @@ struct mlx5dr_ste_htbl *mlx5dr_ste_htbl_alloc(struct mlx5dr_icm_pool *pool,
2033 htbl->ste_arr = chunk->ste_arr;
2034 htbl->hw_ste_arr = chunk->hw_ste_arr;
2035 htbl->miss_list = chunk->miss_list;
2036 - refcount_set(&htbl->refcount, 0);
2037 + htbl->refcount = 0;
2038
2039 for (i = 0; i < chunk->num_of_entries; i++) {
2040 struct mlx5dr_ste *ste = &htbl->ste_arr[i];
2041
2042 ste->hw_ste = htbl->hw_ste_arr + i * DR_STE_SIZE_REDUCED;
2043 ste->htbl = htbl;
2044 - refcount_set(&ste->refcount, 0);
2045 + ste->refcount = 0;
2046 INIT_LIST_HEAD(&ste->miss_list_node);
2047 INIT_LIST_HEAD(&htbl->miss_list[i]);
2048 INIT_LIST_HEAD(&ste->rule_list);
2049 @@ -705,7 +705,7 @@ out_free_htbl:
2050
2051 int mlx5dr_ste_htbl_free(struct mlx5dr_ste_htbl *htbl)
2052 {
2053 - if (refcount_read(&htbl->refcount))
2054 + if (htbl->refcount)
2055 return -EBUSY;
2056
2057 mlx5dr_icm_free_chunk(htbl->chunk);
2058 diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
2059 index 1cb3769d4e3c..31737dfca4ea 100644
2060 --- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
2061 +++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h
2062 @@ -117,7 +117,7 @@ struct mlx5dr_matcher_rx_tx;
2063 struct mlx5dr_ste {
2064 u8 *hw_ste;
2065 /* refcount: indicates the num of rules that using this ste */
2066 - refcount_t refcount;
2067 + u32 refcount;
2068
2069 /* attached to the miss_list head at each htbl entry */
2070 struct list_head miss_list_node;
2071 @@ -149,7 +149,7 @@ struct mlx5dr_ste_htbl_ctrl {
2072 struct mlx5dr_ste_htbl {
2073 u8 lu_type;
2074 u16 byte_mask;
2075 - refcount_t refcount;
2076 + u32 refcount;
2077 struct mlx5dr_icm_chunk *chunk;
2078 struct mlx5dr_ste *ste_arr;
2079 u8 *hw_ste_arr;
2080 @@ -200,13 +200,14 @@ int mlx5dr_ste_htbl_free(struct mlx5dr_ste_htbl *htbl);
2081
2082 static inline void mlx5dr_htbl_put(struct mlx5dr_ste_htbl *htbl)
2083 {
2084 - if (refcount_dec_and_test(&htbl->refcount))
2085 + htbl->refcount--;
2086 + if (!htbl->refcount)
2087 mlx5dr_ste_htbl_free(htbl);
2088 }
2089
2090 static inline void mlx5dr_htbl_get(struct mlx5dr_ste_htbl *htbl)
2091 {
2092 - refcount_inc(&htbl->refcount);
2093 + htbl->refcount++;
2094 }
2095
2096 /* STE utils */
2097 @@ -248,14 +249,15 @@ static inline void mlx5dr_ste_put(struct mlx5dr_ste *ste,
2098 struct mlx5dr_matcher *matcher,
2099 struct mlx5dr_matcher_rx_tx *nic_matcher)
2100 {
2101 - if (refcount_dec_and_test(&ste->refcount))
2102 + ste->refcount--;
2103 + if (!ste->refcount)
2104 mlx5dr_ste_free(ste, matcher, nic_matcher);
2105 }
2106
2107 /* initial as 0, increased only when ste appears in a new rule */
2108 static inline void mlx5dr_ste_get(struct mlx5dr_ste *ste)
2109 {
2110 - refcount_inc(&ste->refcount);
2111 + ste->refcount++;
2112 }
2113
2114 void mlx5dr_ste_set_hit_addr_by_next_htbl(u8 *hw_ste,
2115 diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
2116 index bdf53cf350f6..720514b5c006 100644
2117 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
2118 +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
2119 @@ -650,6 +650,13 @@ mlxsw_sp_qdisc_prio_graft(struct mlxsw_sp_port *mlxsw_sp_port,
2120 mlxsw_sp_port->tclass_qdiscs[tclass_num].handle == p->child_handle)
2121 return 0;
2122
2123 + if (!p->child_handle) {
2124 + /* This is an invisible FIFO replacing the original Qdisc.
2125 + * Ignore it--the original Qdisc's destroy will follow.
2126 + */
2127 + return 0;
2128 + }
2129 +
2130 /* See if the grafted qdisc is already offloaded on any tclass. If so,
2131 * unoffload it.
2132 */
2133 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
2134 index 6e47be63a43c..e9e0867ec139 100644
2135 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
2136 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c
2137 @@ -957,6 +957,9 @@ static int sun8i_dwmac_set_syscon(struct stmmac_priv *priv)
2138 /* default */
2139 break;
2140 case PHY_INTERFACE_MODE_RGMII:
2141 + case PHY_INTERFACE_MODE_RGMII_ID:
2142 + case PHY_INTERFACE_MODE_RGMII_RXID:
2143 + case PHY_INTERFACE_MODE_RGMII_TXID:
2144 reg |= SYSCON_EPIT | SYSCON_ETCS_INT_GMII;
2145 break;
2146 case PHY_INTERFACE_MODE_RMII:
2147 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
2148 index a299da3971b4..102d637bc84a 100644
2149 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
2150 +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
2151 @@ -44,7 +44,7 @@ static int sun7i_gmac_init(struct platform_device *pdev, void *priv)
2152 * rate, which then uses the auto-reparenting feature of the
2153 * clock driver, and enabling/disabling the clock.
2154 */
2155 - if (gmac->interface == PHY_INTERFACE_MODE_RGMII) {
2156 + if (phy_interface_mode_is_rgmii(gmac->interface)) {
2157 clk_set_rate(gmac->tx_clk, SUN7I_GMAC_GMII_RGMII_RATE);
2158 clk_prepare_enable(gmac->tx_clk);
2159 gmac->clk_enabled = 1;
2160 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
2161 index 9d08a934fe4f..ff751ab3d765 100644
2162 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
2163 +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2.h
2164 @@ -343,6 +343,8 @@
2165 #define XGMAC_DMA_CH_RX_CONTROL(x) (0x00003108 + (0x80 * (x)))
2166 #define XGMAC_RxPBL GENMASK(21, 16)
2167 #define XGMAC_RxPBL_SHIFT 16
2168 +#define XGMAC_RBSZ GENMASK(14, 1)
2169 +#define XGMAC_RBSZ_SHIFT 1
2170 #define XGMAC_RXST BIT(0)
2171 #define XGMAC_DMA_CH_TxDESC_HADDR(x) (0x00003110 + (0x80 * (x)))
2172 #define XGMAC_DMA_CH_TxDESC_LADDR(x) (0x00003114 + (0x80 * (x)))
2173 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
2174 index f70ca5300b82..4af7271cea56 100644
2175 --- a/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
2176 +++ b/drivers/net/ethernet/stmicro/stmmac/dwxgmac2_dma.c
2177 @@ -489,7 +489,8 @@ static void dwxgmac2_set_bfsize(void __iomem *ioaddr, int bfsize, u32 chan)
2178 u32 value;
2179
2180 value = readl(ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
2181 - value |= bfsize << 1;
2182 + value &= ~XGMAC_RBSZ;
2183 + value |= bfsize << XGMAC_RBSZ_SHIFT;
2184 writel(value, ioaddr + XGMAC_DMA_CH_RX_CONTROL(chan));
2185 }
2186
2187 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2188 index 271a00f24f45..903c5d8a226e 100644
2189 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2190 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
2191 @@ -45,7 +45,7 @@
2192 #include "dwxgmac2.h"
2193 #include "hwif.h"
2194
2195 -#define STMMAC_ALIGN(x) __ALIGN_KERNEL(x, SMP_CACHE_BYTES)
2196 +#define STMMAC_ALIGN(x) ALIGN(ALIGN(x, SMP_CACHE_BYTES), 16)
2197 #define TSO_MAX_BUFF_SIZE (SZ_16K - 1)
2198
2199 /* Module parameters */
2200 @@ -1292,19 +1292,9 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
2201 struct stmmac_priv *priv = netdev_priv(dev);
2202 u32 rx_count = priv->plat->rx_queues_to_use;
2203 int ret = -ENOMEM;
2204 - int bfsize = 0;
2205 int queue;
2206 int i;
2207
2208 - bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
2209 - if (bfsize < 0)
2210 - bfsize = 0;
2211 -
2212 - if (bfsize < BUF_SIZE_16KiB)
2213 - bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
2214 -
2215 - priv->dma_buf_sz = bfsize;
2216 -
2217 /* RX INITIALIZATION */
2218 netif_dbg(priv, probe, priv->dev,
2219 "SKB addresses:\nskb\t\tskb data\tdma data\n");
2220 @@ -1346,8 +1336,6 @@ static int init_dma_rx_desc_rings(struct net_device *dev, gfp_t flags)
2221 }
2222 }
2223
2224 - buf_sz = bfsize;
2225 -
2226 return 0;
2227
2228 err_init_rx_buffers:
2229 @@ -2654,6 +2642,7 @@ static void stmmac_hw_teardown(struct net_device *dev)
2230 static int stmmac_open(struct net_device *dev)
2231 {
2232 struct stmmac_priv *priv = netdev_priv(dev);
2233 + int bfsize = 0;
2234 u32 chan;
2235 int ret;
2236
2237 @@ -2673,7 +2662,16 @@ static int stmmac_open(struct net_device *dev)
2238 memset(&priv->xstats, 0, sizeof(struct stmmac_extra_stats));
2239 priv->xstats.threshold = tc;
2240
2241 - priv->dma_buf_sz = STMMAC_ALIGN(buf_sz);
2242 + bfsize = stmmac_set_16kib_bfsize(priv, dev->mtu);
2243 + if (bfsize < 0)
2244 + bfsize = 0;
2245 +
2246 + if (bfsize < BUF_SIZE_16KiB)
2247 + bfsize = stmmac_set_bfsize(dev->mtu, priv->dma_buf_sz);
2248 +
2249 + priv->dma_buf_sz = bfsize;
2250 + buf_sz = bfsize;
2251 +
2252 priv->rx_copybreak = STMMAC_RX_COPYBREAK;
2253
2254 ret = alloc_dma_desc_resources(priv);
2255 @@ -3103,6 +3101,7 @@ static netdev_tx_t stmmac_tso_xmit(struct sk_buff *skb, struct net_device *dev)
2256
2257 tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
2258 stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
2259 + stmmac_tx_timer_arm(priv, queue);
2260
2261 return NETDEV_TX_OK;
2262
2263 @@ -3330,6 +3329,7 @@ static netdev_tx_t stmmac_xmit(struct sk_buff *skb, struct net_device *dev)
2264
2265 tx_q->tx_tail_addr = tx_q->dma_tx_phy + (tx_q->cur_tx * sizeof(*desc));
2266 stmmac_set_tx_tail_ptr(priv, priv->ioaddr, tx_q->tx_tail_addr, queue);
2267 + stmmac_tx_timer_arm(priv, queue);
2268
2269 return NETDEV_TX_OK;
2270
2271 @@ -3747,12 +3747,24 @@ static void stmmac_set_rx_mode(struct net_device *dev)
2272 static int stmmac_change_mtu(struct net_device *dev, int new_mtu)
2273 {
2274 struct stmmac_priv *priv = netdev_priv(dev);
2275 + int txfifosz = priv->plat->tx_fifo_size;
2276 +
2277 + if (txfifosz == 0)
2278 + txfifosz = priv->dma_cap.tx_fifo_size;
2279 +
2280 + txfifosz /= priv->plat->tx_queues_to_use;
2281
2282 if (netif_running(dev)) {
2283 netdev_err(priv->dev, "must be stopped to change its MTU\n");
2284 return -EBUSY;
2285 }
2286
2287 + new_mtu = STMMAC_ALIGN(new_mtu);
2288 +
2289 + /* If condition true, FIFO is too small or MTU too large */
2290 + if ((txfifosz < new_mtu) || (new_mtu > BUF_SIZE_16KiB))
2291 + return -EINVAL;
2292 +
2293 dev->mtu = new_mtu;
2294
2295 netdev_update_features(dev);
2296 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2297 index 1f230bd854c4..5150551c28be 100644
2298 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2299 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
2300 @@ -320,7 +320,7 @@ out:
2301 static int stmmac_dt_phy(struct plat_stmmacenet_data *plat,
2302 struct device_node *np, struct device *dev)
2303 {
2304 - bool mdio = false;
2305 + bool mdio = !of_phy_is_fixed_link(np);
2306 static const struct of_device_id need_mdio_ids[] = {
2307 { .compatible = "snps,dwc-qos-ethernet-4.10" },
2308 {},
2309 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
2310 index ac3f658105c0..a0513deab1a0 100644
2311 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
2312 +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
2313 @@ -624,6 +624,8 @@ static int stmmac_test_mcfilt(struct stmmac_priv *priv)
2314 return -EOPNOTSUPP;
2315 if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
2316 return -EOPNOTSUPP;
2317 + if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
2318 + return -EOPNOTSUPP;
2319
2320 while (--tries) {
2321 /* We only need to check the mc_addr for collisions */
2322 @@ -666,6 +668,8 @@ static int stmmac_test_ucfilt(struct stmmac_priv *priv)
2323
2324 if (stmmac_filter_check(priv))
2325 return -EOPNOTSUPP;
2326 + if (netdev_uc_count(priv->dev) >= priv->hw->unicast_filter_entries)
2327 + return -EOPNOTSUPP;
2328 if (netdev_mc_count(priv->dev) >= priv->hw->multicast_filter_bins)
2329 return -EOPNOTSUPP;
2330
2331 diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c
2332 index fca471e27f39..f6222ada6818 100644
2333 --- a/drivers/net/gtp.c
2334 +++ b/drivers/net/gtp.c
2335 @@ -813,7 +813,7 @@ static struct sock *gtp_encap_enable_socket(int fd, int type,
2336 lock_sock(sock->sk);
2337 if (sock->sk->sk_user_data) {
2338 sk = ERR_PTR(-EBUSY);
2339 - goto out_sock;
2340 + goto out_rel_sock;
2341 }
2342
2343 sk = sock->sk;
2344 @@ -826,8 +826,9 @@ static struct sock *gtp_encap_enable_socket(int fd, int type,
2345
2346 setup_udp_tunnel_sock(sock_net(sock->sk), sock, &tuncfg);
2347
2348 -out_sock:
2349 +out_rel_sock:
2350 release_sock(sock->sk);
2351 +out_sock:
2352 sockfd_put(sock);
2353 return sk;
2354 }
2355 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
2356 index fb547f37af1e..e74f2d1def80 100644
2357 --- a/drivers/net/hyperv/hyperv_net.h
2358 +++ b/drivers/net/hyperv/hyperv_net.h
2359 @@ -169,7 +169,6 @@ struct rndis_device {
2360
2361 u8 hw_mac_adr[ETH_ALEN];
2362 u8 rss_key[NETVSC_HASH_KEYLEN];
2363 - u16 rx_table[ITAB_NUM];
2364 };
2365
2366
2367 @@ -938,6 +937,8 @@ struct net_device_context {
2368
2369 u32 tx_table[VRSS_SEND_TAB_SIZE];
2370
2371 + u16 rx_table[ITAB_NUM];
2372 +
2373 /* Ethtool settings */
2374 u8 duplex;
2375 u32 speed;
2376 diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c
2377 index 963509add611..78e3e689a733 100644
2378 --- a/drivers/net/hyperv/netvsc_drv.c
2379 +++ b/drivers/net/hyperv/netvsc_drv.c
2380 @@ -1659,7 +1659,7 @@ static int netvsc_get_rxfh(struct net_device *dev, u32 *indir, u8 *key,
2381 rndis_dev = ndev->extension;
2382 if (indir) {
2383 for (i = 0; i < ITAB_NUM; i++)
2384 - indir[i] = rndis_dev->rx_table[i];
2385 + indir[i] = ndc->rx_table[i];
2386 }
2387
2388 if (key)
2389 @@ -1689,7 +1689,7 @@ static int netvsc_set_rxfh(struct net_device *dev, const u32 *indir,
2390 return -EINVAL;
2391
2392 for (i = 0; i < ITAB_NUM; i++)
2393 - rndis_dev->rx_table[i] = indir[i];
2394 + ndc->rx_table[i] = indir[i];
2395 }
2396
2397 if (!key) {
2398 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
2399 index e3d3c9097ff1..f81e58267a6e 100644
2400 --- a/drivers/net/hyperv/rndis_filter.c
2401 +++ b/drivers/net/hyperv/rndis_filter.c
2402 @@ -767,6 +767,7 @@ static int rndis_set_rss_param_msg(struct rndis_device *rdev,
2403 const u8 *rss_key, u16 flag)
2404 {
2405 struct net_device *ndev = rdev->ndev;
2406 + struct net_device_context *ndc = netdev_priv(ndev);
2407 struct rndis_request *request;
2408 struct rndis_set_request *set;
2409 struct rndis_set_complete *set_complete;
2410 @@ -806,7 +807,7 @@ static int rndis_set_rss_param_msg(struct rndis_device *rdev,
2411 /* Set indirection table entries */
2412 itab = (u32 *)(rssp + 1);
2413 for (i = 0; i < ITAB_NUM; i++)
2414 - itab[i] = rdev->rx_table[i];
2415 + itab[i] = ndc->rx_table[i];
2416
2417 /* Set hask key values */
2418 keyp = (u8 *)((unsigned long)rssp + rssp->hashkey_offset);
2419 @@ -1305,6 +1306,7 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
2420 struct netvsc_device_info *device_info)
2421 {
2422 struct net_device *net = hv_get_drvdata(dev);
2423 + struct net_device_context *ndc = netdev_priv(net);
2424 struct netvsc_device *net_device;
2425 struct rndis_device *rndis_device;
2426 struct ndis_recv_scale_cap rsscap;
2427 @@ -1391,9 +1393,11 @@ struct netvsc_device *rndis_filter_device_add(struct hv_device *dev,
2428 /* We will use the given number of channels if available. */
2429 net_device->num_chn = min(net_device->max_chn, device_info->num_chn);
2430
2431 - for (i = 0; i < ITAB_NUM; i++)
2432 - rndis_device->rx_table[i] = ethtool_rxfh_indir_default(
2433 + if (!netif_is_rxfh_configured(net)) {
2434 + for (i = 0; i < ITAB_NUM; i++)
2435 + ndc->rx_table[i] = ethtool_rxfh_indir_default(
2436 i, net_device->num_chn);
2437 + }
2438
2439 atomic_set(&net_device->open_chn, 1);
2440 vmbus_set_sc_create_callback(dev->channel, netvsc_sc_open);
2441 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
2442 index 05631d97eeb4..747c0542a53c 100644
2443 --- a/drivers/net/macvlan.c
2444 +++ b/drivers/net/macvlan.c
2445 @@ -259,7 +259,7 @@ static void macvlan_broadcast(struct sk_buff *skb,
2446 struct net_device *src,
2447 enum macvlan_mode mode)
2448 {
2449 - const struct ethhdr *eth = eth_hdr(skb);
2450 + const struct ethhdr *eth = skb_eth_hdr(skb);
2451 const struct macvlan_dev *vlan;
2452 struct sk_buff *nskb;
2453 unsigned int i;
2454 diff --git a/drivers/net/usb/lan78xx.c b/drivers/net/usb/lan78xx.c
2455 index 0becc79fd431..3e5f2f7a155e 100644
2456 --- a/drivers/net/usb/lan78xx.c
2457 +++ b/drivers/net/usb/lan78xx.c
2458 @@ -511,7 +511,7 @@ static int lan78xx_read_stats(struct lan78xx_net *dev,
2459 }
2460 } else {
2461 netdev_warn(dev->net,
2462 - "Failed to read stat ret = 0x%x", ret);
2463 + "Failed to read stat ret = %d", ret);
2464 }
2465
2466 kfree(stats);
2467 @@ -2724,11 +2724,6 @@ static int lan78xx_stop(struct net_device *net)
2468 return 0;
2469 }
2470
2471 -static int lan78xx_linearize(struct sk_buff *skb)
2472 -{
2473 - return skb_linearize(skb);
2474 -}
2475 -
2476 static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev,
2477 struct sk_buff *skb, gfp_t flags)
2478 {
2479 @@ -2740,8 +2735,10 @@ static struct sk_buff *lan78xx_tx_prep(struct lan78xx_net *dev,
2480 return NULL;
2481 }
2482
2483 - if (lan78xx_linearize(skb) < 0)
2484 + if (skb_linearize(skb)) {
2485 + dev_kfree_skb_any(skb);
2486 return NULL;
2487 + }
2488
2489 tx_cmd_a = (u32)(skb->len & TX_CMD_A_LEN_MASK_) | TX_CMD_A_FCS_;
2490
2491 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
2492 index 404ac3a0d1c3..283dfeb406ad 100644
2493 --- a/drivers/net/vxlan.c
2494 +++ b/drivers/net/vxlan.c
2495 @@ -2542,7 +2542,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2496 ndst = &rt->dst;
2497 skb_tunnel_check_pmtu(skb, ndst, VXLAN_HEADROOM);
2498
2499 - tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
2500 + tos = ip_tunnel_ecn_encap(RT_TOS(tos), old_iph, skb);
2501 ttl = ttl ? : ip4_dst_hoplimit(&rt->dst);
2502 err = vxlan_build_skb(skb, ndst, sizeof(struct iphdr),
2503 vni, md, flags, udp_sum);
2504 @@ -2582,7 +2582,7 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
2505
2506 skb_tunnel_check_pmtu(skb, ndst, VXLAN6_HEADROOM);
2507
2508 - tos = ip_tunnel_ecn_encap(tos, old_iph, skb);
2509 + tos = ip_tunnel_ecn_encap(RT_TOS(tos), old_iph, skb);
2510 ttl = ttl ? : ip6_dst_hoplimit(ndst);
2511 skb_scrub_packet(skb, xnet);
2512 err = vxlan_build_skb(skb, ndst, sizeof(struct ipv6hdr),
2513 diff --git a/drivers/net/wireless/marvell/mwifiex/tdls.c b/drivers/net/wireless/marvell/mwifiex/tdls.c
2514 index 09313047beed..7caf1d26124a 100644
2515 --- a/drivers/net/wireless/marvell/mwifiex/tdls.c
2516 +++ b/drivers/net/wireless/marvell/mwifiex/tdls.c
2517 @@ -953,59 +953,117 @@ void mwifiex_process_tdls_action_frame(struct mwifiex_private *priv,
2518
2519 switch (*pos) {
2520 case WLAN_EID_SUPP_RATES:
2521 + if (pos[1] > 32)
2522 + return;
2523 sta_ptr->tdls_cap.rates_len = pos[1];
2524 for (i = 0; i < pos[1]; i++)
2525 sta_ptr->tdls_cap.rates[i] = pos[i + 2];
2526 break;
2527
2528 case WLAN_EID_EXT_SUPP_RATES:
2529 + if (pos[1] > 32)
2530 + return;
2531 basic = sta_ptr->tdls_cap.rates_len;
2532 + if (pos[1] > 32 - basic)
2533 + return;
2534 for (i = 0; i < pos[1]; i++)
2535 sta_ptr->tdls_cap.rates[basic + i] = pos[i + 2];
2536 sta_ptr->tdls_cap.rates_len += pos[1];
2537 break;
2538 case WLAN_EID_HT_CAPABILITY:
2539 - memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos,
2540 + if (pos > end - sizeof(struct ieee80211_ht_cap) - 2)
2541 + return;
2542 + if (pos[1] != sizeof(struct ieee80211_ht_cap))
2543 + return;
2544 + /* copy the ie's value into ht_capb*/
2545 + memcpy((u8 *)&sta_ptr->tdls_cap.ht_capb, pos + 2,
2546 sizeof(struct ieee80211_ht_cap));
2547 sta_ptr->is_11n_enabled = 1;
2548 break;
2549 case WLAN_EID_HT_OPERATION:
2550 - memcpy(&sta_ptr->tdls_cap.ht_oper, pos,
2551 + if (pos > end -
2552 + sizeof(struct ieee80211_ht_operation) - 2)
2553 + return;
2554 + if (pos[1] != sizeof(struct ieee80211_ht_operation))
2555 + return;
2556 + /* copy the ie's value into ht_oper*/
2557 + memcpy(&sta_ptr->tdls_cap.ht_oper, pos + 2,
2558 sizeof(struct ieee80211_ht_operation));
2559 break;
2560 case WLAN_EID_BSS_COEX_2040:
2561 + if (pos > end - 3)
2562 + return;
2563 + if (pos[1] != 1)
2564 + return;
2565 sta_ptr->tdls_cap.coex_2040 = pos[2];
2566 break;
2567 case WLAN_EID_EXT_CAPABILITY:
2568 + if (pos > end - sizeof(struct ieee_types_header))
2569 + return;
2570 + if (pos[1] < sizeof(struct ieee_types_header))
2571 + return;
2572 + if (pos[1] > 8)
2573 + return;
2574 memcpy((u8 *)&sta_ptr->tdls_cap.extcap, pos,
2575 sizeof(struct ieee_types_header) +
2576 min_t(u8, pos[1], 8));
2577 break;
2578 case WLAN_EID_RSN:
2579 + if (pos > end - sizeof(struct ieee_types_header))
2580 + return;
2581 + if (pos[1] < sizeof(struct ieee_types_header))
2582 + return;
2583 + if (pos[1] > IEEE_MAX_IE_SIZE -
2584 + sizeof(struct ieee_types_header))
2585 + return;
2586 memcpy((u8 *)&sta_ptr->tdls_cap.rsn_ie, pos,
2587 sizeof(struct ieee_types_header) +
2588 min_t(u8, pos[1], IEEE_MAX_IE_SIZE -
2589 sizeof(struct ieee_types_header)));
2590 break;
2591 case WLAN_EID_QOS_CAPA:
2592 + if (pos > end - 3)
2593 + return;
2594 + if (pos[1] != 1)
2595 + return;
2596 sta_ptr->tdls_cap.qos_info = pos[2];
2597 break;
2598 case WLAN_EID_VHT_OPERATION:
2599 - if (priv->adapter->is_hw_11ac_capable)
2600 - memcpy(&sta_ptr->tdls_cap.vhtoper, pos,
2601 + if (priv->adapter->is_hw_11ac_capable) {
2602 + if (pos > end -
2603 + sizeof(struct ieee80211_vht_operation) - 2)
2604 + return;
2605 + if (pos[1] !=
2606 + sizeof(struct ieee80211_vht_operation))
2607 + return;
2608 + /* copy the ie's value into vhtoper*/
2609 + memcpy(&sta_ptr->tdls_cap.vhtoper, pos + 2,
2610 sizeof(struct ieee80211_vht_operation));
2611 + }
2612 break;
2613 case WLAN_EID_VHT_CAPABILITY:
2614 if (priv->adapter->is_hw_11ac_capable) {
2615 - memcpy((u8 *)&sta_ptr->tdls_cap.vhtcap, pos,
2616 + if (pos > end -
2617 + sizeof(struct ieee80211_vht_cap) - 2)
2618 + return;
2619 + if (pos[1] != sizeof(struct ieee80211_vht_cap))
2620 + return;
2621 + /* copy the ie's value into vhtcap*/
2622 + memcpy((u8 *)&sta_ptr->tdls_cap.vhtcap, pos + 2,
2623 sizeof(struct ieee80211_vht_cap));
2624 sta_ptr->is_11ac_enabled = 1;
2625 }
2626 break;
2627 case WLAN_EID_AID:
2628 - if (priv->adapter->is_hw_11ac_capable)
2629 + if (priv->adapter->is_hw_11ac_capable) {
2630 + if (pos > end - 4)
2631 + return;
2632 + if (pos[1] != 2)
2633 + return;
2634 sta_ptr->tdls_cap.aid =
2635 get_unaligned_le16((pos + 2));
2636 + }
2637 + break;
2638 default:
2639 break;
2640 }
2641 diff --git a/drivers/perf/arm_smmuv3_pmu.c b/drivers/perf/arm_smmuv3_pmu.c
2642 index abcf54f7d19c..191f410cf35c 100644
2643 --- a/drivers/perf/arm_smmuv3_pmu.c
2644 +++ b/drivers/perf/arm_smmuv3_pmu.c
2645 @@ -815,7 +815,7 @@ static int smmu_pmu_probe(struct platform_device *pdev)
2646 if (err) {
2647 dev_err(dev, "Error %d registering hotplug, PMU @%pa\n",
2648 err, &res_0->start);
2649 - goto out_cpuhp_err;
2650 + return err;
2651 }
2652
2653 err = perf_pmu_register(&smmu_pmu->pmu, name, -1);
2654 @@ -834,8 +834,6 @@ static int smmu_pmu_probe(struct platform_device *pdev)
2655
2656 out_unregister:
2657 cpuhp_state_remove_instance_nocalls(cpuhp_state_num, &smmu_pmu->node);
2658 -out_cpuhp_err:
2659 - put_cpu();
2660 return err;
2661 }
2662
2663 diff --git a/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
2664 index c6800d220920..bb07024d22ed 100644
2665 --- a/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
2666 +++ b/drivers/pinctrl/aspeed/pinctrl-aspeed-g6.c
2667 @@ -1088,60 +1088,52 @@ SSSF_PIN_DECL(AF15, GPIOV7, LPCSMI, SIG_DESC_SET(SCU434, 15));
2668
2669 #define AB7 176
2670 SIG_EXPR_LIST_DECL_SESG(AB7, LAD0, LPC, SIG_DESC_SET(SCU434, 16),
2671 - SIG_DESC_CLEAR(SCU510, 6));
2672 -SIG_EXPR_LIST_DECL_SESG(AB7, ESPID0, ESPI, SIG_DESC_SET(SCU434, 16),
2673 SIG_DESC_SET(SCU510, 6));
2674 +SIG_EXPR_LIST_DECL_SESG(AB7, ESPID0, ESPI, SIG_DESC_SET(SCU434, 16));
2675 PIN_DECL_2(AB7, GPIOW0, LAD0, ESPID0);
2676
2677 #define AB8 177
2678 SIG_EXPR_LIST_DECL_SESG(AB8, LAD1, LPC, SIG_DESC_SET(SCU434, 17),
2679 - SIG_DESC_CLEAR(SCU510, 6));
2680 -SIG_EXPR_LIST_DECL_SESG(AB8, ESPID1, ESPI, SIG_DESC_SET(SCU434, 17),
2681 SIG_DESC_SET(SCU510, 6));
2682 +SIG_EXPR_LIST_DECL_SESG(AB8, ESPID1, ESPI, SIG_DESC_SET(SCU434, 17));
2683 PIN_DECL_2(AB8, GPIOW1, LAD1, ESPID1);
2684
2685 #define AC8 178
2686 SIG_EXPR_LIST_DECL_SESG(AC8, LAD2, LPC, SIG_DESC_SET(SCU434, 18),
2687 - SIG_DESC_CLEAR(SCU510, 6));
2688 -SIG_EXPR_LIST_DECL_SESG(AC8, ESPID2, ESPI, SIG_DESC_SET(SCU434, 18),
2689 SIG_DESC_SET(SCU510, 6));
2690 +SIG_EXPR_LIST_DECL_SESG(AC8, ESPID2, ESPI, SIG_DESC_SET(SCU434, 18));
2691 PIN_DECL_2(AC8, GPIOW2, LAD2, ESPID2);
2692
2693 #define AC7 179
2694 SIG_EXPR_LIST_DECL_SESG(AC7, LAD3, LPC, SIG_DESC_SET(SCU434, 19),
2695 - SIG_DESC_CLEAR(SCU510, 6));
2696 -SIG_EXPR_LIST_DECL_SESG(AC7, ESPID3, ESPI, SIG_DESC_SET(SCU434, 19),
2697 SIG_DESC_SET(SCU510, 6));
2698 +SIG_EXPR_LIST_DECL_SESG(AC7, ESPID3, ESPI, SIG_DESC_SET(SCU434, 19));
2699 PIN_DECL_2(AC7, GPIOW3, LAD3, ESPID3);
2700
2701 #define AE7 180
2702 SIG_EXPR_LIST_DECL_SESG(AE7, LCLK, LPC, SIG_DESC_SET(SCU434, 20),
2703 - SIG_DESC_CLEAR(SCU510, 6));
2704 -SIG_EXPR_LIST_DECL_SESG(AE7, ESPICK, ESPI, SIG_DESC_SET(SCU434, 20),
2705 SIG_DESC_SET(SCU510, 6));
2706 +SIG_EXPR_LIST_DECL_SESG(AE7, ESPICK, ESPI, SIG_DESC_SET(SCU434, 20));
2707 PIN_DECL_2(AE7, GPIOW4, LCLK, ESPICK);
2708
2709 #define AF7 181
2710 SIG_EXPR_LIST_DECL_SESG(AF7, LFRAME, LPC, SIG_DESC_SET(SCU434, 21),
2711 - SIG_DESC_CLEAR(SCU510, 6));
2712 -SIG_EXPR_LIST_DECL_SESG(AF7, ESPICS, ESPI, SIG_DESC_SET(SCU434, 21),
2713 SIG_DESC_SET(SCU510, 6));
2714 +SIG_EXPR_LIST_DECL_SESG(AF7, ESPICS, ESPI, SIG_DESC_SET(SCU434, 21));
2715 PIN_DECL_2(AF7, GPIOW5, LFRAME, ESPICS);
2716
2717 #define AD7 182
2718 SIG_EXPR_LIST_DECL_SESG(AD7, LSIRQ, LSIRQ, SIG_DESC_SET(SCU434, 22),
2719 - SIG_DESC_CLEAR(SCU510, 6));
2720 -SIG_EXPR_LIST_DECL_SESG(AD7, ESPIALT, ESPIALT, SIG_DESC_SET(SCU434, 22),
2721 SIG_DESC_SET(SCU510, 6));
2722 +SIG_EXPR_LIST_DECL_SESG(AD7, ESPIALT, ESPIALT, SIG_DESC_SET(SCU434, 22));
2723 PIN_DECL_2(AD7, GPIOW6, LSIRQ, ESPIALT);
2724 FUNC_GROUP_DECL(LSIRQ, AD7);
2725 FUNC_GROUP_DECL(ESPIALT, AD7);
2726
2727 #define AD8 183
2728 SIG_EXPR_LIST_DECL_SESG(AD8, LPCRST, LPC, SIG_DESC_SET(SCU434, 23),
2729 - SIG_DESC_CLEAR(SCU510, 6));
2730 -SIG_EXPR_LIST_DECL_SESG(AD8, ESPIRST, ESPI, SIG_DESC_SET(SCU434, 23),
2731 SIG_DESC_SET(SCU510, 6));
2732 +SIG_EXPR_LIST_DECL_SESG(AD8, ESPIRST, ESPI, SIG_DESC_SET(SCU434, 23));
2733 PIN_DECL_2(AD8, GPIOW7, LPCRST, ESPIRST);
2734
2735 FUNC_GROUP_DECL(LPC, AB7, AB8, AC8, AC7, AE7, AF7, AD8);
2736 diff --git a/drivers/pinctrl/pinmux.c b/drivers/pinctrl/pinmux.c
2737 index e914f6efd39e..9503ddf2edc7 100644
2738 --- a/drivers/pinctrl/pinmux.c
2739 +++ b/drivers/pinctrl/pinmux.c
2740 @@ -85,7 +85,7 @@ bool pinmux_can_be_used_for_gpio(struct pinctrl_dev *pctldev, unsigned pin)
2741 const struct pinmux_ops *ops = pctldev->desc->pmxops;
2742
2743 /* Can't inspect pin, assume it can be used */
2744 - if (!desc)
2745 + if (!desc || !ops)
2746 return true;
2747
2748 if (ops->strict && desc->mux_usecount)
2749 diff --git a/drivers/platform/x86/pcengines-apuv2.c b/drivers/platform/x86/pcengines-apuv2.c
2750 index 48b112b4f0b0..c32daf087640 100644
2751 --- a/drivers/platform/x86/pcengines-apuv2.c
2752 +++ b/drivers/platform/x86/pcengines-apuv2.c
2753 @@ -95,7 +95,7 @@ static struct gpiod_lookup_table gpios_led_table = {
2754 NULL, 1, GPIO_ACTIVE_LOW),
2755 GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_LINE_LED3,
2756 NULL, 2, GPIO_ACTIVE_LOW),
2757 - GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_REG_SIMSWAP,
2758 + GPIO_LOOKUP_IDX(AMD_FCH_GPIO_DRIVER_NAME, APU2_GPIO_LINE_SIMSWAP,
2759 NULL, 3, GPIO_ACTIVE_LOW),
2760 }
2761 };
2762 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
2763 index 87bc06b386a0..1dba0bdf3762 100644
2764 --- a/drivers/regulator/core.c
2765 +++ b/drivers/regulator/core.c
2766 @@ -1937,8 +1937,8 @@ struct regulator *_regulator_get(struct device *dev, const char *id,
2767 regulator = create_regulator(rdev, dev, id);
2768 if (regulator == NULL) {
2769 regulator = ERR_PTR(-ENOMEM);
2770 - put_device(&rdev->dev);
2771 module_put(rdev->owner);
2772 + put_device(&rdev->dev);
2773 return regulator;
2774 }
2775
2776 @@ -2059,13 +2059,13 @@ static void _regulator_put(struct regulator *regulator)
2777
2778 rdev->open_count--;
2779 rdev->exclusive = 0;
2780 - put_device(&rdev->dev);
2781 regulator_unlock(rdev);
2782
2783 kfree_const(regulator->supply_name);
2784 kfree(regulator);
2785
2786 module_put(rdev->owner);
2787 + put_device(&rdev->dev);
2788 }
2789
2790 /**
2791 @@ -4992,6 +4992,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
2792 struct regulator_dev *rdev;
2793 bool dangling_cfg_gpiod = false;
2794 bool dangling_of_gpiod = false;
2795 + bool reg_device_fail = false;
2796 struct device *dev;
2797 int ret, i;
2798
2799 @@ -5177,7 +5178,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
2800 dev_set_drvdata(&rdev->dev, rdev);
2801 ret = device_register(&rdev->dev);
2802 if (ret != 0) {
2803 - put_device(&rdev->dev);
2804 + reg_device_fail = true;
2805 goto unset_supplies;
2806 }
2807
2808 @@ -5208,7 +5209,10 @@ wash:
2809 clean:
2810 if (dangling_of_gpiod)
2811 gpiod_put(config->ena_gpiod);
2812 - kfree(rdev);
2813 + if (reg_device_fail)
2814 + put_device(&rdev->dev);
2815 + else
2816 + kfree(rdev);
2817 kfree(config);
2818 rinse:
2819 if (dangling_cfg_gpiod)
2820 diff --git a/drivers/regulator/rn5t618-regulator.c b/drivers/regulator/rn5t618-regulator.c
2821 index eb807a059479..aa6e7c5341ce 100644
2822 --- a/drivers/regulator/rn5t618-regulator.c
2823 +++ b/drivers/regulator/rn5t618-regulator.c
2824 @@ -148,6 +148,7 @@ static struct platform_driver rn5t618_regulator_driver = {
2825
2826 module_platform_driver(rn5t618_regulator_driver);
2827
2828 +MODULE_ALIAS("platform:rn5t618-regulator");
2829 MODULE_AUTHOR("Beniamino Galvani <b.galvani@gmail.com>");
2830 MODULE_DESCRIPTION("RN5T618 regulator driver");
2831 MODULE_LICENSE("GPL v2");
2832 diff --git a/drivers/reset/core.c b/drivers/reset/core.c
2833 index 3c9a64c1b7a8..f343bd814d32 100644
2834 --- a/drivers/reset/core.c
2835 +++ b/drivers/reset/core.c
2836 @@ -787,7 +787,7 @@ struct reset_control *__devm_reset_control_get(struct device *dev,
2837 return ERR_PTR(-ENOMEM);
2838
2839 rstc = __reset_control_get(dev, id, index, shared, optional, acquired);
2840 - if (!IS_ERR(rstc)) {
2841 + if (!IS_ERR_OR_NULL(rstc)) {
2842 *ptr = rstc;
2843 devres_add(dev, ptr);
2844 } else {
2845 @@ -930,7 +930,7 @@ devm_reset_control_array_get(struct device *dev, bool shared, bool optional)
2846 return ERR_PTR(-ENOMEM);
2847
2848 rstc = of_reset_control_array_get(dev->of_node, shared, optional, true);
2849 - if (IS_ERR(rstc)) {
2850 + if (IS_ERR_OR_NULL(rstc)) {
2851 devres_free(devres);
2852 return rstc;
2853 }
2854 diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
2855 index c94184d080f8..a28b9ff82378 100644
2856 --- a/drivers/s390/block/dasd_eckd.c
2857 +++ b/drivers/s390/block/dasd_eckd.c
2858 @@ -1128,7 +1128,8 @@ static u32 get_fcx_max_data(struct dasd_device *device)
2859 {
2860 struct dasd_eckd_private *private = device->private;
2861 int fcx_in_css, fcx_in_gneq, fcx_in_features;
2862 - int tpm, mdc;
2863 + unsigned int mdc;
2864 + int tpm;
2865
2866 if (dasd_nofcx)
2867 return 0;
2868 @@ -1142,7 +1143,7 @@ static u32 get_fcx_max_data(struct dasd_device *device)
2869 return 0;
2870
2871 mdc = ccw_device_get_mdc(device->cdev, 0);
2872 - if (mdc < 0) {
2873 + if (mdc == 0) {
2874 dev_warn(&device->cdev->dev, "Detecting the maximum supported data size for zHPF requests failed\n");
2875 return 0;
2876 } else {
2877 @@ -1153,12 +1154,12 @@ static u32 get_fcx_max_data(struct dasd_device *device)
2878 static int verify_fcx_max_data(struct dasd_device *device, __u8 lpm)
2879 {
2880 struct dasd_eckd_private *private = device->private;
2881 - int mdc;
2882 + unsigned int mdc;
2883 u32 fcx_max_data;
2884
2885 if (private->fcx_max_data) {
2886 mdc = ccw_device_get_mdc(device->cdev, lpm);
2887 - if ((mdc < 0)) {
2888 + if (mdc == 0) {
2889 dev_warn(&device->cdev->dev,
2890 "Detecting the maximum data size for zHPF "
2891 "requests failed (rc=%d) for a new path %x\n",
2892 @@ -2073,7 +2074,7 @@ out_err2:
2893 dasd_free_block(device->block);
2894 device->block = NULL;
2895 out_err1:
2896 - kfree(private->conf_data);
2897 + dasd_eckd_clear_conf_data(device);
2898 kfree(device->private);
2899 device->private = NULL;
2900 return rc;
2901 @@ -2082,7 +2083,6 @@ out_err1:
2902 static void dasd_eckd_uncheck_device(struct dasd_device *device)
2903 {
2904 struct dasd_eckd_private *private = device->private;
2905 - int i;
2906
2907 if (!private)
2908 return;
2909 @@ -2092,21 +2092,7 @@ static void dasd_eckd_uncheck_device(struct dasd_device *device)
2910 private->sneq = NULL;
2911 private->vdsneq = NULL;
2912 private->gneq = NULL;
2913 - private->conf_len = 0;
2914 - for (i = 0; i < 8; i++) {
2915 - kfree(device->path[i].conf_data);
2916 - if ((__u8 *)device->path[i].conf_data ==
2917 - private->conf_data) {
2918 - private->conf_data = NULL;
2919 - private->conf_len = 0;
2920 - }
2921 - device->path[i].conf_data = NULL;
2922 - device->path[i].cssid = 0;
2923 - device->path[i].ssid = 0;
2924 - device->path[i].chpid = 0;
2925 - }
2926 - kfree(private->conf_data);
2927 - private->conf_data = NULL;
2928 + dasd_eckd_clear_conf_data(device);
2929 }
2930
2931 static struct dasd_ccw_req *
2932 diff --git a/drivers/s390/cio/device_ops.c b/drivers/s390/cio/device_ops.c
2933 index 65841af15748..ccecf6b9504e 100644
2934 --- a/drivers/s390/cio/device_ops.c
2935 +++ b/drivers/s390/cio/device_ops.c
2936 @@ -635,7 +635,7 @@ EXPORT_SYMBOL(ccw_device_tm_start_timeout);
2937 * @mask: mask of paths to use
2938 *
2939 * Return the number of 64K-bytes blocks all paths at least support
2940 - * for a transport command. Return values <= 0 indicate failures.
2941 + * for a transport command. Return value 0 indicates failure.
2942 */
2943 int ccw_device_get_mdc(struct ccw_device *cdev, u8 mask)
2944 {
2945 diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c
2946 index 83794d7494d4..9df47421d69c 100644
2947 --- a/drivers/s390/net/qeth_core_main.c
2948 +++ b/drivers/s390/net/qeth_core_main.c
2949 @@ -653,17 +653,17 @@ static int qeth_check_idx_response(struct qeth_card *card,
2950 unsigned char *buffer)
2951 {
2952 QETH_DBF_HEX(CTRL, 2, buffer, QETH_DBF_CTRL_LEN);
2953 - if ((buffer[2] & 0xc0) == 0xc0) {
2954 + if ((buffer[2] & QETH_IDX_TERMINATE_MASK) == QETH_IDX_TERMINATE) {
2955 QETH_DBF_MESSAGE(2, "received an IDX TERMINATE with cause code %#04x\n",
2956 buffer[4]);
2957 QETH_CARD_TEXT(card, 2, "ckidxres");
2958 QETH_CARD_TEXT(card, 2, " idxterm");
2959 - QETH_CARD_TEXT_(card, 2, " rc%d", -EIO);
2960 - if (buffer[4] == 0xf6) {
2961 + QETH_CARD_TEXT_(card, 2, "rc%x", buffer[4]);
2962 + if (buffer[4] == QETH_IDX_TERM_BAD_TRANSPORT ||
2963 + buffer[4] == QETH_IDX_TERM_BAD_TRANSPORT_VM) {
2964 dev_err(&card->gdev->dev,
2965 - "The qeth device is not configured "
2966 - "for the OSI layer required by z/VM\n");
2967 - return -EPERM;
2968 + "The device does not support the configured transport mode\n");
2969 + return -EPROTONOSUPPORT;
2970 }
2971 return -EIO;
2972 }
2973 @@ -740,10 +740,10 @@ static void qeth_issue_next_read_cb(struct qeth_card *card,
2974 case 0:
2975 break;
2976 case -EIO:
2977 - qeth_clear_ipacmd_list(card);
2978 qeth_schedule_recovery(card);
2979 /* fall through */
2980 default:
2981 + qeth_clear_ipacmd_list(card);
2982 goto out;
2983 }
2984
2985 diff --git a/drivers/s390/net/qeth_core_mpc.h b/drivers/s390/net/qeth_core_mpc.h
2986 index 6420b58cf42b..b7c17b5c823b 100644
2987 --- a/drivers/s390/net/qeth_core_mpc.h
2988 +++ b/drivers/s390/net/qeth_core_mpc.h
2989 @@ -912,6 +912,11 @@ extern unsigned char IDX_ACTIVATE_WRITE[];
2990 #define QETH_IDX_ACT_ERR_AUTH 0x1E
2991 #define QETH_IDX_ACT_ERR_AUTH_USER 0x20
2992
2993 +#define QETH_IDX_TERMINATE 0xc0
2994 +#define QETH_IDX_TERMINATE_MASK 0xc0
2995 +#define QETH_IDX_TERM_BAD_TRANSPORT 0x41
2996 +#define QETH_IDX_TERM_BAD_TRANSPORT_VM 0xf6
2997 +
2998 #define PDU_ENCAPSULATION(buffer) \
2999 (buffer + *(buffer + (*(buffer + 0x0b)) + \
3000 *(buffer + *(buffer + 0x0b) + 0x11) + 0x07))
3001 diff --git a/drivers/s390/net/qeth_core_sys.c b/drivers/s390/net/qeth_core_sys.c
3002 index 9f392497d570..4c3e222e5572 100644
3003 --- a/drivers/s390/net/qeth_core_sys.c
3004 +++ b/drivers/s390/net/qeth_core_sys.c
3005 @@ -227,7 +227,7 @@ static ssize_t qeth_dev_prioqing_store(struct device *dev,
3006 card->qdio.default_out_queue = QETH_DEFAULT_QUEUE;
3007 } else if (sysfs_streq(buf, "prio_queueing_vlan")) {
3008 if (IS_LAYER3(card)) {
3009 - rc = -ENOTSUPP;
3010 + rc = -EOPNOTSUPP;
3011 goto out;
3012 }
3013 card->qdio.do_prio_queueing = QETH_PRIO_Q_ING_VLAN;
3014 diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c
3015 index 4bccdce19b5a..8b7d911dccd8 100644
3016 --- a/drivers/s390/net/qeth_l2_main.c
3017 +++ b/drivers/s390/net/qeth_l2_main.c
3018 @@ -295,6 +295,7 @@ static void qeth_l2_stop_card(struct qeth_card *card)
3019
3020 flush_workqueue(card->event_wq);
3021 card->info.mac_bits &= ~QETH_LAYER2_MAC_REGISTERED;
3022 + card->info.promisc_mode = 0;
3023 }
3024
3025 static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
3026 diff --git a/drivers/s390/net/qeth_l2_sys.c b/drivers/s390/net/qeth_l2_sys.c
3027 index e2bcb26105a3..fc7101ad84de 100644
3028 --- a/drivers/s390/net/qeth_l2_sys.c
3029 +++ b/drivers/s390/net/qeth_l2_sys.c
3030 @@ -279,7 +279,8 @@ void qeth_l2_setup_bridgeport_attrs(struct qeth_card *card)
3031 return;
3032
3033 mutex_lock(&card->sbp_lock);
3034 - if (card->options.sbp.role != QETH_SBP_ROLE_NONE) {
3035 + if (!card->options.sbp.reflect_promisc &&
3036 + card->options.sbp.role != QETH_SBP_ROLE_NONE) {
3037 /* Conditional to avoid spurious error messages */
3038 qeth_bridgeport_setrole(card, card->options.sbp.role);
3039 /* Let the callback function refresh the stored role value. */
3040 diff --git a/drivers/s390/net/qeth_l3_main.c b/drivers/s390/net/qeth_l3_main.c
3041 index d7bfc7a0e4c0..32385327539b 100644
3042 --- a/drivers/s390/net/qeth_l3_main.c
3043 +++ b/drivers/s390/net/qeth_l3_main.c
3044 @@ -1433,6 +1433,7 @@ static void qeth_l3_stop_card(struct qeth_card *card)
3045 }
3046
3047 flush_workqueue(card->event_wq);
3048 + card->info.promisc_mode = 0;
3049 }
3050
3051 static void qeth_l3_set_promisc_mode(struct qeth_card *card)
3052 diff --git a/drivers/spi/spi-cavium-thunderx.c b/drivers/spi/spi-cavium-thunderx.c
3053 index d12e149f1a41..fd6b9caffaf0 100644
3054 --- a/drivers/spi/spi-cavium-thunderx.c
3055 +++ b/drivers/spi/spi-cavium-thunderx.c
3056 @@ -82,6 +82,7 @@ static int thunderx_spi_probe(struct pci_dev *pdev,
3057
3058 error:
3059 clk_disable_unprepare(p->clk);
3060 + pci_release_regions(pdev);
3061 spi_master_put(master);
3062 return ret;
3063 }
3064 @@ -96,6 +97,7 @@ static void thunderx_spi_remove(struct pci_dev *pdev)
3065 return;
3066
3067 clk_disable_unprepare(p->clk);
3068 + pci_release_regions(pdev);
3069 /* Put everything in a known state. */
3070 writeq(0, p->register_base + OCTEON_SPI_CFG(p));
3071 }
3072 diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c
3073 index 2d563874b4ac..be7c6ba73072 100644
3074 --- a/drivers/spi/spi-fsl-spi.c
3075 +++ b/drivers/spi/spi-fsl-spi.c
3076 @@ -612,6 +612,7 @@ static struct spi_master * fsl_spi_probe(struct device *dev,
3077 master->setup = fsl_spi_setup;
3078 master->cleanup = fsl_spi_cleanup;
3079 master->transfer_one_message = fsl_spi_do_one_msg;
3080 + master->use_gpio_descriptors = true;
3081
3082 mpc8xxx_spi = spi_master_get_devdata(master);
3083 mpc8xxx_spi->max_bits_per_word = 32;
3084 @@ -728,8 +729,18 @@ static int of_fsl_spi_probe(struct platform_device *ofdev)
3085 }
3086 }
3087 #endif
3088 -
3089 - pdata->cs_control = fsl_spi_cs_control;
3090 + /*
3091 + * Handle the case where we have one hardwired (always selected)
3092 + * device on the first "chipselect". Else we let the core code
3093 + * handle any GPIOs or native chip selects and assign the
3094 + * appropriate callback for dealing with the CS lines. This isn't
3095 + * supported on the GRLIB variant.
3096 + */
3097 + ret = gpiod_count(dev, "cs");
3098 + if (ret <= 0)
3099 + pdata->max_chipselect = 1;
3100 + else
3101 + pdata->cs_control = fsl_spi_cs_control;
3102 }
3103
3104 ret = of_address_to_resource(np, 0, &mem);
3105 diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
3106 index 501b923f2c27..28ae5229f889 100644
3107 --- a/drivers/spi/spi-nxp-fspi.c
3108 +++ b/drivers/spi/spi-nxp-fspi.c
3109 @@ -439,7 +439,7 @@ static bool nxp_fspi_supports_op(struct spi_mem *mem,
3110 op->data.nbytes > f->devtype_data->txfifo)
3111 return false;
3112
3113 - return true;
3114 + return spi_mem_default_supports_op(mem, op);
3115 }
3116
3117 /* Instead of busy looping invoke readl_poll_timeout functionality. */
3118 diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
3119 index 2e73d75a6ac5..ae95ec0bc964 100644
3120 --- a/drivers/spi/spi-pxa2xx.c
3121 +++ b/drivers/spi/spi-pxa2xx.c
3122 @@ -1441,6 +1441,10 @@ static const struct pci_device_id pxa2xx_spi_pci_compound_match[] = {
3123 { PCI_VDEVICE(INTEL, 0x4b2a), LPSS_BXT_SSP },
3124 { PCI_VDEVICE(INTEL, 0x4b2b), LPSS_BXT_SSP },
3125 { PCI_VDEVICE(INTEL, 0x4b37), LPSS_BXT_SSP },
3126 + /* JSL */
3127 + { PCI_VDEVICE(INTEL, 0x4daa), LPSS_CNL_SSP },
3128 + { PCI_VDEVICE(INTEL, 0x4dab), LPSS_CNL_SSP },
3129 + { PCI_VDEVICE(INTEL, 0x4dfb), LPSS_CNL_SSP },
3130 /* APL */
3131 { PCI_VDEVICE(INTEL, 0x5ac2), LPSS_BXT_SSP },
3132 { PCI_VDEVICE(INTEL, 0x5ac4), LPSS_BXT_SSP },
3133 diff --git a/drivers/spi/spi-ti-qspi.c b/drivers/spi/spi-ti-qspi.c
3134 index 3cb65371ae3b..66dcb6128539 100644
3135 --- a/drivers/spi/spi-ti-qspi.c
3136 +++ b/drivers/spi/spi-ti-qspi.c
3137 @@ -62,6 +62,7 @@ struct ti_qspi {
3138 u32 dc;
3139
3140 bool mmap_enabled;
3141 + int current_cs;
3142 };
3143
3144 #define QSPI_PID (0x0)
3145 @@ -487,6 +488,7 @@ static void ti_qspi_enable_memory_map(struct spi_device *spi)
3146 MEM_CS_EN(spi->chip_select));
3147 }
3148 qspi->mmap_enabled = true;
3149 + qspi->current_cs = spi->chip_select;
3150 }
3151
3152 static void ti_qspi_disable_memory_map(struct spi_device *spi)
3153 @@ -498,6 +500,7 @@ static void ti_qspi_disable_memory_map(struct spi_device *spi)
3154 regmap_update_bits(qspi->ctrl_base, qspi->ctrl_reg,
3155 MEM_CS_MASK, 0);
3156 qspi->mmap_enabled = false;
3157 + qspi->current_cs = -1;
3158 }
3159
3160 static void ti_qspi_setup_mmap_read(struct spi_device *spi, u8 opcode,
3161 @@ -543,7 +546,7 @@ static int ti_qspi_exec_mem_op(struct spi_mem *mem,
3162
3163 mutex_lock(&qspi->list_lock);
3164
3165 - if (!qspi->mmap_enabled)
3166 + if (!qspi->mmap_enabled || qspi->current_cs != mem->spi->chip_select)
3167 ti_qspi_enable_memory_map(mem->spi);
3168 ti_qspi_setup_mmap_read(mem->spi, op->cmd.opcode, op->data.buswidth,
3169 op->addr.nbytes, op->dummy.nbytes);
3170 @@ -799,6 +802,7 @@ no_dma:
3171 }
3172 }
3173 qspi->mmap_enabled = false;
3174 + qspi->current_cs = -1;
3175
3176 ret = devm_spi_register_master(&pdev->dev, master);
3177 if (!ret)
3178 diff --git a/drivers/staging/axis-fifo/Kconfig b/drivers/staging/axis-fifo/Kconfig
3179 index 3fffe4d6f327..f180a8e9f58a 100644
3180 --- a/drivers/staging/axis-fifo/Kconfig
3181 +++ b/drivers/staging/axis-fifo/Kconfig
3182 @@ -4,7 +4,7 @@
3183 #
3184 config XIL_AXIS_FIFO
3185 tristate "Xilinx AXI-Stream FIFO IP core driver"
3186 - depends on OF
3187 + depends on OF && HAS_IOMEM
3188 help
3189 This adds support for the Xilinx AXI-Stream FIFO IP core driver.
3190 The AXI Streaming FIFO allows memory mapped access to a AXI Streaming
3191 diff --git a/drivers/usb/core/config.c b/drivers/usb/core/config.c
3192 index 1ac1095bfeac..5e92c6abe306 100644
3193 --- a/drivers/usb/core/config.c
3194 +++ b/drivers/usb/core/config.c
3195 @@ -203,9 +203,58 @@ static const unsigned short super_speed_maxpacket_maxes[4] = {
3196 [USB_ENDPOINT_XFER_INT] = 1024,
3197 };
3198
3199 -static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
3200 - int asnum, struct usb_host_interface *ifp, int num_ep,
3201 - unsigned char *buffer, int size)
3202 +static bool endpoint_is_duplicate(struct usb_endpoint_descriptor *e1,
3203 + struct usb_endpoint_descriptor *e2)
3204 +{
3205 + if (e1->bEndpointAddress == e2->bEndpointAddress)
3206 + return true;
3207 +
3208 + if (usb_endpoint_xfer_control(e1) || usb_endpoint_xfer_control(e2)) {
3209 + if (usb_endpoint_num(e1) == usb_endpoint_num(e2))
3210 + return true;
3211 + }
3212 +
3213 + return false;
3214 +}
3215 +
3216 +/*
3217 + * Check for duplicate endpoint addresses in other interfaces and in the
3218 + * altsetting currently being parsed.
3219 + */
3220 +static bool config_endpoint_is_duplicate(struct usb_host_config *config,
3221 + int inum, int asnum, struct usb_endpoint_descriptor *d)
3222 +{
3223 + struct usb_endpoint_descriptor *epd;
3224 + struct usb_interface_cache *intfc;
3225 + struct usb_host_interface *alt;
3226 + int i, j, k;
3227 +
3228 + for (i = 0; i < config->desc.bNumInterfaces; ++i) {
3229 + intfc = config->intf_cache[i];
3230 +
3231 + for (j = 0; j < intfc->num_altsetting; ++j) {
3232 + alt = &intfc->altsetting[j];
3233 +
3234 + if (alt->desc.bInterfaceNumber == inum &&
3235 + alt->desc.bAlternateSetting != asnum)
3236 + continue;
3237 +
3238 + for (k = 0; k < alt->desc.bNumEndpoints; ++k) {
3239 + epd = &alt->endpoint[k].desc;
3240 +
3241 + if (endpoint_is_duplicate(epd, d))
3242 + return true;
3243 + }
3244 + }
3245 + }
3246 +
3247 + return false;
3248 +}
3249 +
3250 +static int usb_parse_endpoint(struct device *ddev, int cfgno,
3251 + struct usb_host_config *config, int inum, int asnum,
3252 + struct usb_host_interface *ifp, int num_ep,
3253 + unsigned char *buffer, int size)
3254 {
3255 unsigned char *buffer0 = buffer;
3256 struct usb_endpoint_descriptor *d;
3257 @@ -242,13 +291,10 @@ static int usb_parse_endpoint(struct device *ddev, int cfgno, int inum,
3258 goto skip_to_next_endpoint_or_interface_descriptor;
3259
3260 /* Check for duplicate endpoint addresses */
3261 - for (i = 0; i < ifp->desc.bNumEndpoints; ++i) {
3262 - if (ifp->endpoint[i].desc.bEndpointAddress ==
3263 - d->bEndpointAddress) {
3264 - dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
3265 - cfgno, inum, asnum, d->bEndpointAddress);
3266 - goto skip_to_next_endpoint_or_interface_descriptor;
3267 - }
3268 + if (config_endpoint_is_duplicate(config, inum, asnum, d)) {
3269 + dev_warn(ddev, "config %d interface %d altsetting %d has a duplicate endpoint with address 0x%X, skipping\n",
3270 + cfgno, inum, asnum, d->bEndpointAddress);
3271 + goto skip_to_next_endpoint_or_interface_descriptor;
3272 }
3273
3274 endpoint = &ifp->endpoint[ifp->desc.bNumEndpoints];
3275 @@ -522,8 +568,8 @@ static int usb_parse_interface(struct device *ddev, int cfgno,
3276 if (((struct usb_descriptor_header *) buffer)->bDescriptorType
3277 == USB_DT_INTERFACE)
3278 break;
3279 - retval = usb_parse_endpoint(ddev, cfgno, inum, asnum, alt,
3280 - num_ep, buffer, size);
3281 + retval = usb_parse_endpoint(ddev, cfgno, config, inum, asnum,
3282 + alt, num_ep, buffer, size);
3283 if (retval < 0)
3284 return retval;
3285 ++n;
3286 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
3287 index dfe9ac8d2375..8b23162e4239 100644
3288 --- a/drivers/usb/core/hub.c
3289 +++ b/drivers/usb/core/hub.c
3290 @@ -2691,7 +2691,7 @@ static unsigned hub_is_wusb(struct usb_hub *hub)
3291 #define SET_ADDRESS_TRIES 2
3292 #define GET_DESCRIPTOR_TRIES 2
3293 #define SET_CONFIG_TRIES (2 * (use_both_schemes + 1))
3294 -#define USE_NEW_SCHEME(i, scheme) ((i) / 2 == (int)scheme)
3295 +#define USE_NEW_SCHEME(i, scheme) ((i) / 2 == (int)(scheme))
3296
3297 #define HUB_ROOT_RESET_TIME 60 /* times are in msec */
3298 #define HUB_SHORT_RESET_TIME 10
3299 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
3300 index 0c960a97ea02..154f3f3e8cff 100644
3301 --- a/drivers/usb/dwc3/gadget.c
3302 +++ b/drivers/usb/dwc3/gadget.c
3303 @@ -2467,6 +2467,13 @@ static int dwc3_gadget_ep_reclaim_trb_linear(struct dwc3_ep *dep,
3304
3305 static bool dwc3_gadget_ep_request_completed(struct dwc3_request *req)
3306 {
3307 + /*
3308 + * For OUT direction, host may send less than the setup
3309 + * length. Return true for all OUT requests.
3310 + */
3311 + if (!req->direction)
3312 + return true;
3313 +
3314 return req->request.actual == req->request.length;
3315 }
3316
3317 diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c
3318 index a8f1e5707c14..4c9d1e49d5ed 100644
3319 --- a/drivers/usb/gadget/udc/dummy_hcd.c
3320 +++ b/drivers/usb/gadget/udc/dummy_hcd.c
3321 @@ -1321,7 +1321,7 @@ static int dummy_perform_transfer(struct urb *urb, struct dummy_request *req,
3322 u32 this_sg;
3323 bool next_sg;
3324
3325 - to_host = usb_pipein(urb->pipe);
3326 + to_host = usb_urb_dir_in(urb);
3327 rbuf = req->req.buf + req->req.actual;
3328
3329 if (!urb->num_sgs) {
3330 @@ -1409,7 +1409,7 @@ top:
3331
3332 /* FIXME update emulated data toggle too */
3333
3334 - to_host = usb_pipein(urb->pipe);
3335 + to_host = usb_urb_dir_in(urb);
3336 if (unlikely(len == 0))
3337 is_short = 1;
3338 else {
3339 @@ -1830,7 +1830,7 @@ restart:
3340
3341 /* find the gadget's ep for this request (if configured) */
3342 address = usb_pipeendpoint (urb->pipe);
3343 - if (usb_pipein(urb->pipe))
3344 + if (usb_urb_dir_in(urb))
3345 address |= USB_DIR_IN;
3346 ep = find_endpoint(dum, address);
3347 if (!ep) {
3348 @@ -2385,7 +2385,7 @@ static inline ssize_t show_urb(char *buf, size_t size, struct urb *urb)
3349 s = "?";
3350 break;
3351 } s; }),
3352 - ep, ep ? (usb_pipein(urb->pipe) ? "in" : "out") : "",
3353 + ep, ep ? (usb_urb_dir_in(urb) ? "in" : "out") : "",
3354 ({ char *s; \
3355 switch (usb_pipetype(urb->pipe)) { \
3356 case PIPE_CONTROL: \
3357 diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c
3358 index e9491d400a24..fea09a3f491f 100644
3359 --- a/drivers/usb/serial/option.c
3360 +++ b/drivers/usb/serial/option.c
3361 @@ -1172,6 +1172,8 @@ static const struct usb_device_id option_ids[] = {
3362 .driver_info = NCTRL(0) | RSVD(3) },
3363 { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x1102, 0xff), /* Telit ME910 (ECM) */
3364 .driver_info = NCTRL(0) },
3365 + { USB_DEVICE_INTERFACE_CLASS(TELIT_VENDOR_ID, 0x110a, 0xff), /* Telit ME910G1 */
3366 + .driver_info = NCTRL(0) | RSVD(3) },
3367 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910),
3368 .driver_info = NCTRL(0) | RSVD(1) | RSVD(2) },
3369 { USB_DEVICE(TELIT_VENDOR_ID, TELIT_PRODUCT_LE910_USBCFG4),
3370 diff --git a/drivers/usb/typec/tcpm/Kconfig b/drivers/usb/typec/tcpm/Kconfig
3371 index 72481bbb2af3..5b986d6c801d 100644
3372 --- a/drivers/usb/typec/tcpm/Kconfig
3373 +++ b/drivers/usb/typec/tcpm/Kconfig
3374 @@ -32,6 +32,7 @@ endif # TYPEC_TCPCI
3375 config TYPEC_FUSB302
3376 tristate "Fairchild FUSB302 Type-C chip driver"
3377 depends on I2C
3378 + depends on EXTCON || !EXTCON
3379 help
3380 The Fairchild FUSB302 Type-C chip driver that works with
3381 Type-C Port Controller Manager to provide USB PD and USB
3382 diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
3383 index eb95ed78a18e..dc50605ecbda 100644
3384 --- a/fs/btrfs/extent-tree.c
3385 +++ b/fs/btrfs/extent-tree.c
3386 @@ -3781,6 +3781,7 @@ static noinline int find_free_extent(struct btrfs_fs_info *fs_info,
3387 u64 flags, int delalloc)
3388 {
3389 int ret = 0;
3390 + int cache_block_group_error = 0;
3391 struct btrfs_free_cluster *last_ptr = NULL;
3392 struct btrfs_block_group_cache *block_group = NULL;
3393 struct find_free_extent_ctl ffe_ctl = {0};
3394 @@ -3940,7 +3941,20 @@ have_block_group:
3395 if (unlikely(!ffe_ctl.cached)) {
3396 ffe_ctl.have_caching_bg = true;
3397 ret = btrfs_cache_block_group(block_group, 0);
3398 - BUG_ON(ret < 0);
3399 +
3400 + /*
3401 + * If we get ENOMEM here or something else we want to
3402 + * try other block groups, because it may not be fatal.
3403 + * However if we can't find anything else we need to
3404 + * save our return here so that we return the actual
3405 + * error that caused problems, not ENOSPC.
3406 + */
3407 + if (ret < 0) {
3408 + if (!cache_block_group_error)
3409 + cache_block_group_error = ret;
3410 + ret = 0;
3411 + goto loop;
3412 + }
3413 ret = 0;
3414 }
3415
3416 @@ -4027,7 +4041,7 @@ loop:
3417 if (ret > 0)
3418 goto search;
3419
3420 - if (ret == -ENOSPC) {
3421 + if (ret == -ENOSPC && !cache_block_group_error) {
3422 /*
3423 * Use ffe_ctl->total_free_space as fallback if we can't find
3424 * any contiguous hole.
3425 @@ -4038,6 +4052,8 @@ loop:
3426 space_info->max_extent_size = ffe_ctl.max_extent_size;
3427 spin_unlock(&space_info->lock);
3428 ins->offset = ffe_ctl.max_extent_size;
3429 + } else if (ret == -ENOSPC) {
3430 + ret = cache_block_group_error;
3431 }
3432 return ret;
3433 }
3434 diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c
3435 index c332968f9056..eaafd00f93d4 100644
3436 --- a/fs/btrfs/file.c
3437 +++ b/fs/btrfs/file.c
3438 @@ -2601,8 +2601,8 @@ int btrfs_punch_hole_range(struct inode *inode, struct btrfs_path *path,
3439 }
3440 }
3441
3442 - if (clone_info) {
3443 - u64 clone_len = drop_end - cur_offset;
3444 + if (clone_info && drop_end > clone_info->file_offset) {
3445 + u64 clone_len = drop_end - clone_info->file_offset;
3446
3447 ret = btrfs_insert_clone_extent(trans, inode, path,
3448 clone_info, clone_len);
3449 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
3450 index a56dcc0c9c2a..5720e450a46f 100644
3451 --- a/fs/btrfs/ioctl.c
3452 +++ b/fs/btrfs/ioctl.c
3453 @@ -3727,24 +3727,18 @@ process_slot:
3454 ret = 0;
3455
3456 if (last_dest_end < destoff + len) {
3457 - struct btrfs_clone_extent_info clone_info = { 0 };
3458 /*
3459 - * We have an implicit hole (NO_HOLES feature is enabled) that
3460 - * fully or partially overlaps our cloning range at its end.
3461 + * We have an implicit hole that fully or partially overlaps our
3462 + * cloning range at its end. This means that we either have the
3463 + * NO_HOLES feature enabled or the implicit hole happened due to
3464 + * mixing buffered and direct IO writes against this file.
3465 */
3466 btrfs_release_path(path);
3467 path->leave_spinning = 0;
3468
3469 - /*
3470 - * We are dealing with a hole and our clone_info already has a
3471 - * disk_offset of 0, we only need to fill the data length and
3472 - * file offset.
3473 - */
3474 - clone_info.data_len = destoff + len - last_dest_end;
3475 - clone_info.file_offset = last_dest_end;
3476 ret = btrfs_punch_hole_range(inode, path,
3477 last_dest_end, destoff + len - 1,
3478 - &clone_info, &trans);
3479 + NULL, &trans);
3480 if (ret)
3481 goto out;
3482
3483 diff --git a/fs/btrfs/qgroup.c b/fs/btrfs/qgroup.c
3484 index 27a903aaf43b..aeb5f2f3cdd7 100644
3485 --- a/fs/btrfs/qgroup.c
3486 +++ b/fs/btrfs/qgroup.c
3487 @@ -3232,12 +3232,12 @@ qgroup_rescan_init(struct btrfs_fs_info *fs_info, u64 progress_objectid,
3488 if (!(fs_info->qgroup_flags &
3489 BTRFS_QGROUP_STATUS_FLAG_RESCAN)) {
3490 btrfs_warn(fs_info,
3491 - "qgroup rescan init failed, qgroup is not enabled");
3492 + "qgroup rescan init failed, qgroup rescan is not queued");
3493 ret = -EINVAL;
3494 } else if (!(fs_info->qgroup_flags &
3495 BTRFS_QGROUP_STATUS_FLAG_ON)) {
3496 btrfs_warn(fs_info,
3497 - "qgroup rescan init failed, qgroup rescan is not queued");
3498 + "qgroup rescan init failed, qgroup is not enabled");
3499 ret = -EINVAL;
3500 }
3501
3502 diff --git a/fs/drop_caches.c b/fs/drop_caches.c
3503 index d31b6c72b476..dc1a1d5d825b 100644
3504 --- a/fs/drop_caches.c
3505 +++ b/fs/drop_caches.c
3506 @@ -35,11 +35,11 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
3507 spin_unlock(&inode->i_lock);
3508 spin_unlock(&sb->s_inode_list_lock);
3509
3510 - cond_resched();
3511 invalidate_mapping_pages(inode->i_mapping, 0, -1);
3512 iput(toput_inode);
3513 toput_inode = inode;
3514
3515 + cond_resched();
3516 spin_lock(&sb->s_inode_list_lock);
3517 }
3518 spin_unlock(&sb->s_inode_list_lock);
3519 diff --git a/fs/inode.c b/fs/inode.c
3520 index fef457a42882..96d62d97694e 100644
3521 --- a/fs/inode.c
3522 +++ b/fs/inode.c
3523 @@ -676,6 +676,7 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
3524 struct inode *inode, *next;
3525 LIST_HEAD(dispose);
3526
3527 +again:
3528 spin_lock(&sb->s_inode_list_lock);
3529 list_for_each_entry_safe(inode, next, &sb->s_inodes, i_sb_list) {
3530 spin_lock(&inode->i_lock);
3531 @@ -698,6 +699,12 @@ int invalidate_inodes(struct super_block *sb, bool kill_dirty)
3532 inode_lru_list_del(inode);
3533 spin_unlock(&inode->i_lock);
3534 list_add(&inode->i_lru, &dispose);
3535 + if (need_resched()) {
3536 + spin_unlock(&sb->s_inode_list_lock);
3537 + cond_resched();
3538 + dispose_list(&dispose);
3539 + goto again;
3540 + }
3541 }
3542 spin_unlock(&sb->s_inode_list_lock);
3543
3544 diff --git a/fs/io_uring.c b/fs/io_uring.c
3545 index a60c6315a348..709671faaed6 100644
3546 --- a/fs/io_uring.c
3547 +++ b/fs/io_uring.c
3548 @@ -3721,6 +3721,9 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
3549 mutex_lock(&ctx->uring_lock);
3550 submitted = io_ring_submit(ctx, to_submit);
3551 mutex_unlock(&ctx->uring_lock);
3552 +
3553 + if (submitted != to_submit)
3554 + goto out;
3555 }
3556 if (flags & IORING_ENTER_GETEVENTS) {
3557 unsigned nr_events = 0;
3558 @@ -3734,6 +3737,7 @@ SYSCALL_DEFINE6(io_uring_enter, unsigned int, fd, u32, to_submit,
3559 }
3560 }
3561
3562 +out:
3563 percpu_ref_put(&ctx->refs);
3564 out_fput:
3565 fdput(f);
3566 diff --git a/fs/notify/fsnotify.c b/fs/notify/fsnotify.c
3567 index 2ecef6155fc0..f44e39c68328 100644
3568 --- a/fs/notify/fsnotify.c
3569 +++ b/fs/notify/fsnotify.c
3570 @@ -57,6 +57,9 @@ static void fsnotify_unmount_inodes(struct super_block *sb)
3571 * doing an __iget/iput with SB_ACTIVE clear would actually
3572 * evict all inodes with zero i_count from icache which is
3573 * unnecessarily violent and may in fact be illegal to do.
3574 + * However, we should have been called /after/ evict_inodes
3575 + * removed all zero refcount inodes, in any case. Test to
3576 + * be sure.
3577 */
3578 if (!atomic_read(&inode->i_count)) {
3579 spin_unlock(&inode->i_lock);
3580 @@ -77,6 +80,7 @@ static void fsnotify_unmount_inodes(struct super_block *sb)
3581
3582 iput_inode = inode;
3583
3584 + cond_resched();
3585 spin_lock(&sb->s_inode_list_lock);
3586 }
3587 spin_unlock(&sb->s_inode_list_lock);
3588 diff --git a/fs/quota/dquot.c b/fs/quota/dquot.c
3589 index 9b96243de081..7abc3230c21a 100644
3590 --- a/fs/quota/dquot.c
3591 +++ b/fs/quota/dquot.c
3592 @@ -986,6 +986,7 @@ static int add_dquot_ref(struct super_block *sb, int type)
3593 * later.
3594 */
3595 old_inode = inode;
3596 + cond_resched();
3597 spin_lock(&sb->s_inode_list_lock);
3598 }
3599 spin_unlock(&sb->s_inode_list_lock);
3600 diff --git a/fs/super.c b/fs/super.c
3601 index cfadab2cbf35..cd352530eca9 100644
3602 --- a/fs/super.c
3603 +++ b/fs/super.c
3604 @@ -448,10 +448,12 @@ void generic_shutdown_super(struct super_block *sb)
3605 sync_filesystem(sb);
3606 sb->s_flags &= ~SB_ACTIVE;
3607
3608 - fsnotify_sb_delete(sb);
3609 cgroup_writeback_umount();
3610
3611 + /* evict all inodes with zero refcount */
3612 evict_inodes(sb);
3613 + /* only nonzero refcount inodes can have marks */
3614 + fsnotify_sb_delete(sb);
3615
3616 if (sb->s_dio_done_wq) {
3617 destroy_workqueue(sb->s_dio_done_wq);
3618 diff --git a/include/linux/if_ether.h b/include/linux/if_ether.h
3619 index 76cf11e905e1..8a9792a6427a 100644
3620 --- a/include/linux/if_ether.h
3621 +++ b/include/linux/if_ether.h
3622 @@ -24,6 +24,14 @@ static inline struct ethhdr *eth_hdr(const struct sk_buff *skb)
3623 return (struct ethhdr *)skb_mac_header(skb);
3624 }
3625
3626 +/* Prefer this version in TX path, instead of
3627 + * skb_reset_mac_header() + eth_hdr()
3628 + */
3629 +static inline struct ethhdr *skb_eth_hdr(const struct sk_buff *skb)
3630 +{
3631 + return (struct ethhdr *)skb->data;
3632 +}
3633 +
3634 static inline struct ethhdr *inner_eth_hdr(const struct sk_buff *skb)
3635 {
3636 return (struct ethhdr *)skb_inner_mac_header(skb);
3637 diff --git a/include/uapi/linux/netfilter/xt_sctp.h b/include/uapi/linux/netfilter/xt_sctp.h
3638 index 4bc6d1a08781..b4d804a9fccb 100644
3639 --- a/include/uapi/linux/netfilter/xt_sctp.h
3640 +++ b/include/uapi/linux/netfilter/xt_sctp.h
3641 @@ -41,19 +41,19 @@ struct xt_sctp_info {
3642 #define SCTP_CHUNKMAP_SET(chunkmap, type) \
3643 do { \
3644 (chunkmap)[type / bytes(__u32)] |= \
3645 - 1 << (type % bytes(__u32)); \
3646 + 1u << (type % bytes(__u32)); \
3647 } while (0)
3648
3649 #define SCTP_CHUNKMAP_CLEAR(chunkmap, type) \
3650 do { \
3651 (chunkmap)[type / bytes(__u32)] &= \
3652 - ~(1 << (type % bytes(__u32))); \
3653 + ~(1u << (type % bytes(__u32))); \
3654 } while (0)
3655
3656 #define SCTP_CHUNKMAP_IS_SET(chunkmap, type) \
3657 ({ \
3658 ((chunkmap)[type / bytes (__u32)] & \
3659 - (1 << (type % bytes (__u32)))) ? 1: 0; \
3660 + (1u << (type % bytes (__u32)))) ? 1: 0; \
3661 })
3662
3663 #define SCTP_CHUNKMAP_RESET(chunkmap) \
3664 diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
3665 index 5c51021775af..9c74c98f6501 100644
3666 --- a/kernel/bpf/verifier.c
3667 +++ b/kernel/bpf/verifier.c
3668 @@ -6039,6 +6039,7 @@ static bool may_access_skb(enum bpf_prog_type type)
3669 static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
3670 {
3671 struct bpf_reg_state *regs = cur_regs(env);
3672 + static const int ctx_reg = BPF_REG_6;
3673 u8 mode = BPF_MODE(insn->code);
3674 int i, err;
3675
3676 @@ -6072,7 +6073,7 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
3677 }
3678
3679 /* check whether implicit source operand (register R6) is readable */
3680 - err = check_reg_arg(env, BPF_REG_6, SRC_OP);
3681 + err = check_reg_arg(env, ctx_reg, SRC_OP);
3682 if (err)
3683 return err;
3684
3685 @@ -6091,7 +6092,7 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
3686 return -EINVAL;
3687 }
3688
3689 - if (regs[BPF_REG_6].type != PTR_TO_CTX) {
3690 + if (regs[ctx_reg].type != PTR_TO_CTX) {
3691 verbose(env,
3692 "at the time of BPF_LD_ABS|IND R6 != pointer to skb\n");
3693 return -EINVAL;
3694 @@ -6104,6 +6105,10 @@ static int check_ld_abs(struct bpf_verifier_env *env, struct bpf_insn *insn)
3695 return err;
3696 }
3697
3698 + err = check_ctx_reg(env, &regs[ctx_reg], ctx_reg);
3699 + if (err < 0)
3700 + return err;
3701 +
3702 /* reset caller saved regs to unreadable */
3703 for (i = 0; i < CALLER_SAVED_REGS; i++) {
3704 mark_reg_not_init(env, regs, caller_saved[i]);
3705 diff --git a/kernel/locking/spinlock_debug.c b/kernel/locking/spinlock_debug.c
3706 index 399669f7eba8..472dd462a40c 100644
3707 --- a/kernel/locking/spinlock_debug.c
3708 +++ b/kernel/locking/spinlock_debug.c
3709 @@ -51,19 +51,19 @@ EXPORT_SYMBOL(__rwlock_init);
3710
3711 static void spin_dump(raw_spinlock_t *lock, const char *msg)
3712 {
3713 - struct task_struct *owner = NULL;
3714 + struct task_struct *owner = READ_ONCE(lock->owner);
3715
3716 - if (lock->owner && lock->owner != SPINLOCK_OWNER_INIT)
3717 - owner = lock->owner;
3718 + if (owner == SPINLOCK_OWNER_INIT)
3719 + owner = NULL;
3720 printk(KERN_EMERG "BUG: spinlock %s on CPU#%d, %s/%d\n",
3721 msg, raw_smp_processor_id(),
3722 current->comm, task_pid_nr(current));
3723 printk(KERN_EMERG " lock: %pS, .magic: %08x, .owner: %s/%d, "
3724 ".owner_cpu: %d\n",
3725 - lock, lock->magic,
3726 + lock, READ_ONCE(lock->magic),
3727 owner ? owner->comm : "<none>",
3728 owner ? task_pid_nr(owner) : -1,
3729 - lock->owner_cpu);
3730 + READ_ONCE(lock->owner_cpu));
3731 dump_stack();
3732 }
3733
3734 @@ -80,16 +80,16 @@ static void spin_bug(raw_spinlock_t *lock, const char *msg)
3735 static inline void
3736 debug_spin_lock_before(raw_spinlock_t *lock)
3737 {
3738 - SPIN_BUG_ON(lock->magic != SPINLOCK_MAGIC, lock, "bad magic");
3739 - SPIN_BUG_ON(lock->owner == current, lock, "recursion");
3740 - SPIN_BUG_ON(lock->owner_cpu == raw_smp_processor_id(),
3741 + SPIN_BUG_ON(READ_ONCE(lock->magic) != SPINLOCK_MAGIC, lock, "bad magic");
3742 + SPIN_BUG_ON(READ_ONCE(lock->owner) == current, lock, "recursion");
3743 + SPIN_BUG_ON(READ_ONCE(lock->owner_cpu) == raw_smp_processor_id(),
3744 lock, "cpu recursion");
3745 }
3746
3747 static inline void debug_spin_lock_after(raw_spinlock_t *lock)
3748 {
3749 - lock->owner_cpu = raw_smp_processor_id();
3750 - lock->owner = current;
3751 + WRITE_ONCE(lock->owner_cpu, raw_smp_processor_id());
3752 + WRITE_ONCE(lock->owner, current);
3753 }
3754
3755 static inline void debug_spin_unlock(raw_spinlock_t *lock)
3756 @@ -99,8 +99,8 @@ static inline void debug_spin_unlock(raw_spinlock_t *lock)
3757 SPIN_BUG_ON(lock->owner != current, lock, "wrong owner");
3758 SPIN_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
3759 lock, "wrong CPU");
3760 - lock->owner = SPINLOCK_OWNER_INIT;
3761 - lock->owner_cpu = -1;
3762 + WRITE_ONCE(lock->owner, SPINLOCK_OWNER_INIT);
3763 + WRITE_ONCE(lock->owner_cpu, -1);
3764 }
3765
3766 /*
3767 @@ -187,8 +187,8 @@ static inline void debug_write_lock_before(rwlock_t *lock)
3768
3769 static inline void debug_write_lock_after(rwlock_t *lock)
3770 {
3771 - lock->owner_cpu = raw_smp_processor_id();
3772 - lock->owner = current;
3773 + WRITE_ONCE(lock->owner_cpu, raw_smp_processor_id());
3774 + WRITE_ONCE(lock->owner, current);
3775 }
3776
3777 static inline void debug_write_unlock(rwlock_t *lock)
3778 @@ -197,8 +197,8 @@ static inline void debug_write_unlock(rwlock_t *lock)
3779 RWLOCK_BUG_ON(lock->owner != current, lock, "wrong owner");
3780 RWLOCK_BUG_ON(lock->owner_cpu != raw_smp_processor_id(),
3781 lock, "wrong CPU");
3782 - lock->owner = SPINLOCK_OWNER_INIT;
3783 - lock->owner_cpu = -1;
3784 + WRITE_ONCE(lock->owner, SPINLOCK_OWNER_INIT);
3785 + WRITE_ONCE(lock->owner_cpu, -1);
3786 }
3787
3788 void do_raw_write_lock(rwlock_t *lock)
3789 diff --git a/kernel/sched/psi.c b/kernel/sched/psi.c
3790 index 517e3719027e..ce8f6748678a 100644
3791 --- a/kernel/sched/psi.c
3792 +++ b/kernel/sched/psi.c
3793 @@ -185,7 +185,8 @@ static void group_init(struct psi_group *group)
3794
3795 for_each_possible_cpu(cpu)
3796 seqcount_init(&per_cpu_ptr(group->pcpu, cpu)->seq);
3797 - group->avg_next_update = sched_clock() + psi_period;
3798 + group->avg_last_update = sched_clock();
3799 + group->avg_next_update = group->avg_last_update + psi_period;
3800 INIT_DELAYED_WORK(&group->avgs_work, psi_avgs_work);
3801 mutex_init(&group->avgs_lock);
3802 /* Init trigger-related members */
3803 @@ -481,7 +482,7 @@ static u64 window_update(struct psi_window *win, u64 now, u64 value)
3804 u32 remaining;
3805
3806 remaining = win->size - elapsed;
3807 - growth += div_u64(win->prev_growth * remaining, win->size);
3808 + growth += div64_u64(win->prev_growth * remaining, win->size);
3809 }
3810
3811 return growth;
3812 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
3813 index 66358d66c933..4bf050fcfe3b 100644
3814 --- a/kernel/trace/ring_buffer.c
3815 +++ b/kernel/trace/ring_buffer.c
3816 @@ -11,6 +11,7 @@
3817 #include <linux/trace_seq.h>
3818 #include <linux/spinlock.h>
3819 #include <linux/irq_work.h>
3820 +#include <linux/security.h>
3821 #include <linux/uaccess.h>
3822 #include <linux/hardirq.h>
3823 #include <linux/kthread.h> /* for self test */
3824 @@ -5068,6 +5069,11 @@ static __init int test_ringbuffer(void)
3825 int cpu;
3826 int ret = 0;
3827
3828 + if (security_locked_down(LOCKDOWN_TRACEFS)) {
3829 + pr_warning("Lockdown is enabled, skipping ring buffer tests\n");
3830 + return 0;
3831 + }
3832 +
3833 pr_info("Running ring buffer tests...\n");
3834
3835 buffer = ring_buffer_alloc(RB_TEST_BUFFER_SIZE, RB_FL_OVERWRITE);
3836 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
3837 index d8bd9b1d8bce..bcb72f102613 100644
3838 --- a/kernel/trace/trace.c
3839 +++ b/kernel/trace/trace.c
3840 @@ -1804,6 +1804,12 @@ int __init register_tracer(struct tracer *type)
3841 return -1;
3842 }
3843
3844 + if (security_locked_down(LOCKDOWN_TRACEFS)) {
3845 + pr_warning("Can not register tracer %s due to lockdown\n",
3846 + type->name);
3847 + return -EPERM;
3848 + }
3849 +
3850 mutex_lock(&trace_types_lock);
3851
3852 tracing_selftest_running = true;
3853 @@ -8647,6 +8653,11 @@ struct dentry *tracing_init_dentry(void)
3854 {
3855 struct trace_array *tr = &global_trace;
3856
3857 + if (security_locked_down(LOCKDOWN_TRACEFS)) {
3858 + pr_warning("Tracing disabled due to lockdown\n");
3859 + return ERR_PTR(-EPERM);
3860 + }
3861 +
3862 /* The top level trace array uses NULL as parent */
3863 if (tr->dir)
3864 return NULL;
3865 @@ -9089,6 +9100,12 @@ __init static int tracer_alloc_buffers(void)
3866 int ring_buf_size;
3867 int ret = -ENOMEM;
3868
3869 +
3870 + if (security_locked_down(LOCKDOWN_TRACEFS)) {
3871 + pr_warning("Tracing disabled due to lockdown\n");
3872 + return -EPERM;
3873 + }
3874 +
3875 /*
3876 * Make sure we don't accidently add more trace options
3877 * than we have bits for.
3878 diff --git a/lib/sbitmap.c b/lib/sbitmap.c
3879 index 969e5400a615..ee3ce1494568 100644
3880 --- a/lib/sbitmap.c
3881 +++ b/lib/sbitmap.c
3882 @@ -667,8 +667,8 @@ void sbitmap_add_wait_queue(struct sbitmap_queue *sbq,
3883 if (!sbq_wait->sbq) {
3884 sbq_wait->sbq = sbq;
3885 atomic_inc(&sbq->ws_active);
3886 + add_wait_queue(&ws->wait, &sbq_wait->wait);
3887 }
3888 - add_wait_queue(&ws->wait, &sbq_wait->wait);
3889 }
3890 EXPORT_SYMBOL_GPL(sbitmap_add_wait_queue);
3891
3892 diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
3893 index c46daf09a501..bb7ec1a3915d 100644
3894 --- a/net/8021q/vlan.h
3895 +++ b/net/8021q/vlan.h
3896 @@ -126,6 +126,7 @@ int vlan_check_real_dev(struct net_device *real_dev,
3897 void vlan_setup(struct net_device *dev);
3898 int register_vlan_dev(struct net_device *dev, struct netlink_ext_ack *extack);
3899 void unregister_vlan_dev(struct net_device *dev, struct list_head *head);
3900 +void vlan_dev_uninit(struct net_device *dev);
3901 bool vlan_dev_inherit_address(struct net_device *dev,
3902 struct net_device *real_dev);
3903
3904 diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
3905 index e5bff5cc6f97..2a78da4072de 100644
3906 --- a/net/8021q/vlan_dev.c
3907 +++ b/net/8021q/vlan_dev.c
3908 @@ -586,7 +586,8 @@ static int vlan_dev_init(struct net_device *dev)
3909 return 0;
3910 }
3911
3912 -static void vlan_dev_uninit(struct net_device *dev)
3913 +/* Note: this function might be called multiple times for the same device. */
3914 +void vlan_dev_uninit(struct net_device *dev)
3915 {
3916 struct vlan_priority_tci_mapping *pm;
3917 struct vlan_dev_priv *vlan = vlan_dev_priv(dev);
3918 diff --git a/net/8021q/vlan_netlink.c b/net/8021q/vlan_netlink.c
3919 index c482a6fe9393..0db85aeb119b 100644
3920 --- a/net/8021q/vlan_netlink.c
3921 +++ b/net/8021q/vlan_netlink.c
3922 @@ -108,11 +108,13 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
3923 struct ifla_vlan_flags *flags;
3924 struct ifla_vlan_qos_mapping *m;
3925 struct nlattr *attr;
3926 - int rem;
3927 + int rem, err;
3928
3929 if (data[IFLA_VLAN_FLAGS]) {
3930 flags = nla_data(data[IFLA_VLAN_FLAGS]);
3931 - vlan_dev_change_flags(dev, flags->flags, flags->mask);
3932 + err = vlan_dev_change_flags(dev, flags->flags, flags->mask);
3933 + if (err)
3934 + return err;
3935 }
3936 if (data[IFLA_VLAN_INGRESS_QOS]) {
3937 nla_for_each_nested(attr, data[IFLA_VLAN_INGRESS_QOS], rem) {
3938 @@ -123,7 +125,9 @@ static int vlan_changelink(struct net_device *dev, struct nlattr *tb[],
3939 if (data[IFLA_VLAN_EGRESS_QOS]) {
3940 nla_for_each_nested(attr, data[IFLA_VLAN_EGRESS_QOS], rem) {
3941 m = nla_data(attr);
3942 - vlan_dev_set_egress_priority(dev, m->from, m->to);
3943 + err = vlan_dev_set_egress_priority(dev, m->from, m->to);
3944 + if (err)
3945 + return err;
3946 }
3947 }
3948 return 0;
3949 @@ -179,10 +183,11 @@ static int vlan_newlink(struct net *src_net, struct net_device *dev,
3950 return -EINVAL;
3951
3952 err = vlan_changelink(dev, tb, data, extack);
3953 - if (err < 0)
3954 - return err;
3955 -
3956 - return register_vlan_dev(dev, extack);
3957 + if (!err)
3958 + err = register_vlan_dev(dev, extack);
3959 + if (err)
3960 + vlan_dev_uninit(dev);
3961 + return err;
3962 }
3963
3964 static inline size_t vlan_qos_map_size(unsigned int n)
3965 diff --git a/net/core/filter.c b/net/core/filter.c
3966 index 6d0111bfdb4a..2f76461c120d 100644
3967 --- a/net/core/filter.c
3968 +++ b/net/core/filter.c
3969 @@ -2055,6 +2055,7 @@ static inline int __bpf_tx_skb(struct net_device *dev, struct sk_buff *skb)
3970 }
3971
3972 skb->dev = dev;
3973 + skb->tstamp = 0;
3974
3975 dev_xmit_recursion_inc();
3976 ret = dev_queue_xmit(skb);
3977 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
3978 index a2e52ad7cdab..67e44e6717b0 100644
3979 --- a/net/ipv4/tcp_input.c
3980 +++ b/net/ipv4/tcp_input.c
3981 @@ -1727,8 +1727,11 @@ tcp_sacktag_write_queue(struct sock *sk, const struct sk_buff *ack_skb,
3982 }
3983
3984 /* Ignore very old stuff early */
3985 - if (!after(sp[used_sacks].end_seq, prior_snd_una))
3986 + if (!after(sp[used_sacks].end_seq, prior_snd_una)) {
3987 + if (i == 0)
3988 + first_sack_index = -1;
3989 continue;
3990 + }
3991
3992 used_sacks++;
3993 }
3994 diff --git a/net/llc/llc_station.c b/net/llc/llc_station.c
3995 index 204a8351efff..c29170e767a8 100644
3996 --- a/net/llc/llc_station.c
3997 +++ b/net/llc/llc_station.c
3998 @@ -32,7 +32,7 @@ static int llc_stat_ev_rx_null_dsap_xid_c(struct sk_buff *skb)
3999 return LLC_PDU_IS_CMD(pdu) && /* command PDU */
4000 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
4001 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_XID &&
4002 - !pdu->dsap ? 0 : 1; /* NULL DSAP value */
4003 + !pdu->dsap; /* NULL DSAP value */
4004 }
4005
4006 static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
4007 @@ -42,7 +42,7 @@ static int llc_stat_ev_rx_null_dsap_test_c(struct sk_buff *skb)
4008 return LLC_PDU_IS_CMD(pdu) && /* command PDU */
4009 LLC_PDU_TYPE_IS_U(pdu) && /* U type PDU */
4010 LLC_U_PDU_CMD(pdu) == LLC_1_PDU_CMD_TEST &&
4011 - !pdu->dsap ? 0 : 1; /* NULL DSAP */
4012 + !pdu->dsap; /* NULL DSAP */
4013 }
4014
4015 static int llc_station_ac_send_xid_r(struct sk_buff *skb)
4016 diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c
4017 index 1fa422782905..cbd273c0b275 100644
4018 --- a/net/mac80211/tx.c
4019 +++ b/net/mac80211/tx.c
4020 @@ -2263,6 +2263,15 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb,
4021 payload[7]);
4022 }
4023
4024 + /*
4025 + * Initialize skb->priority for QoS frames. This is put in the TID field
4026 + * of the frame before passing it to the driver.
4027 + */
4028 + if (ieee80211_is_data_qos(hdr->frame_control)) {
4029 + u8 *p = ieee80211_get_qos_ctl(hdr);
4030 + skb->priority = *p & IEEE80211_QOS_CTL_TAG1D_MASK;
4031 + }
4032 +
4033 memset(info, 0, sizeof(*info));
4034
4035 info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS |
4036 diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c
4037 index e2d13cd18875..aa8adf930b3c 100644
4038 --- a/net/netfilter/nf_conntrack_netlink.c
4039 +++ b/net/netfilter/nf_conntrack_netlink.c
4040 @@ -3602,6 +3602,9 @@ static void __net_exit ctnetlink_net_exit_batch(struct list_head *net_exit_list)
4041
4042 list_for_each_entry(net, net_exit_list, exit_list)
4043 ctnetlink_net_exit(net);
4044 +
4045 + /* wait for other cpus until they are done with ctnl_notifiers */
4046 + synchronize_rcu();
4047 }
4048
4049 static struct pernet_operations ctnetlink_net_ops = {
4050 diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
4051 index 712a428509ad..67ca47c7ce54 100644
4052 --- a/net/netfilter/nf_tables_api.c
4053 +++ b/net/netfilter/nf_tables_api.c
4054 @@ -4252,8 +4252,10 @@ static int nft_get_set_elem(struct nft_ctx *ctx, struct nft_set *set,
4055 return err;
4056
4057 err = -EINVAL;
4058 - if (desc.type != NFT_DATA_VALUE || desc.len != set->klen)
4059 + if (desc.type != NFT_DATA_VALUE || desc.len != set->klen) {
4060 + nft_data_release(&elem.key.val, desc.type);
4061 return err;
4062 + }
4063
4064 priv = set->ops->get(ctx->net, set, &elem, flags);
4065 if (IS_ERR(priv))
4066 @@ -4489,14 +4491,20 @@ static int nft_add_set_elem(struct nft_ctx *ctx, struct nft_set *set,
4067 if (nla[NFTA_SET_ELEM_DATA] == NULL &&
4068 !(flags & NFT_SET_ELEM_INTERVAL_END))
4069 return -EINVAL;
4070 - if (nla[NFTA_SET_ELEM_DATA] != NULL &&
4071 - flags & NFT_SET_ELEM_INTERVAL_END)
4072 - return -EINVAL;
4073 } else {
4074 if (nla[NFTA_SET_ELEM_DATA] != NULL)
4075 return -EINVAL;
4076 }
4077
4078 + if ((flags & NFT_SET_ELEM_INTERVAL_END) &&
4079 + (nla[NFTA_SET_ELEM_DATA] ||
4080 + nla[NFTA_SET_ELEM_OBJREF] ||
4081 + nla[NFTA_SET_ELEM_TIMEOUT] ||
4082 + nla[NFTA_SET_ELEM_EXPIRATION] ||
4083 + nla[NFTA_SET_ELEM_USERDATA] ||
4084 + nla[NFTA_SET_ELEM_EXPR]))
4085 + return -EINVAL;
4086 +
4087 timeout = 0;
4088 if (nla[NFTA_SET_ELEM_TIMEOUT] != NULL) {
4089 if (!(set->flags & NFT_SET_TIMEOUT))
4090 @@ -5209,7 +5217,7 @@ static int nf_tables_newobj(struct net *net, struct sock *nlsk,
4091 if (nlh->nlmsg_flags & NLM_F_REPLACE)
4092 return -EOPNOTSUPP;
4093
4094 - type = nft_obj_type_get(net, objtype);
4095 + type = __nft_obj_type_get(objtype);
4096 nft_ctx_init(&ctx, net, skb, nlh, family, table, NULL, nla);
4097
4098 return nf_tables_updobj(&ctx, type, nla[NFTA_OBJ_DATA], obj);
4099 diff --git a/net/netfilter/nf_tables_offload.c b/net/netfilter/nf_tables_offload.c
4100 index 5f6037695dee..e743f811245f 100644
4101 --- a/net/netfilter/nf_tables_offload.c
4102 +++ b/net/netfilter/nf_tables_offload.c
4103 @@ -44,6 +44,9 @@ struct nft_flow_rule *nft_flow_rule_create(struct net *net,
4104 expr = nft_expr_next(expr);
4105 }
4106
4107 + if (num_actions == 0)
4108 + return ERR_PTR(-EOPNOTSUPP);
4109 +
4110 flow = nft_flow_rule_alloc(num_actions);
4111 if (!flow)
4112 return ERR_PTR(-ENOMEM);
4113 @@ -446,6 +449,9 @@ static int nft_offload_netdev_event(struct notifier_block *this,
4114 struct net *net = dev_net(dev);
4115 struct nft_chain *chain;
4116
4117 + if (event != NETDEV_UNREGISTER)
4118 + return NOTIFY_DONE;
4119 +
4120 mutex_lock(&net->nft.commit_mutex);
4121 chain = __nft_offload_get_chain(dev);
4122 if (chain)
4123 diff --git a/net/netfilter/nft_bitwise.c b/net/netfilter/nft_bitwise.c
4124 index 02afa752dd2e..10e9d50e4e19 100644
4125 --- a/net/netfilter/nft_bitwise.c
4126 +++ b/net/netfilter/nft_bitwise.c
4127 @@ -80,7 +80,7 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
4128 tb[NFTA_BITWISE_MASK]);
4129 if (err < 0)
4130 return err;
4131 - if (d1.len != priv->len) {
4132 + if (d1.type != NFT_DATA_VALUE || d1.len != priv->len) {
4133 err = -EINVAL;
4134 goto err1;
4135 }
4136 @@ -89,7 +89,7 @@ static int nft_bitwise_init(const struct nft_ctx *ctx,
4137 tb[NFTA_BITWISE_XOR]);
4138 if (err < 0)
4139 goto err1;
4140 - if (d2.len != priv->len) {
4141 + if (d2.type != NFT_DATA_VALUE || d2.len != priv->len) {
4142 err = -EINVAL;
4143 goto err2;
4144 }
4145 diff --git a/net/netfilter/nft_cmp.c b/net/netfilter/nft_cmp.c
4146 index 0744b2bb46da..ae730dba60c8 100644
4147 --- a/net/netfilter/nft_cmp.c
4148 +++ b/net/netfilter/nft_cmp.c
4149 @@ -80,6 +80,12 @@ static int nft_cmp_init(const struct nft_ctx *ctx, const struct nft_expr *expr,
4150 if (err < 0)
4151 return err;
4152
4153 + if (desc.type != NFT_DATA_VALUE) {
4154 + err = -EINVAL;
4155 + nft_data_release(&priv->data, desc.type);
4156 + return err;
4157 + }
4158 +
4159 priv->sreg = nft_parse_register(tb[NFTA_CMP_SREG]);
4160 err = nft_validate_register_load(priv->sreg, desc.len);
4161 if (err < 0)
4162 diff --git a/net/netfilter/nft_range.c b/net/netfilter/nft_range.c
4163 index 4701fa8a45e7..89efcc5a533d 100644
4164 --- a/net/netfilter/nft_range.c
4165 +++ b/net/netfilter/nft_range.c
4166 @@ -66,11 +66,21 @@ static int nft_range_init(const struct nft_ctx *ctx, const struct nft_expr *expr
4167 if (err < 0)
4168 return err;
4169
4170 + if (desc_from.type != NFT_DATA_VALUE) {
4171 + err = -EINVAL;
4172 + goto err1;
4173 + }
4174 +
4175 err = nft_data_init(NULL, &priv->data_to, sizeof(priv->data_to),
4176 &desc_to, tb[NFTA_RANGE_TO_DATA]);
4177 if (err < 0)
4178 goto err1;
4179
4180 + if (desc_to.type != NFT_DATA_VALUE) {
4181 + err = -EINVAL;
4182 + goto err2;
4183 + }
4184 +
4185 if (desc_from.len != desc_to.len) {
4186 err = -EINVAL;
4187 goto err2;
4188 diff --git a/net/netfilter/nft_set_rbtree.c b/net/netfilter/nft_set_rbtree.c
4189 index 57123259452f..a9f804f7a04a 100644
4190 --- a/net/netfilter/nft_set_rbtree.c
4191 +++ b/net/netfilter/nft_set_rbtree.c
4192 @@ -74,8 +74,13 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
4193 parent = rcu_dereference_raw(parent->rb_left);
4194 continue;
4195 }
4196 - if (nft_rbtree_interval_end(rbe))
4197 - goto out;
4198 + if (nft_rbtree_interval_end(rbe)) {
4199 + if (nft_set_is_anonymous(set))
4200 + return false;
4201 + parent = rcu_dereference_raw(parent->rb_left);
4202 + interval = NULL;
4203 + continue;
4204 + }
4205
4206 *ext = &rbe->ext;
4207 return true;
4208 @@ -88,7 +93,7 @@ static bool __nft_rbtree_lookup(const struct net *net, const struct nft_set *set
4209 *ext = &interval->ext;
4210 return true;
4211 }
4212 -out:
4213 +
4214 return false;
4215 }
4216
4217 @@ -139,8 +144,10 @@ static bool __nft_rbtree_get(const struct net *net, const struct nft_set *set,
4218 if (flags & NFT_SET_ELEM_INTERVAL_END)
4219 interval = rbe;
4220 } else {
4221 - if (!nft_set_elem_active(&rbe->ext, genmask))
4222 + if (!nft_set_elem_active(&rbe->ext, genmask)) {
4223 parent = rcu_dereference_raw(parent->rb_left);
4224 + continue;
4225 + }
4226
4227 if (!nft_set_ext_exists(&rbe->ext, NFT_SET_EXT_FLAGS) ||
4228 (*nft_set_ext_flags(&rbe->ext) & NFT_SET_ELEM_INTERVAL_END) ==
4229 @@ -148,7 +155,11 @@ static bool __nft_rbtree_get(const struct net *net, const struct nft_set *set,
4230 *elem = rbe;
4231 return true;
4232 }
4233 - return false;
4234 +
4235 + if (nft_rbtree_interval_end(rbe))
4236 + interval = NULL;
4237 +
4238 + parent = rcu_dereference_raw(parent->rb_left);
4239 }
4240 }
4241
4242 diff --git a/net/rfkill/core.c b/net/rfkill/core.c
4243 index 0bf9bf1ceb8f..6c089320ae4f 100644
4244 --- a/net/rfkill/core.c
4245 +++ b/net/rfkill/core.c
4246 @@ -1002,10 +1002,13 @@ static void rfkill_sync_work(struct work_struct *work)
4247 int __must_check rfkill_register(struct rfkill *rfkill)
4248 {
4249 static unsigned long rfkill_no;
4250 - struct device *dev = &rfkill->dev;
4251 + struct device *dev;
4252 int error;
4253
4254 - BUG_ON(!rfkill);
4255 + if (!rfkill)
4256 + return -EINVAL;
4257 +
4258 + dev = &rfkill->dev;
4259
4260 mutex_lock(&rfkill_global_mutex);
4261
4262 diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c
4263 index 53a80bc6b13a..dd0e8680b030 100644
4264 --- a/net/sched/sch_cake.c
4265 +++ b/net/sched/sch_cake.c
4266 @@ -1769,7 +1769,7 @@ static s32 cake_enqueue(struct sk_buff *skb, struct Qdisc *sch,
4267 q->avg_window_begin));
4268 u64 b = q->avg_window_bytes * (u64)NSEC_PER_SEC;
4269
4270 - do_div(b, window_interval);
4271 + b = div64_u64(b, window_interval);
4272 q->avg_peak_bandwidth =
4273 cake_ewma(q->avg_peak_bandwidth, b,
4274 b > q->avg_peak_bandwidth ? 2 : 8);
4275 diff --git a/net/sched/sch_fq.c b/net/sched/sch_fq.c
4276 index 78ecdf146882..712ad248d6a7 100644
4277 --- a/net/sched/sch_fq.c
4278 +++ b/net/sched/sch_fq.c
4279 @@ -787,10 +787,12 @@ static int fq_change(struct Qdisc *sch, struct nlattr *opt,
4280 if (tb[TCA_FQ_QUANTUM]) {
4281 u32 quantum = nla_get_u32(tb[TCA_FQ_QUANTUM]);
4282
4283 - if (quantum > 0)
4284 + if (quantum > 0 && quantum <= (1 << 20)) {
4285 q->quantum = quantum;
4286 - else
4287 + } else {
4288 + NL_SET_ERR_MSG_MOD(extack, "invalid quantum");
4289 err = -EINVAL;
4290 + }
4291 }
4292
4293 if (tb[TCA_FQ_INITIAL_QUANTUM])
4294 diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
4295 index 18b884cfdfe8..647941702f9f 100644
4296 --- a/net/sched/sch_prio.c
4297 +++ b/net/sched/sch_prio.c
4298 @@ -292,8 +292,14 @@ static int prio_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
4299 struct tc_prio_qopt_offload graft_offload;
4300 unsigned long band = arg - 1;
4301
4302 - if (new == NULL)
4303 - new = &noop_qdisc;
4304 + if (!new) {
4305 + new = qdisc_create_dflt(sch->dev_queue, &pfifo_qdisc_ops,
4306 + TC_H_MAKE(sch->handle, arg), extack);
4307 + if (!new)
4308 + new = &noop_qdisc;
4309 + else
4310 + qdisc_hash_add(new, true);
4311 + }
4312
4313 *old = qdisc_replace(sch, new, &q->queues[band]);
4314
4315 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
4316 index e52b2128e43b..b06cae508158 100644
4317 --- a/net/sctp/sm_sideeffect.c
4318 +++ b/net/sctp/sm_sideeffect.c
4319 @@ -1358,8 +1358,10 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
4320 /* Generate an INIT ACK chunk. */
4321 new_obj = sctp_make_init_ack(asoc, chunk, GFP_ATOMIC,
4322 0);
4323 - if (!new_obj)
4324 - goto nomem;
4325 + if (!new_obj) {
4326 + error = -ENOMEM;
4327 + break;
4328 + }
4329
4330 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
4331 SCTP_CHUNK(new_obj));
4332 @@ -1381,7 +1383,8 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
4333 if (!new_obj) {
4334 if (cmd->obj.chunk)
4335 sctp_chunk_free(cmd->obj.chunk);
4336 - goto nomem;
4337 + error = -ENOMEM;
4338 + break;
4339 }
4340 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
4341 SCTP_CHUNK(new_obj));
4342 @@ -1428,8 +1431,10 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
4343
4344 /* Generate a SHUTDOWN chunk. */
4345 new_obj = sctp_make_shutdown(asoc, chunk);
4346 - if (!new_obj)
4347 - goto nomem;
4348 + if (!new_obj) {
4349 + error = -ENOMEM;
4350 + break;
4351 + }
4352 sctp_add_cmd_sf(commands, SCTP_CMD_REPLY,
4353 SCTP_CHUNK(new_obj));
4354 break;
4355 @@ -1765,11 +1770,17 @@ static int sctp_cmd_interpreter(enum sctp_event_type event_type,
4356 break;
4357 }
4358
4359 - if (error)
4360 + if (error) {
4361 + cmd = sctp_next_cmd(commands);
4362 + while (cmd) {
4363 + if (cmd->verb == SCTP_CMD_REPLY)
4364 + sctp_chunk_free(cmd->obj.chunk);
4365 + cmd = sctp_next_cmd(commands);
4366 + }
4367 break;
4368 + }
4369 }
4370
4371 -out:
4372 /* If this is in response to a received chunk, wait until
4373 * we are done with the packet to open the queue so that we don't
4374 * send multiple packets in response to a single request.
4375 @@ -1784,7 +1795,4 @@ out:
4376 sp->data_ready_signalled = 0;
4377
4378 return error;
4379 -nomem:
4380 - error = -ENOMEM;
4381 - goto out;
4382 }
4383 diff --git a/net/wireless/core.c b/net/wireless/core.c
4384 index 350513744575..3e25229a059d 100644
4385 --- a/net/wireless/core.c
4386 +++ b/net/wireless/core.c
4387 @@ -1102,6 +1102,7 @@ static void __cfg80211_unregister_wdev(struct wireless_dev *wdev, bool sync)
4388
4389 #ifdef CONFIG_CFG80211_WEXT
4390 kzfree(wdev->wext.keys);
4391 + wdev->wext.keys = NULL;
4392 #endif
4393 /* only initialized if we have a netdev */
4394 if (wdev->netdev)
4395 diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
4396 index 9044073fbf22..d426fc01c529 100644
4397 --- a/net/xdp/xsk.c
4398 +++ b/net/xdp/xsk.c
4399 @@ -305,12 +305,21 @@ out:
4400 }
4401 EXPORT_SYMBOL(xsk_umem_consume_tx);
4402
4403 -static int xsk_zc_xmit(struct xdp_sock *xs)
4404 +static int xsk_wakeup(struct xdp_sock *xs, u8 flags)
4405 {
4406 struct net_device *dev = xs->dev;
4407 + int err;
4408 +
4409 + rcu_read_lock();
4410 + err = dev->netdev_ops->ndo_xsk_wakeup(dev, xs->queue_id, flags);
4411 + rcu_read_unlock();
4412 +
4413 + return err;
4414 +}
4415
4416 - return dev->netdev_ops->ndo_xsk_wakeup(dev, xs->queue_id,
4417 - XDP_WAKEUP_TX);
4418 +static int xsk_zc_xmit(struct xdp_sock *xs)
4419 +{
4420 + return xsk_wakeup(xs, XDP_WAKEUP_TX);
4421 }
4422
4423 static void xsk_destruct_skb(struct sk_buff *skb)
4424 @@ -424,19 +433,16 @@ static unsigned int xsk_poll(struct file *file, struct socket *sock,
4425 unsigned int mask = datagram_poll(file, sock, wait);
4426 struct sock *sk = sock->sk;
4427 struct xdp_sock *xs = xdp_sk(sk);
4428 - struct net_device *dev;
4429 struct xdp_umem *umem;
4430
4431 if (unlikely(!xsk_is_bound(xs)))
4432 return mask;
4433
4434 - dev = xs->dev;
4435 umem = xs->umem;
4436
4437 if (umem->need_wakeup) {
4438 - if (dev->netdev_ops->ndo_xsk_wakeup)
4439 - dev->netdev_ops->ndo_xsk_wakeup(dev, xs->queue_id,
4440 - umem->need_wakeup);
4441 + if (xs->zc)
4442 + xsk_wakeup(xs, umem->need_wakeup);
4443 else
4444 /* Poll needs to drive Tx also in copy mode */
4445 __xsk_sendmsg(sk);
4446 diff --git a/samples/bpf/syscall_tp_kern.c b/samples/bpf/syscall_tp_kern.c
4447 index 1d78819ffef1..630ce8c4d5a2 100644
4448 --- a/samples/bpf/syscall_tp_kern.c
4449 +++ b/samples/bpf/syscall_tp_kern.c
4450 @@ -47,13 +47,27 @@ static __always_inline void count(void *map)
4451 SEC("tracepoint/syscalls/sys_enter_open")
4452 int trace_enter_open(struct syscalls_enter_open_args *ctx)
4453 {
4454 - count((void *)&enter_open_map);
4455 + count(&enter_open_map);
4456 + return 0;
4457 +}
4458 +
4459 +SEC("tracepoint/syscalls/sys_enter_openat")
4460 +int trace_enter_open_at(struct syscalls_enter_open_args *ctx)
4461 +{
4462 + count(&enter_open_map);
4463 return 0;
4464 }
4465
4466 SEC("tracepoint/syscalls/sys_exit_open")
4467 int trace_enter_exit(struct syscalls_exit_open_args *ctx)
4468 {
4469 - count((void *)&exit_open_map);
4470 + count(&exit_open_map);
4471 + return 0;
4472 +}
4473 +
4474 +SEC("tracepoint/syscalls/sys_exit_openat")
4475 +int trace_enter_exit_at(struct syscalls_exit_open_args *ctx)
4476 +{
4477 + count(&exit_open_map);
4478 return 0;
4479 }
4480 diff --git a/samples/bpf/trace_event_user.c b/samples/bpf/trace_event_user.c
4481 index 16a16eadd509..749a50f2f9f3 100644
4482 --- a/samples/bpf/trace_event_user.c
4483 +++ b/samples/bpf/trace_event_user.c
4484 @@ -37,9 +37,9 @@ static void print_ksym(__u64 addr)
4485 }
4486
4487 printf("%s;", sym->name);
4488 - if (!strcmp(sym->name, "sys_read"))
4489 + if (!strstr(sym->name, "sys_read"))
4490 sys_read_seen = true;
4491 - else if (!strcmp(sym->name, "sys_write"))
4492 + else if (!strstr(sym->name, "sys_write"))
4493 sys_write_seen = true;
4494 }
4495
4496 diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
4497 index 77ffff3a053c..9f1de58e9f0c 100644
4498 --- a/scripts/kconfig/expr.c
4499 +++ b/scripts/kconfig/expr.c
4500 @@ -254,6 +254,13 @@ static int expr_eq(struct expr *e1, struct expr *e2)
4501 {
4502 int res, old_count;
4503
4504 + /*
4505 + * A NULL expr is taken to be yes, but there's also a different way to
4506 + * represent yes. expr_is_yes() checks for either representation.
4507 + */
4508 + if (!e1 || !e2)
4509 + return expr_is_yes(e1) && expr_is_yes(e2);
4510 +
4511 if (e1->type != e2->type)
4512 return 0;
4513 switch (e1->type) {
4514 diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
4515 index e0750b70453f..7c230016b08d 100755
4516 --- a/scripts/package/mkdebian
4517 +++ b/scripts/package/mkdebian
4518 @@ -174,7 +174,7 @@ Source: $sourcename
4519 Section: kernel
4520 Priority: optional
4521 Maintainer: $maintainer
4522 -Build-Depends: bc, kmod, cpio, bison, flex | flex:native $extra_build_depends
4523 +Build-Depends: bc, rsync, kmod, cpio, bison, flex | flex:native $extra_build_depends
4524 Homepage: http://www.kernel.org/
4525
4526 Package: $packagename
4527 diff --git a/sound/soc/codecs/max98090.c b/sound/soc/codecs/max98090.c
4528 index f6bf4cfbea23..45da2b51543e 100644
4529 --- a/sound/soc/codecs/max98090.c
4530 +++ b/sound/soc/codecs/max98090.c
4531 @@ -2103,10 +2103,8 @@ static void max98090_pll_det_disable_work(struct work_struct *work)
4532 M98090_IULK_MASK, 0);
4533 }
4534
4535 -static void max98090_pll_work(struct work_struct *work)
4536 +static void max98090_pll_work(struct max98090_priv *max98090)
4537 {
4538 - struct max98090_priv *max98090 =
4539 - container_of(work, struct max98090_priv, pll_work);
4540 struct snd_soc_component *component = max98090->component;
4541
4542 if (!snd_soc_component_is_active(component))
4543 @@ -2259,7 +2257,7 @@ static irqreturn_t max98090_interrupt(int irq, void *data)
4544
4545 if (active & M98090_ULK_MASK) {
4546 dev_dbg(component->dev, "M98090_ULK_MASK\n");
4547 - schedule_work(&max98090->pll_work);
4548 + max98090_pll_work(max98090);
4549 }
4550
4551 if (active & M98090_JDET_MASK) {
4552 @@ -2422,7 +2420,6 @@ static int max98090_probe(struct snd_soc_component *component)
4553 max98090_pll_det_enable_work);
4554 INIT_WORK(&max98090->pll_det_disable_work,
4555 max98090_pll_det_disable_work);
4556 - INIT_WORK(&max98090->pll_work, max98090_pll_work);
4557
4558 /* Enable jack detection */
4559 snd_soc_component_write(component, M98090_REG_JACK_DETECT,
4560 @@ -2475,7 +2472,6 @@ static void max98090_remove(struct snd_soc_component *component)
4561 cancel_delayed_work_sync(&max98090->jack_work);
4562 cancel_delayed_work_sync(&max98090->pll_det_enable_work);
4563 cancel_work_sync(&max98090->pll_det_disable_work);
4564 - cancel_work_sync(&max98090->pll_work);
4565 max98090->component = NULL;
4566 }
4567
4568 diff --git a/sound/soc/codecs/max98090.h b/sound/soc/codecs/max98090.h
4569 index 57965cd678b4..a197114b0dad 100644
4570 --- a/sound/soc/codecs/max98090.h
4571 +++ b/sound/soc/codecs/max98090.h
4572 @@ -1530,7 +1530,6 @@ struct max98090_priv {
4573 struct delayed_work jack_work;
4574 struct delayed_work pll_det_enable_work;
4575 struct work_struct pll_det_disable_work;
4576 - struct work_struct pll_work;
4577 struct snd_soc_jack *jack;
4578 unsigned int dai_fmt;
4579 int tdm_slots;
4580 diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c
4581 index c50b75ce82e0..05e883a65d7a 100644
4582 --- a/sound/soc/codecs/rt5682.c
4583 +++ b/sound/soc/codecs/rt5682.c
4584 @@ -72,6 +72,7 @@ struct rt5682_priv {
4585 static const struct reg_sequence patch_list[] = {
4586 {RT5682_HP_IMP_SENS_CTRL_19, 0x1000},
4587 {RT5682_DAC_ADC_DIG_VOL1, 0xa020},
4588 + {RT5682_I2C_CTRL, 0x000f},
4589 };
4590
4591 static const struct reg_default rt5682_reg[] = {
4592 @@ -2481,6 +2482,7 @@ static void rt5682_calibrate(struct rt5682_priv *rt5682)
4593 mutex_lock(&rt5682->calibrate_mutex);
4594
4595 rt5682_reset(rt5682->regmap);
4596 + regmap_write(rt5682->regmap, RT5682_I2C_CTRL, 0x000f);
4597 regmap_write(rt5682->regmap, RT5682_PWR_ANLG_1, 0xa2af);
4598 usleep_range(15000, 20000);
4599 regmap_write(rt5682->regmap, RT5682_PWR_ANLG_1, 0xf2af);
4600 diff --git a/sound/soc/codecs/wm8962.c b/sound/soc/codecs/wm8962.c
4601 index 3e5c69fbc33a..d9d59f45833f 100644
4602 --- a/sound/soc/codecs/wm8962.c
4603 +++ b/sound/soc/codecs/wm8962.c
4604 @@ -2788,7 +2788,7 @@ static int fll_factors(struct _fll_div *fll_div, unsigned int Fref,
4605
4606 if (target % Fref == 0) {
4607 fll_div->theta = 0;
4608 - fll_div->lambda = 0;
4609 + fll_div->lambda = 1;
4610 } else {
4611 gcd_fll = gcd(target, fratio * Fref);
4612
4613 @@ -2858,7 +2858,7 @@ static int wm8962_set_fll(struct snd_soc_component *component, int fll_id, int s
4614 return -EINVAL;
4615 }
4616
4617 - if (fll_div.theta || fll_div.lambda)
4618 + if (fll_div.theta)
4619 fll1 |= WM8962_FLL_FRAC;
4620
4621 /* Stop the FLL while we reconfigure */
4622 diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c
4623 index dd2b5ad08659..243f683bc02a 100644
4624 --- a/sound/soc/intel/boards/bytcr_rt5640.c
4625 +++ b/sound/soc/intel/boards/bytcr_rt5640.c
4626 @@ -707,13 +707,17 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = {
4627 BYT_RT5640_MCLK_EN),
4628 },
4629 {
4630 + /* Teclast X89 */
4631 .matches = {
4632 DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
4633 DMI_MATCH(DMI_BOARD_NAME, "tPAD"),
4634 },
4635 .driver_data = (void *)(BYT_RT5640_IN3_MAP |
4636 - BYT_RT5640_MCLK_EN |
4637 - BYT_RT5640_SSP0_AIF1),
4638 + BYT_RT5640_JD_SRC_JD1_IN4P |
4639 + BYT_RT5640_OVCD_TH_2000UA |
4640 + BYT_RT5640_OVCD_SF_1P0 |
4641 + BYT_RT5640_SSP0_AIF1 |
4642 + BYT_RT5640_MCLK_EN),
4643 },
4644 { /* Toshiba Satellite Click Mini L9W-B */
4645 .matches = {
4646 diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c
4647 index 0fd032914a31..fd2d22ddc81b 100644
4648 --- a/sound/soc/soc-topology.c
4649 +++ b/sound/soc/soc-topology.c
4650 @@ -1918,11 +1918,13 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
4651 ret = soc_tplg_dai_link_load(tplg, link, NULL);
4652 if (ret < 0) {
4653 dev_err(tplg->comp->dev, "ASoC: FE link loading failed\n");
4654 - kfree(link->name);
4655 - kfree(link->stream_name);
4656 - kfree(link->cpus->dai_name);
4657 - kfree(link);
4658 - return ret;
4659 + goto err;
4660 + }
4661 +
4662 + ret = snd_soc_add_dai_link(tplg->comp->card, link);
4663 + if (ret < 0) {
4664 + dev_err(tplg->comp->dev, "ASoC: adding FE link failed\n");
4665 + goto err;
4666 }
4667
4668 link->dobj.index = tplg->index;
4669 @@ -1930,8 +1932,13 @@ static int soc_tplg_fe_link_create(struct soc_tplg *tplg,
4670 link->dobj.type = SND_SOC_DOBJ_DAI_LINK;
4671 list_add(&link->dobj.list, &tplg->comp->dobj_list);
4672
4673 - snd_soc_add_dai_link(tplg->comp->card, link);
4674 return 0;
4675 +err:
4676 + kfree(link->name);
4677 + kfree(link->stream_name);
4678 + kfree(link->cpus->dai_name);
4679 + kfree(link);
4680 + return ret;
4681 }
4682
4683 /* create a FE DAI and DAI link from the PCM object */
4684 @@ -2024,6 +2031,7 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
4685 int size;
4686 int i;
4687 bool abi_match;
4688 + int ret;
4689
4690 count = le32_to_cpu(hdr->count);
4691
4692 @@ -2065,7 +2073,12 @@ static int soc_tplg_pcm_elems_load(struct soc_tplg *tplg,
4693 }
4694
4695 /* create the FE DAIs and DAI links */
4696 - soc_tplg_pcm_create(tplg, _pcm);
4697 + ret = soc_tplg_pcm_create(tplg, _pcm);
4698 + if (ret < 0) {
4699 + if (!abi_match)
4700 + kfree(_pcm);
4701 + return ret;
4702 + }
4703
4704 /* offset by version-specific struct size and
4705 * real priv data size
4706 diff --git a/sound/soc/sof/intel/byt.c b/sound/soc/sof/intel/byt.c
4707 index a1e514f71739..41008c974ac6 100644
4708 --- a/sound/soc/sof/intel/byt.c
4709 +++ b/sound/soc/sof/intel/byt.c
4710 @@ -24,7 +24,8 @@
4711 #define DRAM_OFFSET 0x100000
4712 #define DRAM_SIZE (160 * 1024)
4713 #define SHIM_OFFSET 0x140000
4714 -#define SHIM_SIZE 0x100
4715 +#define SHIM_SIZE_BYT 0x100
4716 +#define SHIM_SIZE_CHT 0x118
4717 #define MBOX_OFFSET 0x144000
4718 #define MBOX_SIZE 0x1000
4719 #define EXCEPT_OFFSET 0x800
4720 @@ -75,7 +76,7 @@ static const struct snd_sof_debugfs_map byt_debugfs[] = {
4721 SOF_DEBUGFS_ACCESS_D0_ONLY},
4722 {"dram", BYT_DSP_BAR, DRAM_OFFSET, DRAM_SIZE,
4723 SOF_DEBUGFS_ACCESS_D0_ONLY},
4724 - {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE,
4725 + {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE_BYT,
4726 SOF_DEBUGFS_ACCESS_ALWAYS},
4727 };
4728
4729 @@ -102,7 +103,7 @@ static const struct snd_sof_debugfs_map cht_debugfs[] = {
4730 SOF_DEBUGFS_ACCESS_D0_ONLY},
4731 {"dram", BYT_DSP_BAR, DRAM_OFFSET, DRAM_SIZE,
4732 SOF_DEBUGFS_ACCESS_D0_ONLY},
4733 - {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE,
4734 + {"shim", BYT_DSP_BAR, SHIM_OFFSET, SHIM_SIZE_CHT,
4735 SOF_DEBUGFS_ACCESS_ALWAYS},
4736 };
4737
4738 diff --git a/sound/soc/sof/loader.c b/sound/soc/sof/loader.c
4739 index 9a9a381a908d..a041adf0669d 100644
4740 --- a/sound/soc/sof/loader.c
4741 +++ b/sound/soc/sof/loader.c
4742 @@ -66,6 +66,8 @@ int snd_sof_fw_parse_ext_data(struct snd_sof_dev *sdev, u32 bar, u32 offset)
4743 ret = get_ext_windows(sdev, ext_hdr);
4744 break;
4745 default:
4746 + dev_warn(sdev->dev, "warning: unknown ext header type %d size 0x%x\n",
4747 + ext_hdr->type, ext_hdr->hdr.size);
4748 break;
4749 }
4750
4751 diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
4752 index 43fdbbfe41bb..ea0bcd58bcb9 100644
4753 --- a/tools/bpf/bpftool/prog.c
4754 +++ b/tools/bpf/bpftool/prog.c
4755 @@ -493,7 +493,7 @@ static int do_dump(int argc, char **argv)
4756
4757 info = &info_linear->info;
4758 if (mode == DUMP_JITED) {
4759 - if (info->jited_prog_len == 0) {
4760 + if (info->jited_prog_len == 0 || !info->jited_prog_insns) {
4761 p_info("no instructions returned");
4762 goto err_free;
4763 }
4764 diff --git a/tools/bpf/bpftool/xlated_dumper.c b/tools/bpf/bpftool/xlated_dumper.c
4765 index 494d7ae3614d..5b91ee65a080 100644
4766 --- a/tools/bpf/bpftool/xlated_dumper.c
4767 +++ b/tools/bpf/bpftool/xlated_dumper.c
4768 @@ -174,7 +174,7 @@ static const char *print_call(void *private_data,
4769 struct kernel_sym *sym;
4770
4771 if (insn->src_reg == BPF_PSEUDO_CALL &&
4772 - (__u32) insn->imm < dd->nr_jited_ksyms)
4773 + (__u32) insn->imm < dd->nr_jited_ksyms && dd->jited_ksyms)
4774 address = dd->jited_ksyms[insn->imm];
4775
4776 sym = kernel_syms_search(dd, address);
4777 diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
4778 index 5315f3787f8d..ecf882308d8a 100644
4779 --- a/tools/lib/traceevent/Makefile
4780 +++ b/tools/lib/traceevent/Makefile
4781 @@ -97,6 +97,7 @@ EVENT_PARSE_VERSION = $(EP_VERSION).$(EP_PATCHLEVEL).$(EP_EXTRAVERSION)
4782
4783 LIB_TARGET = libtraceevent.a libtraceevent.so.$(EVENT_PARSE_VERSION)
4784 LIB_INSTALL = libtraceevent.a libtraceevent.so*
4785 +LIB_INSTALL := $(addprefix $(OUTPUT),$(LIB_INSTALL))
4786
4787 INCLUDES = -I. -I $(srctree)/tools/include $(CONFIG_INCLUDES)
4788
4789 @@ -207,10 +208,11 @@ define do_install
4790 $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
4791 endef
4792
4793 -PKG_CONFIG_FILE = libtraceevent.pc
4794 +PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
4795 +PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
4796 define do_install_pkgconfig_file
4797 if [ -n "${pkgconfig_dir}" ]; then \
4798 - cp -f ${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; \
4799 + cp -f ${PKG_CONFIG_SOURCE_FILE}.template ${PKG_CONFIG_FILE}; \
4800 sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \
4801 sed -i "s|LIB_VERSION|${EVENT_PARSE_VERSION}|g" ${PKG_CONFIG_FILE}; \
4802 sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
4803 diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
4804 index becc2d109423..d3412f2c0d18 100644
4805 --- a/tools/perf/util/header.c
4806 +++ b/tools/perf/util/header.c
4807 @@ -1089,21 +1089,18 @@ static void cpu_cache_level__fprintf(FILE *out, struct cpu_cache_level *c)
4808 fprintf(out, "L%d %-15s %8s [%s]\n", c->level, c->type, c->size, c->map);
4809 }
4810
4811 -static int build_caches(struct cpu_cache_level caches[], u32 size, u32 *cntp)
4812 +#define MAX_CACHE_LVL 4
4813 +
4814 +static int build_caches(struct cpu_cache_level caches[], u32 *cntp)
4815 {
4816 u32 i, cnt = 0;
4817 - long ncpus;
4818 u32 nr, cpu;
4819 u16 level;
4820
4821 - ncpus = sysconf(_SC_NPROCESSORS_CONF);
4822 - if (ncpus < 0)
4823 - return -1;
4824 -
4825 - nr = (u32)(ncpus & UINT_MAX);
4826 + nr = cpu__max_cpu();
4827
4828 for (cpu = 0; cpu < nr; cpu++) {
4829 - for (level = 0; level < 10; level++) {
4830 + for (level = 0; level < MAX_CACHE_LVL; level++) {
4831 struct cpu_cache_level c;
4832 int err;
4833
4834 @@ -1123,18 +1120,12 @@ static int build_caches(struct cpu_cache_level caches[], u32 size, u32 *cntp)
4835 caches[cnt++] = c;
4836 else
4837 cpu_cache_level__free(&c);
4838 -
4839 - if (WARN_ONCE(cnt == size, "way too many cpu caches.."))
4840 - goto out;
4841 }
4842 }
4843 - out:
4844 *cntp = cnt;
4845 return 0;
4846 }
4847
4848 -#define MAX_CACHE_LVL 4
4849 -
4850 static int write_cache(struct feat_fd *ff,
4851 struct evlist *evlist __maybe_unused)
4852 {
4853 @@ -1143,7 +1134,7 @@ static int write_cache(struct feat_fd *ff,
4854 u32 cnt = 0, i, version = 1;
4855 int ret;
4856
4857 - ret = build_caches(caches, max_caches, &cnt);
4858 + ret = build_caches(caches, &cnt);
4859 if (ret)
4860 goto out;
4861
4862 diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
4863 index a7c0424dbda3..940a6e7a6854 100644
4864 --- a/tools/perf/util/metricgroup.c
4865 +++ b/tools/perf/util/metricgroup.c
4866 @@ -103,8 +103,11 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
4867 if (!strcmp(ev->name, ids[i])) {
4868 if (!metric_events[i])
4869 metric_events[i] = ev;
4870 + i++;
4871 + if (i == idnum)
4872 + break;
4873 } else {
4874 - if (++i == idnum) {
4875 + if (i + 1 == idnum) {
4876 /* Discard the whole match and start again */
4877 i = 0;
4878 memset(metric_events, 0,
4879 @@ -124,7 +127,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist,
4880 }
4881 }
4882
4883 - if (i != idnum - 1) {
4884 + if (i != idnum) {
4885 /* Not whole match */
4886 return NULL;
4887 }
4888 diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
4889 index 36fb59f886ea..1a52f2883fe0 100644
4890 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
4891 +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func-filter-stacktrace.tc
4892 @@ -3,6 +3,8 @@
4893 # description: ftrace - stacktrace filter command
4894 # flags: instance
4895
4896 +[ ! -f set_ftrace_filter ] && exit_unsupported
4897 +
4898 echo _do_fork:stacktrace >> set_ftrace_filter
4899
4900 grep -q "_do_fork:stacktrace:unlimited" set_ftrace_filter
4901 diff --git a/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc b/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
4902 index 86a1f07ef2ca..71fa3f49e35e 100644
4903 --- a/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
4904 +++ b/tools/testing/selftests/ftrace/test.d/ftrace/func_cpumask.tc
4905 @@ -15,6 +15,11 @@ if [ $NP -eq 1 ] ;then
4906 exit_unresolved
4907 fi
4908
4909 +if ! grep -q "function" available_tracers ; then
4910 + echo "Function trace is not enabled"
4911 + exit_unsupported
4912 +fi
4913 +
4914 ORIG_CPUMASK=`cat tracing_cpumask`
4915
4916 do_reset() {
4917 diff --git a/tools/testing/selftests/ftrace/test.d/functions b/tools/testing/selftests/ftrace/test.d/functions
4918 index 86986c4bba54..5d4550591ff9 100644
4919 --- a/tools/testing/selftests/ftrace/test.d/functions
4920 +++ b/tools/testing/selftests/ftrace/test.d/functions
4921 @@ -46,6 +46,9 @@ reset_events_filter() { # reset all current setting filters
4922 }
4923
4924 reset_ftrace_filter() { # reset all triggers in set_ftrace_filter
4925 + if [ ! -f set_ftrace_filter ]; then
4926 + return 0
4927 + fi
4928 echo > set_ftrace_filter
4929 grep -v '^#' set_ftrace_filter | while read t; do
4930 tr=`echo $t | cut -d: -f2`
4931 @@ -93,7 +96,7 @@ initialize_ftrace() { # Reset ftrace to initial-state
4932 disable_events
4933 [ -f set_event_pid ] && echo > set_event_pid
4934 [ -f set_ftrace_pid ] && echo > set_ftrace_pid
4935 - [ -f set_ftrace_filter ] && echo | tee set_ftrace_*
4936 + [ -f set_ftrace_notrace ] && echo > set_ftrace_notrace
4937 [ -f set_graph_function ] && echo | tee set_graph_*
4938 [ -f stack_trace_filter ] && echo > stack_trace_filter
4939 [ -f kprobe_events ] && echo > kprobe_events
4940 diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
4941 index 5862eee91e1d..6e3dbe5f96b7 100644
4942 --- a/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
4943 +++ b/tools/testing/selftests/ftrace/test.d/kprobe/multiple_kprobes.tc
4944 @@ -20,9 +20,9 @@ while read i; do
4945 test $N -eq 256 && break
4946 done
4947
4948 -L=`wc -l kprobe_events`
4949 -if [ $L -ne $N ]; then
4950 - echo "The number of kprobes events ($L) is not $N"
4951 +L=`cat kprobe_events | wc -l`
4952 +if [ $L -ne 256 ]; then
4953 + echo "The number of kprobes events ($L) is not 256"
4954 exit_fail
4955 fi
4956
4957 diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc
4958 index 1221240f8cf6..3f2aee115f6e 100644
4959 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc
4960 +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-action-hist-xfail.tc
4961 @@ -21,10 +21,10 @@ grep -q "snapshot()" README || exit_unsupported # version issue
4962
4963 echo "Test expected snapshot action failure"
4964
4965 -echo 'hist:keys=comm:onmatch(sched.sched_wakeup).snapshot()' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger && exit_fail
4966 +echo 'hist:keys=comm:onmatch(sched.sched_wakeup).snapshot()' >> events/sched/sched_waking/trigger && exit_fail
4967
4968 echo "Test expected save action failure"
4969
4970 -echo 'hist:keys=comm:onmatch(sched.sched_wakeup).save(comm,prio)' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger && exit_fail
4971 +echo 'hist:keys=comm:onmatch(sched.sched_wakeup).save(comm,prio)' >> events/sched/sched_waking/trigger && exit_fail
4972
4973 exit_xfail
4974 diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
4975 index 064a284e4e75..c80007aa9f86 100644
4976 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
4977 +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-onchange-action-hist.tc
4978 @@ -16,7 +16,7 @@ grep -q "onchange(var)" README || exit_unsupported # version issue
4979
4980 echo "Test onchange action"
4981
4982 -echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
4983 +echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio) if comm=="ping"' >> events/sched/sched_waking/trigger
4984
4985 ping $LOCALHOST -c 3
4986 nice -n 1 ping $LOCALHOST -c 3
4987 diff --git a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
4988 index 18fff69fc433..f546c1b66a9b 100644
4989 --- a/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
4990 +++ b/tools/testing/selftests/ftrace/test.d/trigger/inter-event/trigger-snapshot-action-hist.tc
4991 @@ -23,9 +23,9 @@ grep -q "snapshot()" README || exit_unsupported # version issue
4992
4993 echo "Test snapshot action"
4994
4995 -echo 1 > /sys/kernel/debug/tracing/events/sched/enable
4996 +echo 1 > events/sched/enable
4997
4998 -echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> /sys/kernel/debug/tracing/events/sched/sched_waking/trigger
4999 +echo 'hist:keys=comm:newprio=prio:onchange($newprio).save(comm,prio):onchange($newprio).snapshot() if comm=="ping"' >> events/sched/sched_waking/trigger
5000
5001 ping $LOCALHOST -c 3
5002 nice -n 1 ping $LOCALHOST -c 3
5003 diff --git a/tools/testing/selftests/kselftest/prefix.pl b/tools/testing/selftests/kselftest/prefix.pl
5004 index ec7e48118183..31f7c2a0a8bd 100755
5005 --- a/tools/testing/selftests/kselftest/prefix.pl
5006 +++ b/tools/testing/selftests/kselftest/prefix.pl
5007 @@ -3,6 +3,7 @@
5008 # Prefix all lines with "# ", unbuffered. Command being piped in may need
5009 # to have unbuffering forced with "stdbuf -i0 -o0 -e0 $cmd".
5010 use strict;
5011 +use IO::Handle;
5012
5013 binmode STDIN;
5014 binmode STDOUT;
5015 diff --git a/tools/testing/selftests/kselftest/runner.sh b/tools/testing/selftests/kselftest/runner.sh
5016 index 84de7bc74f2c..a8d20cbb711c 100644
5017 --- a/tools/testing/selftests/kselftest/runner.sh
5018 +++ b/tools/testing/selftests/kselftest/runner.sh
5019 @@ -79,6 +79,7 @@ run_one()
5020 if [ $rc -eq $skip_rc ]; then \
5021 echo "not ok $test_num $TEST_HDR_MSG # SKIP"
5022 elif [ $rc -eq $timeout_rc ]; then \
5023 + echo "#"
5024 echo "not ok $test_num $TEST_HDR_MSG # TIMEOUT"
5025 else
5026 echo "not ok $test_num $TEST_HDR_MSG # exit=$rc"
5027 diff --git a/tools/testing/selftests/net/pmtu.sh b/tools/testing/selftests/net/pmtu.sh
5028 index d697815d2785..71a62e7e35b1 100755
5029 --- a/tools/testing/selftests/net/pmtu.sh
5030 +++ b/tools/testing/selftests/net/pmtu.sh
5031 @@ -11,9 +11,9 @@
5032 # R1 and R2 (also implemented with namespaces), with different MTUs:
5033 #
5034 # segment a_r1 segment b_r1 a_r1: 2000
5035 -# .--------------R1--------------. a_r2: 1500
5036 -# A B a_r3: 2000
5037 -# '--------------R2--------------' a_r4: 1400
5038 +# .--------------R1--------------. b_r1: 1400
5039 +# A B a_r2: 2000
5040 +# '--------------R2--------------' b_r2: 1500
5041 # segment a_r2 segment b_r2
5042 #
5043 # Check that PMTU exceptions with the correct PMTU are created. Then
5044 diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh
5045 index 1be55e705780..d7e07f4c3d7f 100755
5046 --- a/tools/testing/selftests/netfilter/nft_nat.sh
5047 +++ b/tools/testing/selftests/netfilter/nft_nat.sh
5048 @@ -8,9 +8,14 @@ ksft_skip=4
5049 ret=0
5050 test_inet_nat=true
5051
5052 +sfx=$(mktemp -u "XXXXXXXX")
5053 +ns0="ns0-$sfx"
5054 +ns1="ns1-$sfx"
5055 +ns2="ns2-$sfx"
5056 +
5057 cleanup()
5058 {
5059 - for i in 0 1 2; do ip netns del ns$i;done
5060 + for i in 0 1 2; do ip netns del ns$i-"$sfx";done
5061 }
5062
5063 nft --version > /dev/null 2>&1
5064 @@ -25,40 +30,49 @@ if [ $? -ne 0 ];then
5065 exit $ksft_skip
5066 fi
5067
5068 -ip netns add ns0
5069 +ip netns add "$ns0"
5070 if [ $? -ne 0 ];then
5071 - echo "SKIP: Could not create net namespace"
5072 + echo "SKIP: Could not create net namespace $ns0"
5073 exit $ksft_skip
5074 fi
5075
5076 trap cleanup EXIT
5077
5078 -ip netns add ns1
5079 -ip netns add ns2
5080 +ip netns add "$ns1"
5081 +if [ $? -ne 0 ];then
5082 + echo "SKIP: Could not create net namespace $ns1"
5083 + exit $ksft_skip
5084 +fi
5085 +
5086 +ip netns add "$ns2"
5087 +if [ $? -ne 0 ];then
5088 + echo "SKIP: Could not create net namespace $ns2"
5089 + exit $ksft_skip
5090 +fi
5091
5092 -ip link add veth0 netns ns0 type veth peer name eth0 netns ns1 > /dev/null 2>&1
5093 +ip link add veth0 netns "$ns0" type veth peer name eth0 netns "$ns1" > /dev/null 2>&1
5094 if [ $? -ne 0 ];then
5095 echo "SKIP: No virtual ethernet pair device support in kernel"
5096 exit $ksft_skip
5097 fi
5098 -ip link add veth1 netns ns0 type veth peer name eth0 netns ns2
5099 +ip link add veth1 netns "$ns0" type veth peer name eth0 netns "$ns2"
5100
5101 -ip -net ns0 link set lo up
5102 -ip -net ns0 link set veth0 up
5103 -ip -net ns0 addr add 10.0.1.1/24 dev veth0
5104 -ip -net ns0 addr add dead:1::1/64 dev veth0
5105 +ip -net "$ns0" link set lo up
5106 +ip -net "$ns0" link set veth0 up
5107 +ip -net "$ns0" addr add 10.0.1.1/24 dev veth0
5108 +ip -net "$ns0" addr add dead:1::1/64 dev veth0
5109
5110 -ip -net ns0 link set veth1 up
5111 -ip -net ns0 addr add 10.0.2.1/24 dev veth1
5112 -ip -net ns0 addr add dead:2::1/64 dev veth1
5113 +ip -net "$ns0" link set veth1 up
5114 +ip -net "$ns0" addr add 10.0.2.1/24 dev veth1
5115 +ip -net "$ns0" addr add dead:2::1/64 dev veth1
5116
5117 for i in 1 2; do
5118 - ip -net ns$i link set lo up
5119 - ip -net ns$i link set eth0 up
5120 - ip -net ns$i addr add 10.0.$i.99/24 dev eth0
5121 - ip -net ns$i route add default via 10.0.$i.1
5122 - ip -net ns$i addr add dead:$i::99/64 dev eth0
5123 - ip -net ns$i route add default via dead:$i::1
5124 + ip -net ns$i-$sfx link set lo up
5125 + ip -net ns$i-$sfx link set eth0 up
5126 + ip -net ns$i-$sfx addr add 10.0.$i.99/24 dev eth0
5127 + ip -net ns$i-$sfx route add default via 10.0.$i.1
5128 + ip -net ns$i-$sfx addr add dead:$i::99/64 dev eth0
5129 + ip -net ns$i-$sfx route add default via dead:$i::1
5130 done
5131
5132 bad_counter()
5133 @@ -66,8 +80,9 @@ bad_counter()
5134 local ns=$1
5135 local counter=$2
5136 local expect=$3
5137 + local tag=$4
5138
5139 - echo "ERROR: $counter counter in $ns has unexpected value (expected $expect)" 1>&2
5140 + echo "ERROR: $counter counter in $ns has unexpected value (expected $expect) at $tag" 1>&2
5141 ip netns exec $ns nft list counter inet filter $counter 1>&2
5142 }
5143
5144 @@ -78,24 +93,24 @@ check_counters()
5145
5146 cnt=$(ip netns exec $ns nft list counter inet filter ns0in | grep -q "packets 1 bytes 84")
5147 if [ $? -ne 0 ]; then
5148 - bad_counter $ns ns0in "packets 1 bytes 84"
5149 + bad_counter $ns ns0in "packets 1 bytes 84" "check_counters 1"
5150 lret=1
5151 fi
5152 cnt=$(ip netns exec $ns nft list counter inet filter ns0out | grep -q "packets 1 bytes 84")
5153 if [ $? -ne 0 ]; then
5154 - bad_counter $ns ns0out "packets 1 bytes 84"
5155 + bad_counter $ns ns0out "packets 1 bytes 84" "check_counters 2"
5156 lret=1
5157 fi
5158
5159 expect="packets 1 bytes 104"
5160 cnt=$(ip netns exec $ns nft list counter inet filter ns0in6 | grep -q "$expect")
5161 if [ $? -ne 0 ]; then
5162 - bad_counter $ns ns0in6 "$expect"
5163 + bad_counter $ns ns0in6 "$expect" "check_counters 3"
5164 lret=1
5165 fi
5166 cnt=$(ip netns exec $ns nft list counter inet filter ns0out6 | grep -q "$expect")
5167 if [ $? -ne 0 ]; then
5168 - bad_counter $ns ns0out6 "$expect"
5169 + bad_counter $ns ns0out6 "$expect" "check_counters 4"
5170 lret=1
5171 fi
5172
5173 @@ -107,41 +122,41 @@ check_ns0_counters()
5174 local ns=$1
5175 local lret=0
5176
5177 - cnt=$(ip netns exec ns0 nft list counter inet filter ns0in | grep -q "packets 0 bytes 0")
5178 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns0in | grep -q "packets 0 bytes 0")
5179 if [ $? -ne 0 ]; then
5180 - bad_counter ns0 ns0in "packets 0 bytes 0"
5181 + bad_counter "$ns0" ns0in "packets 0 bytes 0" "check_ns0_counters 1"
5182 lret=1
5183 fi
5184
5185 - cnt=$(ip netns exec ns0 nft list counter inet filter ns0in6 | grep -q "packets 0 bytes 0")
5186 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns0in6 | grep -q "packets 0 bytes 0")
5187 if [ $? -ne 0 ]; then
5188 - bad_counter ns0 ns0in6 "packets 0 bytes 0"
5189 + bad_counter "$ns0" ns0in6 "packets 0 bytes 0"
5190 lret=1
5191 fi
5192
5193 - cnt=$(ip netns exec ns0 nft list counter inet filter ns0out | grep -q "packets 0 bytes 0")
5194 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns0out | grep -q "packets 0 bytes 0")
5195 if [ $? -ne 0 ]; then
5196 - bad_counter ns0 ns0out "packets 0 bytes 0"
5197 + bad_counter "$ns0" ns0out "packets 0 bytes 0" "check_ns0_counters 2"
5198 lret=1
5199 fi
5200 - cnt=$(ip netns exec ns0 nft list counter inet filter ns0out6 | grep -q "packets 0 bytes 0")
5201 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns0out6 | grep -q "packets 0 bytes 0")
5202 if [ $? -ne 0 ]; then
5203 - bad_counter ns0 ns0out6 "packets 0 bytes 0"
5204 + bad_counter "$ns0" ns0out6 "packets 0 bytes 0" "check_ns0_counters3 "
5205 lret=1
5206 fi
5207
5208 for dir in "in" "out" ; do
5209 expect="packets 1 bytes 84"
5210 - cnt=$(ip netns exec ns0 nft list counter inet filter ${ns}${dir} | grep -q "$expect")
5211 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ${ns}${dir} | grep -q "$expect")
5212 if [ $? -ne 0 ]; then
5213 - bad_counter ns0 $ns$dir "$expect"
5214 + bad_counter "$ns0" $ns$dir "$expect" "check_ns0_counters 4"
5215 lret=1
5216 fi
5217
5218 expect="packets 1 bytes 104"
5219 - cnt=$(ip netns exec ns0 nft list counter inet filter ${ns}${dir}6 | grep -q "$expect")
5220 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ${ns}${dir}6 | grep -q "$expect")
5221 if [ $? -ne 0 ]; then
5222 - bad_counter ns0 $ns$dir6 "$expect"
5223 + bad_counter "$ns0" $ns$dir6 "$expect" "check_ns0_counters 5"
5224 lret=1
5225 fi
5226 done
5227 @@ -152,7 +167,7 @@ check_ns0_counters()
5228 reset_counters()
5229 {
5230 for i in 0 1 2;do
5231 - ip netns exec ns$i nft reset counters inet > /dev/null
5232 + ip netns exec ns$i-$sfx nft reset counters inet > /dev/null
5233 done
5234 }
5235
5236 @@ -166,7 +181,7 @@ test_local_dnat6()
5237 IPF="ip6"
5238 fi
5239
5240 -ip netns exec ns0 nft -f - <<EOF
5241 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF
5242 table $family nat {
5243 chain output {
5244 type nat hook output priority 0; policy accept;
5245 @@ -180,7 +195,7 @@ EOF
5246 fi
5247
5248 # ping netns1, expect rewrite to netns2
5249 - ip netns exec ns0 ping -q -c 1 dead:1::99 > /dev/null
5250 + ip netns exec "$ns0" ping -q -c 1 dead:1::99 > /dev/null
5251 if [ $? -ne 0 ]; then
5252 lret=1
5253 echo "ERROR: ping6 failed"
5254 @@ -189,18 +204,18 @@ EOF
5255
5256 expect="packets 0 bytes 0"
5257 for dir in "in6" "out6" ; do
5258 - cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
5259 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | grep -q "$expect")
5260 if [ $? -ne 0 ]; then
5261 - bad_counter ns0 ns1$dir "$expect"
5262 + bad_counter "$ns0" ns1$dir "$expect" "test_local_dnat6 1"
5263 lret=1
5264 fi
5265 done
5266
5267 expect="packets 1 bytes 104"
5268 for dir in "in6" "out6" ; do
5269 - cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
5270 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns2${dir} | grep -q "$expect")
5271 if [ $? -ne 0 ]; then
5272 - bad_counter ns0 ns2$dir "$expect"
5273 + bad_counter "$ns0" ns2$dir "$expect" "test_local_dnat6 2"
5274 lret=1
5275 fi
5276 done
5277 @@ -208,9 +223,9 @@ EOF
5278 # expect 0 count in ns1
5279 expect="packets 0 bytes 0"
5280 for dir in "in6" "out6" ; do
5281 - cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
5282 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns0${dir} | grep -q "$expect")
5283 if [ $? -ne 0 ]; then
5284 - bad_counter ns1 ns0$dir "$expect"
5285 + bad_counter "$ns1" ns0$dir "$expect" "test_local_dnat6 3"
5286 lret=1
5287 fi
5288 done
5289 @@ -218,15 +233,15 @@ EOF
5290 # expect 1 packet in ns2
5291 expect="packets 1 bytes 104"
5292 for dir in "in6" "out6" ; do
5293 - cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
5294 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns0${dir} | grep -q "$expect")
5295 if [ $? -ne 0 ]; then
5296 - bad_counter ns2 ns0$dir "$expect"
5297 + bad_counter "$ns2" ns0$dir "$expect" "test_local_dnat6 4"
5298 lret=1
5299 fi
5300 done
5301
5302 - test $lret -eq 0 && echo "PASS: ipv6 ping to ns1 was $family NATted to ns2"
5303 - ip netns exec ns0 nft flush chain ip6 nat output
5304 + test $lret -eq 0 && echo "PASS: ipv6 ping to $ns1 was $family NATted to $ns2"
5305 + ip netns exec "$ns0" nft flush chain ip6 nat output
5306
5307 return $lret
5308 }
5309 @@ -241,7 +256,7 @@ test_local_dnat()
5310 IPF="ip"
5311 fi
5312
5313 -ip netns exec ns0 nft -f - <<EOF 2>/dev/null
5314 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF 2>/dev/null
5315 table $family nat {
5316 chain output {
5317 type nat hook output priority 0; policy accept;
5318 @@ -260,7 +275,7 @@ EOF
5319 fi
5320
5321 # ping netns1, expect rewrite to netns2
5322 - ip netns exec ns0 ping -q -c 1 10.0.1.99 > /dev/null
5323 + ip netns exec "$ns0" ping -q -c 1 10.0.1.99 > /dev/null
5324 if [ $? -ne 0 ]; then
5325 lret=1
5326 echo "ERROR: ping failed"
5327 @@ -269,18 +284,18 @@ EOF
5328
5329 expect="packets 0 bytes 0"
5330 for dir in "in" "out" ; do
5331 - cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
5332 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | grep -q "$expect")
5333 if [ $? -ne 0 ]; then
5334 - bad_counter ns0 ns1$dir "$expect"
5335 + bad_counter "$ns0" ns1$dir "$expect" "test_local_dnat 1"
5336 lret=1
5337 fi
5338 done
5339
5340 expect="packets 1 bytes 84"
5341 for dir in "in" "out" ; do
5342 - cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
5343 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns2${dir} | grep -q "$expect")
5344 if [ $? -ne 0 ]; then
5345 - bad_counter ns0 ns2$dir "$expect"
5346 + bad_counter "$ns0" ns2$dir "$expect" "test_local_dnat 2"
5347 lret=1
5348 fi
5349 done
5350 @@ -288,9 +303,9 @@ EOF
5351 # expect 0 count in ns1
5352 expect="packets 0 bytes 0"
5353 for dir in "in" "out" ; do
5354 - cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
5355 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns0${dir} | grep -q "$expect")
5356 if [ $? -ne 0 ]; then
5357 - bad_counter ns1 ns0$dir "$expect"
5358 + bad_counter "$ns1" ns0$dir "$expect" "test_local_dnat 3"
5359 lret=1
5360 fi
5361 done
5362 @@ -298,19 +313,19 @@ EOF
5363 # expect 1 packet in ns2
5364 expect="packets 1 bytes 84"
5365 for dir in "in" "out" ; do
5366 - cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
5367 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns0${dir} | grep -q "$expect")
5368 if [ $? -ne 0 ]; then
5369 - bad_counter ns2 ns0$dir "$expect"
5370 + bad_counter "$ns2" ns0$dir "$expect" "test_local_dnat 4"
5371 lret=1
5372 fi
5373 done
5374
5375 - test $lret -eq 0 && echo "PASS: ping to ns1 was $family NATted to ns2"
5376 + test $lret -eq 0 && echo "PASS: ping to $ns1 was $family NATted to $ns2"
5377
5378 - ip netns exec ns0 nft flush chain $family nat output
5379 + ip netns exec "$ns0" nft flush chain $family nat output
5380
5381 reset_counters
5382 - ip netns exec ns0 ping -q -c 1 10.0.1.99 > /dev/null
5383 + ip netns exec "$ns0" ping -q -c 1 10.0.1.99 > /dev/null
5384 if [ $? -ne 0 ]; then
5385 lret=1
5386 echo "ERROR: ping failed"
5387 @@ -319,17 +334,17 @@ EOF
5388
5389 expect="packets 1 bytes 84"
5390 for dir in "in" "out" ; do
5391 - cnt=$(ip netns exec ns0 nft list counter inet filter ns1${dir} | grep -q "$expect")
5392 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | grep -q "$expect")
5393 if [ $? -ne 0 ]; then
5394 - bad_counter ns1 ns1$dir "$expect"
5395 + bad_counter "$ns1" ns1$dir "$expect" "test_local_dnat 5"
5396 lret=1
5397 fi
5398 done
5399 expect="packets 0 bytes 0"
5400 for dir in "in" "out" ; do
5401 - cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
5402 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns2${dir} | grep -q "$expect")
5403 if [ $? -ne 0 ]; then
5404 - bad_counter ns0 ns2$dir "$expect"
5405 + bad_counter "$ns0" ns2$dir "$expect" "test_local_dnat 6"
5406 lret=1
5407 fi
5408 done
5409 @@ -337,9 +352,9 @@ EOF
5410 # expect 1 count in ns1
5411 expect="packets 1 bytes 84"
5412 for dir in "in" "out" ; do
5413 - cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
5414 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns0${dir} | grep -q "$expect")
5415 if [ $? -ne 0 ]; then
5416 - bad_counter ns0 ns0$dir "$expect"
5417 + bad_counter "$ns0" ns0$dir "$expect" "test_local_dnat 7"
5418 lret=1
5419 fi
5420 done
5421 @@ -347,14 +362,14 @@ EOF
5422 # expect 0 packet in ns2
5423 expect="packets 0 bytes 0"
5424 for dir in "in" "out" ; do
5425 - cnt=$(ip netns exec ns2 nft list counter inet filter ns0${dir} | grep -q "$expect")
5426 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns0${dir} | grep -q "$expect")
5427 if [ $? -ne 0 ]; then
5428 - bad_counter ns2 ns2$dir "$expect"
5429 + bad_counter "$ns2" ns0$dir "$expect" "test_local_dnat 8"
5430 lret=1
5431 fi
5432 done
5433
5434 - test $lret -eq 0 && echo "PASS: ping to ns1 OK after $family nat output chain flush"
5435 + test $lret -eq 0 && echo "PASS: ping to $ns1 OK after $family nat output chain flush"
5436
5437 return $lret
5438 }
5439 @@ -366,26 +381,26 @@ test_masquerade6()
5440 local natflags=$2
5441 local lret=0
5442
5443 - ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
5444 + ip netns exec "$ns0" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
5445
5446 - ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5447 + ip netns exec "$ns2" ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5448 if [ $? -ne 0 ] ; then
5449 - echo "ERROR: cannot ping ns1 from ns2 via ipv6"
5450 + echo "ERROR: cannot ping $ns1 from $ns2 via ipv6"
5451 return 1
5452 lret=1
5453 fi
5454
5455 expect="packets 1 bytes 104"
5456 for dir in "in6" "out6" ; do
5457 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5458 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5459 if [ $? -ne 0 ]; then
5460 - bad_counter ns1 ns2$dir "$expect"
5461 + bad_counter "$ns1" ns2$dir "$expect" "test_masquerade6 1"
5462 lret=1
5463 fi
5464
5465 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5466 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5467 if [ $? -ne 0 ]; then
5468 - bad_counter ns2 ns1$dir "$expect"
5469 + bad_counter "$ns2" ns1$dir "$expect" "test_masquerade6 2"
5470 lret=1
5471 fi
5472 done
5473 @@ -393,7 +408,7 @@ test_masquerade6()
5474 reset_counters
5475
5476 # add masquerading rule
5477 -ip netns exec ns0 nft -f - <<EOF
5478 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF
5479 table $family nat {
5480 chain postrouting {
5481 type nat hook postrouting priority 0; policy accept;
5482 @@ -406,24 +421,24 @@ EOF
5483 return $ksft_skip
5484 fi
5485
5486 - ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5487 + ip netns exec "$ns2" ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5488 if [ $? -ne 0 ] ; then
5489 - echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
5490 + echo "ERROR: cannot ping $ns1 from $ns2 with active $family masquerade $natflags"
5491 lret=1
5492 fi
5493
5494 # ns1 should have seen packets from ns0, due to masquerade
5495 expect="packets 1 bytes 104"
5496 for dir in "in6" "out6" ; do
5497 - cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
5498 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns0${dir} | grep -q "$expect")
5499 if [ $? -ne 0 ]; then
5500 - bad_counter ns1 ns0$dir "$expect"
5501 + bad_counter "$ns1" ns0$dir "$expect" "test_masquerade6 3"
5502 lret=1
5503 fi
5504
5505 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5506 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5507 if [ $? -ne 0 ]; then
5508 - bad_counter ns2 ns1$dir "$expect"
5509 + bad_counter "$ns2" ns1$dir "$expect" "test_masquerade6 4"
5510 lret=1
5511 fi
5512 done
5513 @@ -431,32 +446,32 @@ EOF
5514 # ns1 should not have seen packets from ns2, due to masquerade
5515 expect="packets 0 bytes 0"
5516 for dir in "in6" "out6" ; do
5517 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5518 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5519 if [ $? -ne 0 ]; then
5520 - bad_counter ns1 ns0$dir "$expect"
5521 + bad_counter "$ns1" ns0$dir "$expect" "test_masquerade6 5"
5522 lret=1
5523 fi
5524
5525 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5526 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | grep -q "$expect")
5527 if [ $? -ne 0 ]; then
5528 - bad_counter ns2 ns1$dir "$expect"
5529 + bad_counter "$ns0" ns1$dir "$expect" "test_masquerade6 6"
5530 lret=1
5531 fi
5532 done
5533
5534 - ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5535 + ip netns exec "$ns2" ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5536 if [ $? -ne 0 ] ; then
5537 - echo "ERROR: cannot ping ns1 from ns2 with active ipv6 masquerade $natflags (attempt 2)"
5538 + echo "ERROR: cannot ping $ns1 from $ns2 with active ipv6 masquerade $natflags (attempt 2)"
5539 lret=1
5540 fi
5541
5542 - ip netns exec ns0 nft flush chain $family nat postrouting
5543 + ip netns exec "$ns0" nft flush chain $family nat postrouting
5544 if [ $? -ne 0 ]; then
5545 echo "ERROR: Could not flush $family nat postrouting" 1>&2
5546 lret=1
5547 fi
5548
5549 - test $lret -eq 0 && echo "PASS: $family IPv6 masquerade $natflags for ns2"
5550 + test $lret -eq 0 && echo "PASS: $family IPv6 masquerade $natflags for $ns2"
5551
5552 return $lret
5553 }
5554 @@ -467,26 +482,26 @@ test_masquerade()
5555 local natflags=$2
5556 local lret=0
5557
5558 - ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
5559 - ip netns exec ns0 sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
5560 + ip netns exec "$ns0" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
5561 + ip netns exec "$ns0" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
5562
5563 - ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5564 + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5565 if [ $? -ne 0 ] ; then
5566 - echo "ERROR: cannot ping ns1 from ns2 $natflags"
5567 + echo "ERROR: cannot ping $ns1 from "$ns2" $natflags"
5568 lret=1
5569 fi
5570
5571 expect="packets 1 bytes 84"
5572 for dir in "in" "out" ; do
5573 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5574 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5575 if [ $? -ne 0 ]; then
5576 - bad_counter ns1 ns2$dir "$expect"
5577 + bad_counter "$ns1" ns2$dir "$expect" "test_masquerade 1"
5578 lret=1
5579 fi
5580
5581 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5582 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5583 if [ $? -ne 0 ]; then
5584 - bad_counter ns2 ns1$dir "$expect"
5585 + bad_counter "$ns2" ns1$dir "$expect" "test_masquerade 2"
5586 lret=1
5587 fi
5588 done
5589 @@ -494,7 +509,7 @@ test_masquerade()
5590 reset_counters
5591
5592 # add masquerading rule
5593 -ip netns exec ns0 nft -f - <<EOF
5594 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF
5595 table $family nat {
5596 chain postrouting {
5597 type nat hook postrouting priority 0; policy accept;
5598 @@ -507,24 +522,24 @@ EOF
5599 return $ksft_skip
5600 fi
5601
5602 - ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5603 + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5604 if [ $? -ne 0 ] ; then
5605 - echo "ERROR: cannot ping ns1 from ns2 with active $family masquerade $natflags"
5606 + echo "ERROR: cannot ping $ns1 from $ns2 with active $family masquerade $natflags"
5607 lret=1
5608 fi
5609
5610 # ns1 should have seen packets from ns0, due to masquerade
5611 expect="packets 1 bytes 84"
5612 for dir in "in" "out" ; do
5613 - cnt=$(ip netns exec ns1 nft list counter inet filter ns0${dir} | grep -q "$expect")
5614 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns0${dir} | grep -q "$expect")
5615 if [ $? -ne 0 ]; then
5616 - bad_counter ns1 ns0$dir "$expect"
5617 + bad_counter "$ns1" ns0$dir "$expect" "test_masquerade 3"
5618 lret=1
5619 fi
5620
5621 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5622 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5623 if [ $? -ne 0 ]; then
5624 - bad_counter ns2 ns1$dir "$expect"
5625 + bad_counter "$ns2" ns1$dir "$expect" "test_masquerade 4"
5626 lret=1
5627 fi
5628 done
5629 @@ -532,32 +547,32 @@ EOF
5630 # ns1 should not have seen packets from ns2, due to masquerade
5631 expect="packets 0 bytes 0"
5632 for dir in "in" "out" ; do
5633 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5634 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5635 if [ $? -ne 0 ]; then
5636 - bad_counter ns1 ns0$dir "$expect"
5637 + bad_counter "$ns1" ns0$dir "$expect" "test_masquerade 5"
5638 lret=1
5639 fi
5640
5641 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5642 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns1${dir} | grep -q "$expect")
5643 if [ $? -ne 0 ]; then
5644 - bad_counter ns2 ns1$dir "$expect"
5645 + bad_counter "$ns0" ns1$dir "$expect" "test_masquerade 6"
5646 lret=1
5647 fi
5648 done
5649
5650 - ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5651 + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5652 if [ $? -ne 0 ] ; then
5653 - echo "ERROR: cannot ping ns1 from ns2 with active ip masquerade $natflags (attempt 2)"
5654 + echo "ERROR: cannot ping $ns1 from $ns2 with active ip masquerade $natflags (attempt 2)"
5655 lret=1
5656 fi
5657
5658 - ip netns exec ns0 nft flush chain $family nat postrouting
5659 + ip netns exec "$ns0" nft flush chain $family nat postrouting
5660 if [ $? -ne 0 ]; then
5661 echo "ERROR: Could not flush $family nat postrouting" 1>&2
5662 lret=1
5663 fi
5664
5665 - test $lret -eq 0 && echo "PASS: $family IP masquerade $natflags for ns2"
5666 + test $lret -eq 0 && echo "PASS: $family IP masquerade $natflags for $ns2"
5667
5668 return $lret
5669 }
5670 @@ -567,25 +582,25 @@ test_redirect6()
5671 local family=$1
5672 local lret=0
5673
5674 - ip netns exec ns0 sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
5675 + ip netns exec "$ns0" sysctl net.ipv6.conf.all.forwarding=1 > /dev/null
5676
5677 - ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5678 + ip netns exec "$ns2" ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5679 if [ $? -ne 0 ] ; then
5680 - echo "ERROR: cannnot ping ns1 from ns2 via ipv6"
5681 + echo "ERROR: cannnot ping $ns1 from $ns2 via ipv6"
5682 lret=1
5683 fi
5684
5685 expect="packets 1 bytes 104"
5686 for dir in "in6" "out6" ; do
5687 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5688 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5689 if [ $? -ne 0 ]; then
5690 - bad_counter ns1 ns2$dir "$expect"
5691 + bad_counter "$ns1" ns2$dir "$expect" "test_redirect6 1"
5692 lret=1
5693 fi
5694
5695 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5696 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5697 if [ $? -ne 0 ]; then
5698 - bad_counter ns2 ns1$dir "$expect"
5699 + bad_counter "$ns2" ns1$dir "$expect" "test_redirect6 2"
5700 lret=1
5701 fi
5702 done
5703 @@ -593,7 +608,7 @@ test_redirect6()
5704 reset_counters
5705
5706 # add redirect rule
5707 -ip netns exec ns0 nft -f - <<EOF
5708 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF
5709 table $family nat {
5710 chain prerouting {
5711 type nat hook prerouting priority 0; policy accept;
5712 @@ -606,18 +621,18 @@ EOF
5713 return $ksft_skip
5714 fi
5715
5716 - ip netns exec ns2 ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5717 + ip netns exec "$ns2" ping -q -c 1 dead:1::99 > /dev/null # ping ns2->ns1
5718 if [ $? -ne 0 ] ; then
5719 - echo "ERROR: cannot ping ns1 from ns2 via ipv6 with active $family redirect"
5720 + echo "ERROR: cannot ping $ns1 from $ns2 via ipv6 with active $family redirect"
5721 lret=1
5722 fi
5723
5724 # ns1 should have seen no packets from ns2, due to redirection
5725 expect="packets 0 bytes 0"
5726 for dir in "in6" "out6" ; do
5727 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5728 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5729 if [ $? -ne 0 ]; then
5730 - bad_counter ns1 ns0$dir "$expect"
5731 + bad_counter "$ns1" ns0$dir "$expect" "test_redirect6 3"
5732 lret=1
5733 fi
5734 done
5735 @@ -625,20 +640,20 @@ EOF
5736 # ns0 should have seen packets from ns2, due to masquerade
5737 expect="packets 1 bytes 104"
5738 for dir in "in6" "out6" ; do
5739 - cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
5740 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns2${dir} | grep -q "$expect")
5741 if [ $? -ne 0 ]; then
5742 - bad_counter ns1 ns0$dir "$expect"
5743 + bad_counter "$ns1" ns0$dir "$expect" "test_redirect6 4"
5744 lret=1
5745 fi
5746 done
5747
5748 - ip netns exec ns0 nft delete table $family nat
5749 + ip netns exec "$ns0" nft delete table $family nat
5750 if [ $? -ne 0 ]; then
5751 echo "ERROR: Could not delete $family nat table" 1>&2
5752 lret=1
5753 fi
5754
5755 - test $lret -eq 0 && echo "PASS: $family IPv6 redirection for ns2"
5756 + test $lret -eq 0 && echo "PASS: $family IPv6 redirection for $ns2"
5757
5758 return $lret
5759 }
5760 @@ -648,26 +663,26 @@ test_redirect()
5761 local family=$1
5762 local lret=0
5763
5764 - ip netns exec ns0 sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
5765 - ip netns exec ns0 sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
5766 + ip netns exec "$ns0" sysctl net.ipv4.conf.veth0.forwarding=1 > /dev/null
5767 + ip netns exec "$ns0" sysctl net.ipv4.conf.veth1.forwarding=1 > /dev/null
5768
5769 - ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5770 + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5771 if [ $? -ne 0 ] ; then
5772 - echo "ERROR: cannot ping ns1 from ns2"
5773 + echo "ERROR: cannot ping $ns1 from $ns2"
5774 lret=1
5775 fi
5776
5777 expect="packets 1 bytes 84"
5778 for dir in "in" "out" ; do
5779 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5780 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5781 if [ $? -ne 0 ]; then
5782 - bad_counter ns1 ns2$dir "$expect"
5783 + bad_counter "$ns1" $ns2$dir "$expect" "test_redirect 1"
5784 lret=1
5785 fi
5786
5787 - cnt=$(ip netns exec ns2 nft list counter inet filter ns1${dir} | grep -q "$expect")
5788 + cnt=$(ip netns exec "$ns2" nft list counter inet filter ns1${dir} | grep -q "$expect")
5789 if [ $? -ne 0 ]; then
5790 - bad_counter ns2 ns1$dir "$expect"
5791 + bad_counter "$ns2" ns1$dir "$expect" "test_redirect 2"
5792 lret=1
5793 fi
5794 done
5795 @@ -675,7 +690,7 @@ test_redirect()
5796 reset_counters
5797
5798 # add redirect rule
5799 -ip netns exec ns0 nft -f - <<EOF
5800 +ip netns exec "$ns0" nft -f /dev/stdin <<EOF
5801 table $family nat {
5802 chain prerouting {
5803 type nat hook prerouting priority 0; policy accept;
5804 @@ -688,9 +703,9 @@ EOF
5805 return $ksft_skip
5806 fi
5807
5808 - ip netns exec ns2 ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5809 + ip netns exec "$ns2" ping -q -c 1 10.0.1.99 > /dev/null # ping ns2->ns1
5810 if [ $? -ne 0 ] ; then
5811 - echo "ERROR: cannot ping ns1 from ns2 with active $family ip redirect"
5812 + echo "ERROR: cannot ping $ns1 from $ns2 with active $family ip redirect"
5813 lret=1
5814 fi
5815
5816 @@ -698,9 +713,9 @@ EOF
5817 expect="packets 0 bytes 0"
5818 for dir in "in" "out" ; do
5819
5820 - cnt=$(ip netns exec ns1 nft list counter inet filter ns2${dir} | grep -q "$expect")
5821 + cnt=$(ip netns exec "$ns1" nft list counter inet filter ns2${dir} | grep -q "$expect")
5822 if [ $? -ne 0 ]; then
5823 - bad_counter ns1 ns0$dir "$expect"
5824 + bad_counter "$ns1" ns0$dir "$expect" "test_redirect 3"
5825 lret=1
5826 fi
5827 done
5828 @@ -708,28 +723,28 @@ EOF
5829 # ns0 should have seen packets from ns2, due to masquerade
5830 expect="packets 1 bytes 84"
5831 for dir in "in" "out" ; do
5832 - cnt=$(ip netns exec ns0 nft list counter inet filter ns2${dir} | grep -q "$expect")
5833 + cnt=$(ip netns exec "$ns0" nft list counter inet filter ns2${dir} | grep -q "$expect")
5834 if [ $? -ne 0 ]; then
5835 - bad_counter ns1 ns0$dir "$expect"
5836 + bad_counter "$ns0" ns0$dir "$expect" "test_redirect 4"
5837 lret=1
5838 fi
5839 done
5840
5841 - ip netns exec ns0 nft delete table $family nat
5842 + ip netns exec "$ns0" nft delete table $family nat
5843 if [ $? -ne 0 ]; then
5844 echo "ERROR: Could not delete $family nat table" 1>&2
5845 lret=1
5846 fi
5847
5848 - test $lret -eq 0 && echo "PASS: $family IP redirection for ns2"
5849 + test $lret -eq 0 && echo "PASS: $family IP redirection for $ns2"
5850
5851 return $lret
5852 }
5853
5854
5855 -# ip netns exec ns0 ping -c 1 -q 10.0.$i.99
5856 +# ip netns exec "$ns0" ping -c 1 -q 10.0.$i.99
5857 for i in 0 1 2; do
5858 -ip netns exec ns$i nft -f - <<EOF
5859 +ip netns exec ns$i-$sfx nft -f /dev/stdin <<EOF
5860 table inet filter {
5861 counter ns0in {}
5862 counter ns1in {}
5863 @@ -796,18 +811,18 @@ done
5864 sleep 3
5865 # test basic connectivity
5866 for i in 1 2; do
5867 - ip netns exec ns0 ping -c 1 -q 10.0.$i.99 > /dev/null
5868 + ip netns exec "$ns0" ping -c 1 -q 10.0.$i.99 > /dev/null
5869 if [ $? -ne 0 ];then
5870 echo "ERROR: Could not reach other namespace(s)" 1>&2
5871 ret=1
5872 fi
5873
5874 - ip netns exec ns0 ping -c 1 -q dead:$i::99 > /dev/null
5875 + ip netns exec "$ns0" ping -c 1 -q dead:$i::99 > /dev/null
5876 if [ $? -ne 0 ];then
5877 echo "ERROR: Could not reach other namespace(s) via ipv6" 1>&2
5878 ret=1
5879 fi
5880 - check_counters ns$i
5881 + check_counters ns$i-$sfx
5882 if [ $? -ne 0 ]; then
5883 ret=1
5884 fi
5885 @@ -820,7 +835,7 @@ for i in 1 2; do
5886 done
5887
5888 if [ $ret -eq 0 ];then
5889 - echo "PASS: netns routing/connectivity: ns0 can reach ns1 and ns2"
5890 + echo "PASS: netns routing/connectivity: $ns0 can reach $ns1 and $ns2"
5891 fi
5892
5893 reset_counters
5894 @@ -846,4 +861,9 @@ reset_counters
5895 $test_inet_nat && test_redirect inet
5896 $test_inet_nat && test_redirect6 inet
5897
5898 +if [ $ret -ne 0 ];then
5899 + echo -n "FAIL: "
5900 + nft --version
5901 +fi
5902 +
5903 exit $ret
5904 diff --git a/tools/testing/selftests/safesetid/Makefile b/tools/testing/selftests/safesetid/Makefile
5905 index 98da7a504737..fa02c4d5ec13 100644
5906 --- a/tools/testing/selftests/safesetid/Makefile
5907 +++ b/tools/testing/selftests/safesetid/Makefile
5908 @@ -1,8 +1,9 @@
5909 # SPDX-License-Identifier: GPL-2.0
5910 # Makefile for mount selftests.
5911 -CFLAGS = -Wall -lcap -O2
5912 +CFLAGS = -Wall -O2
5913 +LDLIBS = -lcap
5914
5915 -TEST_PROGS := run_tests.sh
5916 +TEST_PROGS := safesetid-test.sh
5917 TEST_GEN_FILES := safesetid-test
5918
5919 include ../lib.mk
5920 diff --git a/tools/testing/selftests/safesetid/safesetid-test.c b/tools/testing/selftests/safesetid/safesetid-test.c
5921 index 8f40c6ecdad1..0c4d50644c13 100644
5922 --- a/tools/testing/selftests/safesetid/safesetid-test.c
5923 +++ b/tools/testing/selftests/safesetid/safesetid-test.c
5924 @@ -213,7 +213,8 @@ static void test_setuid(uid_t child_uid, bool expect_success)
5925 }
5926
5927 if (cpid == 0) { /* Code executed by child */
5928 - setuid(child_uid);
5929 + if (setuid(child_uid) < 0)
5930 + exit(EXIT_FAILURE);
5931 if (getuid() == child_uid)
5932 exit(EXIT_SUCCESS);
5933 else
5934 @@ -291,8 +292,10 @@ int main(int argc, char **argv)
5935
5936 // First test to make sure we can write userns mappings from a user
5937 // that doesn't have any restrictions (as long as it has CAP_SETUID);
5938 - setuid(NO_POLICY_USER);
5939 - setgid(NO_POLICY_USER);
5940 + if (setuid(NO_POLICY_USER) < 0)
5941 + die("Error with set uid(%d)\n", NO_POLICY_USER);
5942 + if (setgid(NO_POLICY_USER) < 0)
5943 + die("Error with set gid(%d)\n", NO_POLICY_USER);
5944
5945 // Take away all but setid caps
5946 drop_caps(true);
5947 @@ -306,8 +309,10 @@ int main(int argc, char **argv)
5948 die("test_userns failed when it should work\n");
5949 }
5950
5951 - setuid(RESTRICTED_PARENT);
5952 - setgid(RESTRICTED_PARENT);
5953 + if (setuid(RESTRICTED_PARENT) < 0)
5954 + die("Error with set uid(%d)\n", RESTRICTED_PARENT);
5955 + if (setgid(RESTRICTED_PARENT) < 0)
5956 + die("Error with set gid(%d)\n", RESTRICTED_PARENT);
5957
5958 test_setuid(ROOT_USER, false);
5959 test_setuid(ALLOWED_CHILD1, true);