From 55a86663e095a2876758f3277e9b2f61da494ab8 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Wed, 23 Jun 2021 20:23:36 +0200 Subject: [PATCH] Upstream patches and small kernel config adjustements --- config/kernel/linux-odroidxu4-current.config | 2 +- config/kernel/linux-odroidxu4-edge.config | 2 +- config/kernel/linux-sunxi-current.config | 12 +- config/kernel/linux-sunxi-edge.config | 3 +- config/kernel/linux-sunxi64-current.config | 14 +- config/kernel/linux-sunxi64-edge.config | 7 +- .../odroidxu4-5.4/patch-5.4.127-128.patch | 3152 ++++++++ .../archive/sunxi-5.10/patch-5.10.43-44.patch | 3608 +++++++++ .../archive/sunxi-5.10/patch-5.10.44-45.patch | 1077 +++ .../archive/sunxi-5.10/patch-5.10.45-46.patch | 5158 +++++++++++++ .../archive/sunxi-5.12/patch-5.12.12-13.patch | 6477 +++++++++++++++++ 11 files changed, 19501 insertions(+), 11 deletions(-) create mode 100644 patch/kernel/archive/odroidxu4-5.4/patch-5.4.127-128.patch create mode 100644 patch/kernel/archive/sunxi-5.10/patch-5.10.43-44.patch create mode 100644 patch/kernel/archive/sunxi-5.10/patch-5.10.44-45.patch create mode 100644 patch/kernel/archive/sunxi-5.10/patch-5.10.45-46.patch create mode 100644 patch/kernel/archive/sunxi-5.12/patch-5.12.12-13.patch diff --git a/config/kernel/linux-odroidxu4-current.config b/config/kernel/linux-odroidxu4-current.config index 368cae2a7..e43e211a4 100644 --- a/config/kernel/linux-odroidxu4-current.config +++ b/config/kernel/linux-odroidxu4-current.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 5.4.127 Kernel Configuration +# Linux/arm 5.4.128 Kernel Configuration # # diff --git a/config/kernel/linux-odroidxu4-edge.config b/config/kernel/linux-odroidxu4-edge.config index 089ba2a07..c185e9d65 100644 --- a/config/kernel/linux-odroidxu4-edge.config +++ b/config/kernel/linux-odroidxu4-edge.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 5.12.12 Kernel Configuration +# Linux/arm 5.12.13 Kernel Configuration # CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0" CONFIG_CC_IS_GCC=y diff --git a/config/kernel/linux-sunxi-current.config b/config/kernel/linux-sunxi-current.config index ecdd7312c..56987dd38 100644 --- a/config/kernel/linux-sunxi-current.config +++ b/config/kernel/linux-sunxi-current.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 5.10.41 Kernel Configuration +# Linux/arm 5.10.46 Kernel Configuration # CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0" CONFIG_CC_IS_GCC=y @@ -476,6 +476,7 @@ CONFIG_ALIGNMENT_TRAP=y # CONFIG_PARAVIRT is not set # CONFIG_PARAVIRT_TIME_ACCOUNTING is not set # CONFIG_XEN is not set +CONFIG_STACKPROTECTOR_PER_TASK=y # end of Kernel Features # @@ -689,6 +690,11 @@ CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y # end of GCOV-based kernel profiling CONFIG_HAVE_GCC_PLUGINS=y +CONFIG_GCC_PLUGINS=y +# CONFIG_GCC_PLUGIN_CYC_COMPLEXITY is not set +# CONFIG_GCC_PLUGIN_LATENT_ENTROPY is not set +# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set +CONFIG_GCC_PLUGIN_ARM_SSP_PER_TASK=y # end of General architecture-dependent options CONFIG_RT_MUTEXES=y @@ -2024,6 +2030,7 @@ CONFIG_NVME_CORE=m # CONFIG_NVME_HWMON is not set CONFIG_NVME_FABRICS=m # CONFIG_NVME_FC is not set +CONFIG_NVME_TCP=m CONFIG_NVME_TARGET=m # CONFIG_NVME_TARGET_PASSTHRU is not set CONFIG_NVME_TARGET_LOOP=m @@ -7306,6 +7313,9 @@ CONFIG_LSM="lockdown,yama,integrity,apparmor" # Memory initialization # CONFIG_INIT_STACK_NONE=y +# CONFIG_GCC_PLUGIN_STRUCTLEAK_USER is not set +# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF is not set +# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL is not set CONFIG_INIT_ON_ALLOC_DEFAULT_ON=y # CONFIG_INIT_ON_FREE_DEFAULT_ON is not set # end of Memory initialization diff --git a/config/kernel/linux-sunxi-edge.config b/config/kernel/linux-sunxi-edge.config index 3eb698ac7..c1db33428 100644 --- a/config/kernel/linux-sunxi-edge.config +++ b/config/kernel/linux-sunxi-edge.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm 5.12.8 Kernel Configuration +# Linux/arm 5.12.13 Kernel Configuration # CONFIG_CC_VERSION_TEXT="arm-linux-gnueabihf-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0" CONFIG_CC_IS_GCC=y @@ -2046,6 +2046,7 @@ CONFIG_NVME_CORE=m # CONFIG_NVME_HWMON is not set CONFIG_NVME_FABRICS=m # CONFIG_NVME_FC is not set +CONFIG_NVME_TCP=m CONFIG_NVME_TARGET=m # CONFIG_NVME_TARGET_PASSTHRU is not set CONFIG_NVME_TARGET_LOOP=m diff --git a/config/kernel/linux-sunxi64-current.config b/config/kernel/linux-sunxi64-current.config index 5db337254..53b9112a6 100644 --- a/config/kernel/linux-sunxi64-current.config +++ b/config/kernel/linux-sunxi64-current.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 5.10.41 Kernel Configuration +# Linux/arm64 5.10.46 Kernel Configuration # CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0" CONFIG_CC_IS_GCC=y @@ -677,6 +677,9 @@ CONFIG_ARCH_HAS_GCOV_PROFILE_ALL=y # end of GCOV-based kernel profiling CONFIG_HAVE_GCC_PLUGINS=y +CONFIG_GCC_PLUGINS=y +# CONFIG_GCC_PLUGIN_LATENT_ENTROPY is not set +# CONFIG_GCC_PLUGIN_RANDSTRUCT is not set # end of General architecture-dependent options CONFIG_RT_MUTEXES=y @@ -2041,7 +2044,12 @@ CONFIG_BLK_DEV_RBD=m # # NVME Support # +CONFIG_NVME_CORE=m +# CONFIG_NVME_MULTIPATH is not set +# CONFIG_NVME_HWMON is not set +CONFIG_NVME_FABRICS=m # CONFIG_NVME_FC is not set +CONFIG_NVME_TCP=m # CONFIG_NVME_TARGET is not set # end of NVME Support @@ -7143,6 +7151,10 @@ CONFIG_LSM="lockdown,yama,integrity,apparmor" # Memory initialization # CONFIG_INIT_STACK_NONE=y +# CONFIG_GCC_PLUGIN_STRUCTLEAK_USER is not set +# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF is not set +# CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL is not set +# CONFIG_GCC_PLUGIN_STACKLEAK is not set # CONFIG_INIT_ON_ALLOC_DEFAULT_ON is not set # CONFIG_INIT_ON_FREE_DEFAULT_ON is not set # end of Memory initialization diff --git a/config/kernel/linux-sunxi64-edge.config b/config/kernel/linux-sunxi64-edge.config index 3dc99f07a..2f9e5e33a 100644 --- a/config/kernel/linux-sunxi64-edge.config +++ b/config/kernel/linux-sunxi64-edge.config @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/arm64 5.12.12 Kernel Configuration +# Linux/arm64 5.12.9 Kernel Configuration # CONFIG_CC_VERSION_TEXT="aarch64-linux-gnu-gcc (GNU Toolchain for the A-profile Architecture 8.3-2019.03 (arm-rel-8.36)) 8.3.0" CONFIG_CC_IS_GCC=y @@ -2067,12 +2067,7 @@ CONFIG_BLK_DEV_RBD=m # # NVME Support # -CONFIG_NVME_CORE=m -# CONFIG_NVME_MULTIPATH is not set -# CONFIG_NVME_HWMON is not set -CONFIG_NVME_FABRICS=m # CONFIG_NVME_FC is not set -CONFIG_NVME_TCP=m # CONFIG_NVME_TARGET is not set # end of NVME Support diff --git a/patch/kernel/archive/odroidxu4-5.4/patch-5.4.127-128.patch b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.127-128.patch new file mode 100644 index 000000000..8d3769ada --- /dev/null +++ b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.127-128.patch @@ -0,0 +1,3152 @@ +diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst +index 933ada4368ff3..309c1acb414b7 100644 +--- a/Documentation/vm/slub.rst ++++ b/Documentation/vm/slub.rst +@@ -160,7 +160,7 @@ SLUB Debug output + Here is a sample of slub debug output:: + + ==================================================================== +- BUG kmalloc-8: Redzone overwritten ++ BUG kmalloc-8: Right Redzone overwritten + -------------------------------------------------------------------- + + INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc +@@ -168,10 +168,10 @@ Here is a sample of slub debug output:: + INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58 + INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554 + +- Bytes b4 0xc90f6d10: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ +- Object 0xc90f6d20: 31 30 31 39 2e 30 30 35 1019.005 +- Redzone 0xc90f6d28: 00 cc cc cc . +- Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ ++ Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ ++ Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005 ++ Redzone (0xc90f6d28): 00 cc cc cc . ++ Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ + + [] dump_trace+0x63/0x1eb + [] show_trace_log_lvl+0x1a/0x2f +diff --git a/Makefile b/Makefile +index ba10c68113427..5db87d8031f1e 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 4 +-SUBLEVEL = 127 ++SUBLEVEL = 128 + EXTRAVERSION = + NAME = Kleptomaniac Octopus + +diff --git a/arch/arc/include/uapi/asm/sigcontext.h b/arch/arc/include/uapi/asm/sigcontext.h +index 95f8a4380e110..7a5449dfcb290 100644 +--- a/arch/arc/include/uapi/asm/sigcontext.h ++++ b/arch/arc/include/uapi/asm/sigcontext.h +@@ -18,6 +18,7 @@ + */ + struct sigcontext { + struct user_regs_struct regs; ++ struct user_regs_arcv2 v2abi; + }; + + #endif /* _ASM_ARC_SIGCONTEXT_H */ +diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c +index 4045180510939..8877de0dfe6cf 100644 +--- a/arch/arc/kernel/signal.c ++++ b/arch/arc/kernel/signal.c +@@ -61,6 +61,41 @@ struct rt_sigframe { + unsigned int sigret_magic; + }; + ++static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ v2abi.r30 = regs->r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ v2abi.r58 = regs->r58; ++ v2abi.r59 = regs->r59; ++#else ++ v2abi.r58 = v2abi.r59 = 0; ++#endif ++ err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi)); ++#endif ++ return err; ++} ++ ++static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi)); ++ ++ regs->r30 = v2abi.r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ regs->r58 = v2abi.r58; ++ regs->r59 = v2abi.r59; ++#endif ++#endif ++ return err; ++} ++ + static int + stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + sigset_t *set) +@@ -94,6 +129,10 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + + err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch, + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t)); + + return err ? -EFAULT : 0; +@@ -109,6 +148,10 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) + err |= __copy_from_user(&uregs.scratch, + &(sf->uc.uc_mcontext.regs.scratch), + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + if (err) + return -EFAULT; + +diff --git a/arch/arm/boot/dts/dra7-l4.dtsi b/arch/arm/boot/dts/dra7-l4.dtsi +index 3ae4f6358da41..bc702579488b9 100644 +--- a/arch/arm/boot/dts/dra7-l4.dtsi ++++ b/arch/arm/boot/dts/dra7-l4.dtsi +@@ -1176,7 +1176,7 @@ + }; + }; + +- target-module@34000 { /* 0x48034000, ap 7 46.0 */ ++ timer3_target: target-module@34000 { /* 0x48034000, ap 7 46.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + ti,hwmods = "timer3"; + reg = <0x34000 0x4>, +@@ -1204,7 +1204,7 @@ + }; + }; + +- target-module@36000 { /* 0x48036000, ap 9 4e.0 */ ++ timer4_target: target-module@36000 { /* 0x48036000, ap 9 4e.0 */ + compatible = "ti,sysc-omap4-timer", "ti,sysc"; + ti,hwmods = "timer4"; + reg = <0x36000 0x4>, +diff --git a/arch/arm/boot/dts/dra7.dtsi b/arch/arm/boot/dts/dra7.dtsi +index a6ef3d137c7a0..f73324cb31f31 100644 +--- a/arch/arm/boot/dts/dra7.dtsi ++++ b/arch/arm/boot/dts/dra7.dtsi +@@ -46,6 +46,7 @@ + + timer { + compatible = "arm,armv7-timer"; ++ status = "disabled"; /* See ARM architected timer wrap erratum i940 */ + interrupts = , + , + , +@@ -766,3 +767,22 @@ + + #include "dra7-l4.dtsi" + #include "dra7xx-clocks.dtsi" ++ ++/* Local timers, see ARM architected timer wrap erratum i940 */ ++&timer3_target { ++ ti,no-reset-on-init; ++ ti,no-idle; ++ timer@0 { ++ assigned-clocks = <&l4per_clkctrl DRA7_L4PER_TIMER3_CLKCTRL 24>; ++ assigned-clock-parents = <&timer_sys_clk_div>; ++ }; ++}; ++ ++&timer4_target { ++ ti,no-reset-on-init; ++ ti,no-idle; ++ timer@0 { ++ assigned-clocks = <&l4per_clkctrl DRA7_L4PER_TIMER4_CLKCTRL 24>; ++ assigned-clock-parents = <&timer_sys_clk_div>; ++ }; ++}; +diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c +index d068958d6f8a4..2c1e2b32b9b36 100644 +--- a/arch/arm/mach-omap1/pm.c ++++ b/arch/arm/mach-omap1/pm.c +@@ -596,11 +596,6 @@ static irqreturn_t omap_wakeup_interrupt(int irq, void *dev) + return IRQ_HANDLED; + } + +-static struct irqaction omap_wakeup_irq = { +- .name = "peripheral wakeup", +- .handler = omap_wakeup_interrupt +-}; +- + + + static const struct platform_suspend_ops omap_pm_ops = { +@@ -613,6 +608,7 @@ static const struct platform_suspend_ops omap_pm_ops = { + static int __init omap_pm_init(void) + { + int error = 0; ++ int irq; + + if (!cpu_class_is_omap1()) + return -ENODEV; +@@ -656,9 +652,12 @@ static int __init omap_pm_init(void) + arm_pm_idle = omap1_pm_idle; + + if (cpu_is_omap7xx()) +- setup_irq(INT_7XX_WAKE_UP_REQ, &omap_wakeup_irq); ++ irq = INT_7XX_WAKE_UP_REQ; + else if (cpu_is_omap16xx()) +- setup_irq(INT_1610_WAKE_UP_REQ, &omap_wakeup_irq); ++ irq = INT_1610_WAKE_UP_REQ; ++ if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup", ++ NULL)) ++ pr_err("Failed to request irq %d (peripheral wakeup)\n", irq); + + /* Program new power ramp-up time + * (0 for most boards since we don't lower voltage when in deep sleep) +diff --git a/arch/arm/mach-omap1/time.c b/arch/arm/mach-omap1/time.c +index 524977a31a49c..de590a85a42b3 100644 +--- a/arch/arm/mach-omap1/time.c ++++ b/arch/arm/mach-omap1/time.c +@@ -155,15 +155,11 @@ static irqreturn_t omap_mpu_timer1_interrupt(int irq, void *dev_id) + return IRQ_HANDLED; + } + +-static struct irqaction omap_mpu_timer1_irq = { +- .name = "mpu_timer1", +- .flags = IRQF_TIMER | IRQF_IRQPOLL, +- .handler = omap_mpu_timer1_interrupt, +-}; +- + static __init void omap_init_mpu_timer(unsigned long rate) + { +- setup_irq(INT_TIMER1, &omap_mpu_timer1_irq); ++ if (request_irq(INT_TIMER1, omap_mpu_timer1_interrupt, ++ IRQF_TIMER | IRQF_IRQPOLL, "mpu_timer1", NULL)) ++ pr_err("Failed to request irq %d (mpu_timer1)\n", INT_TIMER1); + omap_mpu_timer_start(0, (rate / HZ) - 1, 1); + + clockevent_mpu_timer1.cpumask = cpumask_of(0); +diff --git a/arch/arm/mach-omap1/timer32k.c b/arch/arm/mach-omap1/timer32k.c +index 0ae6c52a7d70b..780fdf03c3cee 100644 +--- a/arch/arm/mach-omap1/timer32k.c ++++ b/arch/arm/mach-omap1/timer32k.c +@@ -148,15 +148,11 @@ static irqreturn_t omap_32k_timer_interrupt(int irq, void *dev_id) + return IRQ_HANDLED; + } + +-static struct irqaction omap_32k_timer_irq = { +- .name = "32KHz timer", +- .flags = IRQF_TIMER | IRQF_IRQPOLL, +- .handler = omap_32k_timer_interrupt, +-}; +- + static __init void omap_init_32k_timer(void) + { +- setup_irq(INT_OS_TIMER, &omap_32k_timer_irq); ++ if (request_irq(INT_OS_TIMER, omap_32k_timer_interrupt, ++ IRQF_TIMER | IRQF_IRQPOLL, "32KHz timer", NULL)) ++ pr_err("Failed to request irq %d(32KHz timer)\n", INT_OS_TIMER); + + clockevent_32k_timer.cpumask = cpumask_of(0); + clockevents_config_and_register(&clockevent_32k_timer, +diff --git a/arch/arm/mach-omap2/board-generic.c b/arch/arm/mach-omap2/board-generic.c +index ff992f8895ee4..ad512f07d5689 100644 +--- a/arch/arm/mach-omap2/board-generic.c ++++ b/arch/arm/mach-omap2/board-generic.c +@@ -327,7 +327,7 @@ DT_MACHINE_START(DRA74X_DT, "Generic DRA74X (Flattened Device Tree)") + .init_late = dra7xx_init_late, + .init_irq = omap_gic_of_init, + .init_machine = omap_generic_init, +- .init_time = omap5_realtime_timer_init, ++ .init_time = omap3_gptimer_timer_init, + .dt_compat = dra74x_boards_compat, + .restart = omap44xx_restart, + MACHINE_END +@@ -350,7 +350,7 @@ DT_MACHINE_START(DRA72X_DT, "Generic DRA72X (Flattened Device Tree)") + .init_late = dra7xx_init_late, + .init_irq = omap_gic_of_init, + .init_machine = omap_generic_init, +- .init_time = omap5_realtime_timer_init, ++ .init_time = omap3_gptimer_timer_init, + .dt_compat = dra72x_boards_compat, + .restart = omap44xx_restart, + MACHINE_END +diff --git a/arch/arm/mach-omap2/timer.c b/arch/arm/mach-omap2/timer.c +index 07bea84c5d6e4..1defb838eae3a 100644 +--- a/arch/arm/mach-omap2/timer.c ++++ b/arch/arm/mach-omap2/timer.c +@@ -42,6 +42,7 @@ + #include + #include + #include ++#include + + #include + +@@ -63,15 +64,28 @@ + + /* Clockevent code */ + +-static struct omap_dm_timer clkev; +-static struct clock_event_device clockevent_gpt; +- + /* Clockevent hwmod for am335x and am437x suspend */ + static struct omap_hwmod *clockevent_gpt_hwmod; + + /* Clockesource hwmod for am437x suspend */ + static struct omap_hwmod *clocksource_gpt_hwmod; + ++struct dmtimer_clockevent { ++ struct clock_event_device dev; ++ struct omap_dm_timer timer; ++}; ++ ++static struct dmtimer_clockevent clockevent; ++ ++static struct omap_dm_timer *to_dmtimer(struct clock_event_device *clockevent) ++{ ++ struct dmtimer_clockevent *clkevt = ++ container_of(clockevent, struct dmtimer_clockevent, dev); ++ struct omap_dm_timer *timer = &clkevt->timer; ++ ++ return timer; ++} ++ + #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER + static unsigned long arch_timer_freq; + +@@ -83,24 +97,21 @@ void set_cntfreq(void) + + static irqreturn_t omap2_gp_timer_interrupt(int irq, void *dev_id) + { +- struct clock_event_device *evt = &clockevent_gpt; +- +- __omap_dm_timer_write_status(&clkev, OMAP_TIMER_INT_OVERFLOW); ++ struct dmtimer_clockevent *clkevt = dev_id; ++ struct clock_event_device *evt = &clkevt->dev; ++ struct omap_dm_timer *timer = &clkevt->timer; + ++ __omap_dm_timer_write_status(timer, OMAP_TIMER_INT_OVERFLOW); + evt->event_handler(evt); + return IRQ_HANDLED; + } + +-static struct irqaction omap2_gp_timer_irq = { +- .name = "gp_timer", +- .flags = IRQF_TIMER | IRQF_IRQPOLL, +- .handler = omap2_gp_timer_interrupt, +-}; +- + static int omap2_gp_timer_set_next_event(unsigned long cycles, + struct clock_event_device *evt) + { +- __omap_dm_timer_load_start(&clkev, OMAP_TIMER_CTRL_ST, ++ struct omap_dm_timer *timer = to_dmtimer(evt); ++ ++ __omap_dm_timer_load_start(timer, OMAP_TIMER_CTRL_ST, + 0xffffffff - cycles, OMAP_TIMER_POSTED); + + return 0; +@@ -108,22 +119,26 @@ static int omap2_gp_timer_set_next_event(unsigned long cycles, + + static int omap2_gp_timer_shutdown(struct clock_event_device *evt) + { +- __omap_dm_timer_stop(&clkev, OMAP_TIMER_POSTED, clkev.rate); ++ struct omap_dm_timer *timer = to_dmtimer(evt); ++ ++ __omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate); ++ + return 0; + } + + static int omap2_gp_timer_set_periodic(struct clock_event_device *evt) + { ++ struct omap_dm_timer *timer = to_dmtimer(evt); + u32 period; + +- __omap_dm_timer_stop(&clkev, OMAP_TIMER_POSTED, clkev.rate); ++ __omap_dm_timer_stop(timer, OMAP_TIMER_POSTED, timer->rate); + +- period = clkev.rate / HZ; ++ period = timer->rate / HZ; + period -= 1; + /* Looks like we need to first set the load value separately */ +- __omap_dm_timer_write(&clkev, OMAP_TIMER_LOAD_REG, 0xffffffff - period, ++ __omap_dm_timer_write(timer, OMAP_TIMER_LOAD_REG, 0xffffffff - period, + OMAP_TIMER_POSTED); +- __omap_dm_timer_load_start(&clkev, ++ __omap_dm_timer_load_start(timer, + OMAP_TIMER_CTRL_AR | OMAP_TIMER_CTRL_ST, + 0xffffffff - period, OMAP_TIMER_POSTED); + return 0; +@@ -137,25 +152,16 @@ static void omap_clkevt_idle(struct clock_event_device *unused) + omap_hwmod_idle(clockevent_gpt_hwmod); + } + +-static void omap_clkevt_unidle(struct clock_event_device *unused) ++static void omap_clkevt_unidle(struct clock_event_device *evt) + { ++ struct omap_dm_timer *timer = to_dmtimer(evt); ++ + if (!clockevent_gpt_hwmod) + return; + + omap_hwmod_enable(clockevent_gpt_hwmod); +- __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW); +-} +- +-static struct clock_event_device clockevent_gpt = { +- .features = CLOCK_EVT_FEAT_PERIODIC | +- CLOCK_EVT_FEAT_ONESHOT, +- .rating = 300, +- .set_next_event = omap2_gp_timer_set_next_event, +- .set_state_shutdown = omap2_gp_timer_shutdown, +- .set_state_periodic = omap2_gp_timer_set_periodic, +- .set_state_oneshot = omap2_gp_timer_shutdown, +- .tick_resume = omap2_gp_timer_shutdown, +-}; ++ __omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW); ++} + + static const struct of_device_id omap_timer_match[] __initconst = { + { .compatible = "ti,omap2420-timer", }, +@@ -362,47 +368,104 @@ void tick_broadcast(const struct cpumask *mask) + } + #endif + +-static void __init omap2_gp_clockevent_init(int gptimer_id, +- const char *fck_source, +- const char *property) ++static void __init dmtimer_clkevt_init_common(struct dmtimer_clockevent *clkevt, ++ int gptimer_id, ++ const char *fck_source, ++ unsigned int features, ++ const struct cpumask *cpumask, ++ const char *property, ++ int rating, const char *name) + { ++ struct omap_dm_timer *timer = &clkevt->timer; + int res; + +- clkev.id = gptimer_id; +- clkev.errata = omap_dm_timer_get_errata(); ++ timer->id = gptimer_id; ++ timer->errata = omap_dm_timer_get_errata(); ++ clkevt->dev.features = features; ++ clkevt->dev.rating = rating; ++ clkevt->dev.set_next_event = omap2_gp_timer_set_next_event; ++ clkevt->dev.set_state_shutdown = omap2_gp_timer_shutdown; ++ clkevt->dev.set_state_periodic = omap2_gp_timer_set_periodic; ++ clkevt->dev.set_state_oneshot = omap2_gp_timer_shutdown; ++ clkevt->dev.tick_resume = omap2_gp_timer_shutdown; + + /* + * For clock-event timers we never read the timer counter and + * so we are not impacted by errata i103 and i767. Therefore, + * we can safely ignore this errata for clock-event timers. + */ +- __omap_dm_timer_override_errata(&clkev, OMAP_TIMER_ERRATA_I103_I767); ++ __omap_dm_timer_override_errata(timer, OMAP_TIMER_ERRATA_I103_I767); + +- res = omap_dm_timer_init_one(&clkev, fck_source, property, +- &clockevent_gpt.name, OMAP_TIMER_POSTED); ++ res = omap_dm_timer_init_one(timer, fck_source, property, ++ &clkevt->dev.name, OMAP_TIMER_POSTED); + BUG_ON(res); + +- omap2_gp_timer_irq.dev_id = &clkev; +- setup_irq(clkev.irq, &omap2_gp_timer_irq); ++ clkevt->dev.cpumask = cpumask; ++ clkevt->dev.irq = omap_dm_timer_get_irq(timer); + +- __omap_dm_timer_int_enable(&clkev, OMAP_TIMER_INT_OVERFLOW); ++ if (request_irq(clkevt->dev.irq, omap2_gp_timer_interrupt, ++ IRQF_TIMER | IRQF_IRQPOLL, name, clkevt)) ++ pr_err("Failed to request irq %d (gp_timer)\n", clkevt->dev.irq); + +- clockevent_gpt.cpumask = cpu_possible_mask; +- clockevent_gpt.irq = omap_dm_timer_get_irq(&clkev); +- clockevents_config_and_register(&clockevent_gpt, clkev.rate, +- 3, /* Timer internal resynch latency */ +- 0xffffffff); ++ __omap_dm_timer_int_enable(timer, OMAP_TIMER_INT_OVERFLOW); + + if (soc_is_am33xx() || soc_is_am43xx()) { +- clockevent_gpt.suspend = omap_clkevt_idle; +- clockevent_gpt.resume = omap_clkevt_unidle; ++ clkevt->dev.suspend = omap_clkevt_idle; ++ clkevt->dev.resume = omap_clkevt_unidle; + + clockevent_gpt_hwmod = +- omap_hwmod_lookup(clockevent_gpt.name); ++ omap_hwmod_lookup(clkevt->dev.name); ++ } ++ ++ pr_info("OMAP clockevent source: %s at %lu Hz\n", clkevt->dev.name, ++ timer->rate); ++} ++ ++static DEFINE_PER_CPU(struct dmtimer_clockevent, dmtimer_percpu_timer); ++ ++static int omap_gptimer_starting_cpu(unsigned int cpu) ++{ ++ struct dmtimer_clockevent *clkevt = per_cpu_ptr(&dmtimer_percpu_timer, cpu); ++ struct clock_event_device *dev = &clkevt->dev; ++ struct omap_dm_timer *timer = &clkevt->timer; ++ ++ clockevents_config_and_register(dev, timer->rate, 3, ULONG_MAX); ++ irq_force_affinity(dev->irq, cpumask_of(cpu)); ++ ++ return 0; ++} ++ ++static int __init dmtimer_percpu_quirk_init(void) ++{ ++ struct dmtimer_clockevent *clkevt; ++ struct clock_event_device *dev; ++ struct device_node *arm_timer; ++ struct omap_dm_timer *timer; ++ int cpu = 0; ++ ++ arm_timer = of_find_compatible_node(NULL, NULL, "arm,armv7-timer"); ++ if (of_device_is_available(arm_timer)) { ++ pr_warn_once("ARM architected timer wrap issue i940 detected\n"); ++ return 0; ++ } ++ ++ for_each_possible_cpu(cpu) { ++ clkevt = per_cpu_ptr(&dmtimer_percpu_timer, cpu); ++ dev = &clkevt->dev; ++ timer = &clkevt->timer; ++ ++ dmtimer_clkevt_init_common(clkevt, 0, "timer_sys_ck", ++ CLOCK_EVT_FEAT_ONESHOT, ++ cpumask_of(cpu), ++ "assigned-clock-parents", ++ 500, "percpu timer"); + } + +- pr_info("OMAP clockevent source: %s at %lu Hz\n", clockevent_gpt.name, +- clkev.rate); ++ cpuhp_setup_state(CPUHP_AP_OMAP_DM_TIMER_STARTING, ++ "clockevents/omap/gptimer:starting", ++ omap_gptimer_starting_cpu, NULL); ++ ++ return 0; + } + + /* Clocksource code */ +@@ -542,7 +605,15 @@ static void __init __omap_sync32k_timer_init(int clkev_nr, const char *clkev_src + { + omap_clk_init(); + omap_dmtimer_init(); +- omap2_gp_clockevent_init(clkev_nr, clkev_src, clkev_prop); ++ dmtimer_clkevt_init_common(&clockevent, clkev_nr, clkev_src, ++ CLOCK_EVT_FEAT_PERIODIC | CLOCK_EVT_FEAT_ONESHOT, ++ cpu_possible_mask, clkev_prop, 300, "clockevent"); ++ clockevents_config_and_register(&clockevent.dev, clockevent.timer.rate, ++ 3, /* Timer internal resynch latency */ ++ 0xffffffff); ++ ++ if (soc_is_dra7xx()) ++ dmtimer_percpu_quirk_init(); + + /* Enable the use of clocksource="gp_timer" kernel parameter */ + if (use_gptimer_clksrc || gptimer) +@@ -571,7 +642,7 @@ void __init omap3_secure_sync32k_timer_init(void) + #endif /* CONFIG_ARCH_OMAP3 */ + + #if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_SOC_AM33XX) || \ +- defined(CONFIG_SOC_AM43XX) ++ defined(CONFIG_SOC_AM43XX) || defined(CONFIG_SOC_DRA7XX) + void __init omap3_gptimer_timer_init(void) + { + __omap_sync32k_timer_init(2, "timer_sys_ck", NULL, +diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h +index 00eac7f1529b0..9f135e5b9cf51 100644 +--- a/arch/x86/include/asm/fpu/internal.h ++++ b/arch/x86/include/asm/fpu/internal.h +@@ -607,10 +607,17 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) + * PKRU state is switched eagerly because it needs to be valid before we + * return to userland e.g. for a copy_to_user() operation. + */ +- if (current->mm) { ++ if (!(current->flags & PF_KTHREAD)) { ++ /* ++ * If the PKRU bit in xsave.header.xfeatures is not set, ++ * then the PKRU component was in init state, which means ++ * XRSTOR will set PKRU to 0. If the bit is not set then ++ * get_xsave_addr() will return NULL because the PKRU value ++ * in memory is not valid. This means pkru_val has to be ++ * set to 0 and not to init_pkru_value. ++ */ + pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); +- if (pk) +- pkru_val = pk->pkru; ++ pkru_val = pk ? pk->pkru : 0; + } + __write_pkru(pkru_val); + } +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c +index 400a05e1c1c51..ab2f9c2f0683a 100644 +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -289,13 +289,17 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + return 0; + } + +- if (!access_ok(buf, size)) +- return -EACCES; ++ if (!access_ok(buf, size)) { ++ ret = -EACCES; ++ goto out; ++ } + +- if (!static_cpu_has(X86_FEATURE_FPU)) +- return fpregs_soft_set(current, NULL, +- 0, sizeof(struct user_i387_ia32_struct), +- NULL, buf) != 0; ++ if (!static_cpu_has(X86_FEATURE_FPU)) { ++ ret = fpregs_soft_set(current, NULL, 0, ++ sizeof(struct user_i387_ia32_struct), ++ NULL, buf); ++ goto out; ++ } + + if (use_xsave()) { + struct _fpx_sw_bytes fx_sw_user; +@@ -333,7 +337,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + if (ia32_fxstate) { + ret = __copy_from_user(&env, buf, sizeof(env)); + if (ret) +- goto err_out; ++ goto out; + envp = &env; + } else { + /* +@@ -369,7 +373,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + ret = validate_xstate_header(&fpu->state.xsave.header); + } + if (ret) +- goto err_out; ++ goto out; + + sanitize_restored_xstate(&fpu->state, envp, xfeatures, fx_only); + +@@ -382,7 +386,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + ret = __copy_from_user(&fpu->state.fxsave, buf_fx, state_size); + if (ret) { + ret = -EFAULT; +- goto err_out; ++ goto out; + } + + sanitize_restored_xstate(&fpu->state, envp, xfeatures, fx_only); +@@ -397,7 +401,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + } else { + ret = __copy_from_user(&fpu->state.fsave, buf_fx, state_size); + if (ret) +- goto err_out; ++ goto out; + + fpregs_lock(); + ret = copy_kernel_to_fregs_err(&fpu->state.fsave); +@@ -408,7 +412,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + fpregs_deactivate(fpu); + fpregs_unlock(); + +-err_out: ++out: + if (ret) + fpu__clear(fpu); + return ret; +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c +index 3f6b866c644d5..eea2d6f10f59a 100644 +--- a/arch/x86/kvm/lapic.c ++++ b/arch/x86/kvm/lapic.c +@@ -1332,6 +1332,9 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, + if (!apic_x2apic_mode(apic)) + valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI); + ++ if (alignment + len > 4) ++ return 1; ++ + if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset))) + return 1; + +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index 79b5d0ca44724..4cc052108f156 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -6279,7 +6279,10 @@ static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt) + + static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags) + { +- emul_to_vcpu(ctxt)->arch.hflags = emul_flags; ++ struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); ++ ++ vcpu->arch.hflags = emul_flags; ++ kvm_mmu_reset_context(vcpu); + } + + static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, +diff --git a/drivers/clk/ti/clk-7xx.c b/drivers/clk/ti/clk-7xx.c +index 66e4b2b9ec600..04ed6614ee316 100644 +--- a/drivers/clk/ti/clk-7xx.c ++++ b/drivers/clk/ti/clk-7xx.c +@@ -793,6 +793,7 @@ static struct ti_dt_clk dra7xx_clks[] = { + DT_CLK(NULL, "timer_32k_ck", "sys_32k_ck"), + DT_CLK(NULL, "sys_clkin_ck", "timer_sys_clk_div"), + DT_CLK(NULL, "sys_clkin", "sys_clkin1"), ++ DT_CLK(NULL, "timer_sys_ck", "timer_sys_clk_div"), + DT_CLK(NULL, "atl_dpll_clk_mux", "atl-clkctrl:0000:24"), + DT_CLK(NULL, "atl_gfclk_mux", "atl-clkctrl:0000:26"), + DT_CLK(NULL, "dcan1_sys_clk_mux", "wkupaon-clkctrl:0068:24"), +diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig +index 7af874b69ffb9..a32d0d7152475 100644 +--- a/drivers/dma/Kconfig ++++ b/drivers/dma/Kconfig +@@ -59,6 +59,7 @@ config DMA_OF + #devices + config ALTERA_MSGDMA + tristate "Altera / Intel mSGDMA Engine" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for Altera / Intel mSGDMA controller. +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c +index 57b6555d6d042..9a94d5b9e0590 100644 +--- a/drivers/dma/pl330.c ++++ b/drivers/dma/pl330.c +@@ -2690,13 +2690,15 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + for (i = 0; i < len / period_len; i++) { + desc = pl330_get_desc(pch); + if (!desc) { ++ unsigned long iflags; ++ + dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", + __func__, __LINE__); + + if (!first) + return NULL; + +- spin_lock_irqsave(&pl330->pool_lock, flags); ++ spin_lock_irqsave(&pl330->pool_lock, iflags); + + while (!list_empty(&first->node)) { + desc = list_entry(first->node.next, +@@ -2706,7 +2708,7 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + + list_move_tail(&first->node, &pl330->desc_pool); + +- spin_unlock_irqrestore(&pl330->pool_lock, flags); ++ spin_unlock_irqrestore(&pl330->pool_lock, iflags); + + return NULL; + } +diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig +index 1d189438aeb0b..bef309ef6a71b 100644 +--- a/drivers/dma/qcom/Kconfig ++++ b/drivers/dma/qcom/Kconfig +@@ -10,6 +10,7 @@ config QCOM_BAM_DMA + + config QCOM_HIDMA_MGMT + tristate "Qualcomm Technologies HIDMA Management support" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for the Qualcomm Technologies HIDMA Management. +diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c +index de8bfd9a76e9e..6671bfe084895 100644 +--- a/drivers/dma/ste_dma40.c ++++ b/drivers/dma/ste_dma40.c +@@ -3678,6 +3678,9 @@ static int __init d40_probe(struct platform_device *pdev) + + kfree(base->lcla_pool.base_unaligned); + ++ if (base->lcpa_base) ++ iounmap(base->lcpa_base); ++ + if (base->phy_lcpa) + release_mem_region(base->phy_lcpa, + base->lcpa_size); +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +index 1d8739a4fbcad..9964ec0035ede 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +@@ -3416,8 +3416,12 @@ static int gfx_v10_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +index 06cdc22b5501d..354da41f52def 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +@@ -3593,8 +3593,12 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c +index 1ad5c3b86b640..a18bf70a251e4 100644 +--- a/drivers/gpu/drm/radeon/radeon_uvd.c ++++ b/drivers/gpu/drm/radeon/radeon_uvd.c +@@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + if (rdev->uvd.vcpu_bo == NULL) + return -EINVAL; + +- memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); ++ memcpy_toio((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); + + size = radeon_bo_size(rdev->uvd.vcpu_bo); + size -= rdev->uvd_fw->size; +@@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + ptr = rdev->uvd.cpu_addr; + ptr += rdev->uvd_fw->size; + +- memset(ptr, 0, size); ++ memset_io((void __iomem *)ptr, 0, size); + + return 0; + } +diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c +index 25aac40f2764a..919877970ae3b 100644 +--- a/drivers/hwmon/scpi-hwmon.c ++++ b/drivers/hwmon/scpi-hwmon.c +@@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) + + scpi_scale_reading(&value, sensor); + ++ /* ++ * Temperature sensor values are treated as signed values based on ++ * observation even though that is not explicitly specified, and ++ * because an unsigned u64 temperature does not really make practical ++ * sense especially when the temperature is below zero degrees Celsius. ++ */ ++ if (sensor->info.class == TEMPERATURE) ++ return sprintf(buf, "%lld\n", (s64)value); ++ + return sprintf(buf, "%llu\n", value); + } + +diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c +index 8f785c199e220..c5ed73d45623d 100644 +--- a/drivers/net/can/usb/mcba_usb.c ++++ b/drivers/net/can/usb/mcba_usb.c +@@ -82,6 +82,8 @@ struct mcba_priv { + bool can_ka_first_pass; + bool can_speed_check; + atomic_t free_ctx_cnt; ++ void *rxbuf[MCBA_MAX_RX_URBS]; ++ dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS]; + }; + + /* CAN frame */ +@@ -633,6 +635,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + for (i = 0; i < MCBA_MAX_RX_URBS; i++) { + struct urb *urb = NULL; + u8 *buf; ++ dma_addr_t buf_dma; + + /* create a URB, and a buffer for it */ + urb = usb_alloc_urb(0, GFP_KERNEL); +@@ -642,7 +645,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + } + + buf = usb_alloc_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- GFP_KERNEL, &urb->transfer_dma); ++ GFP_KERNEL, &buf_dma); + if (!buf) { + netdev_err(netdev, "No memory left for USB buffer\n"); + usb_free_urb(urb); +@@ -661,11 +664,14 @@ static int mcba_usb_start(struct mcba_priv *priv) + if (err) { + usb_unanchor_urb(urb); + usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- buf, urb->transfer_dma); ++ buf, buf_dma); + usb_free_urb(urb); + break; + } + ++ priv->rxbuf[i] = buf; ++ priv->rxbuf_dma[i] = buf_dma; ++ + /* Drop reference, USB core will take care of freeing it */ + usb_free_urb(urb); + } +@@ -708,7 +714,14 @@ static int mcba_usb_open(struct net_device *netdev) + + static void mcba_urb_unlink(struct mcba_priv *priv) + { ++ int i; ++ + usb_kill_anchored_urbs(&priv->rx_submitted); ++ ++ for (i = 0; i < MCBA_MAX_RX_URBS; ++i) ++ usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, ++ priv->rxbuf[i], priv->rxbuf_dma[i]); ++ + usb_kill_anchored_urbs(&priv->tx_submitted); + } + +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c +index bde8ec75ac4e9..bee62d7caccc4 100644 +--- a/drivers/net/ethernet/atheros/alx/main.c ++++ b/drivers/net/ethernet/atheros/alx/main.c +@@ -1852,6 +1852,7 @@ out_free_netdev: + free_netdev(netdev); + out_pci_release: + pci_release_mem_regions(pdev); ++ pci_disable_pcie_error_reporting(pdev); + out_pci_disable: + pci_disable_device(pdev); + return err; +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index 00ae7a9a42bfe..d1c3939b0307f 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -10610,6 +10610,8 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp) + bnxt_hwrm_coal_params_qcaps(bp); + } + ++static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt); ++ + static int bnxt_fw_init_one(struct bnxt *bp) + { + int rc; +@@ -10624,6 +10626,9 @@ static int bnxt_fw_init_one(struct bnxt *bp) + netdev_err(bp->dev, "Firmware init phase 2 failed\n"); + return rc; + } ++ rc = bnxt_probe_phy(bp, false); ++ if (rc) ++ return rc; + rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); + if (rc) + return rc; +@@ -11958,6 +11963,7 @@ init_err_cleanup: + init_err_pci_clean: + bnxt_free_hwrm_short_cmd_req(bp); + bnxt_free_hwrm_resources(bp); ++ bnxt_ethtool_free(bp); + kfree(bp->fw_health); + bp->fw_health = NULL; + bnxt_cleanup_pci(bp); +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +index ccb28182f745b..44f86a33ef624 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +@@ -198,7 +198,7 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, + WORD_MASK, f->fs.nat_lip[3] | + f->fs.nat_lip[2] << 8 | + f->fs.nat_lip[1] << 16 | +- (u64)f->fs.nat_lip[0] << 25, 1); ++ (u64)f->fs.nat_lip[0] << 24, 1); + } + } + +diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c +index 46b0dbab8aadc..7c992172933bc 100644 +--- a/drivers/net/ethernet/ec_bhf.c ++++ b/drivers/net/ethernet/ec_bhf.c +@@ -576,10 +576,12 @@ static void ec_bhf_remove(struct pci_dev *dev) + struct ec_bhf_priv *priv = netdev_priv(net_dev); + + unregister_netdev(net_dev); +- free_netdev(net_dev); + + pci_iounmap(dev, priv->dma_io); + pci_iounmap(dev, priv->io); ++ ++ free_netdev(net_dev); ++ + pci_release_regions(dev); + pci_clear_master(dev); + pci_disable_device(dev); +diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c +index 39eb7d525043d..9aebb121365f5 100644 +--- a/drivers/net/ethernet/emulex/benet/be_main.c ++++ b/drivers/net/ethernet/emulex/benet/be_main.c +@@ -6030,6 +6030,7 @@ drv_cleanup: + unmap_bars: + be_unmap_pci_bars(adapter); + free_netdev: ++ pci_disable_pcie_error_reporting(pdev); + free_netdev(netdev); + rel_reg: + pci_release_regions(pdev); +diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c +index 49fad118988bc..3b54a37e780eb 100644 +--- a/drivers/net/ethernet/freescale/fec_ptp.c ++++ b/drivers/net/ethernet/freescale/fec_ptp.c +@@ -220,15 +220,13 @@ static u64 fec_ptp_read(const struct cyclecounter *cc) + { + struct fec_enet_private *fep = + container_of(cc, struct fec_enet_private, cc); +- const struct platform_device_id *id_entry = +- platform_get_device_id(fep->pdev); + u32 tempval; + + tempval = readl(fep->hwp + FEC_ATIME_CTRL); + tempval |= FEC_T_CTRL_CAPTURE; + writel(tempval, fep->hwp + FEC_ATIME_CTRL); + +- if (id_entry->driver_data & FEC_QUIRK_BUG_CAPTURE) ++ if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) + udelay(1); + + return readl(fep->hwp + FEC_ATIME); +@@ -599,6 +597,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) + fep->ptp_caps.enable = fec_ptp_enable; + + fep->cycle_speed = clk_get_rate(fep->clk_ptp); ++ if (!fep->cycle_speed) { ++ fep->cycle_speed = NSEC_PER_SEC; ++ dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); ++ } + fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed; + + spin_lock_init(&fep->tmreg_lock); +diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c +index 6ece99e6b6dde..6e504854571cf 100644 +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev) + + static int xrx200_alloc_skb(struct xrx200_chan *ch) + { ++ struct sk_buff *skb = ch->skb[ch->dma.desc]; + dma_addr_t mapping; + int ret = 0; + +@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch) + XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) { + dev_kfree_skb_any(ch->skb[ch->dma.desc]); ++ ch->skb[ch->dma.desc] = skb; + ret = -ENOMEM; + goto skip; + } +@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch) + ch->dma.desc %= LTQ_DESC_NUM; + + if (ret) { +- ch->skb[ch->dma.desc] = skb; + net_dev->stats.rx_dropped++; + netdev_err(net_dev, "failed to allocate new rx buffer\n"); + return ret; +@@ -351,8 +352,8 @@ static irqreturn_t xrx200_dma_irq(int irq, void *ptr) + struct xrx200_chan *ch = ptr; + + if (napi_schedule_prep(&ch->napi)) { +- __napi_schedule(&ch->napi); + ltq_dma_disable_irq(&ch->dma); ++ __napi_schedule(&ch->napi); + } + + ltq_dma_ack_irq(&ch->dma); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +index cf58c96379047..c467f5e981f61 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +@@ -515,9 +515,6 @@ void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv) + struct mlx5_core_dev *mdev = priv->mdev; + struct net_device *netdev = priv->netdev; + +- if (!priv->ipsec) +- return; +- + if (!(mlx5_accel_ipsec_device_caps(mdev) & MLX5_ACCEL_IPSEC_CAP_ESP) || + !MLX5_CAP_ETH(mdev, swp)) { + mlx5_core_dbg(mdev, "mlx5e: ESP and SWP offload not supported\n"); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +index 36b9a364ef26b..24c49a84947f3 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +@@ -5007,11 +5007,9 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) + } + + if (mlx5_vxlan_allowed(mdev->vxlan) || mlx5_geneve_tx_allowed(mdev)) { +- netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM; ++ netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL; + } + + if (mlx5e_tunnel_proto_supported(mdev, IPPROTO_GRE)) { +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +index fe7342e8a043b..9d26463f3fa5d 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -4079,7 +4079,7 @@ static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv, + list_for_each_entry_safe(hpe, tmp, &init_wait_list, dead_peer_wait_list) { + wait_for_completion(&hpe->res_ready); + if (!IS_ERR_OR_NULL(hpe->hp) && hpe->peer_vhca_id == peer_vhca_id) +- hpe->hp->pair->peer_gone = true; ++ mlx5_core_hairpin_clear_dead_peer(hpe->hp->pair); + + mlx5e_hairpin_put(priv, hpe); + } +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +index 8e0dddc6383f0..2389239acadc9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +@@ -156,6 +156,9 @@ void mlx5_rdma_enable_roce(struct mlx5_core_dev *dev) + { + int err; + ++ if (!MLX5_CAP_GEN(dev, roce)) ++ return; ++ + err = mlx5_nic_vport_enable_roce(dev); + if (err) { + mlx5_core_err(dev, "Failed to enable RoCE: %d\n", err); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +index b1068500f1df5..0b5437051a3b2 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +@@ -457,6 +457,15 @@ err_modify_sq: + return err; + } + ++static void mlx5_hairpin_unpair_peer_sq(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, ++ MLX5_SQC_STATE_RST, 0, 0); ++} ++ + static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + { + int i; +@@ -465,13 +474,9 @@ static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + for (i = 0; i < hp->num_channels; i++) + mlx5_hairpin_modify_rq(hp->func_mdev, hp->rqn[i], MLX5_RQC_STATE_RDY, + MLX5_RQC_STATE_RST, 0, 0); +- + /* unset peer SQs */ +- if (hp->peer_gone) +- return; +- for (i = 0; i < hp->num_channels; i++) +- mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, +- MLX5_SQC_STATE_RST, 0, 0); ++ if (!hp->peer_gone) ++ mlx5_hairpin_unpair_peer_sq(hp); + } + + struct mlx5_hairpin * +@@ -518,3 +523,16 @@ void mlx5_core_hairpin_destroy(struct mlx5_hairpin *hp) + mlx5_hairpin_destroy_queues(hp); + kfree(hp); + } ++ ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ mlx5_hairpin_unpair_peer_sq(hp); ++ ++ /* destroy peer SQ */ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_core_destroy_sq(hp->peer_mdev, hp->sqn[i]); ++ ++ hp->peer_gone = true; ++} +diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +index 25b6f2ee2beb8..1b9867ea43336 100644 +--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c ++++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +@@ -1602,6 +1602,8 @@ err_out_free_netdev: + free_netdev(netdev); + + err_out_free_res: ++ if (NX_IS_REVISION_P3(pdev->revision)) ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +index f2e5f494462b3..3a96fd6deef72 100644 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +@@ -2709,6 +2709,7 @@ err_out_free_hw_res: + kfree(ahw); + + err_out_free_res: ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +index b70d44ac09906..3c73453725f94 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +@@ -76,10 +76,10 @@ enum power_event { + #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */ + + /* GMAC HW ADDR regs */ +-#define GMAC_ADDR_HIGH(reg) (((reg > 15) ? 0x00000800 : 0x00000040) + \ +- (reg * 8)) +-#define GMAC_ADDR_LOW(reg) (((reg > 15) ? 0x00000804 : 0x00000044) + \ +- (reg * 8)) ++#define GMAC_ADDR_HIGH(reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \ ++ 0x00000040 + (reg * 8)) ++#define GMAC_ADDR_LOW(reg) ((reg > 15) ? 0x00000804 + (reg - 16) * 8 : \ ++ 0x00000044 + (reg * 8)) + #define GMAC_MAX_PERFECT_ADDRESSES 1 + + #define GMAC_PCS_BASE 0x000000c0 /* PCS register base */ +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +index 508325cc105d5..678aa2b001e01 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +@@ -624,6 +624,8 @@ error_pclk_get: + void stmmac_remove_config_dt(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) + { ++ clk_disable_unprepare(plat->stmmac_clk); ++ clk_disable_unprepare(plat->pclk); + of_node_put(plat->phy_node); + of_node_put(plat->mdio_node); + } +diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c +index 5b8451c58aa4c..9b55fbdc3a7c6 100644 +--- a/drivers/net/ethernet/xilinx/ll_temac_main.c ++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c +@@ -846,7 +846,7 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + smp_mb(); + + /* Space might have just been freed - check again */ +- if (temac_check_tx_bd_space(lp, num_frag)) ++ if (temac_check_tx_bd_space(lp, num_frag + 1)) + return NETDEV_TX_BUSY; + + netif_wake_queue(ndev); +@@ -873,7 +873,6 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + return NETDEV_TX_OK; + } + cur_p->phys = cpu_to_be32(skb_dma_addr); +- ptr_to_txbd((void *)skb, cur_p); + + for (ii = 0; ii < num_frag; ii++) { + if (++lp->tx_bd_tail >= TX_BD_NUM) +@@ -912,6 +911,11 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + } + cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_EOP); + ++ /* Mark last fragment with skb address, so it can be consumed ++ * in temac_start_xmit_done() ++ */ ++ ptr_to_txbd((void *)skb, cur_p); ++ + tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; + lp->tx_bd_tail++; + if (lp->tx_bd_tail >= TX_BD_NUM) +diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c +index deef142151104..352f9e75954ce 100644 +--- a/drivers/net/hamradio/mkiss.c ++++ b/drivers/net/hamradio/mkiss.c +@@ -800,6 +800,7 @@ static void mkiss_close(struct tty_struct *tty) + ax->tty = NULL; + + unregister_netdev(ax->dev); ++ free_netdev(ax->dev); + } + + /* Perform I/O control on an active ax25 channel. */ +diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c +index 0eeec80bec311..e4a5703666461 100644 +--- a/drivers/net/usb/cdc_eem.c ++++ b/drivers/net/usb/cdc_eem.c +@@ -123,10 +123,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, + } + + skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); ++ dev_kfree_skb_any(skb); + if (!skb2) + return NULL; + +- dev_kfree_skb_any(skb); + skb = skb2; + + done: +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c +index 0646bcd269682..4cff0a6b1098a 100644 +--- a/drivers/net/usb/cdc_ncm.c ++++ b/drivers/net/usb/cdc_ncm.c +@@ -1662,7 +1662,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) + static const struct driver_info cdc_ncm_info = { + .description = "CDC NCM", + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET +- | FLAG_LINK_INTR, ++ | FLAG_LINK_INTR | FLAG_ETHER, + .bind = cdc_ncm_bind, + .unbind = cdc_ncm_unbind, + .manage_power = usbnet_manage_power, +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c +index d0ae0df34e132..aa848be459ec7 100644 +--- a/drivers/net/usb/smsc75xx.c ++++ b/drivers/net/usb/smsc75xx.c +@@ -1482,7 +1482,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_wait_ready(dev, 0); + if (ret < 0) { + netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); +- goto err; ++ goto free_pdata; + } + + smsc75xx_init_mac_address(dev); +@@ -1491,7 +1491,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_reset(dev); + if (ret < 0) { + netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); +- goto err; ++ goto cancel_work; + } + + dev->net->netdev_ops = &smsc75xx_netdev_ops; +@@ -1502,8 +1502,11 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; + return 0; + +-err: ++cancel_work: ++ cancel_work_sync(&pdata->set_multicast); ++free_pdata: + kfree(pdata); ++ dev->data[0] = 0; + return ret; + } + +@@ -1514,7 +1517,6 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) + cancel_work_sync(&pdata->set_multicast); + netif_dbg(dev, ifdown, dev->net, "free pdata\n"); + kfree(pdata); +- pdata = NULL; + dev->data[0] = 0; + } + } +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c +index 14dfb92783456..1267786d2931b 100644 +--- a/drivers/net/vrf.c ++++ b/drivers/net/vrf.c +@@ -908,9 +908,6 @@ static int vrf_dev_init(struct net_device *dev) + + dev->flags = IFF_MASTER | IFF_NOARP; + +- /* MTU is irrelevant for VRF device; set to 64k similar to lo */ +- dev->mtu = 64 * 1024; +- + /* similarly, oper state is irrelevant; set to up to avoid confusion */ + dev->operstate = IF_OPER_UP; + return 0; +@@ -1343,7 +1340,8 @@ static void vrf_setup(struct net_device *dev) + * which breaks networking. + */ + dev->min_mtu = IPV6_MIN_MTU; +- dev->max_mtu = ETH_MAX_MTU; ++ dev->max_mtu = IP6_MAX_MTU; ++ dev->mtu = dev->max_mtu; + } + + static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], +diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c +index d0e60441dc8f2..89cc6980b5964 100644 +--- a/drivers/pci/controller/pci-aardvark.c ++++ b/drivers/pci/controller/pci-aardvark.c +@@ -175,7 +175,8 @@ + (PCIE_CONF_BUS(bus) | PCIE_CONF_DEV(PCI_SLOT(devfn)) | \ + PCIE_CONF_FUNC(PCI_FUNC(devfn)) | PCIE_CONF_REG(where)) + +-#define PIO_TIMEOUT_MS 1 ++#define PIO_RETRY_CNT 500 ++#define PIO_RETRY_DELAY 2 /* 2 us*/ + + #define LINK_WAIT_MAX_RETRIES 10 + #define LINK_WAIT_USLEEP_MIN 90000 +@@ -392,20 +393,19 @@ static void advk_pcie_check_pio_status(struct advk_pcie *pcie) + static int advk_pcie_wait_pio(struct advk_pcie *pcie) + { + struct device *dev = &pcie->pdev->dev; +- unsigned long timeout; ++ int i; + +- timeout = jiffies + msecs_to_jiffies(PIO_TIMEOUT_MS); +- +- while (time_before(jiffies, timeout)) { ++ for (i = 0; i < PIO_RETRY_CNT; i++) { + u32 start, isr; + + start = advk_readl(pcie, PIO_START); + isr = advk_readl(pcie, PIO_ISR); + if (!start && isr) + return 0; ++ udelay(PIO_RETRY_DELAY); + } + +- dev_err(dev, "config read/write timed out\n"); ++ dev_err(dev, "PIO read/write transfer time out\n"); + return -ETIMEDOUT; + } + +@@ -539,6 +539,35 @@ static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, + return true; + } + ++static bool advk_pcie_pio_is_running(struct advk_pcie *pcie) ++{ ++ struct device *dev = &pcie->pdev->dev; ++ ++ /* ++ * Trying to start a new PIO transfer when previous has not completed ++ * cause External Abort on CPU which results in kernel panic: ++ * ++ * SError Interrupt on CPU0, code 0xbf000002 -- SError ++ * Kernel panic - not syncing: Asynchronous SError Interrupt ++ * ++ * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected ++ * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent ++ * concurrent calls at the same time. But because PIO transfer may take ++ * about 1.5s when link is down or card is disconnected, it means that ++ * advk_pcie_wait_pio() does not always have to wait for completion. ++ * ++ * Some versions of ARM Trusted Firmware handles this External Abort at ++ * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit: ++ * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50 ++ */ ++ if (advk_readl(pcie, PIO_START)) { ++ dev_err(dev, "Previous PIO read/write transfer is still running\n"); ++ return true; ++ } ++ ++ return false; ++} ++ + static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + int where, int size, u32 *val) + { +@@ -555,9 +584,10 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + return pci_bridge_emul_conf_read(&pcie->bridge, where, + size, val); + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) { ++ *val = 0xffffffff; ++ return PCIBIOS_SET_FAILED; ++ } + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -576,7 +606,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, 0xf, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +@@ -614,9 +645,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + if (where % size) + return PCIBIOS_SET_FAILED; + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) ++ return PCIBIOS_SET_FAILED; + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -643,7 +673,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index 53376bcda1f3f..cd0b13ddd000d 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -3557,6 +3557,18 @@ static void quirk_no_bus_reset(struct pci_dev *dev) + dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; + } + ++/* ++ * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be ++ * prevented for those affected devices. ++ */ ++static void quirk_nvidia_no_bus_reset(struct pci_dev *dev) ++{ ++ if ((dev->device & 0xffc0) == 0x2340) ++ quirk_no_bus_reset(dev); ++} ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, ++ quirk_nvidia_no_bus_reset); ++ + /* + * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. + * The device will throw a Link Down error on AER-capable systems and +@@ -3577,6 +3589,16 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset); + */ + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset); + ++/* ++ * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS ++ * automatically disables LTSSM when Secondary Bus Reset is received and ++ * the device stops working. Prevent bus reset for these devices. With ++ * this change, the device can be assigned to VMs with VFIO, but it will ++ * leak state between VMs. Reference ++ * https://e2e.ti.com/support/processors/f/791/t/954382 ++ */ ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0xb005, quirk_no_bus_reset); ++ + static void quirk_no_pm_reset(struct pci_dev *dev) + { + /* +@@ -3969,6 +3991,69 @@ static int delay_250ms_after_flr(struct pci_dev *dev, int probe) + return 0; + } + ++#define PCI_DEVICE_ID_HINIC_VF 0x375E ++#define HINIC_VF_FLR_TYPE 0x1000 ++#define HINIC_VF_FLR_CAP_BIT (1UL << 30) ++#define HINIC_VF_OP 0xE80 ++#define HINIC_VF_FLR_PROC_BIT (1UL << 18) ++#define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */ ++ ++/* Device-specific reset method for Huawei Intelligent NIC virtual functions */ ++static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe) ++{ ++ unsigned long timeout; ++ void __iomem *bar; ++ u32 val; ++ ++ if (probe) ++ return 0; ++ ++ bar = pci_iomap(pdev, 0, 0); ++ if (!bar) ++ return -ENOTTY; ++ ++ /* Get and check firmware capabilities */ ++ val = ioread32be(bar + HINIC_VF_FLR_TYPE); ++ if (!(val & HINIC_VF_FLR_CAP_BIT)) { ++ pci_iounmap(pdev, bar); ++ return -ENOTTY; ++ } ++ ++ /* Set HINIC_VF_FLR_PROC_BIT for the start of FLR */ ++ val = ioread32be(bar + HINIC_VF_OP); ++ val = val | HINIC_VF_FLR_PROC_BIT; ++ iowrite32be(val, bar + HINIC_VF_OP); ++ ++ pcie_flr(pdev); ++ ++ /* ++ * The device must recapture its Bus and Device Numbers after FLR ++ * in order generate Completions. Issue a config write to let the ++ * device capture this information. ++ */ ++ pci_write_config_word(pdev, PCI_VENDOR_ID, 0); ++ ++ /* Firmware clears HINIC_VF_FLR_PROC_BIT when reset is complete */ ++ timeout = jiffies + msecs_to_jiffies(HINIC_OPERATION_TIMEOUT); ++ do { ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ msleep(20); ++ } while (time_before(jiffies, timeout)); ++ ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ ++ pci_warn(pdev, "Reset dev timeout, FLR ack reg: %#010x\n", val); ++ ++reset_complete: ++ pci_iounmap(pdev, bar); ++ ++ return 0; ++} ++ + static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF, + reset_intel_82599_sfp_virtfn }, +@@ -3980,6 +4065,8 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, 0x0953, delay_250ms_after_flr }, + { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, + reset_chelsio_generic_dev }, ++ { PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF, ++ reset_hinic_vf_dev }, + { 0 } + }; + +@@ -4821,6 +4908,8 @@ static const struct pci_dev_acs_enabled { + { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, ++ /* Broadcom multi-function device */ ++ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, + /* Amazon Annapurna Labs */ + { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, +diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c +index b84f16bbd6f24..eedf067ee8e35 100644 +--- a/drivers/ptp/ptp_clock.c ++++ b/drivers/ptp/ptp_clock.c +@@ -63,7 +63,7 @@ static void enqueue_external_timestamp(struct timestamp_event_queue *queue, + spin_unlock_irqrestore(&queue->lock, flags); + } + +-s32 scaled_ppm_to_ppb(long ppm) ++long scaled_ppm_to_ppb(long ppm) + { + /* + * The 'freq' field in the 'struct timex' is in parts per +@@ -80,7 +80,7 @@ s32 scaled_ppm_to_ppb(long ppm) + s64 ppb = 1 + ppm; + ppb *= 125; + ppb >>= 13; +- return (s32) ppb; ++ return (long) ppb; + } + EXPORT_SYMBOL(scaled_ppm_to_ppb); + +@@ -138,7 +138,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx) + delta = ktime_to_ns(kt); + err = ops->adjtime(ops, delta); + } else if (tx->modes & ADJ_FREQUENCY) { +- s32 ppb = scaled_ppm_to_ppb(tx->freq); ++ long ppb = scaled_ppm_to_ppb(tx->freq); + if (ppb > ops->max_adj || ppb < -ops->max_adj) + return -ERANGE; + if (ops->adjfine) +diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c +index 4e726929bb4f5..ea77d915216a2 100644 +--- a/drivers/spi/spi-stm32-qspi.c ++++ b/drivers/spi/spi-stm32-qspi.c +@@ -291,7 +291,7 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + int err = 0; + + if (!op->data.nbytes) +- return stm32_qspi_wait_nobusy(qspi); ++ goto wait_nobusy; + + if (readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) + goto out; +@@ -312,6 +312,9 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + out: + /* clear flags */ + writel_relaxed(FCR_CTCF | FCR_CTEF, qspi->io_base + QSPI_FCR); ++wait_nobusy: ++ if (!err) ++ err = stm32_qspi_wait_nobusy(qspi); + + return err; + } +diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +index d0f06790d38f8..0ba4e4e070a9f 100644 +--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c ++++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +@@ -127,7 +127,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, + if (p->groups[group].enabled) { + dev_err(p->dev, "%s is already enabled\n", + p->groups[group].name); +- return -EBUSY; ++ return 0; + } + + p->groups[group].enabled = 1; +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 6c89d714adb62..3a2d9318604bb 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -39,6 +39,8 @@ + #define USB_VENDOR_GENESYS_LOGIC 0x05e3 + #define USB_VENDOR_SMSC 0x0424 + #define USB_PRODUCT_USB5534B 0x5534 ++#define USB_VENDOR_CYPRESS 0x04b4 ++#define USB_PRODUCT_CY7C65632 0x6570 + #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 + #define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02 + +@@ -5514,6 +5516,11 @@ static const struct usb_device_id hub_id_table[] = { + .idProduct = USB_PRODUCT_USB5534B, + .bInterfaceClass = USB_CLASS_HUB, + .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, ++ { .match_flags = USB_DEVICE_ID_MATCH_VENDOR ++ | USB_DEVICE_ID_MATCH_PRODUCT, ++ .idVendor = USB_VENDOR_CYPRESS, ++ .idProduct = USB_PRODUCT_CY7C65632, ++ .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR + | USB_DEVICE_ID_MATCH_INT_CLASS, + .idVendor = USB_VENDOR_GENESYS_LOGIC, +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index 90ec65d31059f..b9d4fc636b329 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -1575,8 +1575,8 @@ static int dwc3_remove(struct platform_device *pdev) + + pm_runtime_get_sync(&pdev->dev); + +- dwc3_debugfs_exit(dwc); + dwc3_core_exit_mode(dwc); ++ dwc3_debugfs_exit(dwc); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); +diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h +index f2c97058a00b8..e105ddfdf4403 100644 +--- a/drivers/usb/dwc3/debug.h ++++ b/drivers/usb/dwc3/debug.h +@@ -409,9 +409,12 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status) + + + #ifdef CONFIG_DEBUG_FS ++extern void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep); + extern void dwc3_debugfs_init(struct dwc3 *); + extern void dwc3_debugfs_exit(struct dwc3 *); + #else ++static inline void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) ++{ } + static inline void dwc3_debugfs_init(struct dwc3 *d) + { } + static inline void dwc3_debugfs_exit(struct dwc3 *d) +diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c +index 1c792710348f1..9fb519b2efb45 100644 +--- a/drivers/usb/dwc3/debugfs.c ++++ b/drivers/usb/dwc3/debugfs.c +@@ -878,30 +878,14 @@ static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, + } + } + +-static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep, +- struct dentry *parent) ++void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) + { + struct dentry *dir; + +- dir = debugfs_create_dir(dep->name, parent); ++ dir = debugfs_create_dir(dep->name, dep->dwc->root); + dwc3_debugfs_create_endpoint_files(dep, dir); + } + +-static void dwc3_debugfs_create_endpoint_dirs(struct dwc3 *dwc, +- struct dentry *parent) +-{ +- int i; +- +- for (i = 0; i < dwc->num_eps; i++) { +- struct dwc3_ep *dep = dwc->eps[i]; +- +- if (!dep) +- continue; +- +- dwc3_debugfs_create_endpoint_dir(dep, parent); +- } +-} +- + void dwc3_debugfs_init(struct dwc3 *dwc) + { + struct dentry *root; +@@ -935,7 +919,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) + &dwc3_testmode_fops); + debugfs_create_file("link_state", S_IRUGO | S_IWUSR, root, dwc, + &dwc3_link_state_fops); +- dwc3_debugfs_create_endpoint_dirs(dwc, root); + } + } + +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index ecd83526f26fe..9cf66636b19d5 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -2483,6 +2483,8 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) + INIT_LIST_HEAD(&dep->started_list); + INIT_LIST_HEAD(&dep->cancelled_list); + ++ dwc3_debugfs_create_endpoint_dir(dep); ++ + return 0; + } + +@@ -2526,6 +2528,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) + list_del(&dep->endpoint.ep_list); + } + ++ debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root)); + kfree(dep); + } + } +diff --git a/fs/afs/main.c b/fs/afs/main.c +index 5cd26af2464c9..d129a1a49616b 100644 +--- a/fs/afs/main.c ++++ b/fs/afs/main.c +@@ -196,8 +196,8 @@ static int __init afs_init(void) + goto error_fs; + + afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs"); +- if (IS_ERR(afs_proc_symlink)) { +- ret = PTR_ERR(afs_proc_symlink); ++ if (!afs_proc_symlink) { ++ ret = -ENOMEM; + goto error_proc; + } + +diff --git a/include/linux/cpuhotplug.h b/include/linux/cpuhotplug.h +index 2d55cee638fc6..bd1f23536b1b6 100644 +--- a/include/linux/cpuhotplug.h ++++ b/include/linux/cpuhotplug.h +@@ -119,6 +119,7 @@ enum cpuhp_state { + CPUHP_AP_ARM_L2X0_STARTING, + CPUHP_AP_EXYNOS4_MCT_TIMER_STARTING, + CPUHP_AP_ARM_ARCH_TIMER_STARTING, ++ CPUHP_AP_OMAP_DM_TIMER_STARTING, + CPUHP_AP_ARM_GLOBAL_TIMER_STARTING, + CPUHP_AP_JCORE_TIMER_STARTING, + CPUHP_AP_ARM_TWD_STARTING, +diff --git a/include/linux/mfd/rohm-bd70528.h b/include/linux/mfd/rohm-bd70528.h +index b0109ee6dae29..1c3014d2f28b1 100644 +--- a/include/linux/mfd/rohm-bd70528.h ++++ b/include/linux/mfd/rohm-bd70528.h +@@ -25,9 +25,7 @@ struct bd70528_data { + struct mutex rtc_timer_lock; + }; + +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 ++#define BD70528_BUCK_VOLTS 0x10 + #define BD70528_LDO_VOLTS 0x20 + + #define BD70528_REG_BUCK1_EN 0x0F +diff --git a/include/linux/mlx5/transobj.h b/include/linux/mlx5/transobj.h +index dc6b1e7cb8c42..3abefd40a4d8a 100644 +--- a/include/linux/mlx5/transobj.h ++++ b/include/linux/mlx5/transobj.h +@@ -92,4 +92,5 @@ mlx5_core_hairpin_create(struct mlx5_core_dev *func_mdev, + struct mlx5_hairpin_params *params); + + void mlx5_core_hairpin_destroy(struct mlx5_hairpin *pair); ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp); + #endif /* __TRANSOBJ_H__ */ +diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h +index 93cc4f1d444ae..874f7e73ed01b 100644 +--- a/include/linux/ptp_clock_kernel.h ++++ b/include/linux/ptp_clock_kernel.h +@@ -218,7 +218,7 @@ extern int ptp_clock_index(struct ptp_clock *ptp); + * @ppm: Parts per million, but with a 16 bit binary fractional field + */ + +-extern s32 scaled_ppm_to_ppb(long ppm); ++extern long scaled_ppm_to_ppb(long ppm); + + /** + * ptp_find_pin() - obtain the pin index of a given auxiliary function +diff --git a/include/linux/socket.h b/include/linux/socket.h +index 4049d9755cf19..a465c6a45d6fa 100644 +--- a/include/linux/socket.h ++++ b/include/linux/socket.h +@@ -406,6 +406,4 @@ extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr, + extern int __sys_socketpair(int family, int type, int protocol, + int __user *usockvec); + extern int __sys_shutdown(int fd, int how); +- +-extern struct ns_common *get_net_ns(struct ns_common *ns); + #endif /* _LINUX_SOCKET_H */ +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h +index 0fca98a3d2d3f..167e390ac9d4e 100644 +--- a/include/net/net_namespace.h ++++ b/include/net/net_namespace.h +@@ -195,6 +195,8 @@ struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns, + void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid); + + void net_ns_barrier(void); ++ ++struct ns_common *get_net_ns(struct ns_common *ns); + #else /* CONFIG_NET_NS */ + #include + #include +@@ -214,6 +216,11 @@ static inline void net_ns_get_ownership(const struct net *net, + } + + static inline void net_ns_barrier(void) {} ++ ++static inline struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return ERR_PTR(-EINVAL); ++} + #endif /* CONFIG_NET_NS */ + + +diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h +index e7ad9d350a283..60e1241d4b77b 100644 +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -284,6 +284,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 1baa284a27533..37eacfe0d6733 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -1948,9 +1948,6 @@ struct saved_cmdlines_buffer { + }; + static struct saved_cmdlines_buffer *savedcmd; + +-/* temporary disable recording */ +-static atomic_t trace_record_taskinfo_disabled __read_mostly; +- + static inline char *get_saved_cmdlines(int idx) + { + return &savedcmd->saved_cmdlines[idx * TASK_COMM_LEN]; +@@ -2236,8 +2233,6 @@ static bool tracing_record_taskinfo_skip(int flags) + { + if (unlikely(!(flags & (TRACE_RECORD_CMDLINE | TRACE_RECORD_TGID)))) + return true; +- if (atomic_read(&trace_record_taskinfo_disabled) || !tracing_is_on()) +- return true; + if (!__this_cpu_read(trace_taskinfo_save)) + return true; + return false; +@@ -3460,9 +3455,6 @@ static void *s_start(struct seq_file *m, loff_t *pos) + return ERR_PTR(-EBUSY); + #endif + +- if (!iter->snapshot) +- atomic_inc(&trace_record_taskinfo_disabled); +- + if (*pos != iter->pos) { + iter->ent = NULL; + iter->cpu = 0; +@@ -3505,9 +3497,6 @@ static void s_stop(struct seq_file *m, void *p) + return; + #endif + +- if (!iter->snapshot) +- atomic_dec(&trace_record_taskinfo_disabled); +- + trace_access_unlock(iter->cpu_file); + trace_event_read_unlock(); + } +diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c +index c1637f90c8a38..4702efb00ff21 100644 +--- a/kernel/trace/trace_clock.c ++++ b/kernel/trace/trace_clock.c +@@ -115,9 +115,9 @@ u64 notrace trace_clock_global(void) + prev_time = READ_ONCE(trace_clock_struct.prev_time); + now = sched_clock_cpu(this_cpu); + +- /* Make sure that now is always greater than prev_time */ ++ /* Make sure that now is always greater than or equal to prev_time */ + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + /* + * If in an NMI context then dont risk lockups and simply return +@@ -131,7 +131,7 @@ u64 notrace trace_clock_global(void) + /* Reread prev_time in case it was already updated */ + prev_time = READ_ONCE(trace_clock_struct.prev_time); + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + trace_clock_struct.prev_time = now; + +diff --git a/mm/memory-failure.c b/mm/memory-failure.c +index d823ec74f3fc7..9030ab0d9d975 100644 +--- a/mm/memory-failure.c ++++ b/mm/memory-failure.c +@@ -1382,7 +1382,12 @@ int memory_failure(unsigned long pfn, int flags) + return 0; + } + +- if (!PageTransTail(p) && !PageLRU(p)) ++ /* ++ * __munlock_pagevec may clear a writeback page's LRU flag without ++ * page_lock. We need wait writeback completion for this page or it ++ * may trigger vfs BUG while evict inode. ++ */ ++ if (!PageTransTail(p) && !PageLRU(p) && !PageWriteback(p)) + goto identify_page_state; + + /* +diff --git a/mm/slab_common.c b/mm/slab_common.c +index e36dd36c7076a..636cd496417cf 100644 +--- a/mm/slab_common.c ++++ b/mm/slab_common.c +@@ -85,8 +85,7 @@ EXPORT_SYMBOL(kmem_cache_size); + #ifdef CONFIG_DEBUG_VM + static int kmem_cache_sanity_check(const char *name, unsigned int size) + { +- if (!name || in_interrupt() || size < sizeof(void *) || +- size > KMALLOC_MAX_SIZE) { ++ if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) { + pr_err("kmem_cache_create(%s) integrity check failed\n", name); + return -EINVAL; + } +diff --git a/mm/slub.c b/mm/slub.c +index 52ded855b4ed0..ca7143fe25b56 100644 +--- a/mm/slub.c ++++ b/mm/slub.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include "slab.h" +@@ -688,15 +689,15 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + p, p - addr, get_freepointer(s, p)); + + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, ++ print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, + s->red_left_pad); + else if (p > addr + 16) + print_section(KERN_ERR, "Bytes b4 ", p - 16, 16); + +- print_section(KERN_ERR, "Object ", p, ++ print_section(KERN_ERR, "Object ", p, + min_t(unsigned int, s->object_size, PAGE_SIZE)); + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p + s->object_size, ++ print_section(KERN_ERR, "Redzone ", p + s->object_size, + s->inuse - s->object_size); + + off = get_info_end(s); +@@ -708,7 +709,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + + if (off != size_from_object(s)) + /* Beginning of the filler is the free pointer */ +- print_section(KERN_ERR, "Padding ", p + off, ++ print_section(KERN_ERR, "Padding ", p + off, + size_from_object(s) - off); + + dump_stack(); +@@ -882,11 +883,11 @@ static int check_object(struct kmem_cache *s, struct page *page, + u8 *endobject = object + s->object_size; + + if (s->flags & SLAB_RED_ZONE) { +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Left Redzone", + object - s->red_left_pad, val, s->red_left_pad)) + return 0; + +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Right Redzone", + endobject, val, s->inuse - s->object_size)) + return 0; + } else { +@@ -901,7 +902,7 @@ static int check_object(struct kmem_cache *s, struct page *page, + if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) && + (!check_bytes_and_report(s, page, p, "Poison", p, + POISON_FREE, s->object_size - 1) || +- !check_bytes_and_report(s, page, p, "Poison", ++ !check_bytes_and_report(s, page, p, "End Poison", + p + s->object_size - 1, POISON_END, 1))) + return 0; + /* +@@ -3586,15 +3587,17 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + */ + s->inuse = size; + +- if (((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || +- s->ctor)) { ++ if ((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || ++ ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) || ++ s->ctor) { + /* + * Relocate free pointer after the object if it is not + * permitted to overwrite the first word of the object on + * kmem_cache_free. + * + * This is the case if we do RCU, have a constructor or +- * destructor or are poisoning the objects. ++ * destructor, are poisoning the objects, or are ++ * redzoning an object smaller than sizeof(void *). + * + * The assumption that s->offset >= s->inuse means free + * pointer is outside of the object is used in the +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c +index d88a4de022372..8be8a1feca843 100644 +--- a/net/batman-adv/bat_iv_ogm.c ++++ b/net/batman-adv/bat_iv_ogm.c +@@ -409,8 +409,10 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet) + if (WARN_ON(!forw_packet->if_outgoing)) + return; + +- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface)) ++ if (forw_packet->if_outgoing->soft_iface != soft_iface) { ++ pr_warn("%s: soft interface switch for queued OGM\n", __func__); + return; ++ } + + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE) + return; +diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h +index 7615c2210e0da..c83d3a954b5f3 100644 +--- a/net/bridge/br_private.h ++++ b/net/bridge/br_private.h +@@ -96,8 +96,8 @@ struct br_vlan_stats { + }; + + struct br_tunnel_info { +- __be64 tunnel_id; +- struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; ++ struct metadata_dst __rcu *tunnel_dst; + }; + + /* private vlan flags */ +diff --git a/net/bridge/br_vlan_tunnel.c b/net/bridge/br_vlan_tunnel.c +index d13d2080f5277..4d761d943fad2 100644 +--- a/net/bridge/br_vlan_tunnel.c ++++ b/net/bridge/br_vlan_tunnel.c +@@ -41,26 +41,33 @@ static struct net_bridge_vlan *br_vlan_tunnel_lookup(struct rhashtable *tbl, + br_vlan_tunnel_rht_params); + } + ++static void vlan_tunnel_info_release(struct net_bridge_vlan *vlan) ++{ ++ struct metadata_dst *tdst = rtnl_dereference(vlan->tinfo.tunnel_dst); ++ ++ WRITE_ONCE(vlan->tinfo.tunnel_id, 0); ++ RCU_INIT_POINTER(vlan->tinfo.tunnel_dst, NULL); ++ dst_release(&tdst->dst); ++} ++ + void vlan_tunnel_info_del(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan) + { +- if (!vlan->tinfo.tunnel_dst) ++ if (!rcu_access_pointer(vlan->tinfo.tunnel_dst)) + return; + rhashtable_remove_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +- vlan->tinfo.tunnel_id = 0; +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; ++ vlan_tunnel_info_release(vlan); + } + + static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan, u32 tun_id) + { +- struct metadata_dst *metadata = NULL; ++ struct metadata_dst *metadata = rtnl_dereference(vlan->tinfo.tunnel_dst); + __be64 key = key32_to_tunnel_id(cpu_to_be32(tun_id)); + int err; + +- if (vlan->tinfo.tunnel_dst) ++ if (metadata) + return -EEXIST; + + metadata = __ip_tun_set_dst(0, 0, 0, 0, 0, TUNNEL_KEY, +@@ -69,8 +76,8 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + return -EINVAL; + + metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_BRIDGE; +- vlan->tinfo.tunnel_dst = metadata; +- vlan->tinfo.tunnel_id = key; ++ rcu_assign_pointer(vlan->tinfo.tunnel_dst, metadata); ++ WRITE_ONCE(vlan->tinfo.tunnel_id, key); + + err = rhashtable_lookup_insert_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +@@ -79,9 +86,7 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + + return 0; + out: +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; +- vlan->tinfo.tunnel_id = 0; ++ vlan_tunnel_info_release(vlan); + + return err; + } +@@ -181,12 +186,15 @@ int br_handle_ingress_vlan_tunnel(struct sk_buff *skb, + int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + struct net_bridge_vlan *vlan) + { ++ struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; + int err; + +- if (!vlan || !vlan->tinfo.tunnel_id) ++ if (!vlan) + return 0; + +- if (unlikely(!skb_vlan_tag_present(skb))) ++ tunnel_id = READ_ONCE(vlan->tinfo.tunnel_id); ++ if (!tunnel_id || unlikely(!skb_vlan_tag_present(skb))) + return 0; + + skb_dst_drop(skb); +@@ -194,7 +202,9 @@ int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + if (err) + return err; + +- skb_dst_set(skb, dst_clone(&vlan->tinfo.tunnel_dst->dst)); ++ tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst); ++ if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst)) ++ skb_dst_set(skb, &tunnel_dst->dst); + + return 0; + } +diff --git a/net/can/bcm.c b/net/can/bcm.c +index d3aac6a2479b5..a7abced793765 100644 +--- a/net/can/bcm.c ++++ b/net/can/bcm.c +@@ -127,7 +127,7 @@ struct bcm_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + struct list_head rx_ops; + struct list_head tx_ops; + unsigned long dropped_usr_msgs; +@@ -135,6 +135,10 @@ struct bcm_sock { + char procname [32]; /* inode number in decimal with \0 */ + }; + ++static LIST_HEAD(bcm_notifier_list); ++static DEFINE_SPINLOCK(bcm_notifier_lock); ++static struct bcm_sock *bcm_busy_notifier; ++ + static inline struct bcm_sock *bcm_sk(const struct sock *sk) + { + return (struct bcm_sock *)sk; +@@ -404,6 +408,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer) + if (!op->count && (op->flags & TX_COUNTEVT)) { + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = TX_EXPIRED; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -441,6 +446,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data) + /* this element is not throttled anymore */ + data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV); + ++ memset(&head, 0, sizeof(head)); + head.opcode = RX_CHANGED; + head.flags = op->flags; + head.count = op->count; +@@ -562,6 +568,7 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer) + } + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = RX_TIMEOUT; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -1380,20 +1387,15 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) + /* + * notification handler for netdevice status changes + */ +-static int bcm_notifier(struct notifier_block *nb, unsigned long msg, +- void *ptr) ++static void bcm_notify(struct bcm_sock *bo, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct bcm_sock *bo = container_of(nb, struct bcm_sock, notifier); + struct sock *sk = &bo->sk; + struct bcm_op *op; + int notify_enodev = 0; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + +@@ -1428,7 +1430,28 @@ static int bcm_notifier(struct notifier_block *nb, unsigned long msg, + sk->sk_error_report(sk); + } + } ++} + ++static int bcm_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(bcm_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; ++ ++ spin_lock(&bcm_notifier_lock); ++ list_for_each_entry(bcm_busy_notifier, &bcm_notifier_list, notifier) { ++ spin_unlock(&bcm_notifier_lock); ++ bcm_notify(bcm_busy_notifier, msg, dev); ++ spin_lock(&bcm_notifier_lock); ++ } ++ bcm_busy_notifier = NULL; ++ spin_unlock(&bcm_notifier_lock); + return NOTIFY_DONE; + } + +@@ -1448,9 +1471,9 @@ static int bcm_init(struct sock *sk) + INIT_LIST_HEAD(&bo->rx_ops); + + /* set notifier */ +- bo->notifier.notifier_call = bcm_notifier; +- +- register_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ list_add_tail(&bo->notifier, &bcm_notifier_list); ++ spin_unlock(&bcm_notifier_lock); + + return 0; + } +@@ -1473,7 +1496,14 @@ static int bcm_release(struct socket *sock) + + /* remove bcm_ops, timer, rx_unregister(), etc. */ + +- unregister_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ while (bcm_busy_notifier == bo) { ++ spin_unlock(&bcm_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&bcm_notifier_lock); ++ } ++ list_del(&bo->notifier); ++ spin_unlock(&bcm_notifier_lock); + + lock_sock(sk); + +@@ -1696,6 +1726,10 @@ static struct pernet_operations canbcm_pernet_ops __read_mostly = { + .exit = canbcm_pernet_exit, + }; + ++static struct notifier_block canbcm_notifier = { ++ .notifier_call = bcm_notifier ++}; ++ + static int __init bcm_module_init(void) + { + int err; +@@ -1709,12 +1743,14 @@ static int __init bcm_module_init(void) + } + + register_pernet_subsys(&canbcm_pernet_ops); ++ register_netdevice_notifier(&canbcm_notifier); + return 0; + } + + static void __exit bcm_module_exit(void) + { + can_proto_unregister(&bcm_can_proto); ++ unregister_netdevice_notifier(&canbcm_notifier); + unregister_pernet_subsys(&canbcm_pernet_ops); + } + +diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c +index 916fdf2464bc2..5252bbd1617c6 100644 +--- a/net/can/j1939/transport.c ++++ b/net/can/j1939/transport.c +@@ -330,6 +330,9 @@ static void j1939_session_skb_drop_old(struct j1939_session *session) + + if ((do_skcb->offset + do_skb->len) < offset_start) { + __skb_unlink(do_skb, &session->skb_queue); ++ /* drop ref taken in j1939_session_skb_queue() */ ++ skb_unref(do_skb); ++ + kfree_skb(do_skb); + } + spin_unlock_irqrestore(&session->skb_queue.lock, flags); +@@ -349,12 +352,13 @@ void j1939_session_skb_queue(struct j1939_session *session, + + skcb->flags |= J1939_ECU_LOCAL_SRC; + ++ skb_get(skb); + skb_queue_tail(&session->skb_queue, skb); + } + + static struct +-sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, +- unsigned int offset_start) ++sk_buff *j1939_session_skb_get_by_offset(struct j1939_session *session, ++ unsigned int offset_start) + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *do_skcb; +@@ -371,6 +375,10 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + skb = do_skb; + } + } ++ ++ if (skb) ++ skb_get(skb); ++ + spin_unlock_irqrestore(&session->skb_queue.lock, flags); + + if (!skb) +@@ -381,12 +389,12 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + return skb; + } + +-static struct sk_buff *j1939_session_skb_find(struct j1939_session *session) ++static struct sk_buff *j1939_session_skb_get(struct j1939_session *session) + { + unsigned int offset_start; + + offset_start = session->pkt.dpo * 7; +- return j1939_session_skb_find_by_offset(session, offset_start); ++ return j1939_session_skb_get_by_offset(session, offset_start); + } + + /* see if we are receiver +@@ -776,7 +784,7 @@ static int j1939_session_tx_dat(struct j1939_session *session) + int ret = 0; + u8 dat[8]; + +- se_skb = j1939_session_skb_find_by_offset(session, session->pkt.tx * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, session->pkt.tx * 7); + if (!se_skb) + return -ENOBUFS; + +@@ -801,7 +809,8 @@ static int j1939_session_tx_dat(struct j1939_session *session) + netdev_err_once(priv->ndev, + "%s: 0x%p: requested data outside of queued buffer: offset %i, len %i, pkt.tx: %i\n", + __func__, session, skcb->offset, se_skb->len , session->pkt.tx); +- return -EOVERFLOW; ++ ret = -EOVERFLOW; ++ goto out_free; + } + + if (!len) { +@@ -835,6 +844,12 @@ static int j1939_session_tx_dat(struct j1939_session *session) + if (pkt_done) + j1939_tp_set_rxtimeout(session, 250); + ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ + return ret; + } + +@@ -1007,7 +1022,7 @@ static int j1939_xtp_txnext_receiver(struct j1939_session *session) + static int j1939_simple_txnext(struct j1939_session *session) + { + struct j1939_priv *priv = session->priv; +- struct sk_buff *se_skb = j1939_session_skb_find(session); ++ struct sk_buff *se_skb = j1939_session_skb_get(session); + struct sk_buff *skb; + int ret; + +@@ -1015,8 +1030,10 @@ static int j1939_simple_txnext(struct j1939_session *session) + return 0; + + skb = skb_clone(se_skb, GFP_ATOMIC); +- if (!skb) +- return -ENOMEM; ++ if (!skb) { ++ ret = -ENOMEM; ++ goto out_free; ++ } + + can_skb_set_owner(skb, se_skb->sk); + +@@ -1024,12 +1041,18 @@ static int j1939_simple_txnext(struct j1939_session *session) + + ret = j1939_send_one(priv, skb); + if (ret) +- return ret; ++ goto out_free; + + j1939_sk_errqueue(session, J1939_ERRQUEUE_SCHED); + j1939_sk_queue_activate_next(session); + +- return 0; ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ ++ return ret; + } + + static bool j1939_session_deactivate_locked(struct j1939_session *session) +@@ -1170,9 +1193,10 @@ static void j1939_session_completed(struct j1939_session *session) + struct sk_buff *skb; + + if (!session->transmission) { +- skb = j1939_session_skb_find(session); ++ skb = j1939_session_skb_get(session); + /* distribute among j1939 receivers */ + j1939_sk_recv(session->priv, skb); ++ consume_skb(skb); + } + + j1939_session_deactivate_activate_next(session); +@@ -1744,7 +1768,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *skcb; +- struct sk_buff *se_skb; ++ struct sk_buff *se_skb = NULL; + const u8 *dat; + u8 *tpdat; + int offset; +@@ -1786,7 +1810,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + goto out_session_cancel; + } + +- se_skb = j1939_session_skb_find_by_offset(session, packet * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, packet * 7); + if (!se_skb) { + netdev_warn(priv->ndev, "%s: 0x%p: no skb found\n", __func__, + session); +@@ -1848,11 +1872,13 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + j1939_tp_set_rxtimeout(session, 250); + } + session->last_cmd = 0xff; ++ consume_skb(se_skb); + j1939_session_put(session); + + return; + + out_session_cancel: ++ kfree_skb(se_skb); + j1939_session_timers_cancel(session); + j1939_session_cancel(session, J1939_XTP_ABORT_FAULT); + j1939_session_put(session); +diff --git a/net/can/raw.c b/net/can/raw.c +index af513d0957c74..c968034ed275b 100644 +--- a/net/can/raw.c ++++ b/net/can/raw.c +@@ -85,7 +85,7 @@ struct raw_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + int loopback; + int recv_own_msgs; + int fd_frames; +@@ -97,6 +97,10 @@ struct raw_sock { + struct uniqframe __percpu *uniq; + }; + ++static LIST_HEAD(raw_notifier_list); ++static DEFINE_SPINLOCK(raw_notifier_lock); ++static struct raw_sock *raw_busy_notifier; ++ + /* Return pointer to store the extra msg flags for raw_recvmsg(). + * We use the space of one unsigned int beyond the 'struct sockaddr_can' + * in skb->cb. +@@ -265,21 +269,16 @@ static int raw_enable_allfilters(struct net *net, struct net_device *dev, + return err; + } + +-static int raw_notifier(struct notifier_block *nb, +- unsigned long msg, void *ptr) ++static void raw_notify(struct raw_sock *ro, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct raw_sock *ro = container_of(nb, struct raw_sock, notifier); + struct sock *sk = &ro->sk; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + if (ro->ifindex != dev->ifindex) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + case NETDEV_UNREGISTER: +@@ -307,7 +306,28 @@ static int raw_notifier(struct notifier_block *nb, + sk->sk_error_report(sk); + break; + } ++} ++ ++static int raw_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(raw_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; + ++ spin_lock(&raw_notifier_lock); ++ list_for_each_entry(raw_busy_notifier, &raw_notifier_list, notifier) { ++ spin_unlock(&raw_notifier_lock); ++ raw_notify(raw_busy_notifier, msg, dev); ++ spin_lock(&raw_notifier_lock); ++ } ++ raw_busy_notifier = NULL; ++ spin_unlock(&raw_notifier_lock); + return NOTIFY_DONE; + } + +@@ -336,9 +356,9 @@ static int raw_init(struct sock *sk) + return -ENOMEM; + + /* set notifier */ +- ro->notifier.notifier_call = raw_notifier; +- +- register_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ list_add_tail(&ro->notifier, &raw_notifier_list); ++ spin_unlock(&raw_notifier_lock); + + return 0; + } +@@ -353,7 +373,14 @@ static int raw_release(struct socket *sock) + + ro = raw_sk(sk); + +- unregister_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ while (raw_busy_notifier == ro) { ++ spin_unlock(&raw_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&raw_notifier_lock); ++ } ++ list_del(&ro->notifier); ++ spin_unlock(&raw_notifier_lock); + + lock_sock(sk); + +@@ -879,6 +906,10 @@ static const struct can_proto raw_can_proto = { + .prot = &raw_proto, + }; + ++static struct notifier_block canraw_notifier = { ++ .notifier_call = raw_notifier ++}; ++ + static __init int raw_module_init(void) + { + int err; +@@ -888,6 +919,8 @@ static __init int raw_module_init(void) + err = can_proto_register(&raw_can_proto); + if (err < 0) + pr_err("can: registration of raw protocol failed\n"); ++ else ++ register_netdevice_notifier(&canraw_notifier); + + return err; + } +@@ -895,6 +928,7 @@ static __init int raw_module_init(void) + static __exit void raw_module_exit(void) + { + can_proto_unregister(&raw_can_proto); ++ unregister_netdevice_notifier(&canraw_notifier); + } + + module_init(raw_module_init); +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c +index 39402840025e1..c303873496a34 100644 +--- a/net/core/net_namespace.c ++++ b/net/core/net_namespace.c +@@ -643,6 +643,18 @@ void __put_net(struct net *net) + } + EXPORT_SYMBOL_GPL(__put_net); + ++/** ++ * get_net_ns - increment the refcount of the network namespace ++ * @ns: common namespace (net) ++ * ++ * Returns the net's common namespace. ++ */ ++struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return &get_net(container_of(ns, struct net, ns))->ns; ++} ++EXPORT_SYMBOL_GPL(get_net_ns); ++ + struct net *get_net_ns_by_fd(int fd) + { + struct file *file; +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index bdeb169a7a999..0bad5db23129a 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -4535,10 +4535,12 @@ static int rtnl_bridge_notify(struct net_device *dev) + if (err < 0) + goto errout; + +- if (!skb->len) { +- err = -EINVAL; ++ /* Notification info is only filled for bridge ports, not the bridge ++ * device itself. Therefore, a zero notification length is valid and ++ * should not result in an error. ++ */ ++ if (!skb->len) + goto errout; +- } + + rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); + return 0; +diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c +index e290a0c9e9282..c1ac802d6894a 100644 +--- a/net/ipv4/cipso_ipv4.c ++++ b/net/ipv4/cipso_ipv4.c +@@ -472,6 +472,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) + kfree(doi_def->map.std->lvl.local); + kfree(doi_def->map.std->cat.cipso); + kfree(doi_def->map.std->cat.local); ++ kfree(doi_def->map.std); + break; + } + kfree(doi_def); +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c +index dd8fae89be723..c88612242c89f 100644 +--- a/net/ipv4/icmp.c ++++ b/net/ipv4/icmp.c +@@ -739,6 +739,13 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, + icmp_param.data_len = room; + icmp_param.head_len = sizeof(struct icmphdr); + ++ /* if we don't have a source address at this point, fall back to the ++ * dummy address instead of sending out a packet with a source address ++ * of 0.0.0.0 ++ */ ++ if (!fl4.saddr) ++ fl4.saddr = htonl(INADDR_DUMMY); ++ + icmp_push_reply(&icmp_param, &fl4, &ipc, &rt); + ende: + ip_rt_put(rt); +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c +index 480d0b22db1a6..c8cbdc4d5cbc7 100644 +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -1803,6 +1803,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) + while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) { + in_dev->mc_list = i->next_rcu; + in_dev->mc_count--; ++ ip_mc_clear_src(i); + ip_ma_put(i); + } + } +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index 24841a9e99668..4644f86c932fc 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -2511,6 +2511,9 @@ void udp_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + bool slow = lock_sock_fast(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_flush_pending_frames(sk); + unlock_sock_fast(sk, slow); + if (static_branch_unlikely(&udp_encap_needed_key)) { +@@ -2770,10 +2773,17 @@ int udp_abort(struct sock *sk, int err) + { + lock_sock(sk); + ++ /* udp{v6}_destroy_sock() sets it under the sk lock, avoid racing ++ * with close() ++ */ ++ if (sock_flag(sk, SOCK_DEAD)) ++ goto out; ++ + sk->sk_err = err; + sk->sk_error_report(sk); + __udp_disconnect(sk, 0); + ++out: + release_sock(sk); + + return 0; +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c +index 6762430280f5e..3c94b81bb459a 100644 +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -1539,6 +1539,9 @@ void udpv6_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + lock_sock(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_v6_flush_pending_frames(sk); + release_sock(sk); + +diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c +index 4bb4cfde28b47..c6c0d27caaed3 100644 +--- a/net/netfilter/nf_synproxy_core.c ++++ b/net/netfilter/nf_synproxy_core.c +@@ -31,6 +31,9 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + int length = (th->doff * 4) - sizeof(*th); + u8 buf[40], *ptr; + ++ if (unlikely(length < 0)) ++ return false; ++ + ptr = skb_header_pointer(skb, doff + sizeof(*th), length, buf); + if (ptr == NULL) + return false; +@@ -47,6 +50,8 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + length--; + continue; + default: ++ if (length < 2) ++ return true; + opsize = *ptr++; + if (opsize < 2) + return true; +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c +index 46273a8383615..faea2ce125110 100644 +--- a/net/qrtr/qrtr.c ++++ b/net/qrtr/qrtr.c +@@ -257,7 +257,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) + const struct qrtr_hdr_v2 *v2; + struct sk_buff *skb; + struct qrtr_cb *cb; +- unsigned int size; ++ size_t size; + unsigned int ver; + size_t hdrlen; + +diff --git a/net/rds/recv.c b/net/rds/recv.c +index aba4afe4dfedc..967d115f97efd 100644 +--- a/net/rds/recv.c ++++ b/net/rds/recv.c +@@ -714,7 +714,7 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, + + if (rds_cmsg_recv(inc, msg, rs)) { + ret = -EFAULT; +- goto out; ++ break; + } + rds_recvmsg_zcookie(rs, msg); + +diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c +index 31eb8eefc8681..16c4cbf6d1f0a 100644 +--- a/net/sched/act_ct.c ++++ b/net/sched/act_ct.c +@@ -361,14 +361,19 @@ static int tcf_ct_act_nat(struct sk_buff *skb, + } + + err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); +- if (err == NF_ACCEPT && +- ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { +- if (maniptype == NF_NAT_MANIP_SRC) +- maniptype = NF_NAT_MANIP_DST; +- else +- maniptype = NF_NAT_MANIP_SRC; +- +- err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); ++ if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { ++ if (ct->status & IPS_SRC_NAT) { ++ if (maniptype == NF_NAT_MANIP_SRC) ++ maniptype = NF_NAT_MANIP_DST; ++ else ++ maniptype = NF_NAT_MANIP_SRC; ++ ++ err = ct_nat_execute(skb, ct, ctinfo, range, ++ maniptype); ++ } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) { ++ err = ct_nat_execute(skb, ct, ctinfo, NULL, ++ NF_NAT_MANIP_SRC); ++ } + } + return err; + #else +diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c +index 896c0562cb42a..e8eebe40e0ae9 100644 +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -907,7 +907,7 @@ static struct tcphdr *cake_get_tcphdr(const struct sk_buff *skb, + } + + tcph = skb_header_pointer(skb, offset, sizeof(_tcph), &_tcph); +- if (!tcph) ++ if (!tcph || tcph->doff < 5) + return NULL; + + return skb_header_pointer(skb, offset, +@@ -931,6 +931,8 @@ static const void *cake_get_tcpopt(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +@@ -1068,6 +1070,8 @@ static bool cake_tcph_may_drop(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +diff --git a/net/socket.c b/net/socket.c +index d1a0264401b7f..b14917dd811ad 100644 +--- a/net/socket.c ++++ b/net/socket.c +@@ -1071,19 +1071,6 @@ static long sock_do_ioctl(struct net *net, struct socket *sock, + * what to do with it - that's up to the protocol still. + */ + +-/** +- * get_net_ns - increment the refcount of the network namespace +- * @ns: common namespace (net) +- * +- * Returns the net's common namespace. +- */ +- +-struct ns_common *get_net_ns(struct ns_common *ns) +-{ +- return &get_net(container_of(ns, struct net, ns))->ns; +-} +-EXPORT_SYMBOL_GPL(get_net_ns); +- + static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) + { + struct socket *sock; +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c +index ecadd9e482c46..9f96826eb3ba0 100644 +--- a/net/unix/af_unix.c ++++ b/net/unix/af_unix.c +@@ -537,12 +537,14 @@ static void unix_release_sock(struct sock *sk, int embrion) + u->path.mnt = NULL; + state = sk->sk_state; + sk->sk_state = TCP_CLOSE; ++ ++ skpair = unix_peer(sk); ++ unix_peer(sk) = NULL; ++ + unix_state_unlock(sk); + + wake_up_interruptible_all(&u->peer_wait); + +- skpair = unix_peer(sk); +- + if (skpair != NULL) { + if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { + unix_state_lock(skpair); +@@ -557,7 +559,6 @@ static void unix_release_sock(struct sock *sk, int embrion) + + unix_dgram_peer_wake_disconnect(sk, skpair); + sock_put(skpair); /* It may now die */ +- unix_peer(sk) = NULL; + } + + /* Try to flush out this socket. Throw out buffers at least */ +diff --git a/net/wireless/Makefile b/net/wireless/Makefile +index 2eee93985ab0d..af590ae606b69 100644 +--- a/net/wireless/Makefile ++++ b/net/wireless/Makefile +@@ -28,7 +28,7 @@ $(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.hex) + @$(kecho) " GEN $@" + @(echo '#include "reg.h"'; \ + echo 'const u8 shipped_regdb_certs[] = {'; \ +- cat $^ ; \ ++ echo | cat - $^ ; \ + echo '};'; \ + echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \ + ) > $@ +diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c +index c09fbf09549df..0c7bd1f2c55c0 100644 +--- a/net/wireless/pmsr.c ++++ b/net/wireless/pmsr.c +@@ -293,6 +293,7 @@ void cfg80211_pmsr_complete(struct wireless_dev *wdev, + gfp_t gfp) + { + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); ++ struct cfg80211_pmsr_request *tmp, *prev, *to_free = NULL; + struct sk_buff *msg; + void *hdr; + +@@ -323,9 +324,20 @@ free_msg: + nlmsg_free(msg); + free_request: + spin_lock_bh(&wdev->pmsr_lock); +- list_del(&req->list); ++ /* ++ * cfg80211_pmsr_process_abort() may have already moved this request ++ * to the free list, and will free it later. In this case, don't free ++ * it here. ++ */ ++ list_for_each_entry_safe(tmp, prev, &wdev->pmsr_list, list) { ++ if (tmp == req) { ++ list_del(&req->list); ++ to_free = req; ++ break; ++ } ++ } + spin_unlock_bh(&wdev->pmsr_lock); +- kfree(req); ++ kfree(to_free); + } + EXPORT_SYMBOL_GPL(cfg80211_pmsr_complete); + +diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c +index afd61599d94c9..a28afb4800603 100644 +--- a/sound/soc/codecs/rt5659.c ++++ b/sound/soc/codecs/rt5659.c +@@ -2470,13 +2470,18 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w, + return 0; + } + +-static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0, + NULL, 0), +- SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, +- NULL, 0), ++ SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, ++ 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL, + RT5659_PWR_MIC_DET_BIT, 0, NULL, 0), ++}; ++ ++static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++ SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, ++ NULL, 0), + SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1, + RT5659_PWR_VREF3_BIT, 0, NULL, 0), + +@@ -2501,8 +2506,6 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { + RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0), + + /* Input Side */ +- SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, +- 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT, + 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT, +@@ -3697,10 +3700,23 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, + + static int rt5659_probe(struct snd_soc_component *component) + { ++ struct snd_soc_dapm_context *dapm = ++ snd_soc_component_get_dapm(component); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); + + rt5659->component = component; + ++ switch (rt5659->pdata.jd_src) { ++ case RT5659_JD_HDA_HEADER: ++ break; ++ ++ default: ++ snd_soc_dapm_new_controls(dapm, ++ rt5659_particular_dapm_widgets, ++ ARRAY_SIZE(rt5659_particular_dapm_widgets)); ++ break; ++ } ++ + return 0; + } + +diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h +index e7ad9d350a283..60e1241d4b77b 100644 +--- a/tools/include/uapi/linux/in.h ++++ b/tools/include/uapi/linux/in.h +@@ -284,6 +284,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/virt/kvm/arm/vgic/vgic-kvm-device.c b/virt/kvm/arm/vgic/vgic-kvm-device.c +index 44419679f91ad..5eaede3e3b5a5 100644 +--- a/virt/kvm/arm/vgic/vgic-kvm-device.c ++++ b/virt/kvm/arm/vgic/vgic-kvm-device.c +@@ -87,8 +87,8 @@ int kvm_vgic_addr(struct kvm *kvm, unsigned long type, u64 *addr, bool write) + r = vgic_v3_set_redist_base(kvm, 0, *addr, 0); + goto out; + } +- rdreg = list_first_entry(&vgic->rd_regions, +- struct vgic_redist_region, list); ++ rdreg = list_first_entry_or_null(&vgic->rd_regions, ++ struct vgic_redist_region, list); + if (!rdreg) + addr_ptr = &undef_value; + else diff --git a/patch/kernel/archive/sunxi-5.10/patch-5.10.43-44.patch b/patch/kernel/archive/sunxi-5.10/patch-5.10.43-44.patch new file mode 100644 index 000000000..c7232fd5d --- /dev/null +++ b/patch/kernel/archive/sunxi-5.10/patch-5.10.43-44.patch @@ -0,0 +1,3608 @@ +diff --git a/Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml b/Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +index db61f0731a203..2e35aeaa8781d 100644 +--- a/Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml ++++ b/Documentation/devicetree/bindings/sound/amlogic,gx-sound-card.yaml +@@ -57,7 +57,7 @@ patternProperties: + rate + + sound-dai: +- $ref: /schemas/types.yaml#/definitions/phandle ++ $ref: /schemas/types.yaml#/definitions/phandle-array + description: phandle of the CPU DAI + + patternProperties: +@@ -71,7 +71,7 @@ patternProperties: + + properties: + sound-dai: +- $ref: /schemas/types.yaml#/definitions/phandle ++ $ref: /schemas/types.yaml#/definitions/phandle-array + description: phandle of the codec DAI + + required: +diff --git a/Documentation/virt/kvm/mmu.rst b/Documentation/virt/kvm/mmu.rst +index 5bfe28b0728e8..20d85daed395e 100644 +--- a/Documentation/virt/kvm/mmu.rst ++++ b/Documentation/virt/kvm/mmu.rst +@@ -171,8 +171,8 @@ Shadow pages contain the following information: + shadow pages) so role.quadrant takes values in the range 0..3. Each + quadrant maps 1GB virtual address space. + role.access: +- Inherited guest access permissions in the form uwx. Note execute +- permission is positive, not negative. ++ Inherited guest access permissions from the parent ptes in the form uwx. ++ Note execute permission is positive, not negative. + role.invalid: + The page is invalid and should not be used. It is a root page that is + currently pinned (by a cpu hardware register pointing to it); once it is +diff --git a/Makefile b/Makefile +index ec9ee8032a985..ae33e048eb8db 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 10 +-SUBLEVEL = 43 ++SUBLEVEL = 44 + EXTRAVERSION = + NAME = Dare mighty things + +diff --git a/arch/arm/include/asm/cpuidle.h b/arch/arm/include/asm/cpuidle.h +index 0d67ed682e077..bc4ffa7ca04c7 100644 +--- a/arch/arm/include/asm/cpuidle.h ++++ b/arch/arm/include/asm/cpuidle.h +@@ -7,9 +7,11 @@ + #ifdef CONFIG_CPU_IDLE + extern int arm_cpuidle_simple_enter(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index); ++#define __cpuidle_method_section __used __section("__cpuidle_method_of_table") + #else + static inline int arm_cpuidle_simple_enter(struct cpuidle_device *dev, + struct cpuidle_driver *drv, int index) { return -ENODEV; } ++#define __cpuidle_method_section __maybe_unused /* drop silently */ + #endif + + /* Common ARM WFI state */ +@@ -42,8 +44,7 @@ struct of_cpuidle_method { + + #define CPUIDLE_METHOD_OF_DECLARE(name, _method, _ops) \ + static const struct of_cpuidle_method __cpuidle_method_of_table_##name \ +- __used __section("__cpuidle_method_of_table") \ +- = { .method = _method, .ops = _ops } ++ __cpuidle_method_section = { .method = _method, .ops = _ops } + + extern int arm_cpuidle_suspend(int index); + +diff --git a/arch/mips/lib/mips-atomic.c b/arch/mips/lib/mips-atomic.c +index de03838b343b8..a9b72eacfc0b3 100644 +--- a/arch/mips/lib/mips-atomic.c ++++ b/arch/mips/lib/mips-atomic.c +@@ -37,7 +37,7 @@ + */ + notrace void arch_local_irq_disable(void) + { +- preempt_disable(); ++ preempt_disable_notrace(); + + __asm__ __volatile__( + " .set push \n" +@@ -53,7 +53,7 @@ notrace void arch_local_irq_disable(void) + : /* no inputs */ + : "memory"); + +- preempt_enable(); ++ preempt_enable_notrace(); + } + EXPORT_SYMBOL(arch_local_irq_disable); + +@@ -61,7 +61,7 @@ notrace unsigned long arch_local_irq_save(void) + { + unsigned long flags; + +- preempt_disable(); ++ preempt_disable_notrace(); + + __asm__ __volatile__( + " .set push \n" +@@ -78,7 +78,7 @@ notrace unsigned long arch_local_irq_save(void) + : /* no inputs */ + : "memory"); + +- preempt_enable(); ++ preempt_enable_notrace(); + + return flags; + } +@@ -88,7 +88,7 @@ notrace void arch_local_irq_restore(unsigned long flags) + { + unsigned long __tmp1; + +- preempt_disable(); ++ preempt_disable_notrace(); + + __asm__ __volatile__( + " .set push \n" +@@ -106,7 +106,7 @@ notrace void arch_local_irq_restore(unsigned long flags) + : "0" (flags) + : "memory"); + +- preempt_enable(); ++ preempt_enable_notrace(); + } + EXPORT_SYMBOL(arch_local_irq_restore); + +diff --git a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi +index 1b4aafc1f6a27..9716a0484ecf0 100644 +--- a/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/p1010si-post.dtsi +@@ -122,7 +122,15 @@ + }; + + /include/ "pq3-i2c-0.dtsi" ++ i2c@3000 { ++ fsl,i2c-erratum-a004447; ++ }; ++ + /include/ "pq3-i2c-1.dtsi" ++ i2c@3100 { ++ fsl,i2c-erratum-a004447; ++ }; ++ + /include/ "pq3-duart-0.dtsi" + /include/ "pq3-espi-0.dtsi" + spi0: spi@7000 { +diff --git a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi +index 872e4485dc3f0..ddc018d42252f 100644 +--- a/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi ++++ b/arch/powerpc/boot/dts/fsl/p2041si-post.dtsi +@@ -371,7 +371,23 @@ + }; + + /include/ "qoriq-i2c-0.dtsi" ++ i2c@118000 { ++ fsl,i2c-erratum-a004447; ++ }; ++ ++ i2c@118100 { ++ fsl,i2c-erratum-a004447; ++ }; ++ + /include/ "qoriq-i2c-1.dtsi" ++ i2c@119000 { ++ fsl,i2c-erratum-a004447; ++ }; ++ ++ i2c@119100 { ++ fsl,i2c-erratum-a004447; ++ }; ++ + /include/ "qoriq-duart-0.dtsi" + /include/ "qoriq-duart-1.dtsi" + /include/ "qoriq-gpio-0.dtsi" +diff --git a/arch/x86/events/intel/uncore_snbep.c b/arch/x86/events/intel/uncore_snbep.c +index 3112186a4f4b2..16159950fcf5b 100644 +--- a/arch/x86/events/intel/uncore_snbep.c ++++ b/arch/x86/events/intel/uncore_snbep.c +@@ -5067,9 +5067,10 @@ static struct intel_uncore_type icx_uncore_m2m = { + .perf_ctr = SNR_M2M_PCI_PMON_CTR0, + .event_ctl = SNR_M2M_PCI_PMON_CTL0, + .event_mask = SNBEP_PMON_RAW_EVENT_MASK, ++ .event_mask_ext = SNR_M2M_PCI_PMON_UMASK_EXT, + .box_ctl = SNR_M2M_PCI_PMON_BOX_CTL, + .ops = &snr_m2m_uncore_pci_ops, +- .format_group = &skx_uncore_format_group, ++ .format_group = &snr_m2m_uncore_format_group, + }; + + static struct attribute *icx_upi_uncore_formats_attr[] = { +diff --git a/arch/x86/kernel/cpu/perfctr-watchdog.c b/arch/x86/kernel/cpu/perfctr-watchdog.c +index a5ee607a3b893..a548d9104604f 100644 +--- a/arch/x86/kernel/cpu/perfctr-watchdog.c ++++ b/arch/x86/kernel/cpu/perfctr-watchdog.c +@@ -63,7 +63,7 @@ static inline unsigned int nmi_perfctr_msr_to_bit(unsigned int msr) + case 15: + return msr - MSR_P4_BPU_PERFCTR0; + } +- fallthrough; ++ break; + case X86_VENDOR_ZHAOXIN: + case X86_VENDOR_CENTAUR: + return msr - MSR_ARCH_PERFMON_PERFCTR0; +@@ -96,7 +96,7 @@ static inline unsigned int nmi_evntsel_msr_to_bit(unsigned int msr) + case 15: + return msr - MSR_P4_BSU_ESCR0; + } +- fallthrough; ++ break; + case X86_VENDOR_ZHAOXIN: + case X86_VENDOR_CENTAUR: + return msr - MSR_ARCH_PERFMON_EVENTSEL0; +diff --git a/arch/x86/kvm/mmu/paging_tmpl.h b/arch/x86/kvm/mmu/paging_tmpl.h +index 50e268eb8e1a9..00a0bfaed6e86 100644 +--- a/arch/x86/kvm/mmu/paging_tmpl.h ++++ b/arch/x86/kvm/mmu/paging_tmpl.h +@@ -90,8 +90,8 @@ struct guest_walker { + gpa_t pte_gpa[PT_MAX_FULL_LEVELS]; + pt_element_t __user *ptep_user[PT_MAX_FULL_LEVELS]; + bool pte_writable[PT_MAX_FULL_LEVELS]; +- unsigned pt_access; +- unsigned pte_access; ++ unsigned int pt_access[PT_MAX_FULL_LEVELS]; ++ unsigned int pte_access; + gfn_t gfn; + struct x86_exception fault; + }; +@@ -418,13 +418,15 @@ retry_walk: + } + + walker->ptes[walker->level - 1] = pte; ++ ++ /* Convert to ACC_*_MASK flags for struct guest_walker. */ ++ walker->pt_access[walker->level - 1] = FNAME(gpte_access)(pt_access ^ walk_nx_mask); + } while (!is_last_gpte(mmu, walker->level, pte)); + + pte_pkey = FNAME(gpte_pkeys)(vcpu, pte); + accessed_dirty = have_ad ? pte_access & PT_GUEST_ACCESSED_MASK : 0; + + /* Convert to ACC_*_MASK flags for struct guest_walker. */ +- walker->pt_access = FNAME(gpte_access)(pt_access ^ walk_nx_mask); + walker->pte_access = FNAME(gpte_access)(pte_access ^ walk_nx_mask); + errcode = permission_fault(vcpu, mmu, walker->pte_access, pte_pkey, access); + if (unlikely(errcode)) +@@ -463,7 +465,8 @@ retry_walk: + } + + pgprintk("%s: pte %llx pte_access %x pt_access %x\n", +- __func__, (u64)pte, walker->pte_access, walker->pt_access); ++ __func__, (u64)pte, walker->pte_access, ++ walker->pt_access[walker->level - 1]); + return 1; + + error: +@@ -635,7 +638,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, + bool huge_page_disallowed = exec && nx_huge_page_workaround_enabled; + struct kvm_mmu_page *sp = NULL; + struct kvm_shadow_walk_iterator it; +- unsigned direct_access, access = gw->pt_access; ++ unsigned int direct_access, access; + int top_level, level, req_level, ret; + gfn_t base_gfn = gw->gfn; + +@@ -667,6 +670,7 @@ static int FNAME(fetch)(struct kvm_vcpu *vcpu, gpa_t addr, + sp = NULL; + if (!is_shadow_present_pte(*it.sptep)) { + table_gfn = gw->table_gfn[it.level - 2]; ++ access = gw->pt_access[it.level - 2]; + sp = kvm_mmu_get_page(vcpu, table_gfn, addr, it.level-1, + false, access); + } +diff --git a/arch/x86/kvm/trace.h b/arch/x86/kvm/trace.h +index aef960f90f26e..a2835d784f4be 100644 +--- a/arch/x86/kvm/trace.h ++++ b/arch/x86/kvm/trace.h +@@ -1514,16 +1514,16 @@ TRACE_EVENT(kvm_nested_vmenter_failed, + TP_ARGS(msg, err), + + TP_STRUCT__entry( +- __field(const char *, msg) ++ __string(msg, msg) + __field(u32, err) + ), + + TP_fast_assign( +- __entry->msg = msg; ++ __assign_str(msg, msg); + __entry->err = err; + ), + +- TP_printk("%s%s", __entry->msg, !__entry->err ? "" : ++ TP_printk("%s%s", __get_str(msg), !__entry->err ? "" : + __print_symbolic(__entry->err, VMX_VMENTER_INSTRUCTION_ERRORS)) + ); + +diff --git a/crypto/async_tx/async_xor.c b/crypto/async_tx/async_xor.c +index 6cd7f7025df47..d8a91521144e0 100644 +--- a/crypto/async_tx/async_xor.c ++++ b/crypto/async_tx/async_xor.c +@@ -233,7 +233,8 @@ async_xor_offs(struct page *dest, unsigned int offset, + if (submit->flags & ASYNC_TX_XOR_DROP_DST) { + src_cnt--; + src_list++; +- src_offs++; ++ if (src_offs) ++ src_offs++; + } + + /* wait for any prerequisite operations */ +diff --git a/drivers/acpi/sleep.c b/drivers/acpi/sleep.c +index aff13bf4d9470..31c9d0c8ae11f 100644 +--- a/drivers/acpi/sleep.c ++++ b/drivers/acpi/sleep.c +@@ -1290,10 +1290,8 @@ static void acpi_sleep_hibernate_setup(void) + return; + + acpi_get_table(ACPI_SIG_FACS, 1, (struct acpi_table_header **)&facs); +- if (facs) { ++ if (facs) + s4_hardware_signature = facs->hardware_signature; +- acpi_put_table((struct acpi_table_header *)facs); +- } + } + #else /* !CONFIG_HIBERNATION */ + static inline void acpi_sleep_hibernate_setup(void) {} +diff --git a/drivers/gpio/gpio-wcd934x.c b/drivers/gpio/gpio-wcd934x.c +index 1cbce59908558..97e6caedf1f33 100644 +--- a/drivers/gpio/gpio-wcd934x.c ++++ b/drivers/gpio/gpio-wcd934x.c +@@ -7,7 +7,7 @@ + #include + #include + +-#define WCD_PIN_MASK(p) BIT(p - 1) ++#define WCD_PIN_MASK(p) BIT(p) + #define WCD_REG_DIR_CTL_OFFSET 0x42 + #define WCD_REG_VAL_CTL_OFFSET 0x43 + #define WCD934X_NPINS 5 +diff --git a/drivers/gpu/drm/drm_auth.c b/drivers/gpu/drm/drm_auth.c +index f2d46b7ac6f9f..232abbba36868 100644 +--- a/drivers/gpu/drm/drm_auth.c ++++ b/drivers/gpu/drm/drm_auth.c +@@ -314,9 +314,10 @@ int drm_master_open(struct drm_file *file_priv) + void drm_master_release(struct drm_file *file_priv) + { + struct drm_device *dev = file_priv->minor->dev; +- struct drm_master *master = file_priv->master; ++ struct drm_master *master; + + mutex_lock(&dev->master_mutex); ++ master = file_priv->master; + if (file_priv->magic) + idr_remove(&file_priv->master->magic_map, file_priv->magic); + +diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c +index 789ee65ac1f57..ae647be4a49fb 100644 +--- a/drivers/gpu/drm/drm_ioctl.c ++++ b/drivers/gpu/drm/drm_ioctl.c +@@ -118,17 +118,18 @@ int drm_getunique(struct drm_device *dev, void *data, + struct drm_file *file_priv) + { + struct drm_unique *u = data; +- struct drm_master *master = file_priv->master; ++ struct drm_master *master; + +- mutex_lock(&master->dev->master_mutex); ++ mutex_lock(&dev->master_mutex); ++ master = file_priv->master; + if (u->unique_len >= master->unique_len) { + if (copy_to_user(u->unique, master->unique, master->unique_len)) { +- mutex_unlock(&master->dev->master_mutex); ++ mutex_unlock(&dev->master_mutex); + return -EFAULT; + } + } + u->unique_len = master->unique_len; +- mutex_unlock(&master->dev->master_mutex); ++ mutex_unlock(&dev->master_mutex); + + return 0; + } +diff --git a/drivers/gpu/drm/mcde/mcde_dsi.c b/drivers/gpu/drm/mcde/mcde_dsi.c +index b3fd3501c4127..5275b2723293b 100644 +--- a/drivers/gpu/drm/mcde/mcde_dsi.c ++++ b/drivers/gpu/drm/mcde/mcde_dsi.c +@@ -577,7 +577,7 @@ static void mcde_dsi_setup_video_mode(struct mcde_dsi *d, + * porches and sync. + */ + /* (ps/s) / (pixels/s) = ps/pixels */ +- pclk = DIV_ROUND_UP_ULL(1000000000000, mode->clock); ++ pclk = DIV_ROUND_UP_ULL(1000000000000, (mode->clock * 1000)); + dev_dbg(d->dev, "picoseconds between two pixels: %llu\n", + pclk); + +diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +index 722c2fe3bfd56..2dcbe02846cd9 100644 +--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c ++++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c +@@ -154,7 +154,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) + * GPU registers so we need to add 0x1a800 to the register value on A630 + * to get the right value from PM4. + */ +- get_stats_counter(ring, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L + 0x1a800, ++ get_stats_counter(ring, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, + rbmemptr_stats(ring, index, alwayson_start)); + + /* Invalidate CCU depth and color */ +@@ -184,7 +184,7 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) + + get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, + rbmemptr_stats(ring, index, cpcycles_end)); +- get_stats_counter(ring, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L + 0x1a800, ++ get_stats_counter(ring, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, + rbmemptr_stats(ring, index, alwayson_end)); + + /* Write the fence to the scratch register */ +@@ -203,8 +203,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) + OUT_RING(ring, submit->seqno); + + trace_msm_gpu_submit_flush(submit, +- gmu_read64(&a6xx_gpu->gmu, REG_A6XX_GMU_ALWAYS_ON_COUNTER_L, +- REG_A6XX_GMU_ALWAYS_ON_COUNTER_H)); ++ gpu_read64(gpu, REG_A6XX_CP_ALWAYS_ON_COUNTER_LO, ++ REG_A6XX_CP_ALWAYS_ON_COUNTER_HI)); + + a6xx_flush(gpu, ring); + } +@@ -459,6 +459,113 @@ static void a6xx_set_hwcg(struct msm_gpu *gpu, bool state) + gpu_write(gpu, REG_A6XX_RBBM_CLOCK_CNTL, state ? clock_cntl_on : 0); + } + ++/* For a615, a616, a618, A619, a630, a640 and a680 */ ++static const u32 a6xx_protect[] = { ++ A6XX_PROTECT_RDONLY(0x00000, 0x04ff), ++ A6XX_PROTECT_RDONLY(0x00501, 0x0005), ++ A6XX_PROTECT_RDONLY(0x0050b, 0x02f4), ++ A6XX_PROTECT_NORDWR(0x0050e, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00510, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00534, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00800, 0x0082), ++ A6XX_PROTECT_NORDWR(0x008a0, 0x0008), ++ A6XX_PROTECT_NORDWR(0x008ab, 0x0024), ++ A6XX_PROTECT_RDONLY(0x008de, 0x00ae), ++ A6XX_PROTECT_NORDWR(0x00900, 0x004d), ++ A6XX_PROTECT_NORDWR(0x0098d, 0x0272), ++ A6XX_PROTECT_NORDWR(0x00e00, 0x0001), ++ A6XX_PROTECT_NORDWR(0x00e03, 0x000c), ++ A6XX_PROTECT_NORDWR(0x03c00, 0x00c3), ++ A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x08630, 0x01cf), ++ A6XX_PROTECT_NORDWR(0x08e00, 0x0000), ++ A6XX_PROTECT_NORDWR(0x08e08, 0x0000), ++ A6XX_PROTECT_NORDWR(0x08e50, 0x001f), ++ A6XX_PROTECT_NORDWR(0x09624, 0x01db), ++ A6XX_PROTECT_NORDWR(0x09e70, 0x0001), ++ A6XX_PROTECT_NORDWR(0x09e78, 0x0187), ++ A6XX_PROTECT_NORDWR(0x0a630, 0x01cf), ++ A6XX_PROTECT_NORDWR(0x0ae02, 0x0000), ++ A6XX_PROTECT_NORDWR(0x0ae50, 0x032f), ++ A6XX_PROTECT_NORDWR(0x0b604, 0x0000), ++ A6XX_PROTECT_NORDWR(0x0be02, 0x0001), ++ A6XX_PROTECT_NORDWR(0x0be20, 0x17df), ++ A6XX_PROTECT_NORDWR(0x0f000, 0x0bff), ++ A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x11c00, 0x0000), /* note: infinite range */ ++}; ++ ++/* These are for a620 and a650 */ ++static const u32 a650_protect[] = { ++ A6XX_PROTECT_RDONLY(0x00000, 0x04ff), ++ A6XX_PROTECT_RDONLY(0x00501, 0x0005), ++ A6XX_PROTECT_RDONLY(0x0050b, 0x02f4), ++ A6XX_PROTECT_NORDWR(0x0050e, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00510, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00534, 0x0000), ++ A6XX_PROTECT_NORDWR(0x00800, 0x0082), ++ A6XX_PROTECT_NORDWR(0x008a0, 0x0008), ++ A6XX_PROTECT_NORDWR(0x008ab, 0x0024), ++ A6XX_PROTECT_RDONLY(0x008de, 0x00ae), ++ A6XX_PROTECT_NORDWR(0x00900, 0x004d), ++ A6XX_PROTECT_NORDWR(0x0098d, 0x0272), ++ A6XX_PROTECT_NORDWR(0x00e00, 0x0001), ++ A6XX_PROTECT_NORDWR(0x00e03, 0x000c), ++ A6XX_PROTECT_NORDWR(0x03c00, 0x00c3), ++ A6XX_PROTECT_RDONLY(0x03cc4, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x08630, 0x01cf), ++ A6XX_PROTECT_NORDWR(0x08e00, 0x0000), ++ A6XX_PROTECT_NORDWR(0x08e08, 0x0000), ++ A6XX_PROTECT_NORDWR(0x08e50, 0x001f), ++ A6XX_PROTECT_NORDWR(0x08e80, 0x027f), ++ A6XX_PROTECT_NORDWR(0x09624, 0x01db), ++ A6XX_PROTECT_NORDWR(0x09e60, 0x0011), ++ A6XX_PROTECT_NORDWR(0x09e78, 0x0187), ++ A6XX_PROTECT_NORDWR(0x0a630, 0x01cf), ++ A6XX_PROTECT_NORDWR(0x0ae02, 0x0000), ++ A6XX_PROTECT_NORDWR(0x0ae50, 0x032f), ++ A6XX_PROTECT_NORDWR(0x0b604, 0x0000), ++ A6XX_PROTECT_NORDWR(0x0b608, 0x0007), ++ A6XX_PROTECT_NORDWR(0x0be02, 0x0001), ++ A6XX_PROTECT_NORDWR(0x0be20, 0x17df), ++ A6XX_PROTECT_NORDWR(0x0f000, 0x0bff), ++ A6XX_PROTECT_RDONLY(0x0fc00, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x18400, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x1a800, 0x1fff), ++ A6XX_PROTECT_NORDWR(0x1f400, 0x0443), ++ A6XX_PROTECT_RDONLY(0x1f844, 0x007b), ++ A6XX_PROTECT_NORDWR(0x1f887, 0x001b), ++ A6XX_PROTECT_NORDWR(0x1f8c0, 0x0000), /* note: infinite range */ ++}; ++ ++static void a6xx_set_cp_protect(struct msm_gpu *gpu) ++{ ++ struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); ++ const u32 *regs = a6xx_protect; ++ unsigned i, count = ARRAY_SIZE(a6xx_protect), count_max = 32; ++ ++ BUILD_BUG_ON(ARRAY_SIZE(a6xx_protect) > 32); ++ BUILD_BUG_ON(ARRAY_SIZE(a650_protect) > 48); ++ ++ if (adreno_is_a650(adreno_gpu)) { ++ regs = a650_protect; ++ count = ARRAY_SIZE(a650_protect); ++ count_max = 48; ++ } ++ ++ /* ++ * Enable access protection to privileged registers, fault on an access ++ * protect violation and select the last span to protect from the start ++ * address all the way to the end of the register address space ++ */ ++ gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL, BIT(0) | BIT(1) | BIT(3)); ++ ++ for (i = 0; i < count - 1; i++) ++ gpu_write(gpu, REG_A6XX_CP_PROTECT(i), regs[i]); ++ /* last CP_PROTECT to have "infinite" length on the last entry */ ++ gpu_write(gpu, REG_A6XX_CP_PROTECT(count_max - 1), regs[i]); ++} ++ + static void a6xx_set_ubwc_config(struct msm_gpu *gpu) + { + struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); +@@ -486,7 +593,7 @@ static void a6xx_set_ubwc_config(struct msm_gpu *gpu) + rgb565_predicator << 11 | amsbc << 4 | lower_bit << 1); + gpu_write(gpu, REG_A6XX_TPL1_NC_MODE_CNTL, lower_bit << 1); + gpu_write(gpu, REG_A6XX_SP_NC_MODE_CNTL, +- uavflagprd_inv >> 4 | lower_bit << 1); ++ uavflagprd_inv << 4 | lower_bit << 1); + gpu_write(gpu, REG_A6XX_UCHE_MODE_CNTL, lower_bit << 21); + } + +@@ -722,41 +829,7 @@ static int a6xx_hw_init(struct msm_gpu *gpu) + } + + /* Protect registers from the CP */ +- gpu_write(gpu, REG_A6XX_CP_PROTECT_CNTL, 0x00000003); +- +- gpu_write(gpu, REG_A6XX_CP_PROTECT(0), +- A6XX_PROTECT_RDONLY(0x600, 0x51)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(1), A6XX_PROTECT_RW(0xae50, 0x2)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(2), A6XX_PROTECT_RW(0x9624, 0x13)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(3), A6XX_PROTECT_RW(0x8630, 0x8)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(4), A6XX_PROTECT_RW(0x9e70, 0x1)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(5), A6XX_PROTECT_RW(0x9e78, 0x187)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(6), A6XX_PROTECT_RW(0xf000, 0x810)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(7), +- A6XX_PROTECT_RDONLY(0xfc00, 0x3)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(8), A6XX_PROTECT_RW(0x50e, 0x0)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(9), A6XX_PROTECT_RDONLY(0x50f, 0x0)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(10), A6XX_PROTECT_RW(0x510, 0x0)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(11), +- A6XX_PROTECT_RDONLY(0x0, 0x4f9)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(12), +- A6XX_PROTECT_RDONLY(0x501, 0xa)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(13), +- A6XX_PROTECT_RDONLY(0x511, 0x44)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(14), A6XX_PROTECT_RW(0xe00, 0xe)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(15), A6XX_PROTECT_RW(0x8e00, 0x0)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(16), A6XX_PROTECT_RW(0x8e50, 0xf)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(17), A6XX_PROTECT_RW(0xbe02, 0x0)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(18), +- A6XX_PROTECT_RW(0xbe20, 0x11f3)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(19), A6XX_PROTECT_RW(0x800, 0x82)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(20), A6XX_PROTECT_RW(0x8a0, 0x8)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(21), A6XX_PROTECT_RW(0x8ab, 0x19)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(22), A6XX_PROTECT_RW(0x900, 0x4d)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(23), A6XX_PROTECT_RW(0x98d, 0x76)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(24), +- A6XX_PROTECT_RDONLY(0x980, 0x4)); +- gpu_write(gpu, REG_A6XX_CP_PROTECT(25), A6XX_PROTECT_RW(0xa630, 0x0)); ++ a6xx_set_cp_protect(gpu); + + /* Enable expanded apriv for targets that support it */ + if (gpu->hw_apriv) { +@@ -1055,7 +1128,7 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu) + if (ret) + return ret; + +- if (adreno_gpu->base.hw_apriv || a6xx_gpu->has_whereami) ++ if (a6xx_gpu->shadow_bo) + for (i = 0; i < gpu->nr_rings; i++) + a6xx_gpu->shadow[i] = 0; + +diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +index 3eeebf6a754b9..69765a722cae6 100644 +--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h ++++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h +@@ -37,7 +37,7 @@ struct a6xx_gpu { + * REG_CP_PROTECT_REG(n) - this will block both reads and writes for _len + * registers starting at _reg. + */ +-#define A6XX_PROTECT_RW(_reg, _len) \ ++#define A6XX_PROTECT_NORDWR(_reg, _len) \ + ((1 << 31) | \ + (((_len) & 0x3FFF) << 18) | ((_reg) & 0x3FFFF)) + +diff --git a/drivers/i2c/busses/i2c-mpc.c b/drivers/i2c/busses/i2c-mpc.c +index d94f05c8b8b79..af349661fd769 100644 +--- a/drivers/i2c/busses/i2c-mpc.c ++++ b/drivers/i2c/busses/i2c-mpc.c +@@ -23,6 +23,7 @@ + + #include + #include ++#include + #include + #include + #include +@@ -49,6 +50,7 @@ + #define CCR_MTX 0x10 + #define CCR_TXAK 0x08 + #define CCR_RSTA 0x04 ++#define CCR_RSVD 0x02 + + #define CSR_MCF 0x80 + #define CSR_MAAS 0x40 +@@ -70,6 +72,7 @@ struct mpc_i2c { + u8 fdr, dfsrr; + #endif + struct clk *clk_per; ++ bool has_errata_A004447; + }; + + struct mpc_i2c_divider { +@@ -176,6 +179,75 @@ static int i2c_wait(struct mpc_i2c *i2c, unsigned timeout, int writing) + return 0; + } + ++static int i2c_mpc_wait_sr(struct mpc_i2c *i2c, int mask) ++{ ++ void __iomem *addr = i2c->base + MPC_I2C_SR; ++ u8 val; ++ ++ return readb_poll_timeout(addr, val, val & mask, 0, 100); ++} ++ ++/* ++ * Workaround for Erratum A004447. From the P2040CE Rev Q ++ * ++ * 1. Set up the frequency divider and sampling rate. ++ * 2. I2CCR - a0h ++ * 3. Poll for I2CSR[MBB] to get set. ++ * 4. If I2CSR[MAL] is set (an indication that SDA is stuck low), then go to ++ * step 5. If MAL is not set, then go to step 13. ++ * 5. I2CCR - 00h ++ * 6. I2CCR - 22h ++ * 7. I2CCR - a2h ++ * 8. Poll for I2CSR[MBB] to get set. ++ * 9. Issue read to I2CDR. ++ * 10. Poll for I2CSR[MIF] to be set. ++ * 11. I2CCR - 82h ++ * 12. Workaround complete. Skip the next steps. ++ * 13. Issue read to I2CDR. ++ * 14. Poll for I2CSR[MIF] to be set. ++ * 15. I2CCR - 80h ++ */ ++static void mpc_i2c_fixup_A004447(struct mpc_i2c *i2c) ++{ ++ int ret; ++ u32 val; ++ ++ writeccr(i2c, CCR_MEN | CCR_MSTA); ++ ret = i2c_mpc_wait_sr(i2c, CSR_MBB); ++ if (ret) { ++ dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); ++ return; ++ } ++ ++ val = readb(i2c->base + MPC_I2C_SR); ++ ++ if (val & CSR_MAL) { ++ writeccr(i2c, 0x00); ++ writeccr(i2c, CCR_MSTA | CCR_RSVD); ++ writeccr(i2c, CCR_MEN | CCR_MSTA | CCR_RSVD); ++ ret = i2c_mpc_wait_sr(i2c, CSR_MBB); ++ if (ret) { ++ dev_err(i2c->dev, "timeout waiting for CSR_MBB\n"); ++ return; ++ } ++ val = readb(i2c->base + MPC_I2C_DR); ++ ret = i2c_mpc_wait_sr(i2c, CSR_MIF); ++ if (ret) { ++ dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); ++ return; ++ } ++ writeccr(i2c, CCR_MEN | CCR_RSVD); ++ } else { ++ val = readb(i2c->base + MPC_I2C_DR); ++ ret = i2c_mpc_wait_sr(i2c, CSR_MIF); ++ if (ret) { ++ dev_err(i2c->dev, "timeout waiting for CSR_MIF\n"); ++ return; ++ } ++ writeccr(i2c, CCR_MEN); ++ } ++} ++ + #if defined(CONFIG_PPC_MPC52xx) || defined(CONFIG_PPC_MPC512x) + static const struct mpc_i2c_divider mpc_i2c_dividers_52xx[] = { + {20, 0x20}, {22, 0x21}, {24, 0x22}, {26, 0x23}, +@@ -586,7 +658,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) + if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { + writeb(status & ~CSR_MAL, + i2c->base + MPC_I2C_SR); +- mpc_i2c_fixup(i2c); ++ i2c_recover_bus(&i2c->adap); + } + return -EIO; + } +@@ -622,7 +694,7 @@ static int mpc_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num) + if ((status & (CSR_MCF | CSR_MBB | CSR_RXAK)) != 0) { + writeb(status & ~CSR_MAL, + i2c->base + MPC_I2C_SR); +- mpc_i2c_fixup(i2c); ++ i2c_recover_bus(&i2c->adap); + } + return -EIO; + } +@@ -637,6 +709,18 @@ static u32 mpc_functionality(struct i2c_adapter *adap) + | I2C_FUNC_SMBUS_READ_BLOCK_DATA | I2C_FUNC_SMBUS_BLOCK_PROC_CALL; + } + ++static int fsl_i2c_bus_recovery(struct i2c_adapter *adap) ++{ ++ struct mpc_i2c *i2c = i2c_get_adapdata(adap); ++ ++ if (i2c->has_errata_A004447) ++ mpc_i2c_fixup_A004447(i2c); ++ else ++ mpc_i2c_fixup(i2c); ++ ++ return 0; ++} ++ + static const struct i2c_algorithm mpc_algo = { + .master_xfer = mpc_xfer, + .functionality = mpc_functionality, +@@ -648,6 +732,10 @@ static struct i2c_adapter mpc_ops = { + .timeout = HZ, + }; + ++static struct i2c_bus_recovery_info fsl_i2c_recovery_info = { ++ .recover_bus = fsl_i2c_bus_recovery, ++}; ++ + static const struct of_device_id mpc_i2c_of_match[]; + static int fsl_i2c_probe(struct platform_device *op) + { +@@ -732,6 +820,8 @@ static int fsl_i2c_probe(struct platform_device *op) + dev_info(i2c->dev, "timeout %u us\n", mpc_ops.timeout * 1000000 / HZ); + + platform_set_drvdata(op, i2c); ++ if (of_property_read_bool(op->dev.of_node, "fsl,i2c-erratum-a004447")) ++ i2c->has_errata_A004447 = true; + + i2c->adap = mpc_ops; + of_address_to_resource(op->dev.of_node, 0, &res); +@@ -740,6 +830,7 @@ static int fsl_i2c_probe(struct platform_device *op) + i2c_set_adapdata(&i2c->adap, i2c); + i2c->adap.dev.parent = &op->dev; + i2c->adap.dev.of_node = of_node_get(op->dev.of_node); ++ i2c->adap.bus_recovery_info = &fsl_i2c_recovery_info; + + result = i2c_add_adapter(&i2c->adap); + if (result < 0) +diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c +index cd0fba6b09642..7b11aff8a5ea7 100644 +--- a/drivers/infiniband/hw/mlx4/main.c ++++ b/drivers/infiniband/hw/mlx4/main.c +@@ -580,12 +580,9 @@ static int mlx4_ib_query_device(struct ib_device *ibdev, + props->cq_caps.max_cq_moderation_count = MLX4_MAX_CQ_COUNT; + props->cq_caps.max_cq_moderation_period = MLX4_MAX_CQ_PERIOD; + +- if (!mlx4_is_slave(dev->dev)) +- err = mlx4_get_internal_clock_params(dev->dev, &clock_params); +- + if (uhw->outlen >= resp.response_length + sizeof(resp.hca_core_clock_offset)) { + resp.response_length += sizeof(resp.hca_core_clock_offset); +- if (!err && !mlx4_is_slave(dev->dev)) { ++ if (!mlx4_get_internal_clock_params(dev->dev, &clock_params)) { + resp.comp_mask |= MLX4_IB_QUERY_DEV_RESP_MASK_CORE_CLOCK_OFFSET; + resp.hca_core_clock_offset = clock_params.offset % PAGE_SIZE; + } +diff --git a/drivers/infiniband/hw/mlx5/cq.c b/drivers/infiniband/hw/mlx5/cq.c +index fb62f1d04afa7..372adb7ceb74e 100644 +--- a/drivers/infiniband/hw/mlx5/cq.c ++++ b/drivers/infiniband/hw/mlx5/cq.c +@@ -838,15 +838,14 @@ static void destroy_cq_user(struct mlx5_ib_cq *cq, struct ib_udata *udata) + ib_umem_release(cq->buf.umem); + } + +-static void init_cq_frag_buf(struct mlx5_ib_cq *cq, +- struct mlx5_ib_cq_buf *buf) ++static void init_cq_frag_buf(struct mlx5_ib_cq_buf *buf) + { + int i; + void *cqe; + struct mlx5_cqe64 *cqe64; + + for (i = 0; i < buf->nent; i++) { +- cqe = get_cqe(cq, i); ++ cqe = mlx5_frag_buf_get_wqe(&buf->fbc, i); + cqe64 = buf->cqe_size == 64 ? cqe : cqe + 64; + cqe64->op_own = MLX5_CQE_INVALID << 4; + } +@@ -872,7 +871,7 @@ static int create_cq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq, + if (err) + goto err_db; + +- init_cq_frag_buf(cq, &cq->buf); ++ init_cq_frag_buf(&cq->buf); + + *inlen = MLX5_ST_SZ_BYTES(create_cq_in) + + MLX5_FLD_SZ_BYTES(create_cq_in, pas[0]) * +@@ -1177,7 +1176,7 @@ static int resize_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_cq *cq, + if (err) + goto ex; + +- init_cq_frag_buf(cq, cq->resize_buf); ++ init_cq_frag_buf(cq->resize_buf); + + return 0; + +diff --git a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c +index d5a90a66b45cf..5b05cf3837da1 100644 +--- a/drivers/infiniband/ulp/ipoib/ipoib_netlink.c ++++ b/drivers/infiniband/ulp/ipoib/ipoib_netlink.c +@@ -163,6 +163,7 @@ static size_t ipoib_get_size(const struct net_device *dev) + + static struct rtnl_link_ops ipoib_link_ops __read_mostly = { + .kind = "ipoib", ++ .netns_refund = true, + .maxtype = IFLA_IPOIB_MAX, + .policy = ipoib_policy, + .priv_size = sizeof(struct ipoib_dev_priv), +diff --git a/drivers/isdn/hardware/mISDN/netjet.c b/drivers/isdn/hardware/mISDN/netjet.c +index ee925b58bbcea..2a1ddd47a0968 100644 +--- a/drivers/isdn/hardware/mISDN/netjet.c ++++ b/drivers/isdn/hardware/mISDN/netjet.c +@@ -1100,7 +1100,6 @@ nj_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + card->typ = NETJET_S_TJ300; + + card->base = pci_resource_start(pdev, 0); +- card->irq = pdev->irq; + pci_set_drvdata(pdev, card); + err = setup_instance(card); + if (err) +diff --git a/drivers/md/dm-verity-verify-sig.c b/drivers/md/dm-verity-verify-sig.c +index 614e43db93aa8..919154ae4cae6 100644 +--- a/drivers/md/dm-verity-verify-sig.c ++++ b/drivers/md/dm-verity-verify-sig.c +@@ -15,7 +15,7 @@ + #define DM_VERITY_VERIFY_ERR(s) DM_VERITY_ROOT_HASH_VERIFICATION " " s + + static bool require_signatures; +-module_param(require_signatures, bool, false); ++module_param(require_signatures, bool, 0444); + MODULE_PARM_DESC(require_signatures, + "Verify the roothash of dm-verity hash tree"); + +diff --git a/drivers/mmc/host/renesas_sdhi_core.c b/drivers/mmc/host/renesas_sdhi_core.c +index acb9c81a4e456..addaaf2810e26 100644 +--- a/drivers/mmc/host/renesas_sdhi_core.c ++++ b/drivers/mmc/host/renesas_sdhi_core.c +@@ -660,14 +660,19 @@ static int renesas_sdhi_execute_tuning(struct mmc_host *mmc, u32 opcode) + + /* Issue CMD19 twice for each tap */ + for (i = 0; i < 2 * priv->tap_num; i++) { ++ int cmd_error; ++ + /* Set sampling clock position */ + sd_scc_write32(host, priv, SH_MOBILE_SDHI_SCC_TAPSET, i % priv->tap_num); + +- if (mmc_send_tuning(mmc, opcode, NULL) == 0) ++ if (mmc_send_tuning(mmc, opcode, &cmd_error) == 0) + set_bit(i, priv->taps); + + if (sd_scc_read32(host, priv, SH_MOBILE_SDHI_SCC_SMPCMP) == 0) + set_bit(i, priv->smpcmp); ++ ++ if (cmd_error) ++ mmc_abort_tuning(mmc, opcode); + } + + ret = renesas_sdhi_select_tuning(host); +@@ -897,7 +902,7 @@ static const struct soc_device_attribute sdhi_quirks_match[] = { + { .soc_id = "r8a7795", .revision = "ES3.*", .data = &sdhi_quirks_bad_taps2367 }, + { .soc_id = "r8a7796", .revision = "ES1.[012]", .data = &sdhi_quirks_4tap_nohs400 }, + { .soc_id = "r8a7796", .revision = "ES1.*", .data = &sdhi_quirks_r8a7796_es13 }, +- { .soc_id = "r8a7796", .revision = "ES3.*", .data = &sdhi_quirks_bad_taps1357 }, ++ { .soc_id = "r8a77961", .data = &sdhi_quirks_bad_taps1357 }, + { .soc_id = "r8a77965", .data = &sdhi_quirks_r8a77965 }, + { .soc_id = "r8a77980", .data = &sdhi_quirks_nohs400 }, + { .soc_id = "r8a77990", .data = &sdhi_quirks_r8a77990 }, +diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c +index ba8e70a8e3125..6b12ce822e51a 100644 +--- a/drivers/net/appletalk/cops.c ++++ b/drivers/net/appletalk/cops.c +@@ -327,6 +327,8 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr) + break; + } + ++ dev->base_addr = ioaddr; ++ + /* Reserve any actual interrupt. */ + if (dev->irq) { + retval = request_irq(dev->irq, cops_interrupt, 0, dev->name, dev); +@@ -334,8 +336,6 @@ static int __init cops_probe1(struct net_device *dev, int ioaddr) + goto err_out; + } + +- dev->base_addr = ioaddr; +- + lp = netdev_priv(dev); + spin_lock_init(&lp->lock); + +diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c +index 47afc5938c26b..345a3f61c723c 100644 +--- a/drivers/net/bonding/bond_main.c ++++ b/drivers/net/bonding/bond_main.c +@@ -1502,6 +1502,7 @@ static struct slave *bond_alloc_slave(struct bonding *bond, + + slave->bond = bond; + slave->dev = slave_dev; ++ INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); + + if (bond_kobj_init(slave)) + return NULL; +@@ -1514,7 +1515,6 @@ static struct slave *bond_alloc_slave(struct bonding *bond, + return NULL; + } + } +- INIT_DELAYED_WORK(&slave->notify_work, bond_netdev_notify_work); + + return slave; + } +diff --git a/drivers/net/dsa/microchip/ksz9477.c b/drivers/net/dsa/microchip/ksz9477.c +index abfd3802bb517..b3aa99eb6c2c5 100644 +--- a/drivers/net/dsa/microchip/ksz9477.c ++++ b/drivers/net/dsa/microchip/ksz9477.c +@@ -1532,6 +1532,7 @@ static const struct ksz_chip_data ksz9477_switch_chips[] = { + .num_statics = 16, + .cpu_ports = 0x7F, /* can be configured as cpu port */ + .port_cnt = 7, /* total physical port count */ ++ .phy_errata_9477 = true, + }, + }; + +diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +index 9c2f51f230351..9108b497b3c99 100644 +--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c ++++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +@@ -1224,8 +1224,10 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, + goto failed; + + /* SR-IOV capability was enabled but there are no VFs*/ +- if (iov->total == 0) ++ if (iov->total == 0) { ++ err = -EINVAL; + goto failed; ++ } + + iov->nr_virtfn = min_t(u16, iov->total, num_vfs_param); + +diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c +index 390f45e49eaf7..1e8bf6b9834bb 100644 +--- a/drivers/net/ethernet/cadence/macb_main.c ++++ b/drivers/net/ethernet/cadence/macb_main.c +@@ -2709,6 +2709,9 @@ static struct net_device_stats *gem_get_stats(struct macb *bp) + struct gem_stats *hwstat = &bp->hw_stats.gem; + struct net_device_stats *nstat = &bp->dev->stats; + ++ if (!netif_running(bp->dev)) ++ return nstat; ++ + gem_update_stats(bp); + + nstat->rx_errors = (hwstat->rx_frame_check_sequence_errors + +diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c +index f6cfec81ccc3b..dc4ac1a2b6b67 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/fw.c ++++ b/drivers/net/ethernet/mellanox/mlx4/fw.c +@@ -823,6 +823,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) + #define QUERY_DEV_CAP_MAD_DEMUX_OFFSET 0xb0 + #define QUERY_DEV_CAP_DMFS_HIGH_RATE_QPN_BASE_OFFSET 0xa8 + #define QUERY_DEV_CAP_DMFS_HIGH_RATE_QPN_RANGE_OFFSET 0xac ++#define QUERY_DEV_CAP_MAP_CLOCK_TO_USER 0xc1 + #define QUERY_DEV_CAP_QP_RATE_LIMIT_NUM_OFFSET 0xcc + #define QUERY_DEV_CAP_QP_RATE_LIMIT_MAX_OFFSET 0xd0 + #define QUERY_DEV_CAP_QP_RATE_LIMIT_MIN_OFFSET 0xd2 +@@ -841,6 +842,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) + + if (mlx4_is_mfunc(dev)) + disable_unsupported_roce_caps(outbox); ++ MLX4_GET(field, outbox, QUERY_DEV_CAP_MAP_CLOCK_TO_USER); ++ dev_cap->map_clock_to_user = field & 0x80; + MLX4_GET(field, outbox, QUERY_DEV_CAP_RSVD_QP_OFFSET); + dev_cap->reserved_qps = 1 << (field & 0xf); + MLX4_GET(field, outbox, QUERY_DEV_CAP_MAX_QP_OFFSET); +diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.h b/drivers/net/ethernet/mellanox/mlx4/fw.h +index 8f020f26ebf5f..cf64e54eecb05 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/fw.h ++++ b/drivers/net/ethernet/mellanox/mlx4/fw.h +@@ -131,6 +131,7 @@ struct mlx4_dev_cap { + u32 health_buffer_addrs; + struct mlx4_port_cap port_cap[MLX4_MAX_PORTS + 1]; + bool wol_port[MLX4_MAX_PORTS + 1]; ++ bool map_clock_to_user; + }; + + struct mlx4_func_cap { +diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c +index c326b434734e1..00c84656b2e7e 100644 +--- a/drivers/net/ethernet/mellanox/mlx4/main.c ++++ b/drivers/net/ethernet/mellanox/mlx4/main.c +@@ -498,6 +498,7 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap) + } + } + ++ dev->caps.map_clock_to_user = dev_cap->map_clock_to_user; + dev->caps.uar_page_size = PAGE_SIZE; + dev->caps.num_uars = dev_cap->uar_size / PAGE_SIZE; + dev->caps.local_ca_ack_delay = dev_cap->local_ca_ack_delay; +@@ -1948,6 +1949,11 @@ int mlx4_get_internal_clock_params(struct mlx4_dev *dev, + if (mlx4_is_slave(dev)) + return -EOPNOTSUPP; + ++ if (!dev->caps.map_clock_to_user) { ++ mlx4_dbg(dev, "Map clock to user is not supported.\n"); ++ return -EOPNOTSUPP; ++ } ++ + if (!params) + return -EINVAL; + +diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c +index 27740c027681b..a83b3d69a6565 100644 +--- a/drivers/net/ethernet/qlogic/qla3xxx.c ++++ b/drivers/net/ethernet/qlogic/qla3xxx.c +@@ -114,7 +114,7 @@ static int ql_sem_spinlock(struct ql3_adapter *qdev, + value = readl(&port_regs->CommonRegs.semaphoreReg); + if ((value & (sem_mask >> 16)) == sem_bits) + return 0; +- ssleep(1); ++ mdelay(1000); + } while (--seconds); + return -1; + } +diff --git a/drivers/net/ethernet/sfc/nic.c b/drivers/net/ethernet/sfc/nic.c +index d1e908846f5dd..22fbb0ae77fba 100644 +--- a/drivers/net/ethernet/sfc/nic.c ++++ b/drivers/net/ethernet/sfc/nic.c +@@ -90,6 +90,7 @@ int efx_nic_init_interrupt(struct efx_nic *efx) + efx->pci_dev->irq); + goto fail1; + } ++ efx->irqs_hooked = true; + return 0; + } + +diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c +index 757e950fb745b..b848439fa837c 100644 +--- a/drivers/net/phy/mdio_bus.c ++++ b/drivers/net/phy/mdio_bus.c +@@ -608,7 +608,8 @@ void mdiobus_unregister(struct mii_bus *bus) + struct mdio_device *mdiodev; + int i; + +- BUG_ON(bus->state != MDIOBUS_REGISTERED); ++ if (WARN_ON_ONCE(bus->state != MDIOBUS_REGISTERED)) ++ return; + bus->state = MDIOBUS_UNREGISTERED; + + for (i = 0; i < PHY_MAX_ADDR; i++) { +diff --git a/drivers/nvme/host/Kconfig b/drivers/nvme/host/Kconfig +index a44d49d63968a..494675aeaaad7 100644 +--- a/drivers/nvme/host/Kconfig ++++ b/drivers/nvme/host/Kconfig +@@ -71,7 +71,8 @@ config NVME_FC + config NVME_TCP + tristate "NVM Express over Fabrics TCP host driver" + depends on INET +- depends on BLK_DEV_NVME ++ depends on BLOCK ++ select NVME_CORE + select NVME_FABRICS + select CRYPTO + select CRYPTO_CRC32C +diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c +index 8575724734e02..7015fba2e5125 100644 +--- a/drivers/nvme/host/fabrics.c ++++ b/drivers/nvme/host/fabrics.c +@@ -336,6 +336,11 @@ static void nvmf_log_connect_error(struct nvme_ctrl *ctrl, + cmd->connect.recfmt); + break; + ++ case NVME_SC_HOST_PATH_ERROR: ++ dev_err(ctrl->device, ++ "Connect command failed: host path error\n"); ++ break; ++ + default: + dev_err(ctrl->device, + "Connect command failed, error wo/DNR bit: %d\n", +diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c +index 8b939e9db470c..9a8fa2e582d5b 100644 +--- a/drivers/nvme/target/core.c ++++ b/drivers/nvme/target/core.c +@@ -379,10 +379,10 @@ static void nvmet_keep_alive_timer(struct work_struct *work) + { + struct nvmet_ctrl *ctrl = container_of(to_delayed_work(work), + struct nvmet_ctrl, ka_work); +- bool cmd_seen = ctrl->cmd_seen; ++ bool reset_tbkas = ctrl->reset_tbkas; + +- ctrl->cmd_seen = false; +- if (cmd_seen) { ++ ctrl->reset_tbkas = false; ++ if (reset_tbkas) { + pr_debug("ctrl %d reschedule traffic based keep-alive timer\n", + ctrl->cntlid); + schedule_delayed_work(&ctrl->ka_work, ctrl->kato * HZ); +@@ -792,6 +792,13 @@ void nvmet_sq_destroy(struct nvmet_sq *sq) + percpu_ref_exit(&sq->ref); + + if (ctrl) { ++ /* ++ * The teardown flow may take some time, and the host may not ++ * send us keep-alive during this period, hence reset the ++ * traffic based keep-alive timer so we don't trigger a ++ * controller teardown as a result of a keep-alive expiration. ++ */ ++ ctrl->reset_tbkas = true; + nvmet_ctrl_put(ctrl); + sq->ctrl = NULL; /* allows reusing the queue later */ + } +@@ -942,7 +949,7 @@ bool nvmet_req_init(struct nvmet_req *req, struct nvmet_cq *cq, + } + + if (sq->ctrl) +- sq->ctrl->cmd_seen = true; ++ sq->ctrl->reset_tbkas = true; + + return true; + +diff --git a/drivers/nvme/target/nvmet.h b/drivers/nvme/target/nvmet.h +index ea96487b5424e..4bf6d21290c23 100644 +--- a/drivers/nvme/target/nvmet.h ++++ b/drivers/nvme/target/nvmet.h +@@ -166,7 +166,7 @@ struct nvmet_ctrl { + struct nvmet_subsys *subsys; + struct nvmet_sq **sqs; + +- bool cmd_seen; ++ bool reset_tbkas; + + struct mutex lock; + u64 cap; +diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.h b/drivers/phy/broadcom/phy-brcm-usb-init.h +index 899b9eb43fad6..a39f30fa2e991 100644 +--- a/drivers/phy/broadcom/phy-brcm-usb-init.h ++++ b/drivers/phy/broadcom/phy-brcm-usb-init.h +@@ -78,7 +78,7 @@ static inline u32 brcm_usb_readl(void __iomem *addr) + * Other architectures (e.g., ARM) either do not support big endian, or + * else leave I/O in little endian mode. + */ +- if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) ++ if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + return __raw_readl(addr); + else + return readl_relaxed(addr); +@@ -87,7 +87,7 @@ static inline u32 brcm_usb_readl(void __iomem *addr) + static inline void brcm_usb_writel(u32 val, void __iomem *addr) + { + /* See brcmnand_readl() comments */ +- if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(__BIG_ENDIAN)) ++ if (IS_ENABLED(CONFIG_MIPS) && IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)) + __raw_writel(val, addr); + else + writel_relaxed(val, addr); +diff --git a/drivers/phy/cadence/phy-cadence-sierra.c b/drivers/phy/cadence/phy-cadence-sierra.c +index aaa0bbe473f76..7d990613ce837 100644 +--- a/drivers/phy/cadence/phy-cadence-sierra.c ++++ b/drivers/phy/cadence/phy-cadence-sierra.c +@@ -614,6 +614,7 @@ static int cdns_sierra_phy_probe(struct platform_device *pdev) + sp->nsubnodes = node; + + if (sp->num_lanes > SIERRA_MAX_LANES) { ++ ret = -EINVAL; + dev_err(dev, "Invalid lane configuration\n"); + goto put_child2; + } +diff --git a/drivers/phy/ti/phy-j721e-wiz.c b/drivers/phy/ti/phy-j721e-wiz.c +index e28e25f98708c..dceac77148721 100644 +--- a/drivers/phy/ti/phy-j721e-wiz.c ++++ b/drivers/phy/ti/phy-j721e-wiz.c +@@ -894,6 +894,7 @@ static int wiz_probe(struct platform_device *pdev) + + if (wiz->typec_dir_delay < WIZ_TYPEC_DIR_DEBOUNCE_MIN || + wiz->typec_dir_delay > WIZ_TYPEC_DIR_DEBOUNCE_MAX) { ++ ret = -EINVAL; + dev_err(dev, "Invalid typec-dir-debounce property\n"); + goto err_addr_to_resource; + } +diff --git a/drivers/regulator/bd718x7-regulator.c b/drivers/regulator/bd718x7-regulator.c +index 3333b8905f1b7..2c097ee6cb021 100644 +--- a/drivers/regulator/bd718x7-regulator.c ++++ b/drivers/regulator/bd718x7-regulator.c +@@ -364,7 +364,7 @@ BD718XX_OPS(bd71837_buck_regulator_ops, regulator_list_voltage_linear_range, + NULL); + + BD718XX_OPS(bd71837_buck_regulator_nolinear_ops, regulator_list_voltage_table, +- regulator_map_voltage_ascend, bd718xx_set_voltage_sel_restricted, ++ regulator_map_voltage_ascend, bd71837_set_voltage_sel_restricted, + regulator_get_voltage_sel_regmap, regulator_set_voltage_time_sel, + NULL); + /* +diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c +index 7b3de8b0b1caf..043b5f63b94a1 100644 +--- a/drivers/regulator/core.c ++++ b/drivers/regulator/core.c +@@ -1422,6 +1422,12 @@ static int set_machine_constraints(struct regulator_dev *rdev) + * and we have control then make sure it is enabled. + */ + if (rdev->constraints->always_on || rdev->constraints->boot_on) { ++ /* If we want to enable this regulator, make sure that we know ++ * the supplying regulator. ++ */ ++ if (rdev->supply_name && !rdev->supply) ++ return -EPROBE_DEFER; ++ + if (rdev->supply) { + ret = regulator_enable(rdev->supply); + if (ret < 0) { +diff --git a/drivers/regulator/fan53880.c b/drivers/regulator/fan53880.c +index e83eb4fb1876a..1684faf82ed25 100644 +--- a/drivers/regulator/fan53880.c ++++ b/drivers/regulator/fan53880.c +@@ -51,6 +51,7 @@ static const struct regulator_ops fan53880_ops = { + REGULATOR_LINEAR_RANGE(800000, 0xf, 0x73, 25000), \ + }, \ + .n_linear_ranges = 2, \ ++ .n_voltages = 0x74, \ + .vsel_reg = FAN53880_LDO ## _num ## VOUT, \ + .vsel_mask = 0x7f, \ + .enable_reg = FAN53880_ENABLE, \ +@@ -76,6 +77,7 @@ static const struct regulator_desc fan53880_regulators[] = { + REGULATOR_LINEAR_RANGE(600000, 0x1f, 0xf7, 12500), + }, + .n_linear_ranges = 2, ++ .n_voltages = 0xf8, + .vsel_reg = FAN53880_BUCKVOUT, + .vsel_mask = 0x7f, + .enable_reg = FAN53880_ENABLE, +@@ -95,6 +97,7 @@ static const struct regulator_desc fan53880_regulators[] = { + REGULATOR_LINEAR_RANGE(3000000, 0x4, 0x70, 25000), + }, + .n_linear_ranges = 2, ++ .n_voltages = 0x71, + .vsel_reg = FAN53880_BOOSTVOUT, + .vsel_mask = 0x7f, + .enable_reg = FAN53880_ENABLE_BOOST, +diff --git a/drivers/regulator/max77620-regulator.c b/drivers/regulator/max77620-regulator.c +index 8d9731e4052bf..5c439c850d090 100644 +--- a/drivers/regulator/max77620-regulator.c ++++ b/drivers/regulator/max77620-regulator.c +@@ -814,6 +814,13 @@ static int max77620_regulator_probe(struct platform_device *pdev) + config.dev = dev; + config.driver_data = pmic; + ++ /* ++ * Set of_node_reuse flag to prevent driver core from attempting to ++ * claim any pinmux resources already claimed by the parent device. ++ * Otherwise PMIC driver will fail to re-probe. ++ */ ++ device_set_of_node_from_dev(&pdev->dev, pdev->dev.parent); ++ + for (id = 0; id < MAX77620_NUM_REGS; id++) { + struct regulator_dev *rdev; + struct regulator_desc *rdesc; +diff --git a/drivers/regulator/rtmv20-regulator.c b/drivers/regulator/rtmv20-regulator.c +index 852fb2596ffda..5adc552dffd58 100644 +--- a/drivers/regulator/rtmv20-regulator.c ++++ b/drivers/regulator/rtmv20-regulator.c +@@ -103,9 +103,47 @@ static int rtmv20_lsw_disable(struct regulator_dev *rdev) + return 0; + } + ++static int rtmv20_lsw_set_current_limit(struct regulator_dev *rdev, int min_uA, ++ int max_uA) ++{ ++ int sel; ++ ++ if (min_uA > RTMV20_LSW_MAXUA || max_uA < RTMV20_LSW_MINUA) ++ return -EINVAL; ++ ++ if (max_uA > RTMV20_LSW_MAXUA) ++ max_uA = RTMV20_LSW_MAXUA; ++ ++ sel = (max_uA - RTMV20_LSW_MINUA) / RTMV20_LSW_STEPUA; ++ ++ /* Ensure the selected setting is still in range */ ++ if ((sel * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA) < min_uA) ++ return -EINVAL; ++ ++ sel <<= ffs(rdev->desc->csel_mask) - 1; ++ ++ return regmap_update_bits(rdev->regmap, rdev->desc->csel_reg, ++ rdev->desc->csel_mask, sel); ++} ++ ++static int rtmv20_lsw_get_current_limit(struct regulator_dev *rdev) ++{ ++ unsigned int val; ++ int ret; ++ ++ ret = regmap_read(rdev->regmap, rdev->desc->csel_reg, &val); ++ if (ret) ++ return ret; ++ ++ val &= rdev->desc->csel_mask; ++ val >>= ffs(rdev->desc->csel_mask) - 1; ++ ++ return val * RTMV20_LSW_STEPUA + RTMV20_LSW_MINUA; ++} ++ + static const struct regulator_ops rtmv20_regulator_ops = { +- .set_current_limit = regulator_set_current_limit_regmap, +- .get_current_limit = regulator_get_current_limit_regmap, ++ .set_current_limit = rtmv20_lsw_set_current_limit, ++ .get_current_limit = rtmv20_lsw_get_current_limit, + .enable = rtmv20_lsw_enable, + .disable = rtmv20_lsw_disable, + .is_enabled = regulator_is_enabled_regmap, +diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c +index 8c625b530035f..9b61e9b131ade 100644 +--- a/drivers/s390/cio/vfio_ccw_drv.c ++++ b/drivers/s390/cio/vfio_ccw_drv.c +@@ -86,6 +86,7 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) + struct vfio_ccw_private *private; + struct irb *irb; + bool is_final; ++ bool cp_is_finished = false; + + private = container_of(work, struct vfio_ccw_private, io_work); + irb = &private->irb; +@@ -94,14 +95,21 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work) + (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT)); + if (scsw_is_solicited(&irb->scsw)) { + cp_update_scsw(&private->cp, &irb->scsw); +- if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) ++ if (is_final && private->state == VFIO_CCW_STATE_CP_PENDING) { + cp_free(&private->cp); ++ cp_is_finished = true; ++ } + } + mutex_lock(&private->io_mutex); + memcpy(private->io_region->irb_area, irb, sizeof(*irb)); + mutex_unlock(&private->io_mutex); + +- if (private->mdev && is_final) ++ /* ++ * Reset to IDLE only if processing of a channel program ++ * has finished. Do not overwrite a possible processing ++ * state if the final interrupt was for HSCH or CSCH. ++ */ ++ if (private->mdev && cp_is_finished) + private->state = VFIO_CCW_STATE_IDLE; + + if (private->io_trigger) +diff --git a/drivers/s390/cio/vfio_ccw_fsm.c b/drivers/s390/cio/vfio_ccw_fsm.c +index 23e61aa638e4e..e435a9cd92dac 100644 +--- a/drivers/s390/cio/vfio_ccw_fsm.c ++++ b/drivers/s390/cio/vfio_ccw_fsm.c +@@ -318,6 +318,7 @@ static void fsm_io_request(struct vfio_ccw_private *private, + } + + err_out: ++ private->state = VFIO_CCW_STATE_IDLE; + trace_vfio_ccw_fsm_io_request(scsw->cmd.fctl, schid, + io_region->ret_code, errstr); + } +diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c +index 1ad5f7018ec2d..2280f51dd679d 100644 +--- a/drivers/s390/cio/vfio_ccw_ops.c ++++ b/drivers/s390/cio/vfio_ccw_ops.c +@@ -276,8 +276,6 @@ static ssize_t vfio_ccw_mdev_write_io_region(struct vfio_ccw_private *private, + } + + vfio_ccw_fsm_event(private, VFIO_CCW_EVENT_IO_REQ); +- if (region->ret_code != 0) +- private->state = VFIO_CCW_STATE_IDLE; + ret = (region->ret_code != 0) ? region->ret_code : count; + + out_unlock: +diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c +index 1a0dc18d69155..ed300a279a387 100644 +--- a/drivers/scsi/bnx2fc/bnx2fc_io.c ++++ b/drivers/scsi/bnx2fc/bnx2fc_io.c +@@ -1220,6 +1220,7 @@ int bnx2fc_eh_abort(struct scsi_cmnd *sc_cmd) + was a result from the ABTS request rather than the CLEANUP + request */ + set_bit(BNX2FC_FLAG_IO_CLEANUP, &io_req->req_flags); ++ rc = FAILED; + goto done; + } + +diff --git a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +index 19170c7ac336f..e9a82a390672c 100644 +--- a/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c ++++ b/drivers/scsi/hisi_sas/hisi_sas_v3_hw.c +@@ -3359,14 +3359,14 @@ hisi_sas_v3_destroy_irqs(struct pci_dev *pdev, struct hisi_hba *hisi_hba) + { + int i; + +- free_irq(pci_irq_vector(pdev, 1), hisi_hba); +- free_irq(pci_irq_vector(pdev, 2), hisi_hba); +- free_irq(pci_irq_vector(pdev, 11), hisi_hba); ++ devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 1), hisi_hba); ++ devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 2), hisi_hba); ++ devm_free_irq(&pdev->dev, pci_irq_vector(pdev, 11), hisi_hba); + for (i = 0; i < hisi_hba->cq_nvecs; i++) { + struct hisi_sas_cq *cq = &hisi_hba->cq[i]; + int nr = hisi_sas_intr_conv ? 16 : 16 + i; + +- free_irq(pci_irq_vector(pdev, nr), cq); ++ devm_free_irq(&pdev->dev, pci_irq_vector(pdev, nr), cq); + } + pci_free_irq_vectors(pdev); + } +diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c +index 2f162603876f9..b93dd8ef4ac82 100644 +--- a/drivers/scsi/hosts.c ++++ b/drivers/scsi/hosts.c +@@ -254,12 +254,11 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, + + device_enable_async_suspend(&shost->shost_dev); + ++ get_device(&shost->shost_gendev); + error = device_add(&shost->shost_dev); + if (error) + goto out_del_gendev; + +- get_device(&shost->shost_gendev); +- + if (shost->transportt->host_size) { + shost->shost_data = kzalloc(shost->transportt->host_size, + GFP_KERNEL); +@@ -278,33 +277,36 @@ int scsi_add_host_with_dma(struct Scsi_Host *shost, struct device *dev, + + if (!shost->work_q) { + error = -EINVAL; +- goto out_free_shost_data; ++ goto out_del_dev; + } + } + + error = scsi_sysfs_add_host(shost); + if (error) +- goto out_destroy_host; ++ goto out_del_dev; + + scsi_proc_host_add(shost); + scsi_autopm_put_host(shost); + return error; + +- out_destroy_host: +- if (shost->work_q) +- destroy_workqueue(shost->work_q); +- out_free_shost_data: +- kfree(shost->shost_data); ++ /* ++ * Any host allocation in this function will be freed in ++ * scsi_host_dev_release(). ++ */ + out_del_dev: + device_del(&shost->shost_dev); + out_del_gendev: ++ /* ++ * Host state is SHOST_RUNNING so we have to explicitly release ++ * ->shost_dev. ++ */ ++ put_device(&shost->shost_dev); + device_del(&shost->shost_gendev); + out_disable_runtime_pm: + device_disable_async_suspend(&shost->shost_gendev); + pm_runtime_disable(&shost->shost_gendev); + pm_runtime_set_suspended(&shost->shost_gendev); + pm_runtime_put_noidle(&shost->shost_gendev); +- scsi_mq_destroy_tags(shost); + fail: + return error; + } +@@ -345,7 +347,7 @@ static void scsi_host_dev_release(struct device *dev) + + ida_simple_remove(&host_index_ida, shost->host_no); + +- if (parent) ++ if (shost->shost_state != SHOST_CREATED) + put_device(parent); + kfree(shost); + } +@@ -392,8 +394,10 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) + mutex_init(&shost->scan_mutex); + + index = ida_simple_get(&host_index_ida, 0, 0, GFP_KERNEL); +- if (index < 0) +- goto fail_kfree; ++ if (index < 0) { ++ kfree(shost); ++ return NULL; ++ } + shost->host_no = index; + + shost->dma_channel = 0xff; +@@ -486,7 +490,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) + shost_printk(KERN_WARNING, shost, + "error handler thread failed to spawn, error = %ld\n", + PTR_ERR(shost->ehandler)); +- goto fail_index_remove; ++ goto fail; + } + + shost->tmf_work_q = alloc_workqueue("scsi_tmf_%d", +@@ -495,17 +499,18 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize) + if (!shost->tmf_work_q) { + shost_printk(KERN_WARNING, shost, + "failed to create tmf workq\n"); +- goto fail_kthread; ++ goto fail; + } + scsi_proc_hostdir_add(shost->hostt); + return shost; ++ fail: ++ /* ++ * Host state is still SHOST_CREATED and that is enough to release ++ * ->shost_gendev. scsi_host_dev_release() will free ++ * dev_name(&shost->shost_dev). ++ */ ++ put_device(&shost->shost_gendev); + +- fail_kthread: +- kthread_stop(shost->ehandler); +- fail_index_remove: +- ida_simple_remove(&host_index_ida, shost->host_no); +- fail_kfree: +- kfree(shost); + return NULL; + } + EXPORT_SYMBOL(scsi_host_alloc); +diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c +index dcae8f071c355..8d4976725a75a 100644 +--- a/drivers/scsi/qla2xxx/qla_target.c ++++ b/drivers/scsi/qla2xxx/qla_target.c +@@ -1559,10 +1559,12 @@ void qlt_stop_phase2(struct qla_tgt *tgt) + return; + } + ++ mutex_lock(&tgt->ha->optrom_mutex); + mutex_lock(&vha->vha_tgt.tgt_mutex); + tgt->tgt_stop = 0; + tgt->tgt_stopped = 1; + mutex_unlock(&vha->vha_tgt.tgt_mutex); ++ mutex_unlock(&tgt->ha->optrom_mutex); + + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00c, "Stop of tgt %p finished\n", + tgt); +diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c +index 081f54ab7d86c..1421b1394d816 100644 +--- a/drivers/scsi/vmw_pvscsi.c ++++ b/drivers/scsi/vmw_pvscsi.c +@@ -587,7 +587,13 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, + case BTSTAT_SUCCESS: + case BTSTAT_LINKED_COMMAND_COMPLETED: + case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG: +- /* If everything went fine, let's move on.. */ ++ /* ++ * Commands like INQUIRY may transfer less data than ++ * requested by the initiator via bufflen. Set residual ++ * count to make upper layer aware of the actual amount ++ * of data returned. ++ */ ++ scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen); + cmd->result = (DID_OK << 16); + break; + +diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c +index 197485f2c2b22..29ee555a42f90 100644 +--- a/drivers/spi/spi-bcm2835.c ++++ b/drivers/spi/spi-bcm2835.c +@@ -68,7 +68,7 @@ + #define BCM2835_SPI_FIFO_SIZE 64 + #define BCM2835_SPI_FIFO_SIZE_3_4 48 + #define BCM2835_SPI_DMA_MIN_LENGTH 96 +-#define BCM2835_SPI_NUM_CS 4 /* raise as necessary */ ++#define BCM2835_SPI_NUM_CS 24 /* raise as necessary */ + #define BCM2835_SPI_MODE_BITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH \ + | SPI_NO_CS | SPI_3WIRE) + +@@ -1195,6 +1195,12 @@ static int bcm2835_spi_setup(struct spi_device *spi) + struct gpio_chip *chip; + u32 cs; + ++ if (spi->chip_select >= BCM2835_SPI_NUM_CS) { ++ dev_err(&spi->dev, "only %d chip-selects supported\n", ++ BCM2835_SPI_NUM_CS - 1); ++ return -EINVAL; ++ } ++ + /* + * Precalculate SPI slave's CS register value for ->prepare_message(): + * The driver always uses software-controlled GPIO chip select, hence +@@ -1288,7 +1294,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev) + ctlr->use_gpio_descriptors = true; + ctlr->mode_bits = BCM2835_SPI_MODE_BITS; + ctlr->bits_per_word_mask = SPI_BPW_MASK(8); +- ctlr->num_chipselect = BCM2835_SPI_NUM_CS; ++ ctlr->num_chipselect = 3; + ctlr->setup = bcm2835_spi_setup; + ctlr->transfer_one = bcm2835_spi_transfer_one; + ctlr->handle_err = bcm2835_spi_handle_err; +diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c +index 1a7352abd8786..3d8948a17095b 100644 +--- a/drivers/spi/spi-bitbang.c ++++ b/drivers/spi/spi-bitbang.c +@@ -181,6 +181,8 @@ int spi_bitbang_setup(struct spi_device *spi) + { + struct spi_bitbang_cs *cs = spi->controller_state; + struct spi_bitbang *bitbang; ++ bool initial_setup = false; ++ int retval; + + bitbang = spi_master_get_devdata(spi->master); + +@@ -189,22 +191,30 @@ int spi_bitbang_setup(struct spi_device *spi) + if (!cs) + return -ENOMEM; + spi->controller_state = cs; ++ initial_setup = true; + } + + /* per-word shift register access, in hardware or bitbanging */ + cs->txrx_word = bitbang->txrx_word[spi->mode & (SPI_CPOL|SPI_CPHA)]; +- if (!cs->txrx_word) +- return -EINVAL; ++ if (!cs->txrx_word) { ++ retval = -EINVAL; ++ goto err_free; ++ } + + if (bitbang->setup_transfer) { +- int retval = bitbang->setup_transfer(spi, NULL); ++ retval = bitbang->setup_transfer(spi, NULL); + if (retval < 0) +- return retval; ++ goto err_free; + } + + dev_dbg(&spi->dev, "%s, %u nsec/bit\n", __func__, 2 * cs->nsecs); + + return 0; ++ ++err_free: ++ if (initial_setup) ++ kfree(cs); ++ return retval; + } + EXPORT_SYMBOL_GPL(spi_bitbang_setup); + +diff --git a/drivers/spi/spi-fsl-spi.c b/drivers/spi/spi-fsl-spi.c +index d0e5aa18b7bad..bdf94cc7be1af 100644 +--- a/drivers/spi/spi-fsl-spi.c ++++ b/drivers/spi/spi-fsl-spi.c +@@ -440,6 +440,7 @@ static int fsl_spi_setup(struct spi_device *spi) + { + struct mpc8xxx_spi *mpc8xxx_spi; + struct fsl_spi_reg __iomem *reg_base; ++ bool initial_setup = false; + int retval; + u32 hw_mode; + struct spi_mpc8xxx_cs *cs = spi_get_ctldata(spi); +@@ -452,6 +453,7 @@ static int fsl_spi_setup(struct spi_device *spi) + if (!cs) + return -ENOMEM; + spi_set_ctldata(spi, cs); ++ initial_setup = true; + } + mpc8xxx_spi = spi_master_get_devdata(spi->master); + +@@ -475,6 +477,8 @@ static int fsl_spi_setup(struct spi_device *spi) + retval = fsl_spi_setup_transfer(spi, NULL); + if (retval < 0) { + cs->hw_mode = hw_mode; /* Restore settings */ ++ if (initial_setup) ++ kfree(cs); + return retval; + } + +diff --git a/drivers/spi/spi-omap-uwire.c b/drivers/spi/spi-omap-uwire.c +index 71402f71ddd85..df28c6664aba6 100644 +--- a/drivers/spi/spi-omap-uwire.c ++++ b/drivers/spi/spi-omap-uwire.c +@@ -424,15 +424,22 @@ done: + static int uwire_setup(struct spi_device *spi) + { + struct uwire_state *ust = spi->controller_state; ++ bool initial_setup = false; ++ int status; + + if (ust == NULL) { + ust = kzalloc(sizeof(*ust), GFP_KERNEL); + if (ust == NULL) + return -ENOMEM; + spi->controller_state = ust; ++ initial_setup = true; + } + +- return uwire_setup_transfer(spi, NULL); ++ status = uwire_setup_transfer(spi, NULL); ++ if (status && initial_setup) ++ kfree(ust); ++ ++ return status; + } + + static void uwire_cleanup(struct spi_device *spi) +diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c +index d4c9510af3931..3596bbe4b7760 100644 +--- a/drivers/spi/spi-omap2-mcspi.c ++++ b/drivers/spi/spi-omap2-mcspi.c +@@ -1032,8 +1032,22 @@ static void omap2_mcspi_release_dma(struct spi_master *master) + } + } + ++static void omap2_mcspi_cleanup(struct spi_device *spi) ++{ ++ struct omap2_mcspi_cs *cs; ++ ++ if (spi->controller_state) { ++ /* Unlink controller state from context save list */ ++ cs = spi->controller_state; ++ list_del(&cs->node); ++ ++ kfree(cs); ++ } ++} ++ + static int omap2_mcspi_setup(struct spi_device *spi) + { ++ bool initial_setup = false; + int ret; + struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master); + struct omap2_mcspi_regs *ctx = &mcspi->ctx; +@@ -1051,35 +1065,28 @@ static int omap2_mcspi_setup(struct spi_device *spi) + spi->controller_state = cs; + /* Link this to context save list */ + list_add_tail(&cs->node, &ctx->cs); ++ initial_setup = true; + } + + ret = pm_runtime_get_sync(mcspi->dev); + if (ret < 0) { + pm_runtime_put_noidle(mcspi->dev); ++ if (initial_setup) ++ omap2_mcspi_cleanup(spi); + + return ret; + } + + ret = omap2_mcspi_setup_transfer(spi, NULL); ++ if (ret && initial_setup) ++ omap2_mcspi_cleanup(spi); ++ + pm_runtime_mark_last_busy(mcspi->dev); + pm_runtime_put_autosuspend(mcspi->dev); + + return ret; + } + +-static void omap2_mcspi_cleanup(struct spi_device *spi) +-{ +- struct omap2_mcspi_cs *cs; +- +- if (spi->controller_state) { +- /* Unlink controller state from context save list */ +- cs = spi->controller_state; +- list_del(&cs->node); +- +- kfree(cs); +- } +-} +- + static irqreturn_t omap2_mcspi_irq_handler(int irq, void *data) + { + struct omap2_mcspi *mcspi = data; +diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c +index d6b534d38e5da..56a62095ec8c2 100644 +--- a/drivers/spi/spi-pxa2xx.c ++++ b/drivers/spi/spi-pxa2xx.c +@@ -1254,6 +1254,8 @@ static int setup_cs(struct spi_device *spi, struct chip_data *chip, + chip->gpio_cs_inverted = spi->mode & SPI_CS_HIGH; + + err = gpiod_direction_output(gpiod, !chip->gpio_cs_inverted); ++ if (err) ++ gpiod_put(chip->gpiod_cs); + } + + return err; +@@ -1267,6 +1269,7 @@ static int setup(struct spi_device *spi) + struct driver_data *drv_data = + spi_controller_get_devdata(spi->controller); + uint tx_thres, tx_hi_thres, rx_thres; ++ int err; + + switch (drv_data->ssp_type) { + case QUARK_X1000_SSP: +@@ -1413,7 +1416,11 @@ static int setup(struct spi_device *spi) + if (drv_data->ssp_type == CE4100_SSP) + return 0; + +- return setup_cs(spi, chip, chip_info); ++ err = setup_cs(spi, chip, chip_info); ++ if (err) ++ kfree(chip); ++ ++ return err; + } + + static void cleanup(struct spi_device *spi) +diff --git a/drivers/spi/spi-sprd.c b/drivers/spi/spi-sprd.c +index b41a75749b498..28e70db9bbba8 100644 +--- a/drivers/spi/spi-sprd.c ++++ b/drivers/spi/spi-sprd.c +@@ -1068,6 +1068,7 @@ static const struct of_device_id sprd_spi_of_match[] = { + { .compatible = "sprd,sc9860-spi", }, + { /* sentinel */ } + }; ++MODULE_DEVICE_TABLE(of, sprd_spi_of_match); + + static struct platform_driver sprd_spi_driver = { + .driver = { +diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c +index 5d8a5ee62fa23..2765289028fae 100644 +--- a/drivers/spi/spi-zynq-qspi.c ++++ b/drivers/spi/spi-zynq-qspi.c +@@ -528,18 +528,17 @@ static int zynq_qspi_exec_mem_op(struct spi_mem *mem, + struct zynq_qspi *xqspi = spi_controller_get_devdata(mem->spi->master); + int err = 0, i; + u8 *tmpbuf; +- u8 opcode = op->cmd.opcode; + + dev_dbg(xqspi->dev, "cmd:%#x mode:%d.%d.%d.%d\n", +- opcode, op->cmd.buswidth, op->addr.buswidth, ++ op->cmd.opcode, op->cmd.buswidth, op->addr.buswidth, + op->dummy.buswidth, op->data.buswidth); + + zynq_qspi_chipselect(mem->spi, true); + zynq_qspi_config_op(xqspi, mem->spi); + +- if (op->cmd.nbytes) { ++ if (op->cmd.opcode) { + reinit_completion(&xqspi->data_completion); +- xqspi->txbuf = &opcode; ++ xqspi->txbuf = (u8 *)&op->cmd.opcode; + xqspi->rxbuf = NULL; + xqspi->tx_bytes = op->cmd.nbytes; + xqspi->rx_bytes = op->cmd.nbytes; +diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c +index a6f1e94af13c5..0cf67de741e78 100644 +--- a/drivers/spi/spi.c ++++ b/drivers/spi/spi.c +@@ -47,10 +47,6 @@ static void spidev_release(struct device *dev) + { + struct spi_device *spi = to_spi_device(dev); + +- /* spi controllers may cleanup for released devices */ +- if (spi->controller->cleanup) +- spi->controller->cleanup(spi); +- + spi_controller_put(spi->controller); + kfree(spi->driver_override); + kfree(spi); +@@ -550,6 +546,12 @@ static int spi_dev_check(struct device *dev, void *data) + return 0; + } + ++static void spi_cleanup(struct spi_device *spi) ++{ ++ if (spi->controller->cleanup) ++ spi->controller->cleanup(spi); ++} ++ + /** + * spi_add_device - Add spi_device allocated with spi_alloc_device + * @spi: spi_device to register +@@ -614,11 +616,13 @@ int spi_add_device(struct spi_device *spi) + + /* Device may be bound to an active driver when this returns */ + status = device_add(&spi->dev); +- if (status < 0) ++ if (status < 0) { + dev_err(dev, "can't add %s, status %d\n", + dev_name(&spi->dev), status); +- else ++ spi_cleanup(spi); ++ } else { + dev_dbg(dev, "registered child %s\n", dev_name(&spi->dev)); ++ } + + done: + mutex_unlock(&spi_add_lock); +@@ -711,7 +715,9 @@ void spi_unregister_device(struct spi_device *spi) + } + if (ACPI_COMPANION(&spi->dev)) + acpi_device_clear_enumerated(ACPI_COMPANION(&spi->dev)); +- device_unregister(&spi->dev); ++ device_del(&spi->dev); ++ spi_cleanup(spi); ++ put_device(&spi->dev); + } + EXPORT_SYMBOL_GPL(spi_unregister_device); + +diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +index ea3ae3d38337e..b7993e25764d5 100644 +--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c ++++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +@@ -2384,7 +2384,7 @@ void rtw_cfg80211_indicate_sta_assoc(struct adapter *padapter, u8 *pmgmt_frame, + DBG_871X(FUNC_ADPT_FMT"\n", FUNC_ADPT_ARG(padapter)); + + { +- struct station_info sinfo; ++ struct station_info sinfo = {}; + u8 ie_offset; + if (GetFrameSubType(pmgmt_frame) == WIFI_ASSOCREQ) + ie_offset = _ASOCREQ_IE_OFFSET_; +diff --git a/drivers/usb/cdns3/gadget.c b/drivers/usb/cdns3/gadget.c +index 0aa85cc07ff19..c24c0e3440e39 100644 +--- a/drivers/usb/cdns3/gadget.c ++++ b/drivers/usb/cdns3/gadget.c +@@ -3255,8 +3255,10 @@ static int __cdns3_gadget_init(struct cdns3 *cdns) + pm_runtime_get_sync(cdns->dev); + + ret = cdns3_gadget_start(cdns); +- if (ret) ++ if (ret) { ++ pm_runtime_put_sync(cdns->dev); + return ret; ++ } + + /* + * Because interrupt line can be shared with other components in +diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c +index 60ea932afe2b8..5f35cdd2cf1dd 100644 +--- a/drivers/usb/chipidea/udc.c ++++ b/drivers/usb/chipidea/udc.c +@@ -2055,6 +2055,7 @@ static int udc_start(struct ci_hdrc *ci) + ci->gadget.name = ci->platdata->name; + ci->gadget.otg_caps = otg_caps; + ci->gadget.sg_supported = 1; ++ ci->gadget.irq = ci->irq; + + if (ci->platdata->flags & CI_HDRC_REQUIRES_ALIGNED_DMA) + ci->gadget.quirk_avoids_skb_reserve = 1; +diff --git a/drivers/usb/dwc3/dwc3-meson-g12a.c b/drivers/usb/dwc3/dwc3-meson-g12a.c +index bdf1f98dfad8c..ffe301d6ea359 100644 +--- a/drivers/usb/dwc3/dwc3-meson-g12a.c ++++ b/drivers/usb/dwc3/dwc3-meson-g12a.c +@@ -651,7 +651,7 @@ static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, + return PTR_ERR(priv->usb_glue_regmap); + + /* Create a regmap for each USB2 PHY control register set */ +- for (i = 0; i < priv->usb2_ports; i++) { ++ for (i = 0; i < priv->drvdata->num_phys; i++) { + struct regmap_config u2p_regmap_config = { + .reg_bits = 8, + .val_bits = 32, +@@ -659,6 +659,9 @@ static int dwc3_meson_g12a_setup_regmaps(struct dwc3_meson_g12a *priv, + .max_register = U2P_R1, + }; + ++ if (!strstr(priv->drvdata->phy_names[i], "usb2")) ++ continue; ++ + u2p_regmap_config.name = devm_kasprintf(priv->dev, GFP_KERNEL, + "u2p-%d", i); + if (!u2p_regmap_config.name) +@@ -772,13 +775,13 @@ static int dwc3_meson_g12a_probe(struct platform_device *pdev) + + ret = priv->drvdata->usb_init(priv); + if (ret) +- goto err_disable_clks; ++ goto err_disable_regulator; + + /* Init PHYs */ + for (i = 0 ; i < PHY_COUNT ; ++i) { + ret = phy_init(priv->phys[i]); + if (ret) +- goto err_disable_clks; ++ goto err_disable_regulator; + } + + /* Set PHY Power */ +@@ -816,6 +819,10 @@ err_phys_exit: + for (i = 0 ; i < PHY_COUNT ; ++i) + phy_exit(priv->phys[i]); + ++err_disable_regulator: ++ if (priv->vbus) ++ regulator_disable(priv->vbus); ++ + err_disable_clks: + clk_bulk_disable_unprepare(priv->drvdata->num_clks, + priv->drvdata->clks); +diff --git a/drivers/usb/dwc3/ep0.c b/drivers/usb/dwc3/ep0.c +index 8b668ef46f7f1..3cd2942643725 100644 +--- a/drivers/usb/dwc3/ep0.c ++++ b/drivers/usb/dwc3/ep0.c +@@ -292,6 +292,9 @@ static struct dwc3_ep *dwc3_wIndex_to_dep(struct dwc3 *dwc, __le16 wIndex_le) + epnum |= 1; + + dep = dwc->eps[epnum]; ++ if (dep == NULL) ++ return NULL; ++ + if (dep->flags & DWC3_EP_ENABLED) + return dep; + +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index ead877e7c87f9..8bccdd7b0ca2e 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -2143,13 +2143,10 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) + } + + /* +- * Synchronize any pending event handling before executing the controller +- * halt routine. ++ * Synchronize and disable any further event handling while controller ++ * is being enabled/disabled. + */ +- if (!is_on) { +- dwc3_gadget_disable_irq(dwc); +- synchronize_irq(dwc->irq_gadget); +- } ++ disable_irq(dwc->irq_gadget); + + spin_lock_irqsave(&dwc->lock, flags); + +@@ -2187,6 +2184,8 @@ static int dwc3_gadget_pullup(struct usb_gadget *g, int is_on) + + ret = dwc3_gadget_run_stop(dwc, is_on, false); + spin_unlock_irqrestore(&dwc->lock, flags); ++ enable_irq(dwc->irq_gadget); ++ + pm_runtime_put(dwc->dev); + + return ret; +@@ -3936,6 +3935,7 @@ err5: + dwc3_gadget_free_endpoints(dwc); + err4: + usb_put_gadget(dwc->gadget); ++ dwc->gadget = NULL; + err3: + dma_free_coherent(dwc->sysdev, DWC3_BOUNCE_SIZE, dwc->bounce, + dwc->bounce_addr); +@@ -3955,6 +3955,9 @@ err0: + + void dwc3_gadget_exit(struct dwc3 *dwc) + { ++ if (!dwc->gadget) ++ return; ++ + usb_del_gadget(dwc->gadget); + dwc3_gadget_free_endpoints(dwc); + usb_put_gadget(dwc->gadget); +diff --git a/drivers/usb/gadget/config.c b/drivers/usb/gadget/config.c +index 8bb25773b61e9..05507606b2b42 100644 +--- a/drivers/usb/gadget/config.c ++++ b/drivers/usb/gadget/config.c +@@ -164,6 +164,14 @@ int usb_assign_descriptors(struct usb_function *f, + { + struct usb_gadget *g = f->config->cdev->gadget; + ++ /* super-speed-plus descriptor falls back to super-speed one, ++ * if such a descriptor was provided, thus avoiding a NULL ++ * pointer dereference if a 5gbps capable gadget is used with ++ * a 10gbps capable config (device port + cable + host port) ++ */ ++ if (!ssp) ++ ssp = ss; ++ + if (fs) { + f->fs_descriptors = usb_copy_descriptors(fs); + if (!f->fs_descriptors) +diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/function/f_ecm.c +index 7f5cf488b2b1e..ffe2486fce71c 100644 +--- a/drivers/usb/gadget/function/f_ecm.c ++++ b/drivers/usb/gadget/function/f_ecm.c +@@ -791,7 +791,7 @@ ecm_bind(struct usb_configuration *c, struct usb_function *f) + fs_ecm_notify_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, ecm_fs_function, ecm_hs_function, +- ecm_ss_function, NULL); ++ ecm_ss_function, ecm_ss_function); + if (status) + goto fail; + +diff --git a/drivers/usb/gadget/function/f_eem.c b/drivers/usb/gadget/function/f_eem.c +index cfcc4e81fb776..2cd9942707b46 100644 +--- a/drivers/usb/gadget/function/f_eem.c ++++ b/drivers/usb/gadget/function/f_eem.c +@@ -302,7 +302,7 @@ static int eem_bind(struct usb_configuration *c, struct usb_function *f) + eem_ss_out_desc.bEndpointAddress = eem_fs_out_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, eem_fs_function, eem_hs_function, +- eem_ss_function, NULL); ++ eem_ss_function, eem_ss_function); + if (status) + goto fail; + +@@ -495,7 +495,7 @@ static int eem_unwrap(struct gether *port, + skb2 = skb_clone(skb, GFP_ATOMIC); + if (unlikely(!skb2)) { + DBG(cdev, "unable to unframe EEM packet\n"); +- continue; ++ goto next; + } + skb_trim(skb2, len - ETH_FCS_LEN); + +@@ -505,7 +505,7 @@ static int eem_unwrap(struct gether *port, + GFP_ATOMIC); + if (unlikely(!skb3)) { + dev_kfree_skb_any(skb2); +- continue; ++ goto next; + } + dev_kfree_skb_any(skb2); + skb_queue_tail(list, skb3); +diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c +index ffe67d836b0ce..7df180b110afc 100644 +--- a/drivers/usb/gadget/function/f_fs.c ++++ b/drivers/usb/gadget/function/f_fs.c +@@ -3566,6 +3566,9 @@ static void ffs_func_unbind(struct usb_configuration *c, + ffs->func = NULL; + } + ++ /* Drain any pending AIO completions */ ++ drain_workqueue(ffs->io_completion_wq); ++ + if (!--opts->refcnt) + functionfs_unbind(ffs); + +diff --git a/drivers/usb/gadget/function/f_hid.c b/drivers/usb/gadget/function/f_hid.c +index 1125f4715830d..e556993081170 100644 +--- a/drivers/usb/gadget/function/f_hid.c ++++ b/drivers/usb/gadget/function/f_hid.c +@@ -802,7 +802,8 @@ static int hidg_bind(struct usb_configuration *c, struct usb_function *f) + hidg_fs_out_ep_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, hidg_fs_descriptors, +- hidg_hs_descriptors, hidg_ss_descriptors, NULL); ++ hidg_hs_descriptors, hidg_ss_descriptors, ++ hidg_ss_descriptors); + if (status) + goto fail; + +diff --git a/drivers/usb/gadget/function/f_loopback.c b/drivers/usb/gadget/function/f_loopback.c +index 1803646b36780..90215a81c178b 100644 +--- a/drivers/usb/gadget/function/f_loopback.c ++++ b/drivers/usb/gadget/function/f_loopback.c +@@ -207,7 +207,7 @@ autoconf_fail: + ss_loop_sink_desc.bEndpointAddress = fs_loop_sink_desc.bEndpointAddress; + + ret = usb_assign_descriptors(f, fs_loopback_descs, hs_loopback_descs, +- ss_loopback_descs, NULL); ++ ss_loopback_descs, ss_loopback_descs); + if (ret) + return ret; + +diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c +index 019bea8e09cce..855127249f242 100644 +--- a/drivers/usb/gadget/function/f_ncm.c ++++ b/drivers/usb/gadget/function/f_ncm.c +@@ -583,7 +583,7 @@ static void ncm_do_notify(struct f_ncm *ncm) + data[0] = cpu_to_le32(ncm_bitrate(cdev->gadget)); + data[1] = data[0]; + +- DBG(cdev, "notify speed %d\n", ncm_bitrate(cdev->gadget)); ++ DBG(cdev, "notify speed %u\n", ncm_bitrate(cdev->gadget)); + ncm->notify_state = NCM_NOTIFY_CONNECT; + break; + } +@@ -1101,11 +1101,11 @@ static struct sk_buff *ncm_wrap_ntb(struct gether *port, + ncm->ndp_dgram_count = 1; + + /* Note: we skip opts->next_ndp_index */ +- } + +- /* Delay the timer. */ +- hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, +- HRTIMER_MODE_REL_SOFT); ++ /* Start the timer. */ ++ hrtimer_start(&ncm->task_timer, TX_TIMEOUT_NSECS, ++ HRTIMER_MODE_REL_SOFT); ++ } + + /* Add the datagram position entries */ + ntb_ndp = skb_put_zero(ncm->skb_tx_ndp, dgram_idx_len); +diff --git a/drivers/usb/gadget/function/f_printer.c b/drivers/usb/gadget/function/f_printer.c +index 2f1eb2e81d306..236ecc9689985 100644 +--- a/drivers/usb/gadget/function/f_printer.c ++++ b/drivers/usb/gadget/function/f_printer.c +@@ -1099,7 +1099,8 @@ autoconf_fail: + ss_ep_out_desc.bEndpointAddress = fs_ep_out_desc.bEndpointAddress; + + ret = usb_assign_descriptors(f, fs_printer_function, +- hs_printer_function, ss_printer_function, NULL); ++ hs_printer_function, ss_printer_function, ++ ss_printer_function); + if (ret) + return ret; + +diff --git a/drivers/usb/gadget/function/f_rndis.c b/drivers/usb/gadget/function/f_rndis.c +index 0739b05a0ef7b..ee95e8f5f9d48 100644 +--- a/drivers/usb/gadget/function/f_rndis.c ++++ b/drivers/usb/gadget/function/f_rndis.c +@@ -789,7 +789,7 @@ rndis_bind(struct usb_configuration *c, struct usb_function *f) + ss_notify_desc.bEndpointAddress = fs_notify_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, eth_fs_function, eth_hs_function, +- eth_ss_function, NULL); ++ eth_ss_function, eth_ss_function); + if (status) + goto fail; + +diff --git a/drivers/usb/gadget/function/f_serial.c b/drivers/usb/gadget/function/f_serial.c +index e627138463504..1ed8ff0ac2d31 100644 +--- a/drivers/usb/gadget/function/f_serial.c ++++ b/drivers/usb/gadget/function/f_serial.c +@@ -233,7 +233,7 @@ static int gser_bind(struct usb_configuration *c, struct usb_function *f) + gser_ss_out_desc.bEndpointAddress = gser_fs_out_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, gser_fs_function, gser_hs_function, +- gser_ss_function, NULL); ++ gser_ss_function, gser_ss_function); + if (status) + goto fail; + dev_dbg(&cdev->gadget->dev, "generic ttyGS%d: %s speed IN/%s OUT/%s\n", +diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadget/function/f_sourcesink.c +index ed68a4860b7d8..282737e4609ce 100644 +--- a/drivers/usb/gadget/function/f_sourcesink.c ++++ b/drivers/usb/gadget/function/f_sourcesink.c +@@ -431,7 +431,8 @@ no_iso: + ss_iso_sink_desc.bEndpointAddress = fs_iso_sink_desc.bEndpointAddress; + + ret = usb_assign_descriptors(f, fs_source_sink_descs, +- hs_source_sink_descs, ss_source_sink_descs, NULL); ++ hs_source_sink_descs, ss_source_sink_descs, ++ ss_source_sink_descs); + if (ret) + return ret; + +diff --git a/drivers/usb/gadget/function/f_subset.c b/drivers/usb/gadget/function/f_subset.c +index 4d945254905d9..51c1cae162d9b 100644 +--- a/drivers/usb/gadget/function/f_subset.c ++++ b/drivers/usb/gadget/function/f_subset.c +@@ -358,7 +358,7 @@ geth_bind(struct usb_configuration *c, struct usb_function *f) + fs_subset_out_desc.bEndpointAddress; + + status = usb_assign_descriptors(f, fs_eth_function, hs_eth_function, +- ss_eth_function, NULL); ++ ss_eth_function, ss_eth_function); + if (status) + goto fail; + +diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c +index 410fa89eae8f6..5a2e9ce2bc352 100644 +--- a/drivers/usb/gadget/function/f_tcm.c ++++ b/drivers/usb/gadget/function/f_tcm.c +@@ -2061,7 +2061,8 @@ static int tcm_bind(struct usb_configuration *c, struct usb_function *f) + uasp_fs_cmd_desc.bEndpointAddress = uasp_ss_cmd_desc.bEndpointAddress; + + ret = usb_assign_descriptors(f, uasp_fs_function_desc, +- uasp_hs_function_desc, uasp_ss_function_desc, NULL); ++ uasp_hs_function_desc, uasp_ss_function_desc, ++ uasp_ss_function_desc); + if (ret) + goto ep_fail; + +diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c +index 8f09a387b7738..4c8f0112481f3 100644 +--- a/drivers/usb/musb/musb_core.c ++++ b/drivers/usb/musb/musb_core.c +@@ -2009,9 +2009,8 @@ static void musb_pm_runtime_check_session(struct musb *musb) + schedule_delayed_work(&musb->irq_work, + msecs_to_jiffies(1000)); + musb->quirk_retries--; +- break; + } +- fallthrough; ++ break; + case MUSB_QUIRK_B_INVALID_VBUS_91: + if (musb->quirk_retries && !musb->flush_irq_work) { + musb_dbg(musb, +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c +index b5f4e584f3c9e..28a728f883bc5 100644 +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -533,6 +533,12 @@ struct cp210x_single_port_config { + #define CP210X_2NCONFIG_GPIO_RSTLATCH_IDX 587 + #define CP210X_2NCONFIG_GPIO_CONTROL_IDX 600 + ++/* CP2102N QFN20 port configuration values */ ++#define CP2102N_QFN20_GPIO2_TXLED_MODE BIT(2) ++#define CP2102N_QFN20_GPIO3_RXLED_MODE BIT(3) ++#define CP2102N_QFN20_GPIO1_RS485_MODE BIT(4) ++#define CP2102N_QFN20_GPIO0_CLK_MODE BIT(6) ++ + /* CP210X_VENDOR_SPECIFIC, CP210X_WRITE_LATCH call writes these 0x2 bytes. */ + struct cp210x_gpio_write { + u8 mask; +@@ -1884,7 +1890,19 @@ static int cp2102n_gpioconf_init(struct usb_serial *serial) + priv->gpio_pushpull = (gpio_pushpull >> 3) & 0x0f; + + /* 0 indicates GPIO mode, 1 is alternate function */ +- priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; ++ if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN20) { ++ /* QFN20 is special... */ ++ if (gpio_ctrl & CP2102N_QFN20_GPIO0_CLK_MODE) /* GPIO 0 */ ++ priv->gpio_altfunc |= BIT(0); ++ if (gpio_ctrl & CP2102N_QFN20_GPIO1_RS485_MODE) /* GPIO 1 */ ++ priv->gpio_altfunc |= BIT(1); ++ if (gpio_ctrl & CP2102N_QFN20_GPIO2_TXLED_MODE) /* GPIO 2 */ ++ priv->gpio_altfunc |= BIT(2); ++ if (gpio_ctrl & CP2102N_QFN20_GPIO3_RXLED_MODE) /* GPIO 3 */ ++ priv->gpio_altfunc |= BIT(3); ++ } else { ++ priv->gpio_altfunc = (gpio_ctrl >> 2) & 0x0f; ++ } + + if (priv->partnum == CP210X_PARTNUM_CP2102N_QFN28) { + /* +diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c +index 7c64b6ee5c194..1aef9b1e1c4eb 100644 +--- a/drivers/usb/serial/ftdi_sio.c ++++ b/drivers/usb/serial/ftdi_sio.c +@@ -611,6 +611,7 @@ static const struct usb_device_id id_table_combined[] = { + .driver_info = (kernel_ulong_t)&ftdi_jtag_quirk }, + { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONLX_PLUS_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_NT_ORION_IO_PID) }, ++ { USB_DEVICE(FTDI_VID, FTDI_NT_ORIONMX_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_SYNAPSE_SS200_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX_PID) }, + { USB_DEVICE(FTDI_VID, FTDI_CUSTOMWARE_MINIPLEX2_PID) }, +diff --git a/drivers/usb/serial/ftdi_sio_ids.h b/drivers/usb/serial/ftdi_sio_ids.h +index d854e04a4286e..add602bebd820 100644 +--- a/drivers/usb/serial/ftdi_sio_ids.h ++++ b/drivers/usb/serial/ftdi_sio_ids.h +@@ -581,6 +581,7 @@ + #define FTDI_NT_ORIONLXM_PID 0x7c90 /* OrionLXm Substation Automation Platform */ + #define FTDI_NT_ORIONLX_PLUS_PID 0x7c91 /* OrionLX+ Substation Automation Platform */ + #define FTDI_NT_ORION_IO_PID 0x7c92 /* Orion I/O */ ++#define FTDI_NT_ORIONMX_PID 0x7c93 /* OrionMX */ + + /* + * Synapse Wireless product ids (FTDI_VID) +diff --git a/drivers/usb/serial/omninet.c b/drivers/usb/serial/omninet.c +index 5b6e982a9376b..ff02eff704162 100644 +--- a/drivers/usb/serial/omninet.c ++++ b/drivers/usb/serial/omninet.c +@@ -26,6 +26,7 @@ + + #define ZYXEL_VENDOR_ID 0x0586 + #define ZYXEL_OMNINET_ID 0x1000 ++#define ZYXEL_OMNI_56K_PLUS_ID 0x1500 + /* This one seems to be a re-branded ZyXEL device */ + #define BT_IGNITIONPRO_ID 0x2000 + +@@ -40,6 +41,7 @@ static int omninet_port_remove(struct usb_serial_port *port); + + static const struct usb_device_id id_table[] = { + { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNINET_ID) }, ++ { USB_DEVICE(ZYXEL_VENDOR_ID, ZYXEL_OMNI_56K_PLUS_ID) }, + { USB_DEVICE(ZYXEL_VENDOR_ID, BT_IGNITIONPRO_ID) }, + { } /* Terminating entry */ + }; +diff --git a/drivers/usb/serial/quatech2.c b/drivers/usb/serial/quatech2.c +index 872d1bc86ab43..a2c3c0944f996 100644 +--- a/drivers/usb/serial/quatech2.c ++++ b/drivers/usb/serial/quatech2.c +@@ -416,7 +416,7 @@ static void qt2_close(struct usb_serial_port *port) + + /* flush the port transmit buffer */ + i = usb_control_msg(serial->dev, +- usb_rcvctrlpipe(serial->dev, 0), ++ usb_sndctrlpipe(serial->dev, 0), + QT2_FLUSH_DEVICE, 0x40, 1, + port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); + +@@ -426,7 +426,7 @@ static void qt2_close(struct usb_serial_port *port) + + /* flush the port receive buffer */ + i = usb_control_msg(serial->dev, +- usb_rcvctrlpipe(serial->dev, 0), ++ usb_sndctrlpipe(serial->dev, 0), + QT2_FLUSH_DEVICE, 0x40, 0, + port_priv->device_port, NULL, 0, QT2_USB_TIMEOUT); + +@@ -654,7 +654,7 @@ static int qt2_attach(struct usb_serial *serial) + int status; + + /* power on unit */ +- status = usb_control_msg(serial->dev, usb_rcvctrlpipe(serial->dev, 0), ++ status = usb_control_msg(serial->dev, usb_sndctrlpipe(serial->dev, 0), + 0xc2, 0x40, 0x8000, 0, NULL, 0, + QT2_USB_TIMEOUT); + if (status < 0) { +diff --git a/drivers/usb/typec/mux.c b/drivers/usb/typec/mux.c +index 42acdc8b684fe..b9035c3407b56 100644 +--- a/drivers/usb/typec/mux.c ++++ b/drivers/usb/typec/mux.c +@@ -239,7 +239,7 @@ find_mux: + dev = class_find_device(&typec_mux_class, NULL, fwnode, + mux_fwnode_match); + +- return dev ? to_typec_switch(dev) : ERR_PTR(-EPROBE_DEFER); ++ return dev ? to_typec_mux(dev) : ERR_PTR(-EPROBE_DEFER); + } + + /** +diff --git a/drivers/usb/typec/mux/intel_pmc_mux.c b/drivers/usb/typec/mux/intel_pmc_mux.c +index 17896bd87fc3f..acdef6fbb85e0 100644 +--- a/drivers/usb/typec/mux/intel_pmc_mux.c ++++ b/drivers/usb/typec/mux/intel_pmc_mux.c +@@ -573,6 +573,11 @@ static int pmc_usb_probe_iom(struct pmc_usb *pmc) + return -ENOMEM; + } + ++ if (IS_ERR(pmc->iom_base)) { ++ put_device(&adev->dev); ++ return PTR_ERR(pmc->iom_base); ++ } ++ + pmc->iom_adev = adev; + + return 0; +@@ -623,8 +628,10 @@ static int pmc_usb_probe(struct platform_device *pdev) + break; + + ret = pmc_usb_register_port(pmc, i, fwnode); +- if (ret) ++ if (ret) { ++ fwnode_handle_put(fwnode); + goto err_remove_ports; ++ } + } + + platform_set_drvdata(pdev, pmc); +diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c +index bdbd346dc59ff..61929d37d7fc4 100644 +--- a/drivers/usb/typec/tcpm/tcpm.c ++++ b/drivers/usb/typec/tcpm/tcpm.c +@@ -5187,6 +5187,10 @@ void tcpm_unregister_port(struct tcpm_port *port) + { + int i; + ++ hrtimer_cancel(&port->enable_frs_timer); ++ hrtimer_cancel(&port->vdm_state_machine_timer); ++ hrtimer_cancel(&port->state_machine_timer); ++ + tcpm_reset_port(port); + for (i = 0; i < ARRAY_SIZE(port->port_altmode); i++) + typec_unregister_altmode(port->port_altmode[i]); +diff --git a/drivers/usb/typec/tcpm/wcove.c b/drivers/usb/typec/tcpm/wcove.c +index 9b745f432c910..7e9c279bf49df 100644 +--- a/drivers/usb/typec/tcpm/wcove.c ++++ b/drivers/usb/typec/tcpm/wcove.c +@@ -377,7 +377,7 @@ static int wcove_pd_transmit(struct tcpc_dev *tcpc, + const u8 *data = (void *)msg; + int i; + +- for (i = 0; i < pd_header_cnt(msg->header) * 4 + 2; i++) { ++ for (i = 0; i < pd_header_cnt_le(msg->header) * 4 + 2; i++) { + ret = regmap_write(wcove->regmap, USBC_TX_DATA + i, + data[i]); + if (ret) +diff --git a/drivers/usb/typec/ucsi/ucsi.c b/drivers/usb/typec/ucsi/ucsi.c +index b4615bb5daab8..310b5caeb05ae 100644 +--- a/drivers/usb/typec/ucsi/ucsi.c ++++ b/drivers/usb/typec/ucsi/ucsi.c +@@ -1118,6 +1118,7 @@ err_unregister: + } + + err_reset: ++ memset(&ucsi->cap, 0, sizeof(ucsi->cap)); + ucsi_reset_ppm(ucsi); + err: + return ret; +diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c +index 56f3b9acd2154..e025cd8f3f071 100644 +--- a/fs/btrfs/disk-io.c ++++ b/fs/btrfs/disk-io.c +@@ -2467,6 +2467,24 @@ static int validate_super(struct btrfs_fs_info *fs_info, + ret = -EINVAL; + } + ++ if (memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, ++ BTRFS_FSID_SIZE)) { ++ btrfs_err(fs_info, ++ "superblock fsid doesn't match fsid of fs_devices: %pU != %pU", ++ fs_info->super_copy->fsid, fs_info->fs_devices->fsid); ++ ret = -EINVAL; ++ } ++ ++ if (btrfs_fs_incompat(fs_info, METADATA_UUID) && ++ memcmp(fs_info->fs_devices->metadata_uuid, ++ fs_info->super_copy->metadata_uuid, BTRFS_FSID_SIZE)) { ++ btrfs_err(fs_info, ++"superblock metadata_uuid doesn't match metadata uuid of fs_devices: %pU != %pU", ++ fs_info->super_copy->metadata_uuid, ++ fs_info->fs_devices->metadata_uuid); ++ ret = -EINVAL; ++ } ++ + if (memcmp(fs_info->fs_devices->metadata_uuid, sb->dev_item.fsid, + BTRFS_FSID_SIZE) != 0) { + btrfs_err(fs_info, +@@ -2969,14 +2987,6 @@ int __cold open_ctree(struct super_block *sb, struct btrfs_fs_devices *fs_device + + disk_super = fs_info->super_copy; + +- ASSERT(!memcmp(fs_info->fs_devices->fsid, fs_info->super_copy->fsid, +- BTRFS_FSID_SIZE)); +- +- if (btrfs_fs_incompat(fs_info, METADATA_UUID)) { +- ASSERT(!memcmp(fs_info->fs_devices->metadata_uuid, +- fs_info->super_copy->metadata_uuid, +- BTRFS_FSID_SIZE)); +- } + + features = btrfs_super_flags(disk_super); + if (features & BTRFS_SUPER_FLAG_CHANGING_FSID_V2) { +diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c +index 7e87549c5edaf..ffa48ac98d1e5 100644 +--- a/fs/btrfs/file.c ++++ b/fs/btrfs/file.c +@@ -1088,7 +1088,7 @@ int btrfs_mark_extent_written(struct btrfs_trans_handle *trans, + int del_nr = 0; + int del_slot = 0; + int recow; +- int ret; ++ int ret = 0; + u64 ino = btrfs_ino(inode); + + path = btrfs_alloc_path(); +@@ -1309,7 +1309,7 @@ again: + } + out: + btrfs_free_path(path); +- return 0; ++ return ret; + } + + /* +diff --git a/fs/nfs/client.c b/fs/nfs/client.c +index 4b8cc93913f74..723d425796cca 100644 +--- a/fs/nfs/client.c ++++ b/fs/nfs/client.c +@@ -406,7 +406,7 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *cl_init) + + if (cl_init->hostname == NULL) { + WARN_ON(1); +- return NULL; ++ return ERR_PTR(-EINVAL); + } + + /* see if the client already exists */ +diff --git a/fs/nfs/nfs4_fs.h b/fs/nfs/nfs4_fs.h +index 065cb04222a1b..543d916f79abb 100644 +--- a/fs/nfs/nfs4_fs.h ++++ b/fs/nfs/nfs4_fs.h +@@ -205,6 +205,7 @@ struct nfs4_exception { + struct inode *inode; + nfs4_stateid *stateid; + long timeout; ++ unsigned char task_is_privileged : 1; + unsigned char delay : 1, + recovering : 1, + retry : 1; +diff --git a/fs/nfs/nfs4client.c b/fs/nfs/nfs4client.c +index be7915c861cef..7491323a58207 100644 +--- a/fs/nfs/nfs4client.c ++++ b/fs/nfs/nfs4client.c +@@ -435,8 +435,8 @@ struct nfs_client *nfs4_init_client(struct nfs_client *clp, + */ + nfs_mark_client_ready(clp, -EPERM); + } +- nfs_put_client(clp); + clear_bit(NFS_CS_TSM_POSSIBLE, &clp->cl_flags); ++ nfs_put_client(clp); + return old; + + error: +diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c +index c92d6ff0fceab..5365000e83bd6 100644 +--- a/fs/nfs/nfs4proc.c ++++ b/fs/nfs/nfs4proc.c +@@ -592,6 +592,8 @@ int nfs4_handle_exception(struct nfs_server *server, int errorcode, struct nfs4_ + goto out_retry; + } + if (exception->recovering) { ++ if (exception->task_is_privileged) ++ return -EDEADLOCK; + ret = nfs4_wait_clnt_recover(clp); + if (test_bit(NFS_MIG_FAILED, &server->mig_status)) + return -EIO; +@@ -617,6 +619,8 @@ nfs4_async_handle_exception(struct rpc_task *task, struct nfs_server *server, + goto out_retry; + } + if (exception->recovering) { ++ if (exception->task_is_privileged) ++ return -EDEADLOCK; + rpc_sleep_on(&clp->cl_rpcwaitq, task, NULL); + if (test_bit(NFS4CLNT_MANAGER_RUNNING, &clp->cl_state) == 0) + rpc_wake_up_queued_task(&clp->cl_rpcwaitq, task); +@@ -5942,6 +5946,14 @@ static int nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t buflen + do { + err = __nfs4_proc_set_acl(inode, buf, buflen); + trace_nfs4_set_acl(inode, err); ++ if (err == -NFS4ERR_BADOWNER || err == -NFS4ERR_BADNAME) { ++ /* ++ * no need to retry since the kernel ++ * isn't involved in encoding the ACEs. ++ */ ++ err = -EINVAL; ++ break; ++ } + err = nfs4_handle_exception(NFS_SERVER(inode), err, + &exception); + } while (exception.retry); +@@ -6383,6 +6395,7 @@ static void nfs4_delegreturn_done(struct rpc_task *task, void *calldata) + struct nfs4_exception exception = { + .inode = data->inode, + .stateid = &data->stateid, ++ .task_is_privileged = data->args.seq_args.sa_privileged, + }; + + if (!nfs4_sequence_done(task, &data->res.seq_res)) +@@ -6506,7 +6519,6 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, + data = kzalloc(sizeof(*data), GFP_NOFS); + if (data == NULL) + return -ENOMEM; +- nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, 0); + + nfs4_state_protect(server->nfs_client, + NFS_SP4_MACH_CRED_CLEANUP, +@@ -6537,6 +6549,12 @@ static int _nfs4_proc_delegreturn(struct inode *inode, const struct cred *cred, + } + } + ++ if (!data->inode) ++ nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, ++ 1); ++ else ++ nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 1, ++ 0); + task_setup_data.callback_data = data; + msg.rpc_argp = &data->args; + msg.rpc_resp = &data->res; +@@ -9619,15 +9637,20 @@ int nfs4_proc_layoutreturn(struct nfs4_layoutreturn *lrp, bool sync) + &task_setup_data.rpc_client, &msg); + + dprintk("--> %s\n", __func__); ++ lrp->inode = nfs_igrab_and_active(lrp->args.inode); + if (!sync) { +- lrp->inode = nfs_igrab_and_active(lrp->args.inode); + if (!lrp->inode) { + nfs4_layoutreturn_release(lrp); + return -EAGAIN; + } + task_setup_data.flags |= RPC_TASK_ASYNC; + } +- nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, 0); ++ if (!lrp->inode) ++ nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, ++ 1); ++ else ++ nfs4_init_sequence(&lrp->args.seq_args, &lrp->res.seq_res, 1, ++ 0); + task = rpc_run_task(&task_setup_data); + if (IS_ERR(task)) + return PTR_ERR(task); +diff --git a/fs/proc/base.c b/fs/proc/base.c +index 297ea12b3cfd2..df9b17dd92cb3 100644 +--- a/fs/proc/base.c ++++ b/fs/proc/base.c +@@ -2675,6 +2675,13 @@ out: + } + + #ifdef CONFIG_SECURITY ++static int proc_pid_attr_open(struct inode *inode, struct file *file) ++{ ++ file->private_data = NULL; ++ __mem_open(inode, file, PTRACE_MODE_READ_FSCREDS); ++ return 0; ++} ++ + static ssize_t proc_pid_attr_read(struct file * file, char __user * buf, + size_t count, loff_t *ppos) + { +@@ -2705,7 +2712,7 @@ static ssize_t proc_pid_attr_write(struct file * file, const char __user * buf, + int rv; + + /* A task may only write when it was the opener. */ +- if (file->f_cred != current_real_cred()) ++ if (file->private_data != current->mm) + return -EPERM; + + rcu_read_lock(); +@@ -2755,9 +2762,11 @@ out: + } + + static const struct file_operations proc_pid_attr_operations = { ++ .open = proc_pid_attr_open, + .read = proc_pid_attr_read, + .write = proc_pid_attr_write, + .llseek = generic_file_llseek, ++ .release = mem_release, + }; + + #define LSM_DIR_OPS(LSM) \ +diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h +index d7efbc5490e8c..18468b46c4506 100644 +--- a/include/asm-generic/vmlinux.lds.h ++++ b/include/asm-generic/vmlinux.lds.h +@@ -971,6 +971,7 @@ + #ifdef CONFIG_AMD_MEM_ENCRYPT + #define PERCPU_DECRYPTED_SECTION \ + . = ALIGN(PAGE_SIZE); \ ++ *(.data..decrypted) \ + *(.data..percpu..decrypted) \ + . = ALIGN(PAGE_SIZE); + #else +diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h +index a2278b9ff57d2..c66c702a4f079 100644 +--- a/include/linux/kvm_host.h ++++ b/include/linux/kvm_host.h +@@ -1104,7 +1104,15 @@ __gfn_to_memslot(struct kvm_memslots *slots, gfn_t gfn) + static inline unsigned long + __gfn_to_hva_memslot(struct kvm_memory_slot *slot, gfn_t gfn) + { +- return slot->userspace_addr + (gfn - slot->base_gfn) * PAGE_SIZE; ++ /* ++ * The index was checked originally in search_memslots. To avoid ++ * that a malicious guest builds a Spectre gadget out of e.g. page ++ * table walks, do not let the processor speculate loads outside ++ * the guest's registered memslots. ++ */ ++ unsigned long offset = gfn - slot->base_gfn; ++ offset = array_index_nospec(offset, slot->npages); ++ return slot->userspace_addr + offset * PAGE_SIZE; + } + + static inline int memslot_id(struct kvm *kvm, gfn_t gfn) +diff --git a/include/linux/mfd/rohm-bd71828.h b/include/linux/mfd/rohm-bd71828.h +index 017a4c01cb315..61f0974c33d72 100644 +--- a/include/linux/mfd/rohm-bd71828.h ++++ b/include/linux/mfd/rohm-bd71828.h +@@ -26,11 +26,11 @@ enum { + BD71828_REGULATOR_AMOUNT, + }; + +-#define BD71828_BUCK1267_VOLTS 0xEF +-#define BD71828_BUCK3_VOLTS 0x10 +-#define BD71828_BUCK4_VOLTS 0x20 +-#define BD71828_BUCK5_VOLTS 0x10 +-#define BD71828_LDO_VOLTS 0x32 ++#define BD71828_BUCK1267_VOLTS 0x100 ++#define BD71828_BUCK3_VOLTS 0x20 ++#define BD71828_BUCK4_VOLTS 0x40 ++#define BD71828_BUCK5_VOLTS 0x20 ++#define BD71828_LDO_VOLTS 0x40 + /* LDO6 is fixed 1.8V voltage */ + #define BD71828_LDO_6_VOLTAGE 1800000 + +diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h +index 06e066e04a4bb..eb8169c03d899 100644 +--- a/include/linux/mlx4/device.h ++++ b/include/linux/mlx4/device.h +@@ -631,6 +631,7 @@ struct mlx4_caps { + bool wol_port[MLX4_MAX_PORTS + 1]; + struct mlx4_rate_limit_caps rl_caps; + u32 health_buffer_addrs; ++ bool map_clock_to_user; + }; + + struct mlx4_buf_list { +diff --git a/include/linux/sched.h b/include/linux/sched.h +index 76cd21fa55016..2660ee4b08adf 100644 +--- a/include/linux/sched.h ++++ b/include/linux/sched.h +@@ -348,11 +348,19 @@ struct load_weight { + * Only for tasks we track a moving average of the past instantaneous + * estimated utilization. This allows to absorb sporadic drops in utilization + * of an otherwise almost periodic task. ++ * ++ * The UTIL_AVG_UNCHANGED flag is used to synchronize util_est with util_avg ++ * updates. When a task is dequeued, its util_est should not be updated if its ++ * util_avg has not been updated in the meantime. ++ * This information is mapped into the MSB bit of util_est.enqueued at dequeue ++ * time. Since max value of util_est.enqueued for a task is 1024 (PELT util_avg ++ * for a task) it is safe to use MSB. + */ + struct util_est { + unsigned int enqueued; + unsigned int ewma; + #define UTIL_EST_WEIGHT_SHIFT 2 ++#define UTIL_AVG_UNCHANGED 0x80000000 + } __attribute__((__aligned__(sizeof(u64)))); + + /* +diff --git a/include/linux/usb/pd.h b/include/linux/usb/pd.h +index 3a805e2ecbc99..433040ff840a3 100644 +--- a/include/linux/usb/pd.h ++++ b/include/linux/usb/pd.h +@@ -459,7 +459,7 @@ static inline unsigned int rdo_max_power(u32 rdo) + #define PD_T_RECEIVER_RESPONSE 15 /* 15ms max */ + #define PD_T_SOURCE_ACTIVITY 45 + #define PD_T_SINK_ACTIVITY 135 +-#define PD_T_SINK_WAIT_CAP 240 ++#define PD_T_SINK_WAIT_CAP 310 /* 310 - 620 ms */ + #define PD_T_PS_TRANSITION 500 + #define PD_T_SRC_TRANSITION 35 + #define PD_T_DRP_SNK 40 +diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c +index ed7d02e8bc939..aaf2fbaa0cc76 100644 +--- a/kernel/bpf/btf.c ++++ b/kernel/bpf/btf.c +@@ -4960,6 +4960,12 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, + m->ret_size = ret; + + for (i = 0; i < nargs; i++) { ++ if (i == nargs - 1 && args[i].type == 0) { ++ bpf_log(log, ++ "The function %s with variable args is unsupported.\n", ++ tname); ++ return -EINVAL; ++ } + ret = __get_type_size(btf, args[i].type, &t); + if (ret < 0) { + bpf_log(log, +@@ -4967,6 +4973,12 @@ int btf_distill_func_proto(struct bpf_verifier_log *log, + tname, i, btf_kind_str[BTF_INFO_KIND(t->info)]); + return -EINVAL; + } ++ if (ret == 0) { ++ bpf_log(log, ++ "The function %s has malformed void argument.\n", ++ tname); ++ return -EINVAL; ++ } + m->arg_size[i] = ret; + } + m->nr_args = nargs; +diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c +index a5751784ad740..f6dddb3a8f4a2 100644 +--- a/kernel/cgroup/cgroup-v1.c ++++ b/kernel/cgroup/cgroup-v1.c +@@ -820,6 +820,10 @@ static int cgroup1_rename(struct kernfs_node *kn, struct kernfs_node *new_parent + struct cgroup *cgrp = kn->priv; + int ret; + ++ /* do not accept '\n' to prevent making /proc//cgroup unparsable */ ++ if (strchr(new_name_str, '\n')) ++ return -EINVAL; ++ + if (kernfs_type(kn) != KERNFS_DIR) + return -ENOTDIR; + if (kn->parent != new_parent) +diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c +index 5d1fdf7c3ec65..c8b811e039cc2 100644 +--- a/kernel/cgroup/cgroup.c ++++ b/kernel/cgroup/cgroup.c +@@ -5665,8 +5665,6 @@ int __init cgroup_init_early(void) + return 0; + } + +-static u16 cgroup_disable_mask __initdata; +- + /** + * cgroup_init - cgroup initialization + * +@@ -5725,12 +5723,8 @@ int __init cgroup_init(void) + * disabled flag and cftype registration needs kmalloc, + * both of which aren't available during early_init. + */ +- if (cgroup_disable_mask & (1 << ssid)) { +- static_branch_disable(cgroup_subsys_enabled_key[ssid]); +- printk(KERN_INFO "Disabling %s control group subsystem\n", +- ss->name); ++ if (!cgroup_ssid_enabled(ssid)) + continue; +- } + + if (cgroup1_ssid_disabled(ssid)) + printk(KERN_INFO "Disabling %s control group subsystem in v1 mounts\n", +@@ -6245,7 +6239,10 @@ static int __init cgroup_disable(char *str) + if (strcmp(token, ss->name) && + strcmp(token, ss->legacy_name)) + continue; +- cgroup_disable_mask |= 1 << i; ++ ++ static_branch_disable(cgroup_subsys_enabled_key[i]); ++ pr_info("Disabling %s control group subsystem\n", ++ ss->name); + } + } + return 1; +diff --git a/kernel/events/core.c b/kernel/events/core.c +index 45fa7167cee2d..7e0fdc19043e4 100644 +--- a/kernel/events/core.c ++++ b/kernel/events/core.c +@@ -4547,7 +4547,9 @@ find_get_context(struct pmu *pmu, struct task_struct *task, + cpuctx = per_cpu_ptr(pmu->pmu_cpu_context, cpu); + ctx = &cpuctx->ctx; + get_ctx(ctx); ++ raw_spin_lock_irqsave(&ctx->lock, flags); + ++ctx->pin_count; ++ raw_spin_unlock_irqrestore(&ctx->lock, flags); + + return ctx; + } +diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c +index 6264584b51c25..70a5782724363 100644 +--- a/kernel/sched/debug.c ++++ b/kernel/sched/debug.c +@@ -888,6 +888,7 @@ __initcall(init_sched_debug_procfs); + #define __PS(S, F) SEQ_printf(m, "%-45s:%21Ld\n", S, (long long)(F)) + #define __P(F) __PS(#F, F) + #define P(F) __PS(#F, p->F) ++#define PM(F, M) __PS(#F, p->F & (M)) + #define __PSN(S, F) SEQ_printf(m, "%-45s:%14Ld.%06ld\n", S, SPLIT_NS((long long)(F))) + #define __PN(F) __PSN(#F, F) + #define PN(F) __PSN(#F, p->F) +@@ -1014,7 +1015,7 @@ void proc_sched_show_task(struct task_struct *p, struct pid_namespace *ns, + P(se.avg.util_avg); + P(se.avg.last_update_time); + P(se.avg.util_est.ewma); +- P(se.avg.util_est.enqueued); ++ PM(se.avg.util_est.enqueued, ~UTIL_AVG_UNCHANGED); + #endif + #ifdef CONFIG_UCLAMP_TASK + __PS("uclamp.min", p->uclamp_req[UCLAMP_MIN].value); +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index 1ad0e52487f6b..ff8a172a69ca9 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -3501,10 +3501,9 @@ update_tg_cfs_runnable(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cf + static inline void + update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq *gcfs_rq) + { +- long delta_avg, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; ++ long delta, running_sum, runnable_sum = gcfs_rq->prop_runnable_sum; + unsigned long load_avg; + u64 load_sum = 0; +- s64 delta_sum; + u32 divider; + + if (!runnable_sum) +@@ -3551,13 +3550,13 @@ update_tg_cfs_load(struct cfs_rq *cfs_rq, struct sched_entity *se, struct cfs_rq + load_sum = (s64)se_weight(se) * runnable_sum; + load_avg = div_s64(load_sum, divider); + +- delta_sum = load_sum - (s64)se_weight(se) * se->avg.load_sum; +- delta_avg = load_avg - se->avg.load_avg; ++ delta = load_avg - se->avg.load_avg; + + se->avg.load_sum = runnable_sum; + se->avg.load_avg = load_avg; +- add_positive(&cfs_rq->avg.load_avg, delta_avg); +- add_positive(&cfs_rq->avg.load_sum, delta_sum); ++ ++ add_positive(&cfs_rq->avg.load_avg, delta); ++ cfs_rq->avg.load_sum = cfs_rq->avg.load_avg * divider; + } + + static inline void add_tg_cfs_propagate(struct cfs_rq *cfs_rq, long runnable_sum) +@@ -3904,7 +3903,7 @@ static inline unsigned long _task_util_est(struct task_struct *p) + { + struct util_est ue = READ_ONCE(p->se.avg.util_est); + +- return (max(ue.ewma, ue.enqueued) | UTIL_AVG_UNCHANGED); ++ return max(ue.ewma, (ue.enqueued & ~UTIL_AVG_UNCHANGED)); + } + + static inline unsigned long task_util_est(struct task_struct *p) +@@ -4004,7 +4003,7 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, + * Reset EWMA on utilization increases, the moving average is used only + * to smooth utilization decreases. + */ +- ue.enqueued = (task_util(p) | UTIL_AVG_UNCHANGED); ++ ue.enqueued = task_util(p); + if (sched_feat(UTIL_EST_FASTUP)) { + if (ue.ewma < ue.enqueued) { + ue.ewma = ue.enqueued; +@@ -4053,6 +4052,7 @@ static inline void util_est_update(struct cfs_rq *cfs_rq, + ue.ewma += last_ewma_diff; + ue.ewma >>= UTIL_EST_WEIGHT_SHIFT; + done: ++ ue.enqueued |= UTIL_AVG_UNCHANGED; + WRITE_ONCE(p->se.avg.util_est, ue); + + trace_sched_util_est_se_tp(&p->se); +@@ -7961,7 +7961,7 @@ static bool __update_blocked_fair(struct rq *rq, bool *done) + /* Propagate pending load changes to the parent, if any: */ + se = cfs_rq->tg->se[cpu]; + if (se && !skip_blocked_update(se)) +- update_load_avg(cfs_rq_of(se), se, 0); ++ update_load_avg(cfs_rq_of(se), se, UPDATE_TG); + + /* + * There can be a lot of idle CPU cgroups. Don't let fully +diff --git a/kernel/sched/pelt.h b/kernel/sched/pelt.h +index 795e43e02afc6..0b9aeebb9c325 100644 +--- a/kernel/sched/pelt.h ++++ b/kernel/sched/pelt.h +@@ -42,15 +42,6 @@ static inline u32 get_pelt_divider(struct sched_avg *avg) + return LOAD_AVG_MAX - 1024 + avg->period_contrib; + } + +-/* +- * When a task is dequeued, its estimated utilization should not be update if +- * its util_avg has not been updated at least once. +- * This flag is used to synchronize util_avg updates with util_est updates. +- * We map this information into the LSB bit of the utilization saved at +- * dequeue time (i.e. util_est.dequeued). +- */ +-#define UTIL_AVG_UNCHANGED 0x1 +- + static inline void cfs_se_util_change(struct sched_avg *avg) + { + unsigned int enqueued; +@@ -58,7 +49,7 @@ static inline void cfs_se_util_change(struct sched_avg *avg) + if (!sched_feat(UTIL_EST)) + return; + +- /* Avoid store if the flag has been already set */ ++ /* Avoid store if the flag has been already reset */ + enqueued = avg->util_est.enqueued; + if (!(enqueued & UTIL_AVG_UNCHANGED)) + return; +diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c +index a6d15a3187d0e..30010614b9237 100644 +--- a/kernel/trace/ftrace.c ++++ b/kernel/trace/ftrace.c +@@ -1968,12 +1968,18 @@ static int ftrace_hash_ipmodify_update(struct ftrace_ops *ops, + + static void print_ip_ins(const char *fmt, const unsigned char *p) + { ++ char ins[MCOUNT_INSN_SIZE]; + int i; + ++ if (copy_from_kernel_nofault(ins, p, MCOUNT_INSN_SIZE)) { ++ printk(KERN_CONT "%s[FAULT] %px\n", fmt, p); ++ return; ++ } ++ + printk(KERN_CONT "%s", fmt); + + for (i = 0; i < MCOUNT_INSN_SIZE; i++) +- printk(KERN_CONT "%s%02x", i ? ":" : "", p[i]); ++ printk(KERN_CONT "%s%02x", i ? ":" : "", ins[i]); + } + + enum ftrace_bug_type ftrace_bug_type; +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 321f7f7a29b4b..b2c141eaca020 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2734,7 +2734,7 @@ trace_event_buffer_lock_reserve(struct trace_buffer **current_rb, + (entry = this_cpu_read(trace_buffered_event))) { + /* Try to use the per cpu buffer first */ + val = this_cpu_inc_return(trace_buffered_event_cnt); +- if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) { ++ if ((len < (PAGE_SIZE - sizeof(*entry) - sizeof(entry->array[0]))) && val == 1) { + trace_event_setup(entry, type, flags, pc); + entry->array[0] = len; + return entry; +diff --git a/kernel/workqueue.c b/kernel/workqueue.c +index 1e2ca744dadbe..b23f7d1044be7 100644 +--- a/kernel/workqueue.c ++++ b/kernel/workqueue.c +@@ -50,6 +50,7 @@ + #include + #include + #include ++#include + + #include "workqueue_internal.h" + +@@ -5758,6 +5759,7 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) + { + unsigned long thresh = READ_ONCE(wq_watchdog_thresh) * HZ; + bool lockup_detected = false; ++ unsigned long now = jiffies; + struct worker_pool *pool; + int pi; + +@@ -5772,6 +5774,12 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) + if (list_empty(&pool->worklist)) + continue; + ++ /* ++ * If a virtual machine is stopped by the host it can look to ++ * the watchdog like a stall. ++ */ ++ kvm_check_and_clear_guest_paused(); ++ + /* get the latest of pool and touched timestamps */ + pool_ts = READ_ONCE(pool->watchdog_ts); + touched = READ_ONCE(wq_watchdog_touched); +@@ -5790,12 +5798,12 @@ static void wq_watchdog_timer_fn(struct timer_list *unused) + } + + /* did we stall? */ +- if (time_after(jiffies, ts + thresh)) { ++ if (time_after(now, ts + thresh)) { + lockup_detected = true; + pr_emerg("BUG: workqueue lockup - pool"); + pr_cont_pool_info(pool); + pr_cont(" stuck for %us!\n", +- jiffies_to_msecs(jiffies - pool_ts) / 1000); ++ jiffies_to_msecs(now - pool_ts) / 1000); + } + } + +diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c +index daca50d6bb128..e527f5686e2bf 100644 +--- a/net/netlink/af_netlink.c ++++ b/net/netlink/af_netlink.c +@@ -453,11 +453,13 @@ void netlink_table_ungrab(void) + static inline void + netlink_lock_table(void) + { ++ unsigned long flags; ++ + /* read_lock() synchronizes us to netlink_table_grab */ + +- read_lock(&nl_table_lock); ++ read_lock_irqsave(&nl_table_lock, flags); + atomic_inc(&nl_table_users); +- read_unlock(&nl_table_lock); ++ read_unlock_irqrestore(&nl_table_lock, flags); + } + + static inline void +diff --git a/net/nfc/rawsock.c b/net/nfc/rawsock.c +index 9c7eb8455ba8e..5f1d438a0a23f 100644 +--- a/net/nfc/rawsock.c ++++ b/net/nfc/rawsock.c +@@ -329,7 +329,7 @@ static int rawsock_create(struct net *net, struct socket *sock, + return -ESOCKTNOSUPPORT; + + if (sock->type == SOCK_RAW) { +- if (!capable(CAP_NET_RAW)) ++ if (!ns_capable(net->user_ns, CAP_NET_RAW)) + return -EPERM; + sock->ops = &rawsock_raw_ops; + } else { +diff --git a/net/rds/connection.c b/net/rds/connection.c +index f2fcab182095c..a3bc4b54d4910 100644 +--- a/net/rds/connection.c ++++ b/net/rds/connection.c +@@ -240,12 +240,23 @@ static struct rds_connection *__rds_conn_create(struct net *net, + if (loop_trans) { + rds_trans_put(loop_trans); + conn->c_loopback = 1; +- if (is_outgoing && trans->t_prefer_loopback) { +- /* "outgoing" connection - and the transport +- * says it wants the connection handled by the +- * loopback transport. This is what TCP does. +- */ +- trans = &rds_loop_transport; ++ if (trans->t_prefer_loopback) { ++ if (likely(is_outgoing)) { ++ /* "outgoing" connection to local address. ++ * Protocol says it wants the connection ++ * handled by the loopback transport. ++ * This is what TCP does. ++ */ ++ trans = &rds_loop_transport; ++ } else { ++ /* No transport currently in use ++ * should end up here, but if it ++ * does, reset/destroy the connection. ++ */ ++ kmem_cache_free(rds_conn_slab, conn); ++ conn = ERR_PTR(-EOPNOTSUPP); ++ goto out; ++ } + } + } + +diff --git a/net/rds/tcp.c b/net/rds/tcp.c +index 43db0eca911fa..abf19c0e3ba0b 100644 +--- a/net/rds/tcp.c ++++ b/net/rds/tcp.c +@@ -313,8 +313,8 @@ out: + } + #endif + +-static int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, +- __u32 scope_id) ++int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, ++ __u32 scope_id) + { + struct net_device *dev = NULL; + #if IS_ENABLED(CONFIG_IPV6) +diff --git a/net/rds/tcp.h b/net/rds/tcp.h +index bad9cf49d5657..dc8d745d68575 100644 +--- a/net/rds/tcp.h ++++ b/net/rds/tcp.h +@@ -59,7 +59,8 @@ u32 rds_tcp_snd_una(struct rds_tcp_connection *tc); + u64 rds_tcp_map_seq(struct rds_tcp_connection *tc, u32 seq); + extern struct rds_transport rds_tcp_transport; + void rds_tcp_accept_work(struct sock *sk); +- ++int rds_tcp_laddr_check(struct net *net, const struct in6_addr *addr, ++ __u32 scope_id); + /* tcp_connect.c */ + int rds_tcp_conn_path_connect(struct rds_conn_path *cp); + void rds_tcp_conn_path_shutdown(struct rds_conn_path *conn); +diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c +index 101cf14215a0b..09cadd556d1e1 100644 +--- a/net/rds/tcp_listen.c ++++ b/net/rds/tcp_listen.c +@@ -167,6 +167,12 @@ int rds_tcp_accept_one(struct socket *sock) + } + #endif + ++ if (!rds_tcp_laddr_check(sock_net(sock->sk), peer_addr, dev_if)) { ++ /* local address connection is only allowed via loopback */ ++ ret = -EOPNOTSUPP; ++ goto out; ++ } ++ + conn = rds_conn_create(sock_net(sock->sk), + my_addr, peer_addr, + &rds_tcp_transport, 0, GFP_KERNEL, dev_if); +diff --git a/sound/core/seq/seq_timer.c b/sound/core/seq/seq_timer.c +index 1645e4142e302..9863be6fd43e1 100644 +--- a/sound/core/seq/seq_timer.c ++++ b/sound/core/seq/seq_timer.c +@@ -297,8 +297,16 @@ int snd_seq_timer_open(struct snd_seq_queue *q) + return err; + } + spin_lock_irq(&tmr->lock); +- tmr->timeri = t; ++ if (tmr->timeri) ++ err = -EBUSY; ++ else ++ tmr->timeri = t; + spin_unlock_irq(&tmr->lock); ++ if (err < 0) { ++ snd_timer_close(t); ++ snd_timer_instance_free(t); ++ return err; ++ } + return 0; + } + +diff --git a/sound/firewire/amdtp-stream.c b/sound/firewire/amdtp-stream.c +index e0faa6601966c..5805c5de39fbf 100644 +--- a/sound/firewire/amdtp-stream.c ++++ b/sound/firewire/amdtp-stream.c +@@ -804,7 +804,7 @@ static void generate_pkt_descs(struct amdtp_stream *s, struct pkt_desc *descs, + static inline void cancel_stream(struct amdtp_stream *s) + { + s->packet_index = -1; +- if (current_work() == &s->period_work) ++ if (in_interrupt()) + amdtp_stream_pcm_abort(s); + WRITE_ONCE(s->pcm_buffer_pointer, SNDRV_PCM_POS_XRUN); + } +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index cc13a68197f3c..e46e43dac6bfd 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -6560,6 +6560,7 @@ enum { + ALC285_FIXUP_HP_SPECTRE_X360, + ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, + ALC623_FIXUP_LENOVO_THINKSTATION_P340, ++ ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, + }; + + static const struct hda_fixup alc269_fixups[] = { +@@ -8132,6 +8133,15 @@ static const struct hda_fixup alc269_fixups[] = { + .chained = true, + .chain_id = ALC283_FIXUP_HEADSET_MIC, + }, ++ [ALC255_FIXUP_ACER_HEADPHONE_AND_MIC] = { ++ .type = HDA_FIXUP_PINS, ++ .v.pins = (const struct hda_pintbl[]) { ++ { 0x21, 0x03211030 }, /* Change the Headphone location to Left */ ++ { } ++ }, ++ .chained = true, ++ .chain_id = ALC255_FIXUP_XIAOMI_HEADSET_MIC ++ }, + }; + + static const struct snd_pci_quirk alc269_fixup_tbl[] = { +@@ -8168,6 +8178,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x1025, 0x132a, "Acer TravelMate B114-21", ALC233_FIXUP_ACER_HEADSET_MIC), + SND_PCI_QUIRK(0x1025, 0x1330, "Acer TravelMate X514-51T", ALC255_FIXUP_ACER_HEADSET_MIC), + SND_PCI_QUIRK(0x1025, 0x1430, "Acer TravelMate B311R-31", ALC256_FIXUP_ACER_MIC_NO_PRESENCE), ++ SND_PCI_QUIRK(0x1025, 0x1466, "Acer Aspire A515-56", ALC255_FIXUP_ACER_HEADPHONE_AND_MIC), + SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z), + SND_PCI_QUIRK(0x1028, 0x054b, "Dell XPS one 2710", ALC275_FIXUP_DELL_XPS), + SND_PCI_QUIRK(0x1028, 0x05bd, "Dell Latitude E6440", ALC292_FIXUP_DELL_E7X), +@@ -8296,6 +8307,8 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x8519, "HP Spectre x360 15-df0xxx", ALC285_FIXUP_HP_SPECTRE_X360), + SND_PCI_QUIRK(0x103c, 0x869d, "HP", ALC236_FIXUP_HP_MUTE_LED), + SND_PCI_QUIRK(0x103c, 0x86c7, "HP Envy AiO 32", ALC274_FIXUP_HP_ENVY_GPIO), ++ SND_PCI_QUIRK(0x103c, 0x8716, "HP Elite Dragonfly G2 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), ++ SND_PCI_QUIRK(0x103c, 0x8720, "HP EliteBook x360 1040 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), + SND_PCI_QUIRK(0x103c, 0x8724, "HP EliteBook 850 G7", ALC285_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8729, "HP", ALC285_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8730, "HP ProBook 445 G7", ALC236_FIXUP_HP_MUTE_LED_MICMUTE_VREF), +@@ -8314,10 +8327,12 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x103c, 0x87f5, "HP", ALC287_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x87f7, "HP Spectre x360 14", ALC245_FIXUP_HP_X360_AMP), + SND_PCI_QUIRK(0x103c, 0x8846, "HP EliteBook 850 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), ++ SND_PCI_QUIRK(0x103c, 0x884b, "HP EliteBook 840 Aero G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x884c, "HP EliteBook 840 G8 Notebook PC", ALC285_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x886d, "HP ZBook Fury 17.3 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), + SND_PCI_QUIRK(0x103c, 0x8870, "HP ZBook Fury 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), + SND_PCI_QUIRK(0x103c, 0x8873, "HP ZBook Studio 15.6 Inch G8 Mobile Workstation PC", ALC285_FIXUP_HP_GPIO_AMP_INIT), ++ SND_PCI_QUIRK(0x103c, 0x888d, "HP ZBook Power 15.6 inch G8 Mobile Workstation PC", ALC236_FIXUP_HP_GPIO_LED), + SND_PCI_QUIRK(0x103c, 0x8896, "HP EliteBook 855 G8 Notebook PC", ALC285_FIXUP_HP_MUTE_LED), + SND_PCI_QUIRK(0x1043, 0x103e, "ASUS X540SA", ALC256_FIXUP_ASUS_MIC), + SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300), +@@ -8722,6 +8737,7 @@ static const struct hda_model_fixup alc269_fixup_models[] = { + {.id = ALC285_FIXUP_HP_SPECTRE_X360, .name = "alc285-hp-spectre-x360"}, + {.id = ALC287_FIXUP_IDEAPAD_BASS_SPK_AMP, .name = "alc287-ideapad-bass-spk-amp"}, + {.id = ALC623_FIXUP_LENOVO_THINKSTATION_P340, .name = "alc623-lenovo-thinkstation-p340"}, ++ {.id = ALC255_FIXUP_ACER_HEADPHONE_AND_MIC, .name = "alc255-acer-headphone-and-mic"}, + {} + }; + #define ALC225_STANDARD_PINS \ +diff --git a/sound/soc/amd/raven/acp3x-pcm-dma.c b/sound/soc/amd/raven/acp3x-pcm-dma.c +index 417cda24030cd..2447a1e6e913f 100644 +--- a/sound/soc/amd/raven/acp3x-pcm-dma.c ++++ b/sound/soc/amd/raven/acp3x-pcm-dma.c +@@ -237,10 +237,6 @@ static int acp3x_dma_open(struct snd_soc_component *component, + return ret; + } + +- if (!adata->play_stream && !adata->capture_stream && +- !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) +- rv_writel(1, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); +- + i2s_data->acp3x_base = adata->acp3x_base; + runtime->private_data = i2s_data; + return ret; +@@ -367,12 +363,6 @@ static int acp3x_dma_close(struct snd_soc_component *component, + } + } + +- /* Disable ACP irq, when the current stream is being closed and +- * another stream is also not active. +- */ +- if (!adata->play_stream && !adata->capture_stream && +- !adata->i2ssp_play_stream && !adata->i2ssp_capture_stream) +- rv_writel(0, adata->acp3x_base + mmACP_EXTERNAL_INTR_ENB); + return 0; + } + +diff --git a/sound/soc/amd/raven/acp3x.h b/sound/soc/amd/raven/acp3x.h +index 03fe93913e12e..c3f0c8b7545db 100644 +--- a/sound/soc/amd/raven/acp3x.h ++++ b/sound/soc/amd/raven/acp3x.h +@@ -77,6 +77,7 @@ + #define ACP_POWER_OFF_IN_PROGRESS 0x03 + + #define ACP3x_ITER_IRER_SAMP_LEN_MASK 0x38 ++#define ACP_EXT_INTR_STAT_CLEAR_MASK 0xFFFFFFFF + + struct acp3x_platform_info { + u16 play_i2s_instance; +diff --git a/sound/soc/amd/raven/pci-acp3x.c b/sound/soc/amd/raven/pci-acp3x.c +index 77f2d93896067..df83d2ce75ea7 100644 +--- a/sound/soc/amd/raven/pci-acp3x.c ++++ b/sound/soc/amd/raven/pci-acp3x.c +@@ -76,6 +76,19 @@ static int acp3x_reset(void __iomem *acp3x_base) + return -ETIMEDOUT; + } + ++static void acp3x_enable_interrupts(void __iomem *acp_base) ++{ ++ rv_writel(0x01, acp_base + mmACP_EXTERNAL_INTR_ENB); ++} ++ ++static void acp3x_disable_interrupts(void __iomem *acp_base) ++{ ++ rv_writel(ACP_EXT_INTR_STAT_CLEAR_MASK, acp_base + ++ mmACP_EXTERNAL_INTR_STAT); ++ rv_writel(0x00, acp_base + mmACP_EXTERNAL_INTR_CNTL); ++ rv_writel(0x00, acp_base + mmACP_EXTERNAL_INTR_ENB); ++} ++ + static int acp3x_init(struct acp3x_dev_data *adata) + { + void __iomem *acp3x_base = adata->acp3x_base; +@@ -93,6 +106,7 @@ static int acp3x_init(struct acp3x_dev_data *adata) + pr_err("ACP3x reset failed\n"); + return ret; + } ++ acp3x_enable_interrupts(acp3x_base); + return 0; + } + +@@ -100,6 +114,7 @@ static int acp3x_deinit(void __iomem *acp3x_base) + { + int ret; + ++ acp3x_disable_interrupts(acp3x_base); + /* Reset */ + ret = acp3x_reset(acp3x_base); + if (ret) { +diff --git a/sound/soc/codecs/max98088.c b/sound/soc/codecs/max98088.c +index 4be24e7f51c89..f8e49e45ce33f 100644 +--- a/sound/soc/codecs/max98088.c ++++ b/sound/soc/codecs/max98088.c +@@ -41,6 +41,7 @@ struct max98088_priv { + enum max98088_type devtype; + struct max98088_pdata *pdata; + struct clk *mclk; ++ unsigned char mclk_prescaler; + unsigned int sysclk; + struct max98088_cdata dai[2]; + int eq_textcnt; +@@ -998,13 +999,16 @@ static int max98088_dai1_hw_params(struct snd_pcm_substream *substream, + /* Configure NI when operating as master */ + if (snd_soc_component_read(component, M98088_REG_14_DAI1_FORMAT) + & M98088_DAI_MAS) { ++ unsigned long pclk; ++ + if (max98088->sysclk == 0) { + dev_err(component->dev, "Invalid system clock frequency\n"); + return -EINVAL; + } + ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) + * (unsigned long long int)rate; +- do_div(ni, (unsigned long long int)max98088->sysclk); ++ pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); ++ ni = DIV_ROUND_CLOSEST_ULL(ni, pclk); + snd_soc_component_write(component, M98088_REG_12_DAI1_CLKCFG_HI, + (ni >> 8) & 0x7F); + snd_soc_component_write(component, M98088_REG_13_DAI1_CLKCFG_LO, +@@ -1065,13 +1069,16 @@ static int max98088_dai2_hw_params(struct snd_pcm_substream *substream, + /* Configure NI when operating as master */ + if (snd_soc_component_read(component, M98088_REG_1C_DAI2_FORMAT) + & M98088_DAI_MAS) { ++ unsigned long pclk; ++ + if (max98088->sysclk == 0) { + dev_err(component->dev, "Invalid system clock frequency\n"); + return -EINVAL; + } + ni = 65536ULL * (rate < 50000 ? 96ULL : 48ULL) + * (unsigned long long int)rate; +- do_div(ni, (unsigned long long int)max98088->sysclk); ++ pclk = DIV_ROUND_CLOSEST(max98088->sysclk, max98088->mclk_prescaler); ++ ni = DIV_ROUND_CLOSEST_ULL(ni, pclk); + snd_soc_component_write(component, M98088_REG_1A_DAI2_CLKCFG_HI, + (ni >> 8) & 0x7F); + snd_soc_component_write(component, M98088_REG_1B_DAI2_CLKCFG_LO, +@@ -1113,8 +1120,10 @@ static int max98088_dai_set_sysclk(struct snd_soc_dai *dai, + */ + if ((freq >= 10000000) && (freq < 20000000)) { + snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x10); ++ max98088->mclk_prescaler = 1; + } else if ((freq >= 20000000) && (freq < 30000000)) { + snd_soc_component_write(component, M98088_REG_10_SYS_CLK, 0x20); ++ max98088->mclk_prescaler = 2; + } else { + dev_err(component->dev, "Invalid master clock frequency\n"); + return -EINVAL; +diff --git a/sound/soc/codecs/sti-sas.c b/sound/soc/codecs/sti-sas.c +index ec9933b054ad3..423daac9d5a9f 100644 +--- a/sound/soc/codecs/sti-sas.c ++++ b/sound/soc/codecs/sti-sas.c +@@ -411,6 +411,7 @@ static const struct of_device_id sti_sas_dev_match[] = { + }, + {}, + }; ++MODULE_DEVICE_TABLE(of, sti_sas_dev_match); + + static int sti_sas_driver_probe(struct platform_device *pdev) + { +diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c +index 1ef0464249d1b..ca14730232ba9 100644 +--- a/sound/soc/intel/boards/bytcr_rt5640.c ++++ b/sound/soc/intel/boards/bytcr_rt5640.c +@@ -570,6 +570,17 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { + BYT_RT5640_SSP0_AIF1 | + BYT_RT5640_MCLK_EN), + }, ++ { /* Glavey TM800A550L */ ++ .matches = { ++ DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), ++ DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), ++ /* Above strings are too generic, also match on BIOS version */ ++ DMI_MATCH(DMI_BIOS_VERSION, "ZY-8-BI-PX4S70VTR400-X423B-005-D"), ++ }, ++ .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | ++ BYT_RT5640_SSP0_AIF1 | ++ BYT_RT5640_MCLK_EN), ++ }, + { + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), +@@ -648,6 +659,20 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { + BYT_RT5640_MONO_SPEAKER | + BYT_RT5640_MCLK_EN), + }, ++ { /* Lenovo Miix 3-830 */ ++ .matches = { ++ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_EXACT_MATCH(DMI_PRODUCT_VERSION, "Lenovo MIIX 3-830"), ++ }, ++ .driver_data = (void *)(BYT_RT5640_IN1_MAP | ++ BYT_RT5640_JD_SRC_JD2_IN4N | ++ BYT_RT5640_OVCD_TH_2000UA | ++ BYT_RT5640_OVCD_SF_0P75 | ++ BYT_RT5640_MONO_SPEAKER | ++ BYT_RT5640_DIFF_MIC | ++ BYT_RT5640_SSP0_AIF1 | ++ BYT_RT5640_MCLK_EN), ++ }, + { /* Linx Linx7 tablet */ + .matches = { + DMI_EXACT_MATCH(DMI_SYS_VENDOR, "LINX"), +diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c +index bf65cba232e67..b22674e3a89c9 100644 +--- a/sound/soc/soc-core.c ++++ b/sound/soc/soc-core.c +@@ -2231,6 +2231,8 @@ static char *fmt_single_name(struct device *dev, int *id) + return NULL; + + name = devm_kstrdup(dev, devname, GFP_KERNEL); ++ if (!name) ++ return NULL; + + /* are we a "%s.%d" name (platform and SPI components) */ + found = strstr(name, dev->driver->name); +diff --git a/tools/bootconfig/main.c b/tools/bootconfig/main.c +index 7362bef1a3683..6cd6080cac04c 100644 +--- a/tools/bootconfig/main.c ++++ b/tools/bootconfig/main.c +@@ -399,6 +399,7 @@ static int apply_xbc(const char *path, const char *xbc_path) + } + /* TODO: Ensure the @path is initramfs/initrd image */ + if (fstat(fd, &stat) < 0) { ++ ret = -errno; + pr_err("Failed to get the size of %s\n", path); + goto out; + } +diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c +index 63b619084b34a..9dddec19a494e 100644 +--- a/tools/perf/util/session.c ++++ b/tools/perf/util/session.c +@@ -1699,6 +1699,7 @@ int perf_session__peek_event(struct perf_session *session, off_t file_offset, + if (event->header.size < hdr_sz || event->header.size > buf_sz) + return -1; + ++ buf += hdr_sz; + rest = event->header.size - hdr_sz; + + if (readn(fd, buf, rest) != (ssize_t)rest) diff --git a/patch/kernel/archive/sunxi-5.10/patch-5.10.44-45.patch b/patch/kernel/archive/sunxi-5.10/patch-5.10.44-45.patch new file mode 100644 index 000000000..d41c3c12f --- /dev/null +++ b/patch/kernel/archive/sunxi-5.10/patch-5.10.44-45.patch @@ -0,0 +1,1077 @@ +diff --git a/Makefile b/Makefile +index ae33e048eb8db..808b68483002f 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 10 +-SUBLEVEL = 44 ++SUBLEVEL = 45 + EXTRAVERSION = + NAME = Dare mighty things + +diff --git a/arch/arm/mach-omap1/pm.c b/arch/arm/mach-omap1/pm.c +index 2c1e2b32b9b36..a745d64d46995 100644 +--- a/arch/arm/mach-omap1/pm.c ++++ b/arch/arm/mach-omap1/pm.c +@@ -655,9 +655,13 @@ static int __init omap_pm_init(void) + irq = INT_7XX_WAKE_UP_REQ; + else if (cpu_is_omap16xx()) + irq = INT_1610_WAKE_UP_REQ; +- if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup", +- NULL)) +- pr_err("Failed to request irq %d (peripheral wakeup)\n", irq); ++ else ++ irq = -1; ++ ++ if (irq >= 0) { ++ if (request_irq(irq, omap_wakeup_interrupt, 0, "peripheral wakeup", NULL)) ++ pr_err("Failed to request irq %d (peripheral wakeup)\n", irq); ++ } + + /* Program new power ramp-up time + * (0 for most boards since we don't lower voltage when in deep sleep) +diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c +index 418a61ecb8275..5e86145db0e2a 100644 +--- a/arch/arm/mach-omap2/board-n8x0.c ++++ b/arch/arm/mach-omap2/board-n8x0.c +@@ -322,6 +322,7 @@ static int n8x0_mmc_get_cover_state(struct device *dev, int slot) + + static void n8x0_mmc_callback(void *data, u8 card_mask) + { ++#ifdef CONFIG_MMC_OMAP + int bit, *openp, index; + + if (board_is_n800()) { +@@ -339,7 +340,6 @@ static void n8x0_mmc_callback(void *data, u8 card_mask) + else + *openp = 0; + +-#ifdef CONFIG_MMC_OMAP + omap_mmc_notify_cover_event(mmc_device, index, *openp); + #else + pr_warn("MMC: notify cover event not available\n"); +diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile +index 0289a97325d12..e241e0e85ac81 100644 +--- a/arch/riscv/Makefile ++++ b/arch/riscv/Makefile +@@ -36,6 +36,15 @@ else + KBUILD_LDFLAGS += -melf32lriscv + endif + ++ifeq ($(CONFIG_LD_IS_LLD),y) ++ KBUILD_CFLAGS += -mno-relax ++ KBUILD_AFLAGS += -mno-relax ++ifneq ($(LLVM_IAS),1) ++ KBUILD_CFLAGS += -Wa,-mno-relax ++ KBUILD_AFLAGS += -Wa,-mno-relax ++endif ++endif ++ + # ISA string setting + riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima + riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima +diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c +index 175cb1c0d5698..b1f0b13cc8bc6 100644 +--- a/drivers/bluetooth/btusb.c ++++ b/drivers/bluetooth/btusb.c +@@ -385,6 +385,8 @@ static const struct usb_device_id blacklist_table[] = { + /* Realtek 8822CE Bluetooth devices */ + { USB_DEVICE(0x0bda, 0xb00c), .driver_info = BTUSB_REALTEK | + BTUSB_WIDEBAND_SPEECH }, ++ { USB_DEVICE(0x0bda, 0xc822), .driver_info = BTUSB_REALTEK | ++ BTUSB_WIDEBAND_SPEECH }, + + /* Realtek Bluetooth devices */ + { USB_VENDOR_AND_INTERFACE_INFO(0x0bda, 0xe0, 0x01, 0x01), +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +index 8f4a8f8d81463..39b6c6bfab453 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c +@@ -101,7 +101,8 @@ static int amdgpu_fru_read_eeprom(struct amdgpu_device *adev, uint32_t addrptr, + int amdgpu_fru_get_product_info(struct amdgpu_device *adev) + { + unsigned char buff[34]; +- int addrptr = 0, size = 0; ++ int addrptr, size; ++ int len; + + if (!is_fru_eeprom_supported(adev)) + return 0; +@@ -109,7 +110,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) + /* If algo exists, it means that the i2c_adapter's initialized */ + if (!adev->pm.smu_i2c.algo) { + DRM_WARN("Cannot access FRU, EEPROM accessor not initialized"); +- return 0; ++ return -ENODEV; + } + + /* There's a lot of repetition here. This is due to the FRU having +@@ -128,7 +129,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) + size = amdgpu_fru_read_eeprom(adev, addrptr, buff); + if (size < 1) { + DRM_ERROR("Failed to read FRU Manufacturer, ret:%d", size); +- return size; ++ return -EINVAL; + } + + /* Increment the addrptr by the size of the field, and 1 due to the +@@ -138,43 +139,45 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) + size = amdgpu_fru_read_eeprom(adev, addrptr, buff); + if (size < 1) { + DRM_ERROR("Failed to read FRU product name, ret:%d", size); +- return size; ++ return -EINVAL; + } + ++ len = size; + /* Product name should only be 32 characters. Any more, + * and something could be wrong. Cap it at 32 to be safe + */ +- if (size > 32) { ++ if (len >= sizeof(adev->product_name)) { + DRM_WARN("FRU Product Number is larger than 32 characters. This is likely a mistake"); +- size = 32; ++ len = sizeof(adev->product_name) - 1; + } + /* Start at 2 due to buff using fields 0 and 1 for the address */ +- memcpy(adev->product_name, &buff[2], size); +- adev->product_name[size] = '\0'; ++ memcpy(adev->product_name, &buff[2], len); ++ adev->product_name[len] = '\0'; + + addrptr += size + 1; + size = amdgpu_fru_read_eeprom(adev, addrptr, buff); + if (size < 1) { + DRM_ERROR("Failed to read FRU product number, ret:%d", size); +- return size; ++ return -EINVAL; + } + ++ len = size; + /* Product number should only be 16 characters. Any more, + * and something could be wrong. Cap it at 16 to be safe + */ +- if (size > 16) { ++ if (len >= sizeof(adev->product_number)) { + DRM_WARN("FRU Product Number is larger than 16 characters. This is likely a mistake"); +- size = 16; ++ len = sizeof(adev->product_number) - 1; + } +- memcpy(adev->product_number, &buff[2], size); +- adev->product_number[size] = '\0'; ++ memcpy(adev->product_number, &buff[2], len); ++ adev->product_number[len] = '\0'; + + addrptr += size + 1; + size = amdgpu_fru_read_eeprom(adev, addrptr, buff); + + if (size < 1) { + DRM_ERROR("Failed to read FRU product version, ret:%d", size); +- return size; ++ return -EINVAL; + } + + addrptr += size + 1; +@@ -182,18 +185,19 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev) + + if (size < 1) { + DRM_ERROR("Failed to read FRU serial number, ret:%d", size); +- return size; ++ return -EINVAL; + } + ++ len = size; + /* Serial number should only be 16 characters. Any more, + * and something could be wrong. Cap it at 16 to be safe + */ +- if (size > 16) { ++ if (len >= sizeof(adev->serial)) { + DRM_WARN("FRU Serial Number is larger than 16 characters. This is likely a mistake"); +- size = 16; ++ len = sizeof(adev->serial) - 1; + } +- memcpy(adev->serial, &buff[2], size); +- adev->serial[size] = '\0'; ++ memcpy(adev->serial, &buff[2], len); ++ adev->serial[len] = '\0'; + + return 0; + } +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +index 919d2fb7427b1..60b7563f4c05d 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_psp.h +@@ -73,6 +73,7 @@ struct psp_ring + uint64_t ring_mem_mc_addr; + void *ring_mem_handle; + uint32_t ring_size; ++ uint32_t ring_wptr; + }; + + /* More registers may will be supported */ +diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +index 6c5d9612abcb6..cb764b5545527 100644 +--- a/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/psp_v11_0.c +@@ -732,7 +732,7 @@ static uint32_t psp_v11_0_ring_get_wptr(struct psp_context *psp) + struct amdgpu_device *adev = psp->adev; + + if (amdgpu_sriov_vf(adev)) +- data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102); ++ data = psp->km_ring.ring_wptr; + else + data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67); + +@@ -746,6 +746,7 @@ static void psp_v11_0_ring_set_wptr(struct psp_context *psp, uint32_t value) + if (amdgpu_sriov_vf(adev)) { + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102, value); + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101, GFX_CTRL_CMD_ID_CONSUME_CMD); ++ psp->km_ring.ring_wptr = value; + } else + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67, value); + } +diff --git a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +index f2e725f72d2f1..908664a5774bb 100644 +--- a/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c ++++ b/drivers/gpu/drm/amd/amdgpu/psp_v3_1.c +@@ -379,7 +379,7 @@ static uint32_t psp_v3_1_ring_get_wptr(struct psp_context *psp) + struct amdgpu_device *adev = psp->adev; + + if (amdgpu_sriov_vf(adev)) +- data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_102); ++ data = psp->km_ring.ring_wptr; + else + data = RREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67); + return data; +@@ -394,6 +394,7 @@ static void psp_v3_1_ring_set_wptr(struct psp_context *psp, uint32_t value) + /* send interrupt to PSP for SRIOV ring write pointer update */ + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_101, + GFX_CTRL_CMD_ID_CONSUME_CMD); ++ psp->km_ring.ring_wptr = value; + } else + WREG32_SOC15(MP0, 0, mmMP0_SMN_C2PMSG_67, value); + } +diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +index fbbb1bde6b063..df26c07cb9120 100644 +--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c ++++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +@@ -870,7 +870,8 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev) + abm->dmcu_is_running = dmcu->funcs->is_dmcu_initialized(dmcu); + } + +- adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); ++ if (!adev->dm.dc->ctx->dmub_srv) ++ adev->dm.dc->ctx->dmub_srv = dc_dmub_srv_create(adev->dm.dc, dmub_srv); + if (!adev->dm.dc->ctx->dmub_srv) { + DRM_ERROR("Couldn't allocate DC DMUB server!\n"); + return -ENOMEM; +@@ -1755,7 +1756,6 @@ static int dm_suspend(void *handle) + + amdgpu_dm_irq_suspend(adev); + +- + dc_set_power_state(dm->dc, DC_ACPI_CM_POWER_STATE_D3); + + return 0; +diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +index 33488b3c5c3ce..1812ec7ee11bb 100644 +--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c ++++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c +@@ -3232,7 +3232,7 @@ static noinline bool dcn20_validate_bandwidth_fp(struct dc *dc, + voltage_supported = dcn20_validate_bandwidth_internal(dc, context, false); + dummy_pstate_supported = context->bw_ctx.bw.dcn.clk.p_state_change_support; + +- if (voltage_supported && dummy_pstate_supported) { ++ if (voltage_supported && (dummy_pstate_supported || !(context->stream_count))) { + context->bw_ctx.bw.dcn.clk.p_state_change_support = false; + goto restore_dml_state; + } +diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c +index 7b88261f57bb6..32c83f2e386ca 100644 +--- a/drivers/gpu/drm/tegra/sor.c ++++ b/drivers/gpu/drm/tegra/sor.c +@@ -3125,21 +3125,21 @@ static int tegra_sor_init(struct host1x_client *client) + if (err < 0) { + dev_err(sor->dev, "failed to acquire SOR reset: %d\n", + err); +- return err; ++ goto rpm_put; + } + + err = reset_control_assert(sor->rst); + if (err < 0) { + dev_err(sor->dev, "failed to assert SOR reset: %d\n", + err); +- return err; ++ goto rpm_put; + } + } + + err = clk_prepare_enable(sor->clk); + if (err < 0) { + dev_err(sor->dev, "failed to enable clock: %d\n", err); +- return err; ++ goto rpm_put; + } + + usleep_range(1000, 3000); +@@ -3150,7 +3150,7 @@ static int tegra_sor_init(struct host1x_client *client) + dev_err(sor->dev, "failed to deassert SOR reset: %d\n", + err); + clk_disable_unprepare(sor->clk); +- return err; ++ goto rpm_put; + } + + reset_control_release(sor->rst); +@@ -3171,6 +3171,12 @@ static int tegra_sor_init(struct host1x_client *client) + } + + return 0; ++ ++rpm_put: ++ if (sor->rst) ++ pm_runtime_put(sor->dev); ++ ++ return err; + } + + static int tegra_sor_exit(struct host1x_client *client) +@@ -3916,17 +3922,10 @@ static int tegra_sor_probe(struct platform_device *pdev) + platform_set_drvdata(pdev, sor); + pm_runtime_enable(&pdev->dev); + +- INIT_LIST_HEAD(&sor->client.list); ++ host1x_client_init(&sor->client); + sor->client.ops = &sor_client_ops; + sor->client.dev = &pdev->dev; + +- err = host1x_client_register(&sor->client); +- if (err < 0) { +- dev_err(&pdev->dev, "failed to register host1x client: %d\n", +- err); +- goto rpm_disable; +- } +- + /* + * On Tegra210 and earlier, provide our own implementation for the + * pad output clock. +@@ -3938,13 +3937,13 @@ static int tegra_sor_probe(struct platform_device *pdev) + sor->index); + if (!name) { + err = -ENOMEM; +- goto unregister; ++ goto uninit; + } + + err = host1x_client_resume(&sor->client); + if (err < 0) { + dev_err(sor->dev, "failed to resume: %d\n", err); +- goto unregister; ++ goto uninit; + } + + sor->clk_pad = tegra_clk_sor_pad_register(sor, name); +@@ -3955,14 +3954,20 @@ static int tegra_sor_probe(struct platform_device *pdev) + err = PTR_ERR(sor->clk_pad); + dev_err(sor->dev, "failed to register SOR pad clock: %d\n", + err); +- goto unregister; ++ goto uninit; ++ } ++ ++ err = __host1x_client_register(&sor->client); ++ if (err < 0) { ++ dev_err(&pdev->dev, "failed to register host1x client: %d\n", ++ err); ++ goto uninit; + } + + return 0; + +-unregister: +- host1x_client_unregister(&sor->client); +-rpm_disable: ++uninit: ++ host1x_client_exit(&sor->client); + pm_runtime_disable(&pdev->dev); + remove: + tegra_output_remove(&sor->output); +diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c +index 9e2cb6968819e..6e3b49d0de66d 100644 +--- a/drivers/gpu/host1x/bus.c ++++ b/drivers/gpu/host1x/bus.c +@@ -703,6 +703,29 @@ void host1x_driver_unregister(struct host1x_driver *driver) + } + EXPORT_SYMBOL(host1x_driver_unregister); + ++/** ++ * __host1x_client_init() - initialize a host1x client ++ * @client: host1x client ++ * @key: lock class key for the client-specific mutex ++ */ ++void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key) ++{ ++ INIT_LIST_HEAD(&client->list); ++ __mutex_init(&client->lock, "host1x client lock", key); ++ client->usecount = 0; ++} ++EXPORT_SYMBOL(__host1x_client_init); ++ ++/** ++ * host1x_client_exit() - uninitialize a host1x client ++ * @client: host1x client ++ */ ++void host1x_client_exit(struct host1x_client *client) ++{ ++ mutex_destroy(&client->lock); ++} ++EXPORT_SYMBOL(host1x_client_exit); ++ + /** + * __host1x_client_register() - register a host1x client + * @client: host1x client +@@ -715,16 +738,11 @@ EXPORT_SYMBOL(host1x_driver_unregister); + * device and call host1x_device_init(), which will in turn call each client's + * &host1x_client_ops.init implementation. + */ +-int __host1x_client_register(struct host1x_client *client, +- struct lock_class_key *key) ++int __host1x_client_register(struct host1x_client *client) + { + struct host1x *host1x; + int err; + +- INIT_LIST_HEAD(&client->list); +- __mutex_init(&client->lock, "host1x client lock", key); +- client->usecount = 0; +- + mutex_lock(&devices_lock); + + list_for_each_entry(host1x, &devices, list) { +diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig +index 9b56226ce0d1c..54bc563a8dff1 100644 +--- a/drivers/hid/Kconfig ++++ b/drivers/hid/Kconfig +@@ -93,11 +93,11 @@ menu "Special HID drivers" + depends on HID + + config HID_A4TECH +- tristate "A4 tech mice" ++ tristate "A4TECH mice" + depends on HID + default !EXPERT + help +- Support for A4 tech X5 and WOP-35 / Trust 450L mice. ++ Support for some A4TECH mice with two scroll wheels. + + config HID_ACCUTOUCH + tristate "Accutouch touch device" +diff --git a/drivers/hid/hid-a4tech.c b/drivers/hid/hid-a4tech.c +index 3a8c4a5971f70..2cbc32dda7f74 100644 +--- a/drivers/hid/hid-a4tech.c ++++ b/drivers/hid/hid-a4tech.c +@@ -147,6 +147,8 @@ static const struct hid_device_id a4_devices[] = { + .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649), + .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_NB_95), ++ .driver_data = A4_2WHEEL_MOUSE_HACK_B8 }, + { } + }; + MODULE_DEVICE_TABLE(hid, a4_devices); +diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c +index 097cb1ee31268..0f69f35f2957e 100644 +--- a/drivers/hid/hid-core.c ++++ b/drivers/hid/hid-core.c +@@ -2005,6 +2005,9 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask) + case BUS_I2C: + bus = "I2C"; + break; ++ case BUS_VIRTUAL: ++ bus = "VIRTUAL"; ++ break; + default: + bus = ""; + } +diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c +index d7eaf91003706..982737827b871 100644 +--- a/drivers/hid/hid-debug.c ++++ b/drivers/hid/hid-debug.c +@@ -929,6 +929,7 @@ static const char *keys[KEY_MAX + 1] = { + [KEY_APPSELECT] = "AppSelect", + [KEY_SCREENSAVER] = "ScreenSaver", + [KEY_VOICECOMMAND] = "VoiceCommand", ++ [KEY_EMOJI_PICKER] = "EmojiPicker", + [KEY_BRIGHTNESS_MIN] = "BrightnessMin", + [KEY_BRIGHTNESS_MAX] = "BrightnessMax", + [KEY_BRIGHTNESS_AUTO] = "BrightnessAuto", +diff --git a/drivers/hid/hid-gt683r.c b/drivers/hid/hid-gt683r.c +index 898871c8c768e..29ccb0accfba8 100644 +--- a/drivers/hid/hid-gt683r.c ++++ b/drivers/hid/hid-gt683r.c +@@ -54,6 +54,7 @@ static const struct hid_device_id gt683r_led_id[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) }, + { } + }; ++MODULE_DEVICE_TABLE(hid, gt683r_led_id); + + static void gt683r_brightness_set(struct led_classdev *led_cdev, + enum led_brightness brightness) +diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h +index e220a05a05b48..136b58a91c04c 100644 +--- a/drivers/hid/hid-ids.h ++++ b/drivers/hid/hid-ids.h +@@ -26,6 +26,7 @@ + #define USB_DEVICE_ID_A4TECH_WCP32PU 0x0006 + #define USB_DEVICE_ID_A4TECH_X5_005D 0x000a + #define USB_DEVICE_ID_A4TECH_RP_649 0x001a ++#define USB_DEVICE_ID_A4TECH_NB_95 0x022b + + #define USB_VENDOR_ID_AASHIMA 0x06d6 + #define USB_DEVICE_ID_AASHIMA_GAMEPAD 0x0025 +@@ -741,6 +742,7 @@ + #define USB_DEVICE_ID_LENOVO_X1_COVER 0x6085 + #define USB_DEVICE_ID_LENOVO_X1_TAB 0x60a3 + #define USB_DEVICE_ID_LENOVO_X1_TAB3 0x60b5 ++#define USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E 0x600e + #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D 0x608d + #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019 0x6019 + #define USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E 0x602e +@@ -1034,6 +1036,7 @@ + #define USB_DEVICE_ID_SAITEK_X52 0x075c + #define USB_DEVICE_ID_SAITEK_X52_2 0x0255 + #define USB_DEVICE_ID_SAITEK_X52_PRO 0x0762 ++#define USB_DEVICE_ID_SAITEK_X65 0x0b6a + + #define USB_VENDOR_ID_SAMSUNG 0x0419 + #define USB_DEVICE_ID_SAMSUNG_IR_REMOTE 0x0001 +diff --git a/drivers/hid/hid-input.c b/drivers/hid/hid-input.c +index 32024905fd70f..d1ab2dccf6fd7 100644 +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -957,6 +957,9 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel + + case 0x0cd: map_key_clear(KEY_PLAYPAUSE); break; + case 0x0cf: map_key_clear(KEY_VOICECOMMAND); break; ++ ++ case 0x0d9: map_key_clear(KEY_EMOJI_PICKER); break; ++ + case 0x0e0: map_abs_clear(ABS_VOLUME); break; + case 0x0e2: map_key_clear(KEY_MUTE); break; + case 0x0e5: map_key_clear(KEY_BASSBOOST); break; +diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c +index 8580ace596c25..e5a3704b9fe8f 100644 +--- a/drivers/hid/hid-multitouch.c ++++ b/drivers/hid/hid-multitouch.c +@@ -1580,13 +1580,13 @@ static int mt_input_configured(struct hid_device *hdev, struct hid_input *hi) + /* we do not set suffix = "Touchscreen" */ + hi->input->name = hdev->name; + break; +- case HID_DG_STYLUS: +- /* force BTN_STYLUS to allow tablet matching in udev */ +- __set_bit(BTN_STYLUS, hi->input->keybit); +- break; + case HID_VD_ASUS_CUSTOM_MEDIA_KEYS: + suffix = "Custom Media Keys"; + break; ++ case HID_DG_STYLUS: ++ /* force BTN_STYLUS to allow tablet matching in udev */ ++ __set_bit(BTN_STYLUS, hi->input->keybit); ++ fallthrough; + case HID_DG_PEN: + suffix = "Stylus"; + break; +diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c +index 2e38340e19dfb..be53c723c729d 100644 +--- a/drivers/hid/hid-quirks.c ++++ b/drivers/hid/hid-quirks.c +@@ -110,6 +110,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_PENSKETCH_M912), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_KYE_EASYPEN_M406XE), HID_QUIRK_MULTI_INPUT }, + { HID_USB_DEVICE(USB_VENDOR_ID_KYE, USB_DEVICE_ID_PIXART_USB_OPTICAL_MOUSE_ID2), HID_QUIRK_ALWAYS_POLL }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_OPTICAL_USB_MOUSE_600E), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_608D), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_6019), HID_QUIRK_ALWAYS_POLL }, + { HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, USB_DEVICE_ID_LENOVO_PIXART_USB_MOUSE_602E), HID_QUIRK_ALWAYS_POLL }, +@@ -158,6 +159,7 @@ static const struct hid_device_id hid_quirks[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X52_PRO), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_SAITEK, USB_DEVICE_ID_SAITEK_X65), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, + { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD2), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_SEMICO, USB_DEVICE_ID_SEMICO_USB_KEYKOARD), HID_QUIRK_NO_INIT_REPORTS }, + { HID_USB_DEVICE(USB_VENDOR_ID_SENNHEISER, USB_DEVICE_ID_SENNHEISER_BTD500USB), HID_QUIRK_NOGET }, +@@ -212,6 +214,7 @@ static const struct hid_device_id hid_have_special_driver[] = { + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_WCP32PU) }, + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_X5_005D) }, + { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_RP_649) }, ++ { HID_USB_DEVICE(USB_VENDOR_ID_A4TECH, USB_DEVICE_ID_A4TECH_NB_95) }, + #endif + #if IS_ENABLED(CONFIG_HID_ACCUTOUCH) + { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) }, +diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c +index 3dd7d32467378..f9983145d4e70 100644 +--- a/drivers/hid/hid-sensor-hub.c ++++ b/drivers/hid/hid-sensor-hub.c +@@ -210,16 +210,21 @@ int sensor_hub_set_feature(struct hid_sensor_hub_device *hsdev, u32 report_id, + buffer_size = buffer_size / sizeof(__s32); + if (buffer_size) { + for (i = 0; i < buffer_size; ++i) { +- hid_set_field(report->field[field_index], i, +- (__force __s32)cpu_to_le32(*buf32)); ++ ret = hid_set_field(report->field[field_index], i, ++ (__force __s32)cpu_to_le32(*buf32)); ++ if (ret) ++ goto done_proc; ++ + ++buf32; + } + } + if (remaining_bytes) { + value = 0; + memcpy(&value, (u8 *)buf32, remaining_bytes); +- hid_set_field(report->field[field_index], i, +- (__force __s32)cpu_to_le32(value)); ++ ret = hid_set_field(report->field[field_index], i, ++ (__force __s32)cpu_to_le32(value)); ++ if (ret) ++ goto done_proc; + } + hid_hw_request(hsdev->hdev, report, HID_REQ_SET_REPORT); + hid_hw_wait(hsdev->hdev); +diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c +index 17a29ee0ac6c2..8d4ac4b9fb9da 100644 +--- a/drivers/hid/usbhid/hid-core.c ++++ b/drivers/hid/usbhid/hid-core.c +@@ -374,7 +374,7 @@ static int hid_submit_ctrl(struct hid_device *hid) + raw_report = usbhid->ctrl[usbhid->ctrltail].raw_report; + dir = usbhid->ctrl[usbhid->ctrltail].dir; + +- len = ((report->size - 1) >> 3) + 1 + (report->id > 0); ++ len = hid_report_len(report); + if (dir == USB_DIR_OUT) { + usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); + usbhid->urbctrl->transfer_buffer_length = len; +diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +index c84c8bf2bc20e..fc99ad8e4a388 100644 +--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c ++++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c +@@ -3815,6 +3815,7 @@ static int myri10ge_probe(struct pci_dev *pdev, const struct pci_device_id *ent) + dev_err(&pdev->dev, + "invalid sram_size %dB or board span %ldB\n", + mgp->sram_size, mgp->board_span); ++ status = -EINVAL; + goto abort_with_ioremap; + } + memcpy_fromio(mgp->eeprom_strings, +diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c +index b869b686e9623..16d71cc5a50eb 100644 +--- a/drivers/nvme/target/loop.c ++++ b/drivers/nvme/target/loop.c +@@ -251,7 +251,8 @@ static const struct blk_mq_ops nvme_loop_admin_mq_ops = { + + static void nvme_loop_destroy_admin_queue(struct nvme_loop_ctrl *ctrl) + { +- clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); ++ if (!test_and_clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags)) ++ return; + nvmet_sq_destroy(&ctrl->queues[0].nvme_sq); + blk_cleanup_queue(ctrl->ctrl.admin_q); + blk_cleanup_queue(ctrl->ctrl.fabrics_q); +@@ -287,6 +288,7 @@ static void nvme_loop_destroy_io_queues(struct nvme_loop_ctrl *ctrl) + clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[i].flags); + nvmet_sq_destroy(&ctrl->queues[i].nvme_sq); + } ++ ctrl->ctrl.queue_count = 1; + } + + static int nvme_loop_init_io_queues(struct nvme_loop_ctrl *ctrl) +@@ -393,6 +395,7 @@ static int nvme_loop_configure_admin_queue(struct nvme_loop_ctrl *ctrl) + return 0; + + out_cleanup_queue: ++ clear_bit(NVME_LOOP_Q_LIVE, &ctrl->queues[0].flags); + blk_cleanup_queue(ctrl->ctrl.admin_q); + out_cleanup_fabrics_q: + blk_cleanup_queue(ctrl->ctrl.fabrics_q); +@@ -450,8 +453,10 @@ static void nvme_loop_reset_ctrl_work(struct work_struct *work) + nvme_loop_shutdown_ctrl(ctrl); + + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { +- /* state change failure should never happen */ +- WARN_ON_ONCE(1); ++ if (ctrl->ctrl.state != NVME_CTRL_DELETING && ++ ctrl->ctrl.state != NVME_CTRL_DELETING_NOIO) ++ /* state change failure for non-deleted ctrl? */ ++ WARN_ON_ONCE(1); + return; + } + +diff --git a/drivers/scsi/qedf/qedf_main.c b/drivers/scsi/qedf/qedf_main.c +index a464d0a4f4653..846a02de4d510 100644 +--- a/drivers/scsi/qedf/qedf_main.c ++++ b/drivers/scsi/qedf/qedf_main.c +@@ -1827,22 +1827,20 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) + fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); + QEDF_WARN(&(base_qedf->dbg_ctx), "Failed to create vport, " + "WWPN (0x%s) already exists.\n", buf); +- goto err1; ++ return rc; + } + + if (atomic_read(&base_qedf->link_state) != QEDF_LINK_UP) { + QEDF_WARN(&(base_qedf->dbg_ctx), "Cannot create vport " + "because link is not up.\n"); +- rc = -EIO; +- goto err1; ++ return -EIO; + } + + vn_port = libfc_vport_create(vport, sizeof(struct qedf_ctx)); + if (!vn_port) { + QEDF_WARN(&(base_qedf->dbg_ctx), "Could not create lport " + "for vport.\n"); +- rc = -ENOMEM; +- goto err1; ++ return -ENOMEM; + } + + fcoe_wwn_to_str(vport->port_name, buf, sizeof(buf)); +@@ -1866,7 +1864,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) + if (rc) { + QEDF_ERR(&(base_qedf->dbg_ctx), "Could not allocate memory " + "for lport stats.\n"); +- goto err2; ++ goto err; + } + + fc_set_wwnn(vn_port, vport->node_name); +@@ -1884,7 +1882,7 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) + if (rc) { + QEDF_WARN(&base_qedf->dbg_ctx, + "Error adding Scsi_Host rc=0x%x.\n", rc); +- goto err2; ++ goto err; + } + + /* Set default dev_loss_tmo based on module parameter */ +@@ -1925,9 +1923,10 @@ static int qedf_vport_create(struct fc_vport *vport, bool disabled) + vport_qedf->dbg_ctx.host_no = vn_port->host->host_no; + vport_qedf->dbg_ctx.pdev = base_qedf->pdev; + +-err2: ++ return 0; ++ ++err: + scsi_host_put(vn_port->host); +-err1: + return rc; + } + +@@ -1968,8 +1967,7 @@ static int qedf_vport_destroy(struct fc_vport *vport) + fc_lport_free_stats(vn_port); + + /* Release Scsi_Host */ +- if (vn_port->host) +- scsi_host_put(vn_port->host); ++ scsi_host_put(vn_port->host); + + out: + return 0; +diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c +index ba84244c1b4f6..9a8f9f902f3b4 100644 +--- a/drivers/scsi/scsi_devinfo.c ++++ b/drivers/scsi/scsi_devinfo.c +@@ -184,6 +184,7 @@ static struct { + {"HP", "C3323-300", "4269", BLIST_NOTQ}, + {"HP", "C5713A", NULL, BLIST_NOREPORTLUN}, + {"HP", "DISK-SUBSYSTEM", "*", BLIST_REPORTLUN2}, ++ {"HPE", "OPEN-", "*", BLIST_REPORTLUN2 | BLIST_TRY_VPD_PAGES}, + {"IBM", "AuSaV1S2", NULL, BLIST_FORCELUN}, + {"IBM", "ProFibre 4000R", "*", BLIST_SPARSELUN | BLIST_LARGELUN}, + {"IBM", "2105", NULL, BLIST_RETRY_HWERROR}, +diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c +index 484f0ba0a65bb..61b79804d462c 100644 +--- a/drivers/target/target_core_transport.c ++++ b/drivers/target/target_core_transport.c +@@ -3038,9 +3038,7 @@ __transport_wait_for_tasks(struct se_cmd *cmd, bool fabric_stop, + __releases(&cmd->t_state_lock) + __acquires(&cmd->t_state_lock) + { +- +- assert_spin_locked(&cmd->t_state_lock); +- WARN_ON_ONCE(!irqs_disabled()); ++ lockdep_assert_held(&cmd->t_state_lock); + + if (fabric_stop) + cmd->transport_state |= CMD_T_FABRIC_STOP; +diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c +index b39b339feddc9..16fb0184ce5e1 100644 +--- a/fs/gfs2/file.c ++++ b/fs/gfs2/file.c +@@ -938,8 +938,11 @@ static ssize_t gfs2_file_write_iter(struct kiocb *iocb, struct iov_iter *from) + current->backing_dev_info = inode_to_bdi(inode); + buffered = iomap_file_buffered_write(iocb, from, &gfs2_iomap_ops); + current->backing_dev_info = NULL; +- if (unlikely(buffered <= 0)) ++ if (unlikely(buffered <= 0)) { ++ if (!ret) ++ ret = buffered; + goto out_unlock; ++ } + + /* + * We need to ensure that the page cache pages are written to +diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c +index ea2f2de448063..cd43c481df4b4 100644 +--- a/fs/gfs2/glock.c ++++ b/fs/gfs2/glock.c +@@ -569,6 +569,16 @@ out_locked: + spin_unlock(&gl->gl_lockref.lock); + } + ++static bool is_system_glock(struct gfs2_glock *gl) ++{ ++ struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; ++ struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); ++ ++ if (gl == m_ip->i_gl) ++ return true; ++ return false; ++} ++ + /** + * do_xmote - Calls the DLM to change the state of a lock + * @gl: The lock state +@@ -658,17 +668,25 @@ skip_inval: + * to see sd_log_error and withdraw, and in the meantime, requeue the + * work for later. + * ++ * We make a special exception for some system glocks, such as the ++ * system statfs inode glock, which needs to be granted before the ++ * gfs2_quotad daemon can exit, and that exit needs to finish before ++ * we can unmount the withdrawn file system. ++ * + * However, if we're just unlocking the lock (say, for unmount, when + * gfs2_gl_hash_clear calls clear_glock) and recovery is complete + * then it's okay to tell dlm to unlock it. + */ + if (unlikely(sdp->sd_log_error && !gfs2_withdrawn(sdp))) + gfs2_withdraw_delayed(sdp); +- if (glock_blocked_by_withdraw(gl)) { +- if (target != LM_ST_UNLOCKED || +- test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags)) { ++ if (glock_blocked_by_withdraw(gl) && ++ (target != LM_ST_UNLOCKED || ++ test_bit(SDF_WITHDRAW_RECOVERY, &sdp->sd_flags))) { ++ if (!is_system_glock(gl)) { + gfs2_glock_queue_work(gl, GL_GLOCK_DFT_HOLD); + goto out; ++ } else { ++ clear_bit(GLF_INVALIDATE_IN_PROGRESS, &gl->gl_flags); + } + } + +@@ -1766,6 +1784,7 @@ __acquires(&lru_lock) + while(!list_empty(list)) { + gl = list_first_entry(list, struct gfs2_glock, gl_lru); + list_del_init(&gl->gl_lru); ++ clear_bit(GLF_LRU, &gl->gl_flags); + if (!spin_trylock(&gl->gl_lockref.lock)) { + add_back_to_lru: + list_add(&gl->gl_lru, &lru_list); +@@ -1811,7 +1830,6 @@ static long gfs2_scan_glock_lru(int nr) + if (!test_bit(GLF_LOCK, &gl->gl_flags)) { + list_move(&gl->gl_lru, &dispose); + atomic_dec(&lru_count); +- clear_bit(GLF_LRU, &gl->gl_flags); + freed++; + continue; + } +diff --git a/include/linux/hid.h b/include/linux/hid.h +index 8578db50ad734..6ed2a97eb55f1 100644 +--- a/include/linux/hid.h ++++ b/include/linux/hid.h +@@ -1156,8 +1156,7 @@ static inline void hid_hw_wait(struct hid_device *hdev) + */ + static inline u32 hid_report_len(struct hid_report *report) + { +- /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */ +- return ((report->size - 1) >> 3) + 1 + (report->id > 0); ++ return DIV_ROUND_UP(report->size, 8) + (report->id > 0); + } + + int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size, +diff --git a/include/linux/host1x.h b/include/linux/host1x.h +index 9eb77c87a83b0..ed0005ce4285c 100644 +--- a/include/linux/host1x.h ++++ b/include/linux/host1x.h +@@ -320,12 +320,30 @@ static inline struct host1x_device *to_host1x_device(struct device *dev) + int host1x_device_init(struct host1x_device *device); + int host1x_device_exit(struct host1x_device *device); + +-int __host1x_client_register(struct host1x_client *client, +- struct lock_class_key *key); +-#define host1x_client_register(class) \ +- ({ \ +- static struct lock_class_key __key; \ +- __host1x_client_register(class, &__key); \ ++void __host1x_client_init(struct host1x_client *client, struct lock_class_key *key); ++void host1x_client_exit(struct host1x_client *client); ++ ++#define host1x_client_init(client) \ ++ ({ \ ++ static struct lock_class_key __key; \ ++ __host1x_client_init(client, &__key); \ ++ }) ++ ++int __host1x_client_register(struct host1x_client *client); ++ ++/* ++ * Note that this wrapper calls __host1x_client_init() for compatibility ++ * with existing callers. Callers that want to separately initialize and ++ * register a host1x client must first initialize using either of the ++ * __host1x_client_init() or host1x_client_init() functions and then use ++ * the low-level __host1x_client_register() function to avoid the client ++ * getting reinitialized. ++ */ ++#define host1x_client_register(client) \ ++ ({ \ ++ static struct lock_class_key __key; \ ++ __host1x_client_init(client, &__key); \ ++ __host1x_client_register(client); \ + }) + + int host1x_client_unregister(struct host1x_client *client); +diff --git a/include/uapi/linux/input-event-codes.h b/include/uapi/linux/input-event-codes.h +index ee93428ced9a1..225ec87d4f228 100644 +--- a/include/uapi/linux/input-event-codes.h ++++ b/include/uapi/linux/input-event-codes.h +@@ -611,6 +611,7 @@ + #define KEY_VOICECOMMAND 0x246 /* Listening Voice Command */ + #define KEY_ASSISTANT 0x247 /* AL Context-aware desktop assistant */ + #define KEY_KBD_LAYOUT_NEXT 0x248 /* AC Next Keyboard Layout Select */ ++#define KEY_EMOJI_PICKER 0x249 /* Show/hide emoji picker (HUTRR101) */ + + #define KEY_BRIGHTNESS_MIN 0x250 /* Set Brightness to Minimum */ + #define KEY_BRIGHTNESS_MAX 0x251 /* Set Brightness to Maximum */ +diff --git a/net/compat.c b/net/compat.c +index ddd15af3a2837..210fc3b4d0d83 100644 +--- a/net/compat.c ++++ b/net/compat.c +@@ -177,7 +177,7 @@ int cmsghdr_from_user_compat_to_kern(struct msghdr *kmsg, struct sock *sk, + if (kcmlen > stackbuf_size) + kcmsg_base = kcmsg = sock_kmalloc(sk, kcmlen, GFP_KERNEL); + if (kcmsg == NULL) +- return -ENOBUFS; ++ return -ENOMEM; + + /* Now copy them over neatly. */ + memset(kcmsg, 0, kcmlen); +diff --git a/net/core/fib_rules.c b/net/core/fib_rules.c +index 7bcfb16854cbb..9258ffc4ebffc 100644 +--- a/net/core/fib_rules.c ++++ b/net/core/fib_rules.c +@@ -1168,7 +1168,7 @@ static void notify_rule_change(int event, struct fib_rule *rule, + { + struct net *net; + struct sk_buff *skb; +- int err = -ENOBUFS; ++ int err = -ENOMEM; + + net = ops->fro_net; + skb = nlmsg_new(fib_rule_nlmsg_size(ops, rule), GFP_KERNEL); +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index eae8e87930cd7..83894723ebeea 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -4842,8 +4842,10 @@ static int rtnl_bridge_notify(struct net_device *dev) + if (err < 0) + goto errout; + +- if (!skb->len) ++ if (!skb->len) { ++ err = -EINVAL; + goto errout; ++ } + + rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); + return 0; +diff --git a/net/ieee802154/nl802154.c b/net/ieee802154/nl802154.c +index f0b47d43c9f6e..b34e4f827e756 100644 +--- a/net/ieee802154/nl802154.c ++++ b/net/ieee802154/nl802154.c +@@ -1298,19 +1298,20 @@ ieee802154_llsec_parse_dev_addr(struct nlattr *nla, + if (!nla || nla_parse_nested_deprecated(attrs, NL802154_DEV_ADDR_ATTR_MAX, nla, nl802154_dev_addr_policy, NULL)) + return -EINVAL; + +- if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || +- !attrs[NL802154_DEV_ADDR_ATTR_MODE] || +- !(attrs[NL802154_DEV_ADDR_ATTR_SHORT] || +- attrs[NL802154_DEV_ADDR_ATTR_EXTENDED])) ++ if (!attrs[NL802154_DEV_ADDR_ATTR_PAN_ID] || !attrs[NL802154_DEV_ADDR_ATTR_MODE]) + return -EINVAL; + + addr->pan_id = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_PAN_ID]); + addr->mode = nla_get_u32(attrs[NL802154_DEV_ADDR_ATTR_MODE]); + switch (addr->mode) { + case NL802154_DEV_ADDR_SHORT: ++ if (!attrs[NL802154_DEV_ADDR_ATTR_SHORT]) ++ return -EINVAL; + addr->short_addr = nla_get_le16(attrs[NL802154_DEV_ADDR_ATTR_SHORT]); + break; + case NL802154_DEV_ADDR_EXTENDED: ++ if (!attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]) ++ return -EINVAL; + addr->extended_addr = nla_get_le64(attrs[NL802154_DEV_ADDR_ATTR_EXTENDED]); + break; + default: +diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c +index 3cd13e1bc6a70..213a1c91507d9 100644 +--- a/net/ipv4/ipconfig.c ++++ b/net/ipv4/ipconfig.c +@@ -870,7 +870,7 @@ static void __init ic_bootp_send_if(struct ic_device *d, unsigned long jiffies_d + + + /* +- * Copy BOOTP-supplied string if not already set. ++ * Copy BOOTP-supplied string + */ + static int __init ic_bootp_string(char *dest, char *src, int len, int max) + { +@@ -919,12 +919,15 @@ static void __init ic_do_bootp_ext(u8 *ext) + } + break; + case 12: /* Host name */ +- ic_bootp_string(utsname()->nodename, ext+1, *ext, +- __NEW_UTS_LEN); +- ic_host_name_set = 1; ++ if (!ic_host_name_set) { ++ ic_bootp_string(utsname()->nodename, ext+1, *ext, ++ __NEW_UTS_LEN); ++ ic_host_name_set = 1; ++ } + break; + case 15: /* Domain name (DNS) */ +- ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); ++ if (!ic_domain[0]) ++ ic_bootp_string(ic_domain, ext+1, *ext, sizeof(ic_domain)); + break; + case 17: /* Root path */ + if (!root_server_path[0]) +diff --git a/net/x25/af_x25.c b/net/x25/af_x25.c +index e65a50192432c..03ed170b8125e 100644 +--- a/net/x25/af_x25.c ++++ b/net/x25/af_x25.c +@@ -546,7 +546,7 @@ static int x25_create(struct net *net, struct socket *sock, int protocol, + if (protocol) + goto out; + +- rc = -ENOBUFS; ++ rc = -ENOMEM; + if ((sk = x25_alloc_socket(net, kern)) == NULL) + goto out; + diff --git a/patch/kernel/archive/sunxi-5.10/patch-5.10.45-46.patch b/patch/kernel/archive/sunxi-5.10/patch-5.10.45-46.patch new file mode 100644 index 000000000..c2e48b513 --- /dev/null +++ b/patch/kernel/archive/sunxi-5.10/patch-5.10.45-46.patch @@ -0,0 +1,5158 @@ +diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst +index 03f294a638bd8..d3028554b1e9c 100644 +--- a/Documentation/vm/slub.rst ++++ b/Documentation/vm/slub.rst +@@ -181,7 +181,7 @@ SLUB Debug output + Here is a sample of slub debug output:: + + ==================================================================== +- BUG kmalloc-8: Redzone overwritten ++ BUG kmalloc-8: Right Redzone overwritten + -------------------------------------------------------------------- + + INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc +@@ -189,10 +189,10 @@ Here is a sample of slub debug output:: + INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58 + INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554 + +- Bytes b4 0xc90f6d10: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ +- Object 0xc90f6d20: 31 30 31 39 2e 30 30 35 1019.005 +- Redzone 0xc90f6d28: 00 cc cc cc . +- Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ ++ Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ ++ Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005 ++ Redzone (0xc90f6d28): 00 cc cc cc . ++ Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ + + [] dump_trace+0x63/0x1eb + [] show_trace_log_lvl+0x1a/0x2f +diff --git a/Makefile b/Makefile +index 808b68483002f..7ab22f105a032 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 10 +-SUBLEVEL = 45 ++SUBLEVEL = 46 + EXTRAVERSION = + NAME = Dare mighty things + +diff --git a/arch/arc/include/uapi/asm/sigcontext.h b/arch/arc/include/uapi/asm/sigcontext.h +index 95f8a4380e110..7a5449dfcb290 100644 +--- a/arch/arc/include/uapi/asm/sigcontext.h ++++ b/arch/arc/include/uapi/asm/sigcontext.h +@@ -18,6 +18,7 @@ + */ + struct sigcontext { + struct user_regs_struct regs; ++ struct user_regs_arcv2 v2abi; + }; + + #endif /* _ASM_ARC_SIGCONTEXT_H */ +diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c +index 98e575dbcce51..9d5996e014c01 100644 +--- a/arch/arc/kernel/signal.c ++++ b/arch/arc/kernel/signal.c +@@ -61,6 +61,41 @@ struct rt_sigframe { + unsigned int sigret_magic; + }; + ++static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ v2abi.r30 = regs->r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ v2abi.r58 = regs->r58; ++ v2abi.r59 = regs->r59; ++#else ++ v2abi.r58 = v2abi.r59 = 0; ++#endif ++ err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi)); ++#endif ++ return err; ++} ++ ++static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi)); ++ ++ regs->r30 = v2abi.r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ regs->r58 = v2abi.r58; ++ regs->r59 = v2abi.r59; ++#endif ++#endif ++ return err; ++} ++ + static int + stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + sigset_t *set) +@@ -94,6 +129,10 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + + err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch, + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t)); + + return err ? -EFAULT : 0; +@@ -109,6 +148,10 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) + err |= __copy_from_user(&uregs.scratch, + &(sf->uc.uc_mcontext.regs.scratch), + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + if (err) + return -EFAULT; + +diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S +index 81c458e996d9b..963e8cb936e28 100644 +--- a/arch/s390/kernel/entry.S ++++ b/arch/s390/kernel/entry.S +@@ -1284,7 +1284,7 @@ ENDPROC(stack_overflow) + je 1f + larl %r13,.Lsie_entry + slgr %r9,%r13 +- larl %r13,.Lsie_skip ++ lghi %r13,.Lsie_skip - .Lsie_entry + clgr %r9,%r13 + jh 1f + oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST +diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h +index ceeba9f631722..fdee23ea4e173 100644 +--- a/arch/x86/include/asm/fpu/internal.h ++++ b/arch/x86/include/asm/fpu/internal.h +@@ -578,10 +578,17 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) + * PKRU state is switched eagerly because it needs to be valid before we + * return to userland e.g. for a copy_to_user() operation. + */ +- if (current->mm) { ++ if (!(current->flags & PF_KTHREAD)) { ++ /* ++ * If the PKRU bit in xsave.header.xfeatures is not set, ++ * then the PKRU component was in init state, which means ++ * XRSTOR will set PKRU to 0. If the bit is not set then ++ * get_xsave_addr() will return NULL because the PKRU value ++ * in memory is not valid. This means pkru_val has to be ++ * set to 0 and not to init_pkru_value. ++ */ + pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); +- if (pk) +- pkru_val = pk->pkru; ++ pkru_val = pk ? pk->pkru : 0; + } + __write_pkru(pkru_val); + } +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c +index a4ec65317a7fa..ec3ae30547920 100644 +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -307,13 +307,17 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + return 0; + } + +- if (!access_ok(buf, size)) +- return -EACCES; ++ if (!access_ok(buf, size)) { ++ ret = -EACCES; ++ goto out; ++ } + +- if (!static_cpu_has(X86_FEATURE_FPU)) +- return fpregs_soft_set(current, NULL, +- 0, sizeof(struct user_i387_ia32_struct), +- NULL, buf) != 0; ++ if (!static_cpu_has(X86_FEATURE_FPU)) { ++ ret = fpregs_soft_set(current, NULL, 0, ++ sizeof(struct user_i387_ia32_struct), ++ NULL, buf); ++ goto out; ++ } + + if (use_xsave()) { + struct _fpx_sw_bytes fx_sw_user; +@@ -369,6 +373,25 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + fpregs_unlock(); + return 0; + } ++ ++ /* ++ * The above did an FPU restore operation, restricted to ++ * the user portion of the registers, and failed, but the ++ * microcode might have modified the FPU registers ++ * nevertheless. ++ * ++ * If the FPU registers do not belong to current, then ++ * invalidate the FPU register state otherwise the task might ++ * preempt current and return to user space with corrupted ++ * FPU registers. ++ * ++ * In case current owns the FPU registers then no further ++ * action is required. The fixup below will handle it ++ * correctly. ++ */ ++ if (test_thread_flag(TIF_NEED_FPU_LOAD)) ++ __cpu_invalidate_fpregs_state(); ++ + fpregs_unlock(); + } else { + /* +@@ -377,7 +400,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + */ + ret = __copy_from_user(&env, buf, sizeof(env)); + if (ret) +- goto err_out; ++ goto out; + envp = &env; + } + +@@ -405,16 +428,9 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + if (use_xsave() && !fx_only) { + u64 init_bv = xfeatures_mask_user() & ~user_xfeatures; + +- if (using_compacted_format()) { +- ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx); +- } else { +- ret = __copy_from_user(&fpu->state.xsave, buf_fx, state_size); +- +- if (!ret && state_size > offsetof(struct xregs_state, header)) +- ret = validate_user_xstate_header(&fpu->state.xsave.header); +- } ++ ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx); + if (ret) +- goto err_out; ++ goto out; + + sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures, + fx_only); +@@ -434,7 +450,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + ret = __copy_from_user(&fpu->state.fxsave, buf_fx, state_size); + if (ret) { + ret = -EFAULT; +- goto err_out; ++ goto out; + } + + sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures, +@@ -452,7 +468,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + } else { + ret = __copy_from_user(&fpu->state.fsave, buf_fx, state_size); + if (ret) +- goto err_out; ++ goto out; + + fpregs_lock(); + ret = copy_kernel_to_fregs_err(&fpu->state.fsave); +@@ -463,7 +479,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + fpregs_deactivate(fpu); + fpregs_unlock(); + +-err_out: ++out: + if (ret) + fpu__clear_user_states(fpu); + return ret; +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c +index 5759eb075d2fc..677d21082454f 100644 +--- a/arch/x86/kvm/lapic.c ++++ b/arch/x86/kvm/lapic.c +@@ -1405,6 +1405,9 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, + if (!apic_x2apic_mode(apic)) + valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI); + ++ if (alignment + len > 4) ++ return 1; ++ + if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset))) + return 1; + +diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c +index ac5054763e38e..6b794344c02db 100644 +--- a/arch/x86/kvm/mmu/mmu.c ++++ b/arch/x86/kvm/mmu/mmu.c +@@ -4705,9 +4705,33 @@ static void init_kvm_softmmu(struct kvm_vcpu *vcpu) + context->inject_page_fault = kvm_inject_page_fault; + } + ++static union kvm_mmu_role kvm_calc_nested_mmu_role(struct kvm_vcpu *vcpu) ++{ ++ union kvm_mmu_role role = kvm_calc_shadow_root_page_role_common(vcpu, false); ++ ++ /* ++ * Nested MMUs are used only for walking L2's gva->gpa, they never have ++ * shadow pages of their own and so "direct" has no meaning. Set it ++ * to "true" to try to detect bogus usage of the nested MMU. ++ */ ++ role.base.direct = true; ++ ++ if (!is_paging(vcpu)) ++ role.base.level = 0; ++ else if (is_long_mode(vcpu)) ++ role.base.level = is_la57_mode(vcpu) ? PT64_ROOT_5LEVEL : ++ PT64_ROOT_4LEVEL; ++ else if (is_pae(vcpu)) ++ role.base.level = PT32E_ROOT_LEVEL; ++ else ++ role.base.level = PT32_ROOT_LEVEL; ++ ++ return role; ++} ++ + static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu) + { +- union kvm_mmu_role new_role = kvm_calc_mmu_role_common(vcpu, false); ++ union kvm_mmu_role new_role = kvm_calc_nested_mmu_role(vcpu); + struct kvm_mmu *g_context = &vcpu->arch.nested_mmu; + + if (new_role.as_u64 == g_context->mmu_role.as_u64) +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index 109041630d30b..d3372cb973079 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -6876,7 +6876,10 @@ static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt) + + static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags) + { +- emul_to_vcpu(ctxt)->arch.hflags = emul_flags; ++ struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); ++ ++ vcpu->arch.hflags = emul_flags; ++ kvm_mmu_reset_context(vcpu); + } + + static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, +@@ -8018,6 +8021,7 @@ void kvm_arch_exit(void) + kvm_x86_ops.hardware_enable = NULL; + kvm_mmu_module_exit(); + free_percpu(user_return_msrs); ++ kmem_cache_destroy(x86_emulator_cache); + kmem_cache_destroy(x86_fpu_cache); + } + +diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c +index 9e5ccc56f8e07..356b746dfbe7a 100644 +--- a/arch/x86/mm/ioremap.c ++++ b/arch/x86/mm/ioremap.c +@@ -118,7 +118,9 @@ static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *des + if (!IS_ENABLED(CONFIG_EFI)) + return; + +- if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA) ++ if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA || ++ (efi_mem_type(addr) == EFI_BOOT_SERVICES_DATA && ++ efi_mem_attributes(addr) & EFI_MEMORY_RUNTIME)) + desc->flags |= IORES_MAP_ENCRYPTED; + } + +diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c +index 5eb4dc2b97dac..e94da744386f3 100644 +--- a/arch/x86/mm/numa.c ++++ b/arch/x86/mm/numa.c +@@ -254,7 +254,13 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi) + + /* make sure all non-reserved blocks are inside the limits */ + bi->start = max(bi->start, low); +- bi->end = min(bi->end, high); ++ ++ /* preserve info for non-RAM areas above 'max_pfn': */ ++ if (bi->end > high) { ++ numa_add_memblk_to(bi->nid, high, bi->end, ++ &numa_reserved_meminfo); ++ bi->end = high; ++ } + + /* and there's no empty block */ + if (bi->start >= bi->end) +diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig +index 90284ffda58a7..f2db761ee5488 100644 +--- a/drivers/dma/Kconfig ++++ b/drivers/dma/Kconfig +@@ -59,6 +59,7 @@ config DMA_OF + #devices + config ALTERA_MSGDMA + tristate "Altera / Intel mSGDMA Engine" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for Altera / Intel mSGDMA controller. +diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c +index 4ec909e0b8106..4ae057922ef1f 100644 +--- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c ++++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c +@@ -332,6 +332,7 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev) + } + + if (priv->dpdmai_attr.version.major > DPDMAI_VER_MAJOR) { ++ err = -EINVAL; + dev_err(dev, "DPDMAI major version mismatch\n" + "Found %u.%u, supported version is %u.%u\n", + priv->dpdmai_attr.version.major, +@@ -341,6 +342,7 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev) + } + + if (priv->dpdmai_attr.version.minor > DPDMAI_VER_MINOR) { ++ err = -EINVAL; + dev_err(dev, "DPDMAI minor version mismatch\n" + "Found %u.%u, supported version is %u.%u\n", + priv->dpdmai_attr.version.major, +@@ -475,6 +477,7 @@ static int __cold dpaa2_qdma_dpio_setup(struct dpaa2_qdma_priv *priv) + ppriv->store = + dpaa2_io_store_create(DPAA2_QDMA_STORE_SIZE, dev); + if (!ppriv->store) { ++ err = -ENOMEM; + dev_err(dev, "dpaa2_io_store_create() failed\n"); + goto err_store; + } +diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c +index f4c7ce8cb399c..048a23018a3df 100644 +--- a/drivers/dma/idxd/init.c ++++ b/drivers/dma/idxd/init.c +@@ -518,6 +518,7 @@ module_init(idxd_init_module); + + static void __exit idxd_exit_module(void) + { ++ idxd_unregister_driver(); + pci_unregister_driver(&idxd_pci_driver); + idxd_cdev_remove(); + idxd_unregister_bus_type(); +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c +index 0f5c19370f6d7..dfbf514188f37 100644 +--- a/drivers/dma/pl330.c ++++ b/drivers/dma/pl330.c +@@ -2696,13 +2696,15 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + for (i = 0; i < len / period_len; i++) { + desc = pl330_get_desc(pch); + if (!desc) { ++ unsigned long iflags; ++ + dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", + __func__, __LINE__); + + if (!first) + return NULL; + +- spin_lock_irqsave(&pl330->pool_lock, flags); ++ spin_lock_irqsave(&pl330->pool_lock, iflags); + + while (!list_empty(&first->node)) { + desc = list_entry(first->node.next, +@@ -2712,7 +2714,7 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + + list_move_tail(&first->node, &pl330->desc_pool); + +- spin_unlock_irqrestore(&pl330->pool_lock, flags); ++ spin_unlock_irqrestore(&pl330->pool_lock, iflags); + + return NULL; + } +diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig +index 3bcb689162c67..ef038f3c5e328 100644 +--- a/drivers/dma/qcom/Kconfig ++++ b/drivers/dma/qcom/Kconfig +@@ -10,6 +10,7 @@ config QCOM_BAM_DMA + + config QCOM_HIDMA_MGMT + tristate "Qualcomm Technologies HIDMA Management support" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for the Qualcomm Technologies HIDMA Management. +diff --git a/drivers/dma/sf-pdma/Kconfig b/drivers/dma/sf-pdma/Kconfig +index f8ffa02e279ff..ba46a0a15a936 100644 +--- a/drivers/dma/sf-pdma/Kconfig ++++ b/drivers/dma/sf-pdma/Kconfig +@@ -1,5 +1,6 @@ + config SF_PDMA + tristate "Sifive PDMA controller driver" ++ depends on HAS_IOMEM + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help +diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c +index 77ab1f4730be9..b35b97cb8fd25 100644 +--- a/drivers/dma/ste_dma40.c ++++ b/drivers/dma/ste_dma40.c +@@ -3676,6 +3676,9 @@ static int __init d40_probe(struct platform_device *pdev) + + kfree(base->lcla_pool.base_unaligned); + ++ if (base->lcpa_base) ++ iounmap(base->lcpa_base); ++ + if (base->phy_lcpa) + release_mem_region(base->phy_lcpa, + base->lcpa_size); +diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c +index 70b29bd079c9f..ff7dfb3fdeb47 100644 +--- a/drivers/dma/xilinx/xilinx_dpdma.c ++++ b/drivers/dma/xilinx/xilinx_dpdma.c +@@ -1459,7 +1459,7 @@ static void xilinx_dpdma_enable_irq(struct xilinx_dpdma_device *xdev) + */ + static void xilinx_dpdma_disable_irq(struct xilinx_dpdma_device *xdev) + { +- dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ERR_ALL); ++ dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ALL); + dpdma_write(xdev->reg, XILINX_DPDMA_EIDS, XILINX_DPDMA_EINTR_ALL); + } + +@@ -1596,6 +1596,26 @@ static struct dma_chan *of_dma_xilinx_xlate(struct of_phandle_args *dma_spec, + return dma_get_slave_channel(&xdev->chan[chan_id]->vchan.chan); + } + ++static void dpdma_hw_init(struct xilinx_dpdma_device *xdev) ++{ ++ unsigned int i; ++ void __iomem *reg; ++ ++ /* Disable all interrupts */ ++ xilinx_dpdma_disable_irq(xdev); ++ ++ /* Stop all channels */ ++ for (i = 0; i < ARRAY_SIZE(xdev->chan); i++) { ++ reg = xdev->reg + XILINX_DPDMA_CH_BASE ++ + XILINX_DPDMA_CH_OFFSET * i; ++ dpdma_clr(reg, XILINX_DPDMA_CH_CNTL, XILINX_DPDMA_CH_CNTL_ENABLE); ++ } ++ ++ /* Clear the interrupt status registers */ ++ dpdma_write(xdev->reg, XILINX_DPDMA_ISR, XILINX_DPDMA_INTR_ALL); ++ dpdma_write(xdev->reg, XILINX_DPDMA_EISR, XILINX_DPDMA_EINTR_ALL); ++} ++ + static int xilinx_dpdma_probe(struct platform_device *pdev) + { + struct xilinx_dpdma_device *xdev; +@@ -1622,6 +1642,8 @@ static int xilinx_dpdma_probe(struct platform_device *pdev) + if (IS_ERR(xdev->reg)) + return PTR_ERR(xdev->reg); + ++ dpdma_hw_init(xdev); ++ + xdev->irq = platform_get_irq(pdev, 0); + if (xdev->irq < 0) { + dev_err(xdev->dev, "failed to get platform irq\n"); +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +index fc8da5fed779b..3c92dacbc24ad 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +@@ -6590,8 +6590,12 @@ static int gfx_v10_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +index fb15e8b5af32f..1859d293ef712 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +@@ -3619,8 +3619,12 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c +index 57fb3eb3a4b45..1f4e3396d097c 100644 +--- a/drivers/gpu/drm/radeon/radeon_uvd.c ++++ b/drivers/gpu/drm/radeon/radeon_uvd.c +@@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + if (rdev->uvd.vcpu_bo == NULL) + return -EINVAL; + +- memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); ++ memcpy_toio((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); + + size = radeon_bo_size(rdev->uvd.vcpu_bo); + size -= rdev->uvd_fw->size; +@@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + ptr = rdev->uvd.cpu_addr; + ptr += rdev->uvd_fw->size; + +- memset(ptr, 0, size); ++ memset_io((void __iomem *)ptr, 0, size); + + return 0; + } +diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +index bbdfd5e26ec88..f75fb157f2ff7 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c ++++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +@@ -209,7 +209,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, + goto err_disable_clk_tmds; + } + +- ret = sun8i_hdmi_phy_probe(hdmi, phy_node); ++ ret = sun8i_hdmi_phy_get(hdmi, phy_node); + of_node_put(phy_node); + if (ret) { + dev_err(dev, "Couldn't get the HDMI PHY\n"); +@@ -242,7 +242,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, + + cleanup_encoder: + drm_encoder_cleanup(encoder); +- sun8i_hdmi_phy_remove(hdmi); + err_disable_clk_tmds: + clk_disable_unprepare(hdmi->clk_tmds); + err_assert_ctrl_reset: +@@ -263,7 +262,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, + struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev); + + dw_hdmi_unbind(hdmi->hdmi); +- sun8i_hdmi_phy_remove(hdmi); + clk_disable_unprepare(hdmi->clk_tmds); + reset_control_assert(hdmi->rst_ctrl); + gpiod_set_value(hdmi->ddc_en, 0); +@@ -320,7 +318,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { + .of_match_table = sun8i_dw_hdmi_dt_ids, + }, + }; +-module_platform_driver(sun8i_dw_hdmi_pltfm_driver); ++ ++static int __init sun8i_dw_hdmi_init(void) ++{ ++ int ret; ++ ++ ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver); ++ if (ret) ++ return ret; ++ ++ ret = platform_driver_register(&sun8i_hdmi_phy_driver); ++ if (ret) { ++ platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); ++ return ret; ++ } ++ ++ return ret; ++} ++ ++static void __exit sun8i_dw_hdmi_exit(void) ++{ ++ platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); ++ platform_driver_unregister(&sun8i_hdmi_phy_driver); ++} ++ ++module_init(sun8i_dw_hdmi_init); ++module_exit(sun8i_dw_hdmi_exit); + + MODULE_AUTHOR("Jernej Skrabec "); + MODULE_DESCRIPTION("Allwinner DW HDMI bridge"); +diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +index d4b55af0592f8..74f6ed0e25709 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h ++++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +@@ -195,14 +195,15 @@ struct sun8i_dw_hdmi { + struct gpio_desc *ddc_en; + }; + ++extern struct platform_driver sun8i_hdmi_phy_driver; ++ + static inline struct sun8i_dw_hdmi * + encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder) + { + return container_of(encoder, struct sun8i_dw_hdmi, encoder); + } + +-int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node); +-void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi); ++int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node); + + void sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy); + void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy, +diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +index 9994edf675096..c9239708d398c 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c ++++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +@@ -5,6 +5,7 @@ + + #include + #include ++#include + + #include "sun8i_dw_hdmi.h" + +@@ -597,10 +598,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = { + { /* sentinel */ } + }; + +-int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) ++int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) ++{ ++ struct platform_device *pdev = of_find_device_by_node(node); ++ struct sun8i_hdmi_phy *phy; ++ ++ if (!pdev) ++ return -EPROBE_DEFER; ++ ++ phy = platform_get_drvdata(pdev); ++ if (!phy) ++ return -EPROBE_DEFER; ++ ++ hdmi->phy = phy; ++ ++ put_device(&pdev->dev); ++ ++ return 0; ++} ++ ++static int sun8i_hdmi_phy_probe(struct platform_device *pdev) + { + const struct of_device_id *match; +- struct device *dev = hdmi->dev; ++ struct device *dev = &pdev->dev; ++ struct device_node *node = dev->of_node; + struct sun8i_hdmi_phy *phy; + struct resource res; + void __iomem *regs; +@@ -704,7 +725,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) + clk_prepare_enable(phy->clk_phy); + } + +- hdmi->phy = phy; ++ platform_set_drvdata(pdev, phy); + + return 0; + +@@ -728,9 +749,9 @@ err_put_clk_bus: + return ret; + } + +-void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) ++static int sun8i_hdmi_phy_remove(struct platform_device *pdev) + { +- struct sun8i_hdmi_phy *phy = hdmi->phy; ++ struct sun8i_hdmi_phy *phy = platform_get_drvdata(pdev); + + clk_disable_unprepare(phy->clk_mod); + clk_disable_unprepare(phy->clk_bus); +@@ -744,4 +765,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) + clk_put(phy->clk_pll1); + clk_put(phy->clk_mod); + clk_put(phy->clk_bus); ++ return 0; + } ++ ++struct platform_driver sun8i_hdmi_phy_driver = { ++ .probe = sun8i_hdmi_phy_probe, ++ .remove = sun8i_hdmi_phy_remove, ++ .driver = { ++ .name = "sun8i-hdmi-phy", ++ .of_match_table = sun8i_hdmi_phy_of_table, ++ }, ++}; +diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c +index 25aac40f2764a..919877970ae3b 100644 +--- a/drivers/hwmon/scpi-hwmon.c ++++ b/drivers/hwmon/scpi-hwmon.c +@@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) + + scpi_scale_reading(&value, sensor); + ++ /* ++ * Temperature sensor values are treated as signed values based on ++ * observation even though that is not explicitly specified, and ++ * because an unsigned u64 temperature does not really make practical ++ * sense especially when the temperature is below zero degrees Celsius. ++ */ ++ if (sensor->info.class == TEMPERATURE) ++ return sprintf(buf, "%lld\n", (s64)value); ++ + return sprintf(buf, "%llu\n", value); + } + +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c +index 7929bf12651ca..1005b182bab47 100644 +--- a/drivers/irqchip/irq-gic-v3.c ++++ b/drivers/irqchip/irq-gic-v3.c +@@ -642,11 +642,45 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) + nmi_exit(); + } + ++static u32 do_read_iar(struct pt_regs *regs) ++{ ++ u32 iar; ++ ++ if (gic_supports_nmi() && unlikely(!interrupts_enabled(regs))) { ++ u64 pmr; ++ ++ /* ++ * We were in a context with IRQs disabled. However, the ++ * entry code has set PMR to a value that allows any ++ * interrupt to be acknowledged, and not just NMIs. This can ++ * lead to surprising effects if the NMI has been retired in ++ * the meantime, and that there is an IRQ pending. The IRQ ++ * would then be taken in NMI context, something that nobody ++ * wants to debug twice. ++ * ++ * Until we sort this, drop PMR again to a level that will ++ * actually only allow NMIs before reading IAR, and then ++ * restore it to what it was. ++ */ ++ pmr = gic_read_pmr(); ++ gic_pmr_mask_irqs(); ++ isb(); ++ ++ iar = gic_read_iar(); ++ ++ gic_write_pmr(pmr); ++ } else { ++ iar = gic_read_iar(); ++ } ++ ++ return iar; ++} ++ + static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) + { + u32 irqnr; + +- irqnr = gic_read_iar(); ++ irqnr = do_read_iar(regs); + + /* Check for special IDs first */ + if ((irqnr >= 1020 && irqnr <= 1023)) +diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c +index e97f2e0da6b07..6d03f1d6c4d38 100644 +--- a/drivers/net/can/usb/mcba_usb.c ++++ b/drivers/net/can/usb/mcba_usb.c +@@ -82,6 +82,8 @@ struct mcba_priv { + bool can_ka_first_pass; + bool can_speed_check; + atomic_t free_ctx_cnt; ++ void *rxbuf[MCBA_MAX_RX_URBS]; ++ dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS]; + }; + + /* CAN frame */ +@@ -633,6 +635,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + for (i = 0; i < MCBA_MAX_RX_URBS; i++) { + struct urb *urb = NULL; + u8 *buf; ++ dma_addr_t buf_dma; + + /* create a URB, and a buffer for it */ + urb = usb_alloc_urb(0, GFP_KERNEL); +@@ -642,7 +645,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + } + + buf = usb_alloc_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- GFP_KERNEL, &urb->transfer_dma); ++ GFP_KERNEL, &buf_dma); + if (!buf) { + netdev_err(netdev, "No memory left for USB buffer\n"); + usb_free_urb(urb); +@@ -661,11 +664,14 @@ static int mcba_usb_start(struct mcba_priv *priv) + if (err) { + usb_unanchor_urb(urb); + usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- buf, urb->transfer_dma); ++ buf, buf_dma); + usb_free_urb(urb); + break; + } + ++ priv->rxbuf[i] = buf; ++ priv->rxbuf_dma[i] = buf_dma; ++ + /* Drop reference, USB core will take care of freeing it */ + usb_free_urb(urb); + } +@@ -708,7 +714,14 @@ static int mcba_usb_open(struct net_device *netdev) + + static void mcba_urb_unlink(struct mcba_priv *priv) + { ++ int i; ++ + usb_kill_anchored_urbs(&priv->rx_submitted); ++ ++ for (i = 0; i < MCBA_MAX_RX_URBS; ++i) ++ usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, ++ priv->rxbuf[i], priv->rxbuf_dma[i]); ++ + usb_kill_anchored_urbs(&priv->tx_submitted); + } + +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c +index 9e02f88645931..5e90df42b2013 100644 +--- a/drivers/net/ethernet/atheros/alx/main.c ++++ b/drivers/net/ethernet/atheros/alx/main.c +@@ -1849,6 +1849,7 @@ out_free_netdev: + free_netdev(netdev); + out_pci_release: + pci_release_mem_regions(pdev); ++ pci_disable_pcie_error_reporting(pdev); + out_pci_disable: + pci_disable_device(pdev); + return err; +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index adfaa9a850dd3..db1b89f570794 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -7184,7 +7184,7 @@ skip_rdma: + entries_sp = ctx->vnic_max_vnic_entries + ctx->qp_max_l2_entries + + 2 * (extra_qps + ctx->qp_min_qp1_entries) + min; + entries_sp = roundup(entries_sp, ctx->tqm_entries_multiple); +- entries = ctx->qp_max_l2_entries + extra_qps + ctx->qp_min_qp1_entries; ++ entries = ctx->qp_max_l2_entries + 2 * (extra_qps + ctx->qp_min_qp1_entries); + entries = roundup(entries, ctx->tqm_entries_multiple); + entries = clamp_t(u32, entries, min, ctx->tqm_max_entries_per_ring); + for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) { +@@ -11353,6 +11353,8 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp) + bnxt_hwrm_coal_params_qcaps(bp); + } + ++static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt); ++ + static int bnxt_fw_init_one(struct bnxt *bp) + { + int rc; +@@ -11367,6 +11369,9 @@ static int bnxt_fw_init_one(struct bnxt *bp) + netdev_err(bp->dev, "Firmware init phase 2 failed\n"); + return rc; + } ++ rc = bnxt_probe_phy(bp, false); ++ if (rc) ++ return rc; + rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); + if (rc) + return rc; +@@ -12741,6 +12746,7 @@ init_err_pci_clean: + bnxt_hwrm_func_drv_unrgtr(bp); + bnxt_free_hwrm_short_cmd_req(bp); + bnxt_free_hwrm_resources(bp); ++ bnxt_ethtool_free(bp); + kfree(bp->fw_health); + bp->fw_health = NULL; + bnxt_cleanup_pci(bp); +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +index 61ea3ec5c3fcc..83ed10ac86606 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +@@ -1337,13 +1337,27 @@ static int cxgb4_ethtool_flash_phy(struct net_device *netdev, + return ret; + } + +- spin_lock_bh(&adap->win0_lock); ++ /* We have to RESET the chip/firmware because we need the ++ * chip in uninitialized state for loading new PHY image. ++ * Otherwise, the running firmware will only store the PHY ++ * image in local RAM which will be lost after next reset. ++ */ ++ ret = t4_fw_reset(adap, adap->mbox, PIORSTMODE_F | PIORST_F); ++ if (ret < 0) { ++ dev_err(adap->pdev_dev, ++ "Set FW to RESET for flashing PHY FW failed. ret: %d\n", ++ ret); ++ return ret; ++ } ++ + ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size); +- spin_unlock_bh(&adap->win0_lock); +- if (ret) +- dev_err(adap->pdev_dev, "Failed to load PHY FW\n"); ++ if (ret < 0) { ++ dev_err(adap->pdev_dev, "Failed to load PHY FW. ret: %d\n", ++ ret); ++ return ret; ++ } + +- return ret; ++ return 0; + } + + static int cxgb4_ethtool_flash_fw(struct net_device *netdev, +@@ -1610,16 +1624,14 @@ static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap, + u32 ftid) + { + struct tid_info *t = &adap->tids; +- struct filter_entry *f; + +- if (ftid < t->nhpftids) +- f = &adap->tids.hpftid_tab[ftid]; +- else if (ftid < t->nftids) +- f = &adap->tids.ftid_tab[ftid - t->nhpftids]; +- else +- f = lookup_tid(&adap->tids, ftid); ++ if (ftid >= t->hpftid_base && ftid < t->hpftid_base + t->nhpftids) ++ return &t->hpftid_tab[ftid - t->hpftid_base]; + +- return f; ++ if (ftid >= t->ftid_base && ftid < t->ftid_base + t->nftids) ++ return &t->ftid_tab[ftid - t->ftid_base]; ++ ++ return lookup_tid(t, ftid); + } + + static void cxgb4_fill_filter_rule(struct ethtool_rx_flow_spec *fs, +@@ -1826,6 +1838,11 @@ static int cxgb4_ntuple_del_filter(struct net_device *dev, + filter_id = filter_info->loc_array[cmd->fs.location]; + f = cxgb4_get_filter_entry(adapter, filter_id); + ++ if (f->fs.prio) ++ filter_id -= adapter->tids.hpftid_base; ++ else if (!f->fs.hash) ++ filter_id -= (adapter->tids.ftid_base - adapter->tids.nhpftids); ++ + ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id); + if (ret) + goto err; +@@ -1885,6 +1902,11 @@ static int cxgb4_ntuple_set_filter(struct net_device *netdev, + + filter_info = &adapter->ethtool_filters->port[pi->port_id]; + ++ if (fs.prio) ++ tid += adapter->tids.hpftid_base; ++ else if (!fs.hash) ++ tid += (adapter->tids.ftid_base - adapter->tids.nhpftids); ++ + filter_info->loc_array[cmd->fs.location] = tid; + set_bit(cmd->fs.location, filter_info->bmap); + filter_info->in_use++; +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +index e664e05b9f026..5fbc087268dbe 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +@@ -198,7 +198,7 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, + WORD_MASK, f->fs.nat_lip[3] | + f->fs.nat_lip[2] << 8 | + f->fs.nat_lip[1] << 16 | +- (u64)f->fs.nat_lip[0] << 25, 1); ++ (u64)f->fs.nat_lip[0] << 24, 1); + } + } + +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +index 04dcb5e4b3161..8be525c5e2e4a 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +@@ -4428,10 +4428,8 @@ static int adap_init0_phy(struct adapter *adap) + + /* Load PHY Firmware onto adapter. + */ +- spin_lock_bh(&adap->win0_lock); + ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version, + (u8 *)phyf->data, phyf->size); +- spin_unlock_bh(&adap->win0_lock); + if (ret < 0) + dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n", + -ret); +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +index 581670dced6ec..964ea3491b80b 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +@@ -3067,16 +3067,19 @@ int t4_read_flash(struct adapter *adapter, unsigned int addr, + * @addr: the start address to write + * @n: length of data to write in bytes + * @data: the data to write ++ * @byte_oriented: whether to store data as bytes or as words + * + * Writes up to a page of data (256 bytes) to the serial flash starting + * at the given address. All the data must be written to the same page. ++ * If @byte_oriented is set the write data is stored as byte stream ++ * (i.e. matches what on disk), otherwise in big-endian. + */ + static int t4_write_flash(struct adapter *adapter, unsigned int addr, +- unsigned int n, const u8 *data) ++ unsigned int n, const u8 *data, bool byte_oriented) + { +- int ret; +- u32 buf[64]; + unsigned int i, c, left, val, offset = addr & 0xff; ++ u32 buf[64]; ++ int ret; + + if (addr >= adapter->params.sf_size || offset + n > SF_PAGE_SIZE) + return -EINVAL; +@@ -3087,10 +3090,14 @@ static int t4_write_flash(struct adapter *adapter, unsigned int addr, + (ret = sf1_write(adapter, 4, 1, 1, val)) != 0) + goto unlock; + +- for (left = n; left; left -= c) { ++ for (left = n; left; left -= c, data += c) { + c = min(left, 4U); +- for (val = 0, i = 0; i < c; ++i) +- val = (val << 8) + *data++; ++ for (val = 0, i = 0; i < c; ++i) { ++ if (byte_oriented) ++ val = (val << 8) + data[i]; ++ else ++ val = (val << 8) + data[c - i - 1]; ++ } + + ret = sf1_write(adapter, c, c != left, 1, val); + if (ret) +@@ -3103,7 +3110,8 @@ static int t4_write_flash(struct adapter *adapter, unsigned int addr, + t4_write_reg(adapter, SF_OP_A, 0); /* unlock SF */ + + /* Read the page to verify the write succeeded */ +- ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, 1); ++ ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, ++ byte_oriented); + if (ret) + return ret; + +@@ -3699,7 +3707,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) + */ + memcpy(first_page, fw_data, SF_PAGE_SIZE); + ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff); +- ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page); ++ ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page, true); + if (ret) + goto out; + +@@ -3707,14 +3715,14 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) + for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { + addr += SF_PAGE_SIZE; + fw_data += SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data); ++ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data, true); + if (ret) + goto out; + } + +- ret = t4_write_flash(adap, +- fw_start + offsetof(struct fw_hdr, fw_ver), +- sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver); ++ ret = t4_write_flash(adap, fw_start + offsetof(struct fw_hdr, fw_ver), ++ sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver, ++ true); + out: + if (ret) + dev_err(adap->pdev_dev, "firmware download failed, error %d\n", +@@ -3819,9 +3827,11 @@ int t4_load_phy_fw(struct adapter *adap, int win, + /* Copy the supplied PHY Firmware image to the adapter memory location + * allocated by the adapter firmware. + */ ++ spin_lock_bh(&adap->win0_lock); + ret = t4_memory_rw(adap, win, mtype, maddr, + phy_fw_size, (__be32 *)phy_fw_data, + T4_MEMORY_WRITE); ++ spin_unlock_bh(&adap->win0_lock); + if (ret) + return ret; + +@@ -10215,7 +10225,7 @@ int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + n = size - i; + else + n = SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, n, cfg_data); ++ ret = t4_write_flash(adap, addr, n, cfg_data, true); + if (ret) + goto out; + +@@ -10684,13 +10694,14 @@ int t4_load_boot(struct adapter *adap, u8 *boot_data, + for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { + addr += SF_PAGE_SIZE; + boot_data += SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data); ++ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data, ++ false); + if (ret) + goto out; + } + + ret = t4_write_flash(adap, boot_sector, SF_PAGE_SIZE, +- (const u8 *)header); ++ (const u8 *)header, false); + + out: + if (ret) +@@ -10765,7 +10776,7 @@ int t4_load_bootcfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + for (i = 0; i < size; i += SF_PAGE_SIZE) { + n = min_t(u32, size - i, SF_PAGE_SIZE); + +- ret = t4_write_flash(adap, addr, n, cfg_data); ++ ret = t4_write_flash(adap, addr, n, cfg_data, false); + if (ret) + goto out; + +@@ -10777,7 +10788,8 @@ int t4_load_bootcfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + for (i = 0; i < npad; i++) { + u8 data = 0; + +- ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data); ++ ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data, ++ false); + if (ret) + goto out; + } +diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c +index 46b0dbab8aadc..7c992172933bc 100644 +--- a/drivers/net/ethernet/ec_bhf.c ++++ b/drivers/net/ethernet/ec_bhf.c +@@ -576,10 +576,12 @@ static void ec_bhf_remove(struct pci_dev *dev) + struct ec_bhf_priv *priv = netdev_priv(net_dev); + + unregister_netdev(net_dev); +- free_netdev(net_dev); + + pci_iounmap(dev, priv->dma_io); + pci_iounmap(dev, priv->io); ++ ++ free_netdev(net_dev); ++ + pci_release_regions(dev); + pci_clear_master(dev); + pci_disable_device(dev); +diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c +index 676e437d78f6a..cb1e1ad652d09 100644 +--- a/drivers/net/ethernet/emulex/benet/be_main.c ++++ b/drivers/net/ethernet/emulex/benet/be_main.c +@@ -5905,6 +5905,7 @@ drv_cleanup: + unmap_bars: + be_unmap_pci_bars(adapter); + free_netdev: ++ pci_disable_pcie_error_reporting(pdev); + free_netdev(netdev); + rel_reg: + pci_release_regions(pdev); +diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c +index 1753807cbf97e..d71eac7e19249 100644 +--- a/drivers/net/ethernet/freescale/fec_ptp.c ++++ b/drivers/net/ethernet/freescale/fec_ptp.c +@@ -215,15 +215,13 @@ static u64 fec_ptp_read(const struct cyclecounter *cc) + { + struct fec_enet_private *fep = + container_of(cc, struct fec_enet_private, cc); +- const struct platform_device_id *id_entry = +- platform_get_device_id(fep->pdev); + u32 tempval; + + tempval = readl(fep->hwp + FEC_ATIME_CTRL); + tempval |= FEC_T_CTRL_CAPTURE; + writel(tempval, fep->hwp + FEC_ATIME_CTRL); + +- if (id_entry->driver_data & FEC_QUIRK_BUG_CAPTURE) ++ if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) + udelay(1); + + return readl(fep->hwp + FEC_ATIME); +@@ -604,6 +602,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) + fep->ptp_caps.enable = fec_ptp_enable; + + fep->cycle_speed = clk_get_rate(fep->clk_ptp); ++ if (!fep->cycle_speed) { ++ fep->cycle_speed = NSEC_PER_SEC; ++ dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); ++ } + fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed; + + spin_lock_init(&fep->tmreg_lock); +diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c +index fb20c6971f4c7..dc944d605a741 100644 +--- a/drivers/net/ethernet/intel/ice/ice_lib.c ++++ b/drivers/net/ethernet/intel/ice/ice_lib.c +@@ -1705,12 +1705,13 @@ setup_rings: + * ice_vsi_cfg_txqs - Configure the VSI for Tx + * @vsi: the VSI being configured + * @rings: Tx ring array to be configured ++ * @count: number of Tx ring array elements + * + * Return 0 on success and a negative value on error + * Configure the Tx VSI for operation. + */ + static int +-ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings) ++ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, u16 count) + { + struct ice_aqc_add_tx_qgrp *qg_buf; + u16 q_idx = 0; +@@ -1722,7 +1723,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings) + + qg_buf->num_txqs = 1; + +- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) { ++ for (q_idx = 0; q_idx < count; q_idx++) { + err = ice_vsi_cfg_txq(vsi, rings[q_idx], qg_buf); + if (err) + goto err_cfg_txqs; +@@ -1742,7 +1743,7 @@ err_cfg_txqs: + */ + int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi) + { +- return ice_vsi_cfg_txqs(vsi, vsi->tx_rings); ++ return ice_vsi_cfg_txqs(vsi, vsi->tx_rings, vsi->num_txq); + } + + /** +@@ -1757,7 +1758,7 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi) + int ret; + int i; + +- ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings); ++ ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings, vsi->num_xdp_txq); + if (ret) + return ret; + +@@ -1955,17 +1956,18 @@ int ice_vsi_stop_all_rx_rings(struct ice_vsi *vsi) + * @rst_src: reset source + * @rel_vmvf_num: Relative ID of VF/VM + * @rings: Tx ring array to be stopped ++ * @count: number of Tx ring array elements + */ + static int + ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, +- u16 rel_vmvf_num, struct ice_ring **rings) ++ u16 rel_vmvf_num, struct ice_ring **rings, u16 count) + { + u16 q_idx; + + if (vsi->num_txq > ICE_LAN_TXQ_MAX_QDIS) + return -EINVAL; + +- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) { ++ for (q_idx = 0; q_idx < count; q_idx++) { + struct ice_txq_meta txq_meta = { }; + int status; + +@@ -1993,7 +1995,7 @@ int + ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, + u16 rel_vmvf_num) + { +- return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings); ++ return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings, vsi->num_txq); + } + + /** +@@ -2002,7 +2004,7 @@ ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, + */ + int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi) + { +- return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings); ++ return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings, vsi->num_xdp_txq); + } + + /** +diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c +index 6f30aad7695fb..1567ddd4c5b87 100644 +--- a/drivers/net/ethernet/intel/ice/ice_main.c ++++ b/drivers/net/ethernet/intel/ice/ice_main.c +@@ -2539,6 +2539,20 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog, + return (ret || xdp_ring_err) ? -ENOMEM : 0; + } + ++/** ++ * ice_xdp_safe_mode - XDP handler for safe mode ++ * @dev: netdevice ++ * @xdp: XDP command ++ */ ++static int ice_xdp_safe_mode(struct net_device __always_unused *dev, ++ struct netdev_bpf *xdp) ++{ ++ NL_SET_ERR_MSG_MOD(xdp->extack, ++ "Please provide working DDP firmware package in order to use XDP\n" ++ "Refer to Documentation/networking/device_drivers/ethernet/intel/ice.rst"); ++ return -EOPNOTSUPP; ++} ++ + /** + * ice_xdp - implements XDP handler + * @dev: netdevice +@@ -6786,6 +6800,7 @@ static const struct net_device_ops ice_netdev_safe_mode_ops = { + .ndo_change_mtu = ice_change_mtu, + .ndo_get_stats64 = ice_get_stats64, + .ndo_tx_timeout = ice_tx_timeout, ++ .ndo_bpf = ice_xdp_safe_mode, + }; + + static const struct net_device_ops ice_netdev_ops = { +diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c +index 135ba5b6ae980..072075bc60ee9 100644 +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev) + + static int xrx200_alloc_skb(struct xrx200_chan *ch) + { ++ struct sk_buff *skb = ch->skb[ch->dma.desc]; + dma_addr_t mapping; + int ret = 0; + +@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch) + XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) { + dev_kfree_skb_any(ch->skb[ch->dma.desc]); ++ ch->skb[ch->dma.desc] = skb; + ret = -ENOMEM; + goto skip; + } +@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch) + ch->dma.desc %= LTQ_DESC_NUM; + + if (ret) { +- ch->skb[ch->dma.desc] = skb; + net_dev->stats.rx_dropped++; + netdev_err(net_dev, "failed to allocate new rx buffer\n"); + return ret; +@@ -352,8 +353,8 @@ static irqreturn_t xrx200_dma_irq(int irq, void *ptr) + struct xrx200_chan *ch = ptr; + + if (napi_schedule_prep(&ch->napi)) { +- __napi_schedule(&ch->napi); + ltq_dma_disable_irq(&ch->dma); ++ __napi_schedule(&ch->napi); + } + + ltq_dma_ack_irq(&ch->dma); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +index 3d45341e2216f..26f7fab109d97 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +@@ -532,9 +532,6 @@ void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv) + struct mlx5_core_dev *mdev = priv->mdev; + struct net_device *netdev = priv->netdev; + +- if (!priv->ipsec) +- return; +- + if (!(mlx5_accel_ipsec_device_caps(mdev) & MLX5_ACCEL_IPSEC_CAP_ESP) || + !MLX5_CAP_ETH(mdev, swp)) { + mlx5_core_dbg(mdev, "mlx5e: ESP and SWP offload not supported\n"); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +index f18b52be32e98..d81fa8e561991 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +@@ -4958,13 +4958,9 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) + } + + if (mlx5_vxlan_allowed(mdev->vxlan) || mlx5_geneve_tx_allowed(mdev)) { +- netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; ++ netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL; + } + + if (mlx5e_tunnel_proto_supported(mdev, IPPROTO_GRE)) { +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +index 80abdb0b47d7e..59837af959d06 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -5206,7 +5206,7 @@ static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv, + list_for_each_entry_safe(hpe, tmp, &init_wait_list, dead_peer_wait_list) { + wait_for_completion(&hpe->res_ready); + if (!IS_ERR_OR_NULL(hpe->hp) && hpe->peer_vhca_id == peer_vhca_id) +- hpe->hp->pair->peer_gone = true; ++ mlx5_core_hairpin_clear_dead_peer(hpe->hp->pair); + + mlx5e_hairpin_put(priv, hpe); + } +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +index d61539b5567c0..401b2f5128dd4 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +@@ -1302,6 +1302,12 @@ static int esw_enable_vport(struct mlx5_eswitch *esw, u16 vport_num, + (!vport_num && mlx5_core_is_ecpf(esw->dev))) + vport->info.trusted = true; + ++ /* External controller host PF has factory programmed MAC. ++ * Read it from the device. ++ */ ++ if (mlx5_core_is_ecpf(esw->dev) && vport_num == MLX5_VPORT_PF) ++ mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, vport->info.mac); ++ + esw_vport_change_handle_locked(vport); + + esw->enabled_vports++; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c +index 9eb51f06d3ae2..d1972508338cf 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c +@@ -54,7 +54,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, + mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index); + mkey->iova = MLX5_GET64(mkc, mkc, start_addr); + mkey->size = MLX5_GET64(mkc, mkc, len); +- mkey->key |= mlx5_idx_to_mkey(mkey_index); ++ mkey->key = (u32)mlx5_mkey_variant(mkey->key) | mlx5_idx_to_mkey(mkey_index); + mkey->pd = MLX5_GET(mkc, mkc, pd); + + mlx5_core_dbg(dev, "out 0x%x, mkey 0x%x\n", mkey_index, mkey->key); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +index 8e0dddc6383f0..2389239acadc9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +@@ -156,6 +156,9 @@ void mlx5_rdma_enable_roce(struct mlx5_core_dev *dev) + { + int err; + ++ if (!MLX5_CAP_GEN(dev, roce)) ++ return; ++ + err = mlx5_nic_vport_enable_roce(dev); + if (err) { + mlx5_core_err(dev, "Failed to enable RoCE: %d\n", err); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +index 51bbd88ff021c..fd56cae0d54fc 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_cmd.c +@@ -78,9 +78,9 @@ int mlx5dr_cmd_query_esw_caps(struct mlx5_core_dev *mdev, + caps->uplink_icm_address_tx = + MLX5_CAP64_ESW_FLOWTABLE(mdev, + sw_steering_uplink_icm_address_tx); +- caps->sw_owner = +- MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, +- sw_owner); ++ caps->sw_owner_v2 = MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, sw_owner_v2); ++ if (!caps->sw_owner_v2) ++ caps->sw_owner = MLX5_CAP_ESW_FLOWTABLE_FDB(mdev, sw_owner); + + return 0; + } +@@ -113,10 +113,15 @@ int mlx5dr_cmd_query_device(struct mlx5_core_dev *mdev, + caps->nic_tx_allow_address = + MLX5_CAP64_FLOWTABLE(mdev, sw_steering_nic_tx_action_allow_icm_address); + +- caps->rx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner); +- caps->max_ft_level = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, max_ft_level); ++ caps->rx_sw_owner_v2 = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner_v2); ++ caps->tx_sw_owner_v2 = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner_v2); ++ ++ if (!caps->rx_sw_owner_v2) ++ caps->rx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, sw_owner); ++ if (!caps->tx_sw_owner_v2) ++ caps->tx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner); + +- caps->tx_sw_owner = MLX5_CAP_FLOWTABLE_NIC_TX(mdev, sw_owner); ++ caps->max_ft_level = MLX5_CAP_FLOWTABLE_NIC_RX(mdev, max_ft_level); + + caps->log_icm_size = MLX5_CAP_DEV_MEM(mdev, log_steering_sw_icm_size); + caps->hdr_modify_icm_addr = +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +index aa2c2d6c44e6b..00d861361428f 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_domain.c +@@ -4,6 +4,11 @@ + #include + #include "dr_types.h" + ++#define DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, dmn_type) \ ++ ((dmn)->info.caps.dmn_type##_sw_owner || \ ++ ((dmn)->info.caps.dmn_type##_sw_owner_v2 && \ ++ (dmn)->info.caps.sw_format_ver <= MLX5_STEERING_FORMAT_CONNECTX_6DX)) ++ + static int dr_domain_init_cache(struct mlx5dr_domain *dmn) + { + /* Per vport cached FW FT for checksum recalculation, this +@@ -181,6 +186,7 @@ static int dr_domain_query_fdb_caps(struct mlx5_core_dev *mdev, + return ret; + + dmn->info.caps.fdb_sw_owner = dmn->info.caps.esw_caps.sw_owner; ++ dmn->info.caps.fdb_sw_owner_v2 = dmn->info.caps.esw_caps.sw_owner_v2; + dmn->info.caps.esw_rx_drop_address = dmn->info.caps.esw_caps.drop_icm_address_rx; + dmn->info.caps.esw_tx_drop_address = dmn->info.caps.esw_caps.drop_icm_address_tx; + +@@ -223,18 +229,13 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev, + if (ret) + return ret; + +- if (dmn->info.caps.sw_format_ver != MLX5_STEERING_FORMAT_CONNECTX_5) { +- mlx5dr_err(dmn, "SW steering is not supported on this device\n"); +- return -EOPNOTSUPP; +- } +- + ret = dr_domain_query_fdb_caps(mdev, dmn); + if (ret) + return ret; + + switch (dmn->type) { + case MLX5DR_DOMAIN_TYPE_NIC_RX: +- if (!dmn->info.caps.rx_sw_owner) ++ if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, rx)) + return -ENOTSUPP; + + dmn->info.supp_sw_steering = true; +@@ -243,7 +244,7 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev, + dmn->info.rx.drop_icm_addr = dmn->info.caps.nic_rx_drop_address; + break; + case MLX5DR_DOMAIN_TYPE_NIC_TX: +- if (!dmn->info.caps.tx_sw_owner) ++ if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, tx)) + return -ENOTSUPP; + + dmn->info.supp_sw_steering = true; +@@ -255,7 +256,7 @@ static int dr_domain_caps_init(struct mlx5_core_dev *mdev, + if (!dmn->info.caps.eswitch_manager) + return -ENOTSUPP; + +- if (!dmn->info.caps.fdb_sw_owner) ++ if (!DR_DOMAIN_SW_STEERING_SUPPORTED(dmn, fdb)) + return -ENOTSUPP; + + dmn->info.rx.ste_type = MLX5DR_STE_TYPE_RX; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +index cf62ea4f882e6..42c49f09e9d3f 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_types.h +@@ -597,7 +597,8 @@ struct mlx5dr_esw_caps { + u64 drop_icm_address_tx; + u64 uplink_icm_address_rx; + u64 uplink_icm_address_tx; +- bool sw_owner; ++ u8 sw_owner:1; ++ u8 sw_owner_v2:1; + }; + + struct mlx5dr_cmd_vport_cap { +@@ -630,6 +631,9 @@ struct mlx5dr_cmd_caps { + bool rx_sw_owner; + bool tx_sw_owner; + bool fdb_sw_owner; ++ u8 rx_sw_owner_v2:1; ++ u8 tx_sw_owner_v2:1; ++ u8 fdb_sw_owner_v2:1; + u32 num_vports; + struct mlx5dr_esw_caps esw_caps; + struct mlx5dr_cmd_vport_cap *vports_caps; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +index 7914fe3fc68d8..454968ba68313 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +@@ -124,7 +124,11 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action); + static inline bool + mlx5dr_is_supported(struct mlx5_core_dev *dev) + { +- return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner); ++ return MLX5_CAP_GEN(dev, roce) && ++ (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) || ++ (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) && ++ (MLX5_CAP_GEN(dev, steering_format_version) <= ++ MLX5_STEERING_FORMAT_CONNECTX_6DX))); + } + + #endif /* _MLX5DR_H_ */ +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +index 01cc00ad8acf2..b6931bbe52d29 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +@@ -424,6 +424,15 @@ err_modify_sq: + return err; + } + ++static void mlx5_hairpin_unpair_peer_sq(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, ++ MLX5_SQC_STATE_RST, 0, 0); ++} ++ + static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + { + int i; +@@ -432,13 +441,9 @@ static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + for (i = 0; i < hp->num_channels; i++) + mlx5_hairpin_modify_rq(hp->func_mdev, hp->rqn[i], MLX5_RQC_STATE_RDY, + MLX5_RQC_STATE_RST, 0, 0); +- + /* unset peer SQs */ +- if (hp->peer_gone) +- return; +- for (i = 0; i < hp->num_channels; i++) +- mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, +- MLX5_SQC_STATE_RST, 0, 0); ++ if (!hp->peer_gone) ++ mlx5_hairpin_unpair_peer_sq(hp); + } + + struct mlx5_hairpin * +@@ -485,3 +490,16 @@ void mlx5_core_hairpin_destroy(struct mlx5_hairpin *hp) + mlx5_hairpin_destroy_queues(hp); + kfree(hp); + } ++ ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ mlx5_hairpin_unpair_peer_sq(hp); ++ ++ /* destroy peer SQ */ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_core_destroy_sq(hp->peer_mdev, hp->sqn[i]); ++ ++ hp->peer_gone = true; ++} +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c +index bdafc85fd874d..fc91bbf7d0c37 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c +@@ -464,8 +464,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev, + void *in; + int err; + +- if (!vport) +- return -EINVAL; + if (!MLX5_CAP_GEN(mdev, vport_group_manager)) + return -EACCES; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index bf85ce9835d7f..42e4437ac3c16 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -708,7 +708,8 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) + MLXSW_THERMAL_TRIP_MASK, + module_tz, + &mlxsw_thermal_module_ops, +- NULL, 0, 0); ++ NULL, 0, ++ module_tz->parent->polling_delay); + if (IS_ERR(module_tz->tzdev)) { + err = PTR_ERR(module_tz->tzdev); + return err; +@@ -830,7 +831,8 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) + MLXSW_THERMAL_TRIP_MASK, + gearbox_tz, + &mlxsw_thermal_gearbox_ops, +- NULL, 0, 0); ++ NULL, 0, ++ gearbox_tz->parent->polling_delay); + if (IS_ERR(gearbox_tz->tzdev)) + return PTR_ERR(gearbox_tz->tzdev); + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index 3c3069afc0a31..c670bf3464c2a 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -3641,7 +3641,7 @@ MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6); + #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25 + #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5 + #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11 +-#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 5 ++#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11 + + static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port, + enum mlxsw_reg_qeec_hr hr, u8 index, +diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c +index aa400b925b08e..5bfc7acfd13a9 100644 +--- a/drivers/net/ethernet/mscc/ocelot.c ++++ b/drivers/net/ethernet/mscc/ocelot.c +@@ -355,6 +355,7 @@ static u32 ocelot_read_eq_avail(struct ocelot *ocelot, int port) + + int ocelot_port_flush(struct ocelot *ocelot, int port) + { ++ unsigned int pause_ena; + int err, val; + + /* Disable dequeuing from the egress queues */ +@@ -363,6 +364,7 @@ int ocelot_port_flush(struct ocelot *ocelot, int port) + QSYS_PORT_MODE, port); + + /* Disable flow control */ ++ ocelot_fields_read(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, &pause_ena); + ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 0); + + /* Disable priority flow control */ +@@ -398,6 +400,9 @@ int ocelot_port_flush(struct ocelot *ocelot, int port) + /* Clear flushing again. */ + ocelot_rmw_gix(ocelot, 0, REW_PORT_CFG_FLUSH_ENA, REW_PORT_CFG, port); + ++ /* Re-enable flow control */ ++ ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, pause_ena); ++ + return err; + } + EXPORT_SYMBOL(ocelot_port_flush); +diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +index d258e0ccf9465..e2046b6d65a30 100644 +--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c ++++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +@@ -1602,6 +1602,8 @@ err_out_free_netdev: + free_netdev(netdev); + + err_out_free_res: ++ if (NX_IS_REVISION_P3(pdev->revision)) ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +index c2faf96fcade8..27c07b2412f46 100644 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +@@ -2692,6 +2692,7 @@ err_out_free_hw_res: + kfree(ahw); + + err_out_free_res: ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +index fcdecddb28122..8d51b0cb545ca 100644 +--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c ++++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.c +@@ -26,7 +26,7 @@ static int rmnet_is_real_dev_registered(const struct net_device *real_dev) + } + + /* Needs rtnl lock */ +-static struct rmnet_port* ++struct rmnet_port* + rmnet_get_port_rtnl(const struct net_device *real_dev) + { + return rtnl_dereference(real_dev->rx_handler_data); +@@ -253,7 +253,10 @@ static int rmnet_config_notify_cb(struct notifier_block *nb, + netdev_dbg(real_dev, "Kernel unregister\n"); + rmnet_force_unassociate_device(real_dev); + break; +- ++ case NETDEV_CHANGEMTU: ++ if (rmnet_vnd_validate_real_dev_mtu(real_dev)) ++ return NOTIFY_BAD; ++ break; + default: + break; + } +@@ -329,9 +332,17 @@ static int rmnet_changelink(struct net_device *dev, struct nlattr *tb[], + + if (data[IFLA_RMNET_FLAGS]) { + struct ifla_rmnet_flags *flags; ++ u32 old_data_format; + ++ old_data_format = port->data_format; + flags = nla_data(data[IFLA_RMNET_FLAGS]); + port->data_format = flags->flags & flags->mask; ++ ++ if (rmnet_vnd_update_dev_mtu(port, real_dev)) { ++ port->data_format = old_data_format; ++ NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev"); ++ return -EINVAL; ++ } + } + + return 0; +diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +index be515982d6286..8d8d4690a0745 100644 +--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h ++++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_config.h +@@ -73,4 +73,6 @@ int rmnet_add_bridge(struct net_device *rmnet_dev, + struct netlink_ext_ack *extack); + int rmnet_del_bridge(struct net_device *rmnet_dev, + struct net_device *slave_dev); ++struct rmnet_port* ++rmnet_get_port_rtnl(const struct net_device *real_dev); + #endif /* _RMNET_CONFIG_H_ */ +diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +index d58b51d277f18..2adcf24848a45 100644 +--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c ++++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +@@ -58,9 +58,30 @@ static netdev_tx_t rmnet_vnd_start_xmit(struct sk_buff *skb, + return NETDEV_TX_OK; + } + ++static int rmnet_vnd_headroom(struct rmnet_port *port) ++{ ++ u32 headroom; ++ ++ headroom = sizeof(struct rmnet_map_header); ++ ++ if (port->data_format & RMNET_FLAGS_EGRESS_MAP_CKSUMV4) ++ headroom += sizeof(struct rmnet_map_ul_csum_header); ++ ++ return headroom; ++} ++ + static int rmnet_vnd_change_mtu(struct net_device *rmnet_dev, int new_mtu) + { +- if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE) ++ struct rmnet_priv *priv = netdev_priv(rmnet_dev); ++ struct rmnet_port *port; ++ u32 headroom; ++ ++ port = rmnet_get_port_rtnl(priv->real_dev); ++ ++ headroom = rmnet_vnd_headroom(port); ++ ++ if (new_mtu < 0 || new_mtu > RMNET_MAX_PACKET_SIZE || ++ new_mtu > (priv->real_dev->mtu - headroom)) + return -EINVAL; + + rmnet_dev->mtu = new_mtu; +@@ -104,24 +125,24 @@ static void rmnet_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *s) + { + struct rmnet_priv *priv = netdev_priv(dev); +- struct rmnet_vnd_stats total_stats; ++ struct rmnet_vnd_stats total_stats = { }; + struct rmnet_pcpu_stats *pcpu_ptr; ++ struct rmnet_vnd_stats snapshot; + unsigned int cpu, start; + +- memset(&total_stats, 0, sizeof(struct rmnet_vnd_stats)); +- + for_each_possible_cpu(cpu) { + pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu); + + do { + start = u64_stats_fetch_begin_irq(&pcpu_ptr->syncp); +- total_stats.rx_pkts += pcpu_ptr->stats.rx_pkts; +- total_stats.rx_bytes += pcpu_ptr->stats.rx_bytes; +- total_stats.tx_pkts += pcpu_ptr->stats.tx_pkts; +- total_stats.tx_bytes += pcpu_ptr->stats.tx_bytes; ++ snapshot = pcpu_ptr->stats; /* struct assignment */ + } while (u64_stats_fetch_retry_irq(&pcpu_ptr->syncp, start)); + +- total_stats.tx_drops += pcpu_ptr->stats.tx_drops; ++ total_stats.rx_pkts += snapshot.rx_pkts; ++ total_stats.rx_bytes += snapshot.rx_bytes; ++ total_stats.tx_pkts += snapshot.tx_pkts; ++ total_stats.tx_bytes += snapshot.tx_bytes; ++ total_stats.tx_drops += snapshot.tx_drops; + } + + s->rx_packets = total_stats.rx_pkts; +@@ -229,6 +250,7 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, + + { + struct rmnet_priv *priv = netdev_priv(rmnet_dev); ++ u32 headroom; + int rc; + + if (rmnet_get_endpoint(port, id)) { +@@ -242,6 +264,13 @@ int rmnet_vnd_newlink(u8 id, struct net_device *rmnet_dev, + + priv->real_dev = real_dev; + ++ headroom = rmnet_vnd_headroom(port); ++ ++ if (rmnet_vnd_change_mtu(rmnet_dev, real_dev->mtu - headroom)) { ++ NL_SET_ERR_MSG_MOD(extack, "Invalid MTU on real dev"); ++ return -EINVAL; ++ } ++ + rc = register_netdevice(rmnet_dev); + if (!rc) { + ep->egress_dev = rmnet_dev; +@@ -283,3 +312,45 @@ int rmnet_vnd_do_flow_control(struct net_device *rmnet_dev, int enable) + + return 0; + } ++ ++int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev) ++{ ++ struct hlist_node *tmp_ep; ++ struct rmnet_endpoint *ep; ++ struct rmnet_port *port; ++ unsigned long bkt_ep; ++ u32 headroom; ++ ++ port = rmnet_get_port_rtnl(real_dev); ++ ++ headroom = rmnet_vnd_headroom(port); ++ ++ hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) { ++ if (ep->egress_dev->mtu > (real_dev->mtu - headroom)) ++ return -1; ++ } ++ ++ return 0; ++} ++ ++int rmnet_vnd_update_dev_mtu(struct rmnet_port *port, ++ struct net_device *real_dev) ++{ ++ struct hlist_node *tmp_ep; ++ struct rmnet_endpoint *ep; ++ unsigned long bkt_ep; ++ u32 headroom; ++ ++ headroom = rmnet_vnd_headroom(port); ++ ++ hash_for_each_safe(port->muxed_ep, bkt_ep, tmp_ep, ep, hlnode) { ++ if (ep->egress_dev->mtu <= (real_dev->mtu - headroom)) ++ continue; ++ ++ if (rmnet_vnd_change_mtu(ep->egress_dev, ++ real_dev->mtu - headroom)) ++ return -1; ++ } ++ ++ return 0; ++} +diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h +index 4967f3461ed1e..dc3a4443ef0af 100644 +--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h ++++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.h +@@ -18,4 +18,7 @@ int rmnet_vnd_dellink(u8 id, struct rmnet_port *port, + void rmnet_vnd_rx_fixup(struct sk_buff *skb, struct net_device *dev); + void rmnet_vnd_tx_fixup(struct sk_buff *skb, struct net_device *dev); + void rmnet_vnd_setup(struct net_device *dev); ++int rmnet_vnd_validate_real_dev_mtu(struct net_device *real_dev); ++int rmnet_vnd_update_dev_mtu(struct rmnet_port *port, ++ struct net_device *real_dev); + #endif /* _RMNET_VND_H_ */ +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +index b70d44ac09906..3c73453725f94 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +@@ -76,10 +76,10 @@ enum power_event { + #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */ + + /* GMAC HW ADDR regs */ +-#define GMAC_ADDR_HIGH(reg) (((reg > 15) ? 0x00000800 : 0x00000040) + \ +- (reg * 8)) +-#define GMAC_ADDR_LOW(reg) (((reg > 15) ? 0x00000804 : 0x00000044) + \ +- (reg * 8)) ++#define GMAC_ADDR_HIGH(reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \ ++ 0x00000040 + (reg * 8)) ++#define GMAC_ADDR_LOW(reg) ((reg > 15) ? 0x00000804 + (reg - 16) * 8 : \ ++ 0x00000044 + (reg * 8)) + #define GMAC_MAX_PERFECT_ADDRESSES 1 + + #define GMAC_PCS_BASE 0x000000c0 /* PCS register base */ +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +index af34a4cadbb0a..ff95400594fc1 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +@@ -626,6 +626,8 @@ error_pclk_get: + void stmmac_remove_config_dt(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) + { ++ clk_disable_unprepare(plat->stmmac_clk); ++ clk_disable_unprepare(plat->pclk); + of_node_put(plat->phy_node); + of_node_put(plat->mdio_node); + } +diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c +index 030185301014c..01bb36e7cff0a 100644 +--- a/drivers/net/ethernet/xilinx/ll_temac_main.c ++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c +@@ -849,7 +849,7 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + smp_mb(); + + /* Space might have just been freed - check again */ +- if (temac_check_tx_bd_space(lp, num_frag)) ++ if (temac_check_tx_bd_space(lp, num_frag + 1)) + return NETDEV_TX_BUSY; + + netif_wake_queue(ndev); +@@ -876,7 +876,6 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + return NETDEV_TX_OK; + } + cur_p->phys = cpu_to_be32(skb_dma_addr); +- ptr_to_txbd((void *)skb, cur_p); + + for (ii = 0; ii < num_frag; ii++) { + if (++lp->tx_bd_tail >= lp->tx_bd_num) +@@ -915,6 +914,11 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + } + cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_EOP); + ++ /* Mark last fragment with skb address, so it can be consumed ++ * in temac_start_xmit_done() ++ */ ++ ptr_to_txbd((void *)skb, cur_p); ++ + tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; + lp->tx_bd_tail++; + if (lp->tx_bd_tail >= lp->tx_bd_num) +diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c +index 17be2bb2985cd..920e9f888cc35 100644 +--- a/drivers/net/hamradio/mkiss.c ++++ b/drivers/net/hamradio/mkiss.c +@@ -799,6 +799,7 @@ static void mkiss_close(struct tty_struct *tty) + ax->tty = NULL; + + unregister_netdev(ax->dev); ++ free_netdev(ax->dev); + } + + /* Perform I/O control on an active ax25 channel. */ +diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c +index 0eeec80bec311..e4a5703666461 100644 +--- a/drivers/net/usb/cdc_eem.c ++++ b/drivers/net/usb/cdc_eem.c +@@ -123,10 +123,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, + } + + skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); ++ dev_kfree_skb_any(skb); + if (!skb2) + return NULL; + +- dev_kfree_skb_any(skb); + skb = skb2; + + done: +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c +index 1d3bf810f2ca1..04c4f1570bc8c 100644 +--- a/drivers/net/usb/cdc_ncm.c ++++ b/drivers/net/usb/cdc_ncm.c +@@ -1900,7 +1900,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) + static const struct driver_info cdc_ncm_info = { + .description = "CDC NCM", + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET +- | FLAG_LINK_INTR, ++ | FLAG_LINK_INTR | FLAG_ETHER, + .bind = cdc_ncm_bind, + .unbind = cdc_ncm_unbind, + .manage_power = usbnet_manage_power, +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c +index d44657b54d2b6..378a12ae2d957 100644 +--- a/drivers/net/usb/smsc75xx.c ++++ b/drivers/net/usb/smsc75xx.c +@@ -1483,7 +1483,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_wait_ready(dev, 0); + if (ret < 0) { + netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); +- goto err; ++ goto free_pdata; + } + + smsc75xx_init_mac_address(dev); +@@ -1492,7 +1492,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_reset(dev); + if (ret < 0) { + netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); +- goto err; ++ goto cancel_work; + } + + dev->net->netdev_ops = &smsc75xx_netdev_ops; +@@ -1503,8 +1503,11 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; + return 0; + +-err: ++cancel_work: ++ cancel_work_sync(&pdata->set_multicast); ++free_pdata: + kfree(pdata); ++ dev->data[0] = 0; + return ret; + } + +@@ -1515,7 +1518,6 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) + cancel_work_sync(&pdata->set_multicast); + netif_dbg(dev, ifdown, dev->net, "free pdata\n"); + kfree(pdata); +- pdata = NULL; + dev->data[0] = 0; + } + } +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c +index b9b7e00b72a84..bc96ac0c5769c 100644 +--- a/drivers/net/vrf.c ++++ b/drivers/net/vrf.c +@@ -1184,9 +1184,6 @@ static int vrf_dev_init(struct net_device *dev) + + dev->flags = IFF_MASTER | IFF_NOARP; + +- /* MTU is irrelevant for VRF device; set to 64k similar to lo */ +- dev->mtu = 64 * 1024; +- + /* similarly, oper state is irrelevant; set to up to avoid confusion */ + dev->operstate = IF_OPER_UP; + netdev_lockdep_set_classes(dev); +@@ -1620,7 +1617,8 @@ static void vrf_setup(struct net_device *dev) + * which breaks networking. + */ + dev->min_mtu = IPV6_MIN_MTU; +- dev->max_mtu = ETH_MAX_MTU; ++ dev->max_mtu = IP6_MAX_MTU; ++ dev->mtu = dev->max_mtu; + } + + static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], +diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c +index 0be485a253273..41be72c74e3a4 100644 +--- a/drivers/pci/controller/pci-aardvark.c ++++ b/drivers/pci/controller/pci-aardvark.c +@@ -514,7 +514,7 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie) + udelay(PIO_RETRY_DELAY); + } + +- dev_err(dev, "config read/write timed out\n"); ++ dev_err(dev, "PIO read/write transfer time out\n"); + return -ETIMEDOUT; + } + +@@ -657,6 +657,35 @@ static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, + return true; + } + ++static bool advk_pcie_pio_is_running(struct advk_pcie *pcie) ++{ ++ struct device *dev = &pcie->pdev->dev; ++ ++ /* ++ * Trying to start a new PIO transfer when previous has not completed ++ * cause External Abort on CPU which results in kernel panic: ++ * ++ * SError Interrupt on CPU0, code 0xbf000002 -- SError ++ * Kernel panic - not syncing: Asynchronous SError Interrupt ++ * ++ * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected ++ * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent ++ * concurrent calls at the same time. But because PIO transfer may take ++ * about 1.5s when link is down or card is disconnected, it means that ++ * advk_pcie_wait_pio() does not always have to wait for completion. ++ * ++ * Some versions of ARM Trusted Firmware handles this External Abort at ++ * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit: ++ * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50 ++ */ ++ if (advk_readl(pcie, PIO_START)) { ++ dev_err(dev, "Previous PIO read/write transfer is still running\n"); ++ return true; ++ } ++ ++ return false; ++} ++ + static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + int where, int size, u32 *val) + { +@@ -673,9 +702,10 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + return pci_bridge_emul_conf_read(&pcie->bridge, where, + size, val); + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) { ++ *val = 0xffffffff; ++ return PCIBIOS_SET_FAILED; ++ } + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -694,7 +724,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, 0xf, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +@@ -734,9 +765,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + if (where % size) + return PCIBIOS_SET_FAILED; + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) ++ return PCIBIOS_SET_FAILED; + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -763,7 +793,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index b570f297e3ec1..16fb3d7714d51 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -3557,6 +3557,18 @@ static void quirk_no_bus_reset(struct pci_dev *dev) + dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; + } + ++/* ++ * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be ++ * prevented for those affected devices. ++ */ ++static void quirk_nvidia_no_bus_reset(struct pci_dev *dev) ++{ ++ if ((dev->device & 0xffc0) == 0x2340) ++ quirk_no_bus_reset(dev); ++} ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, ++ quirk_nvidia_no_bus_reset); ++ + /* + * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. + * The device will throw a Link Down error on AER-capable systems and +@@ -3577,6 +3589,16 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset); + */ + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset); + ++/* ++ * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS ++ * automatically disables LTSSM when Secondary Bus Reset is received and ++ * the device stops working. Prevent bus reset for these devices. With ++ * this change, the device can be assigned to VMs with VFIO, but it will ++ * leak state between VMs. Reference ++ * https://e2e.ti.com/support/processors/f/791/t/954382 ++ */ ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0xb005, quirk_no_bus_reset); ++ + static void quirk_no_pm_reset(struct pci_dev *dev) + { + /* +@@ -3912,6 +3934,69 @@ static int delay_250ms_after_flr(struct pci_dev *dev, int probe) + return 0; + } + ++#define PCI_DEVICE_ID_HINIC_VF 0x375E ++#define HINIC_VF_FLR_TYPE 0x1000 ++#define HINIC_VF_FLR_CAP_BIT (1UL << 30) ++#define HINIC_VF_OP 0xE80 ++#define HINIC_VF_FLR_PROC_BIT (1UL << 18) ++#define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */ ++ ++/* Device-specific reset method for Huawei Intelligent NIC virtual functions */ ++static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe) ++{ ++ unsigned long timeout; ++ void __iomem *bar; ++ u32 val; ++ ++ if (probe) ++ return 0; ++ ++ bar = pci_iomap(pdev, 0, 0); ++ if (!bar) ++ return -ENOTTY; ++ ++ /* Get and check firmware capabilities */ ++ val = ioread32be(bar + HINIC_VF_FLR_TYPE); ++ if (!(val & HINIC_VF_FLR_CAP_BIT)) { ++ pci_iounmap(pdev, bar); ++ return -ENOTTY; ++ } ++ ++ /* Set HINIC_VF_FLR_PROC_BIT for the start of FLR */ ++ val = ioread32be(bar + HINIC_VF_OP); ++ val = val | HINIC_VF_FLR_PROC_BIT; ++ iowrite32be(val, bar + HINIC_VF_OP); ++ ++ pcie_flr(pdev); ++ ++ /* ++ * The device must recapture its Bus and Device Numbers after FLR ++ * in order generate Completions. Issue a config write to let the ++ * device capture this information. ++ */ ++ pci_write_config_word(pdev, PCI_VENDOR_ID, 0); ++ ++ /* Firmware clears HINIC_VF_FLR_PROC_BIT when reset is complete */ ++ timeout = jiffies + msecs_to_jiffies(HINIC_OPERATION_TIMEOUT); ++ do { ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ msleep(20); ++ } while (time_before(jiffies, timeout)); ++ ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ ++ pci_warn(pdev, "Reset dev timeout, FLR ack reg: %#010x\n", val); ++ ++reset_complete: ++ pci_iounmap(pdev, bar); ++ ++ return 0; ++} ++ + static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF, + reset_intel_82599_sfp_virtfn }, +@@ -3923,6 +4008,8 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, 0x0953, delay_250ms_after_flr }, + { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, + reset_chelsio_generic_dev }, ++ { PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF, ++ reset_hinic_vf_dev }, + { 0 } + }; + +@@ -4763,6 +4850,8 @@ static const struct pci_dev_acs_enabled { + { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, ++ /* Broadcom multi-function device */ ++ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, + /* Amazon Annapurna Labs */ + { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, +diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c +index cdbcc49f71152..731c483a04dea 100644 +--- a/drivers/phy/mediatek/phy-mtk-tphy.c ++++ b/drivers/phy/mediatek/phy-mtk-tphy.c +@@ -949,6 +949,8 @@ static int mtk_phy_init(struct phy *phy) + break; + default: + dev_err(tphy->dev, "incompatible PHY type\n"); ++ clk_disable_unprepare(instance->ref_clk); ++ clk_disable_unprepare(instance->da_ref_clk); + return -EINVAL; + } + +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 1c25af28a7233..5c2f2e337b57b 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -8806,6 +8806,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = { + TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd gen) */ + TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd gen) */ + TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1st gen) */ ++ TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ + }; + + static int __init fan_init(struct ibm_init_struct *iibm) +diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c +index 03a246e60fd98..21c4c34c52d8d 100644 +--- a/drivers/ptp/ptp_clock.c ++++ b/drivers/ptp/ptp_clock.c +@@ -63,7 +63,7 @@ static void enqueue_external_timestamp(struct timestamp_event_queue *queue, + spin_unlock_irqrestore(&queue->lock, flags); + } + +-s32 scaled_ppm_to_ppb(long ppm) ++long scaled_ppm_to_ppb(long ppm) + { + /* + * The 'freq' field in the 'struct timex' is in parts per +@@ -80,7 +80,7 @@ s32 scaled_ppm_to_ppb(long ppm) + s64 ppb = 1 + ppm; + ppb *= 125; + ppb >>= 13; +- return (s32) ppb; ++ return (long) ppb; + } + EXPORT_SYMBOL(scaled_ppm_to_ppb); + +@@ -138,7 +138,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx) + delta = ktime_to_ns(kt); + err = ops->adjtime(ops, delta); + } else if (tx->modes & ADJ_FREQUENCY) { +- s32 ppb = scaled_ppm_to_ppb(tx->freq); ++ long ppb = scaled_ppm_to_ppb(tx->freq); + if (ppb > ops->max_adj || ppb < -ops->max_adj) + return -ERANGE; + if (ops->adjfine) +diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c +index eb3fc1db4edc8..c4754f3cf2337 100644 +--- a/drivers/regulator/cros-ec-regulator.c ++++ b/drivers/regulator/cros-ec-regulator.c +@@ -225,8 +225,9 @@ static int cros_ec_regulator_probe(struct platform_device *pdev) + + drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg); + if (IS_ERR(drvdata->dev)) { ++ ret = PTR_ERR(drvdata->dev); + dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); +- return PTR_ERR(drvdata->dev); ++ return ret; + } + + platform_set_drvdata(pdev, drvdata); +diff --git a/drivers/regulator/rt4801-regulator.c b/drivers/regulator/rt4801-regulator.c +index 2055a9cb13ba5..7a87788d3f092 100644 +--- a/drivers/regulator/rt4801-regulator.c ++++ b/drivers/regulator/rt4801-regulator.c +@@ -66,7 +66,7 @@ static int rt4801_enable(struct regulator_dev *rdev) + struct gpio_descs *gpios = priv->enable_gpios; + int id = rdev_get_id(rdev), ret; + +- if (gpios->ndescs <= id) { ++ if (!gpios || gpios->ndescs <= id) { + dev_warn(&rdev->dev, "no dedicated gpio can control\n"); + goto bypass_gpio; + } +@@ -88,7 +88,7 @@ static int rt4801_disable(struct regulator_dev *rdev) + struct gpio_descs *gpios = priv->enable_gpios; + int id = rdev_get_id(rdev); + +- if (gpios->ndescs <= id) { ++ if (!gpios || gpios->ndescs <= id) { + dev_warn(&rdev->dev, "no dedicated gpio can control\n"); + goto bypass_gpio; + } +diff --git a/drivers/regulator/rtmv20-regulator.c b/drivers/regulator/rtmv20-regulator.c +index 5adc552dffd58..4bca64de0f672 100644 +--- a/drivers/regulator/rtmv20-regulator.c ++++ b/drivers/regulator/rtmv20-regulator.c +@@ -27,6 +27,7 @@ + #define RTMV20_REG_LDIRQ 0x30 + #define RTMV20_REG_LDSTAT 0x40 + #define RTMV20_REG_LDMASK 0x50 ++#define RTMV20_MAX_REGS (RTMV20_REG_LDMASK + 1) + + #define RTMV20_VID_MASK GENMASK(7, 4) + #define RICHTEK_VID 0x80 +@@ -313,6 +314,7 @@ static const struct regmap_config rtmv20_regmap_config = { + .val_bits = 8, + .cache_type = REGCACHE_RBTREE, + .max_register = RTMV20_REG_LDMASK, ++ .num_reg_defaults_raw = RTMV20_MAX_REGS, + + .writeable_reg = rtmv20_is_accessible_reg, + .readable_reg = rtmv20_is_accessible_reg, +diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c +index ecefc25eff0c0..337353c9655ed 100644 +--- a/drivers/s390/crypto/ap_queue.c ++++ b/drivers/s390/crypto/ap_queue.c +@@ -135,12 +135,13 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) + { + struct ap_queue_status status; + struct ap_message *ap_msg; ++ bool found = false; + + status = ap_dqap(aq->qid, &aq->reply->psmid, + aq->reply->msg, aq->reply->len); + switch (status.response_code) { + case AP_RESPONSE_NORMAL: +- aq->queue_count--; ++ aq->queue_count = max_t(int, 0, aq->queue_count - 1); + if (aq->queue_count > 0) + mod_timer(&aq->timeout, + jiffies + aq->request_timeout); +@@ -150,8 +151,14 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) + list_del_init(&ap_msg->list); + aq->pendingq_count--; + ap_msg->receive(aq, ap_msg, aq->reply); ++ found = true; + break; + } ++ if (!found) { ++ AP_DBF_WARN("%s unassociated reply psmid=0x%016llx on 0x%02x.%04x\n", ++ __func__, aq->reply->psmid, ++ AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); ++ } + fallthrough; + case AP_RESPONSE_NO_PENDING_REPLY: + if (!status.queue_empty || aq->queue_count <= 0) +@@ -232,7 +239,7 @@ static enum ap_sm_wait ap_sm_write(struct ap_queue *aq) + ap_msg->flags & AP_MSG_FLAG_SPECIAL); + switch (status.response_code) { + case AP_RESPONSE_NORMAL: +- aq->queue_count++; ++ aq->queue_count = max_t(int, 1, aq->queue_count + 1); + if (aq->queue_count == 1) + mod_timer(&aq->timeout, jiffies + aq->request_timeout); + list_move_tail(&ap_msg->list, &aq->pendingq); +diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c +index 2786470a52011..4f24f63922126 100644 +--- a/drivers/spi/spi-stm32-qspi.c ++++ b/drivers/spi/spi-stm32-qspi.c +@@ -293,7 +293,7 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + int err = 0; + + if (!op->data.nbytes) +- return stm32_qspi_wait_nobusy(qspi); ++ goto wait_nobusy; + + if (readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) + goto out; +@@ -314,6 +314,9 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + out: + /* clear flags */ + writel_relaxed(FCR_CTCF | FCR_CTEF, qspi->io_base + QSPI_FCR); ++wait_nobusy: ++ if (!err) ++ err = stm32_qspi_wait_nobusy(qspi); + + return err; + } +diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c +index 2765289028fae..68193db8b2e3c 100644 +--- a/drivers/spi/spi-zynq-qspi.c ++++ b/drivers/spi/spi-zynq-qspi.c +@@ -678,14 +678,14 @@ static int zynq_qspi_probe(struct platform_device *pdev) + xqspi->irq = platform_get_irq(pdev, 0); + if (xqspi->irq <= 0) { + ret = -ENXIO; +- goto remove_master; ++ goto clk_dis_all; + } + ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, + 0, pdev->name, xqspi); + if (ret != 0) { + ret = -ENXIO; + dev_err(&pdev->dev, "request_irq failed\n"); +- goto remove_master; ++ goto clk_dis_all; + } + + ret = of_property_read_u32(np, "num-cs", +@@ -693,8 +693,9 @@ static int zynq_qspi_probe(struct platform_device *pdev) + if (ret < 0) { + ctlr->num_chipselect = 1; + } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { ++ ret = -EINVAL; + dev_err(&pdev->dev, "only 2 chip selects are available\n"); +- goto remove_master; ++ goto clk_dis_all; + } else { + ctlr->num_chipselect = num_cs; + } +diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +index caaf9e34f1ee2..09b0b8a16e994 100644 +--- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c ++++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +@@ -127,7 +127,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, + if (p->groups[group].enabled) { + dev_err(p->dev, "%s is already enabled\n", + p->groups[group].name); +- return -EBUSY; ++ return 0; + } + + p->groups[group].enabled = 1; +diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c +index 6d8331e7da99e..425b29168b4d0 100644 +--- a/drivers/usb/chipidea/usbmisc_imx.c ++++ b/drivers/usb/chipidea/usbmisc_imx.c +@@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) + int val; + unsigned long flags; + ++ /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */ ++ spin_lock_irqsave(&usbmisc->lock, flags); ++ val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); ++ val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0; ++ writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); ++ spin_unlock_irqrestore(&usbmisc->lock, flags); ++ ++ /* TVDMSRC_DIS */ ++ msleep(20); ++ + /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ + spin_lock_irqsave(&usbmisc->lock, flags); + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); +@@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) + usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + spin_unlock_irqrestore(&usbmisc->lock, flags); + +- usleep_range(1000, 2000); ++ /* TVDMSRC_ON */ ++ msleep(40); + + /* + * Per BC 1.2, check voltage of D+: +@@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) + usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + spin_unlock_irqrestore(&usbmisc->lock, flags); + +- usleep_range(1000, 2000); ++ /* TVDPSRC_ON */ ++ msleep(40); + + /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 228e3d4e1a9fd..357730e8f52f2 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -40,6 +40,8 @@ + #define USB_VENDOR_GENESYS_LOGIC 0x05e3 + #define USB_VENDOR_SMSC 0x0424 + #define USB_PRODUCT_USB5534B 0x5534 ++#define USB_VENDOR_CYPRESS 0x04b4 ++#define USB_PRODUCT_CY7C65632 0x6570 + #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 + #define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02 + +@@ -5643,6 +5645,11 @@ static const struct usb_device_id hub_id_table[] = { + .idProduct = USB_PRODUCT_USB5534B, + .bInterfaceClass = USB_CLASS_HUB, + .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, ++ { .match_flags = USB_DEVICE_ID_MATCH_VENDOR ++ | USB_DEVICE_ID_MATCH_PRODUCT, ++ .idVendor = USB_VENDOR_CYPRESS, ++ .idProduct = USB_PRODUCT_CY7C65632, ++ .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR + | USB_DEVICE_ID_MATCH_INT_CLASS, + .idVendor = USB_VENDOR_GENESYS_LOGIC, +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index e07fd5ee8ed95..7537dd50ad533 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -1642,8 +1642,8 @@ static int dwc3_remove(struct platform_device *pdev) + + pm_runtime_get_sync(&pdev->dev); + +- dwc3_debugfs_exit(dwc); + dwc3_core_exit_mode(dwc); ++ dwc3_debugfs_exit(dwc); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); +diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h +index 8ab3949423604..74d9c2c38193d 100644 +--- a/drivers/usb/dwc3/debug.h ++++ b/drivers/usb/dwc3/debug.h +@@ -413,9 +413,12 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status) + + + #ifdef CONFIG_DEBUG_FS ++extern void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep); + extern void dwc3_debugfs_init(struct dwc3 *d); + extern void dwc3_debugfs_exit(struct dwc3 *d); + #else ++static inline void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) ++{ } + static inline void dwc3_debugfs_init(struct dwc3 *d) + { } + static inline void dwc3_debugfs_exit(struct dwc3 *d) +diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c +index 5da4f6082d930..3ebe3e6c284d2 100644 +--- a/drivers/usb/dwc3/debugfs.c ++++ b/drivers/usb/dwc3/debugfs.c +@@ -890,30 +890,14 @@ static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, + } + } + +-static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep, +- struct dentry *parent) ++void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) + { + struct dentry *dir; + +- dir = debugfs_create_dir(dep->name, parent); ++ dir = debugfs_create_dir(dep->name, dep->dwc->root); + dwc3_debugfs_create_endpoint_files(dep, dir); + } + +-static void dwc3_debugfs_create_endpoint_dirs(struct dwc3 *dwc, +- struct dentry *parent) +-{ +- int i; +- +- for (i = 0; i < dwc->num_eps; i++) { +- struct dwc3_ep *dep = dwc->eps[i]; +- +- if (!dep) +- continue; +- +- dwc3_debugfs_create_endpoint_dir(dep, parent); +- } +-} +- + void dwc3_debugfs_init(struct dwc3 *dwc) + { + struct dentry *root; +@@ -944,7 +928,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) + &dwc3_testmode_fops); + debugfs_create_file("link_state", 0644, root, dwc, + &dwc3_link_state_fops); +- dwc3_debugfs_create_endpoint_dirs(dwc, root); + } + } + +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index 8bccdd7b0ca2e..14a7c05abfe8f 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -2664,6 +2664,8 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) + INIT_LIST_HEAD(&dep->started_list); + INIT_LIST_HEAD(&dep->cancelled_list); + ++ dwc3_debugfs_create_endpoint_dir(dep); ++ + return 0; + } + +@@ -2707,6 +2709,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) + list_del(&dep->endpoint.ep_list); + } + ++ debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root)); + kfree(dep); + } + } +diff --git a/fs/afs/main.c b/fs/afs/main.c +index b2975256dadbd..179004b15566d 100644 +--- a/fs/afs/main.c ++++ b/fs/afs/main.c +@@ -203,8 +203,8 @@ static int __init afs_init(void) + goto error_fs; + + afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs"); +- if (IS_ERR(afs_proc_symlink)) { +- ret = PTR_ERR(afs_proc_symlink); ++ if (!afs_proc_symlink) { ++ ret = -ENOMEM; + goto error_proc; + } + +diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c +index dcab112e1f001..086b6bacbad17 100644 +--- a/fs/notify/fanotify/fanotify_user.c ++++ b/fs/notify/fanotify/fanotify_user.c +@@ -378,7 +378,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, + info_type, fanotify_info_name(info), + info->name_len, buf, count); + if (ret < 0) +- return ret; ++ goto out_close_fd; + + buf += ret; + count -= ret; +@@ -426,7 +426,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, + fanotify_event_object_fh(event), + info_type, dot, dot_len, buf, count); + if (ret < 0) +- return ret; ++ goto out_close_fd; + + buf += ret; + count -= ret; +diff --git a/include/linux/mfd/rohm-bd70528.h b/include/linux/mfd/rohm-bd70528.h +index a57af878fd0cd..4a5966475a35a 100644 +--- a/include/linux/mfd/rohm-bd70528.h ++++ b/include/linux/mfd/rohm-bd70528.h +@@ -26,9 +26,7 @@ struct bd70528_data { + struct mutex rtc_timer_lock; + }; + +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 ++#define BD70528_BUCK_VOLTS 0x10 + #define BD70528_LDO_VOLTS 0x20 + + #define BD70528_REG_BUCK1_EN 0x0F +diff --git a/include/linux/mlx5/transobj.h b/include/linux/mlx5/transobj.h +index 028f442530cf5..60ffeb6b67ae7 100644 +--- a/include/linux/mlx5/transobj.h ++++ b/include/linux/mlx5/transobj.h +@@ -85,4 +85,5 @@ mlx5_core_hairpin_create(struct mlx5_core_dev *func_mdev, + struct mlx5_hairpin_params *params); + + void mlx5_core_hairpin_destroy(struct mlx5_hairpin *pair); ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp); + #endif /* __TRANSOBJ_H__ */ +diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h +index a4fff7d7abe58..4eb38918da8f8 100644 +--- a/include/linux/mm_types.h ++++ b/include/linux/mm_types.h +@@ -448,13 +448,6 @@ struct mm_struct { + */ + atomic_t has_pinned; + +- /** +- * @write_protect_seq: Locked when any thread is write +- * protecting pages mapped by this mm to enforce a later COW, +- * for instance during page table copying for fork(). +- */ +- seqcount_t write_protect_seq; +- + #ifdef CONFIG_MMU + atomic_long_t pgtables_bytes; /* PTE page table pages */ + #endif +@@ -463,6 +456,18 @@ struct mm_struct { + spinlock_t page_table_lock; /* Protects page tables and some + * counters + */ ++ /* ++ * With some kernel config, the current mmap_lock's offset ++ * inside 'mm_struct' is at 0x120, which is very optimal, as ++ * its two hot fields 'count' and 'owner' sit in 2 different ++ * cachelines, and when mmap_lock is highly contended, both ++ * of the 2 fields will be accessed frequently, current layout ++ * will help to reduce cache bouncing. ++ * ++ * So please be careful with adding new fields before ++ * mmap_lock, which can easily push the 2 fields into one ++ * cacheline. ++ */ + struct rw_semaphore mmap_lock; + + struct list_head mmlist; /* List of maybe swapped mm's. These +@@ -483,7 +488,15 @@ struct mm_struct { + unsigned long stack_vm; /* VM_STACK */ + unsigned long def_flags; + ++ /** ++ * @write_protect_seq: Locked when any thread is write ++ * protecting pages mapped by this mm to enforce a later COW, ++ * for instance during page table copying for fork(). ++ */ ++ seqcount_t write_protect_seq; ++ + spinlock_t arg_lock; /* protect the below fields */ ++ + unsigned long start_code, end_code, start_data, end_data; + unsigned long start_brk, brk, start_stack; + unsigned long arg_start, arg_end, env_start, env_end; +diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h +index d3e8ba5c71258..6d6b42143effc 100644 +--- a/include/linux/ptp_clock_kernel.h ++++ b/include/linux/ptp_clock_kernel.h +@@ -222,7 +222,7 @@ extern int ptp_clock_index(struct ptp_clock *ptp); + * @ppm: Parts per million, but with a 16 bit binary fractional field + */ + +-extern s32 scaled_ppm_to_ppb(long ppm); ++extern long scaled_ppm_to_ppb(long ppm); + + /** + * ptp_find_pin() - obtain the pin index of a given auxiliary function +diff --git a/include/linux/socket.h b/include/linux/socket.h +index e9cb30d8cbfb1..9aa530d497da8 100644 +--- a/include/linux/socket.h ++++ b/include/linux/socket.h +@@ -437,6 +437,4 @@ extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr, + extern int __sys_socketpair(int family, int type, int protocol, + int __user *usockvec); + extern int __sys_shutdown(int fd, int how); +- +-extern struct ns_common *get_net_ns(struct ns_common *ns); + #endif /* _LINUX_SOCKET_H */ +diff --git a/include/linux/swapops.h b/include/linux/swapops.h +index d9b7c9132c2f6..6430a94c69818 100644 +--- a/include/linux/swapops.h ++++ b/include/linux/swapops.h +@@ -23,6 +23,16 @@ + #define SWP_TYPE_SHIFT (BITS_PER_XA_VALUE - MAX_SWAPFILES_SHIFT) + #define SWP_OFFSET_MASK ((1UL << SWP_TYPE_SHIFT) - 1) + ++/* Clear all flags but only keep swp_entry_t related information */ ++static inline pte_t pte_swp_clear_flags(pte_t pte) ++{ ++ if (pte_swp_soft_dirty(pte)) ++ pte = pte_swp_clear_soft_dirty(pte); ++ if (pte_swp_uffd_wp(pte)) ++ pte = pte_swp_clear_uffd_wp(pte); ++ return pte; ++} ++ + /* + * Store a type+offset into a swp_entry_t in an arch-independent format + */ +@@ -66,10 +76,7 @@ static inline swp_entry_t pte_to_swp_entry(pte_t pte) + { + swp_entry_t arch_entry; + +- if (pte_swp_soft_dirty(pte)) +- pte = pte_swp_clear_soft_dirty(pte); +- if (pte_swp_uffd_wp(pte)) +- pte = pte_swp_clear_uffd_wp(pte); ++ pte = pte_swp_clear_flags(pte); + arch_entry = __pte_to_swp_entry(pte); + return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); + } +diff --git a/include/net/mac80211.h b/include/net/mac80211.h +index dcdba96814a2b..6ff49c13717bb 100644 +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -6335,7 +6335,12 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw, + + /** + * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header +- * of injected frames ++ * of injected frames. ++ * ++ * To accurately parse and take into account rate and retransmission fields, ++ * you must initialize the chandef field in the ieee80211_tx_info structure ++ * of the skb before calling this function. ++ * + * @skb: packet injected by userspace + * @dev: the &struct device of this 802.11 device + */ +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h +index 22bc07f4b043d..eb0e7731f3b1c 100644 +--- a/include/net/net_namespace.h ++++ b/include/net/net_namespace.h +@@ -203,6 +203,8 @@ struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns, + void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid); + + void net_ns_barrier(void); ++ ++struct ns_common *get_net_ns(struct ns_common *ns); + #else /* CONFIG_NET_NS */ + #include + #include +@@ -222,6 +224,11 @@ static inline void net_ns_get_ownership(const struct net *net, + } + + static inline void net_ns_barrier(void) {} ++ ++static inline struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return ERR_PTR(-EINVAL); ++} + #endif /* CONFIG_NET_NS */ + + +diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h +index 7d6687618d808..d1b327036ae43 100644 +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -289,6 +289,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index 4f50d6f128be3..e97724e36dfb5 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -5740,6 +5740,27 @@ struct bpf_sanitize_info { + bool mask_to_left; + }; + ++static struct bpf_verifier_state * ++sanitize_speculative_path(struct bpf_verifier_env *env, ++ const struct bpf_insn *insn, ++ u32 next_idx, u32 curr_idx) ++{ ++ struct bpf_verifier_state *branch; ++ struct bpf_reg_state *regs; ++ ++ branch = push_stack(env, next_idx, curr_idx, true); ++ if (branch && insn) { ++ regs = branch->frame[branch->curframe]->regs; ++ if (BPF_SRC(insn->code) == BPF_K) { ++ mark_reg_unknown(env, regs, insn->dst_reg); ++ } else if (BPF_SRC(insn->code) == BPF_X) { ++ mark_reg_unknown(env, regs, insn->dst_reg); ++ mark_reg_unknown(env, regs, insn->src_reg); ++ } ++ } ++ return branch; ++} ++ + static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_insn *insn, + const struct bpf_reg_state *ptr_reg, +@@ -5823,12 +5844,26 @@ do_sim: + tmp = *dst_reg; + *dst_reg = *ptr_reg; + } +- ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true); ++ ret = sanitize_speculative_path(env, NULL, env->insn_idx + 1, ++ env->insn_idx); + if (!ptr_is_dst_reg && ret) + *dst_reg = tmp; + return !ret ? REASON_STACK : 0; + } + ++static void sanitize_mark_insn_seen(struct bpf_verifier_env *env) ++{ ++ struct bpf_verifier_state *vstate = env->cur_state; ++ ++ /* If we simulate paths under speculation, we don't update the ++ * insn as 'seen' such that when we verify unreachable paths in ++ * the non-speculative domain, sanitize_dead_code() can still ++ * rewrite/sanitize them. ++ */ ++ if (!vstate->speculative) ++ env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++} ++ + static int sanitize_err(struct bpf_verifier_env *env, + const struct bpf_insn *insn, int reason, + const struct bpf_reg_state *off_reg, +@@ -7974,14 +8009,28 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, + if (err) + return err; + } ++ + if (pred == 1) { +- /* only follow the goto, ignore fall-through */ ++ /* Only follow the goto, ignore fall-through. If needed, push ++ * the fall-through branch for simulation under speculative ++ * execution. ++ */ ++ if (!env->bypass_spec_v1 && ++ !sanitize_speculative_path(env, insn, *insn_idx + 1, ++ *insn_idx)) ++ return -EFAULT; + *insn_idx += insn->off; + return 0; + } else if (pred == 0) { +- /* only follow fall-through branch, since +- * that's where the program will go ++ /* Only follow the fall-through branch, since that's where the ++ * program will go. If needed, push the goto branch for ++ * simulation under speculative execution. + */ ++ if (!env->bypass_spec_v1 && ++ !sanitize_speculative_path(env, insn, ++ *insn_idx + insn->off + 1, ++ *insn_idx)) ++ return -EFAULT; + return 0; + } + +@@ -9811,7 +9860,7 @@ static int do_check(struct bpf_verifier_env *env) + } + + regs = cur_regs(env); +- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++ sanitize_mark_insn_seen(env); + prev_insn_idx = env->insn_idx; + + if (class == BPF_ALU || class == BPF_ALU64) { +@@ -10031,7 +10080,7 @@ process_bpf_exit: + return err; + + env->insn_idx++; +- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++ sanitize_mark_insn_seen(env); + } else { + verbose(env, "invalid BPF_LD mode\n"); + return -EINVAL; +@@ -10439,6 +10488,7 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, + { + struct bpf_insn_aux_data *new_data, *old_data = env->insn_aux_data; + struct bpf_insn *insn = new_prog->insnsi; ++ u32 old_seen = old_data[off].seen; + u32 prog_len; + int i; + +@@ -10459,7 +10509,8 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, + memcpy(new_data + off + cnt - 1, old_data + off, + sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1)); + for (i = off; i < off + cnt - 1; i++) { +- new_data[i].seen = env->pass_cnt; ++ /* Expand insni[off]'s seen count to the patched range. */ ++ new_data[i].seen = old_seen; + new_data[i].zext_dst = insn_has_def32(env, insn + i); + } + env->insn_aux_data = new_data; +@@ -11703,6 +11754,9 @@ static void free_states(struct bpf_verifier_env *env) + * insn_aux_data was touched. These variables are compared to clear temporary + * data from failed pass. For testing and experiments do_check_common() can be + * run multiple times even when prior attempt to verify is unsuccessful. ++ * ++ * Note that special handling is needed on !env->bypass_spec_v1 if this is ++ * ever called outside of error path with subsequent program rejection. + */ + static void sanitize_insn_aux_data(struct bpf_verifier_env *env) + { +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 106e4500fd53d..4a5fed2f497b8 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -463,6 +463,7 @@ static int __init crash_save_vmcoreinfo_init(void) + VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS); + VMCOREINFO_STRUCT_SIZE(mem_section); + VMCOREINFO_OFFSET(mem_section, section_mem_map); ++ VMCOREINFO_NUMBER(SECTION_SIZE_BITS); + VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS); + #endif + VMCOREINFO_STRUCT_SIZE(page); +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index ff8a172a69ca9..d6e1c90de570a 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -3767,11 +3767,17 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s + */ + static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) + { ++ /* ++ * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. ++ * See ___update_load_avg() for details. ++ */ ++ u32 divider = get_pelt_divider(&cfs_rq->avg); ++ + dequeue_load_avg(cfs_rq, se); + sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); +- sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); ++ cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; + sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); +- sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); ++ cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; + + add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); + +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index b2c141eaca020..b09c598065019 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2195,9 +2195,6 @@ struct saved_cmdlines_buffer { + }; + static struct saved_cmdlines_buffer *savedcmd; + +-/* temporary disable recording */ +-static atomic_t trace_record_taskinfo_disabled __read_mostly; +- + static inline char *get_saved_cmdlines(int idx) + { + return &savedcmd->saved_cmdlines[idx * TASK_COMM_LEN]; +@@ -2483,8 +2480,6 @@ static bool tracing_record_taskinfo_skip(int flags) + { + if (unlikely(!(flags & (TRACE_RECORD_CMDLINE | TRACE_RECORD_TGID)))) + return true; +- if (atomic_read(&trace_record_taskinfo_disabled) || !tracing_is_on()) +- return true; + if (!__this_cpu_read(trace_taskinfo_save)) + return true; + return false; +@@ -3685,9 +3680,6 @@ static void *s_start(struct seq_file *m, loff_t *pos) + return ERR_PTR(-EBUSY); + #endif + +- if (!iter->snapshot) +- atomic_inc(&trace_record_taskinfo_disabled); +- + if (*pos != iter->pos) { + iter->ent = NULL; + iter->cpu = 0; +@@ -3730,9 +3722,6 @@ static void s_stop(struct seq_file *m, void *p) + return; + #endif + +- if (!iter->snapshot) +- atomic_dec(&trace_record_taskinfo_disabled); +- + trace_access_unlock(iter->cpu_file); + trace_event_read_unlock(); + } +diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c +index c1637f90c8a38..4702efb00ff21 100644 +--- a/kernel/trace/trace_clock.c ++++ b/kernel/trace/trace_clock.c +@@ -115,9 +115,9 @@ u64 notrace trace_clock_global(void) + prev_time = READ_ONCE(trace_clock_struct.prev_time); + now = sched_clock_cpu(this_cpu); + +- /* Make sure that now is always greater than prev_time */ ++ /* Make sure that now is always greater than or equal to prev_time */ + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + /* + * If in an NMI context then dont risk lockups and simply return +@@ -131,7 +131,7 @@ u64 notrace trace_clock_global(void) + /* Reread prev_time in case it was already updated */ + prev_time = READ_ONCE(trace_clock_struct.prev_time); + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + trace_clock_struct.prev_time = now; + +diff --git a/mm/memory-failure.c b/mm/memory-failure.c +index 2d7a667f8e609..25fb82320e3d5 100644 +--- a/mm/memory-failure.c ++++ b/mm/memory-failure.c +@@ -1445,7 +1445,12 @@ int memory_failure(unsigned long pfn, int flags) + return 0; + } + +- if (!PageTransTail(p) && !PageLRU(p)) ++ /* ++ * __munlock_pagevec may clear a writeback page's LRU flag without ++ * page_lock. We need wait writeback completion for this page or it ++ * may trigger vfs BUG while evict inode. ++ */ ++ if (!PageTransTail(p) && !PageLRU(p) && !PageWriteback(p)) + goto identify_page_state; + + /* +diff --git a/mm/slab_common.c b/mm/slab_common.c +index 8f27ccf9f7f35..ec832904f4084 100644 +--- a/mm/slab_common.c ++++ b/mm/slab_common.c +@@ -87,8 +87,7 @@ EXPORT_SYMBOL(kmem_cache_size); + #ifdef CONFIG_DEBUG_VM + static int kmem_cache_sanity_check(const char *name, unsigned int size) + { +- if (!name || in_interrupt() || size < sizeof(void *) || +- size > KMALLOC_MAX_SIZE) { ++ if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) { + pr_err("kmem_cache_create(%s) integrity check failed\n", name); + return -EINVAL; + } +diff --git a/mm/slub.c b/mm/slub.c +index 05a501b67cd59..f5fc44208bdc3 100644 +--- a/mm/slub.c ++++ b/mm/slub.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include "slab.h" +@@ -698,15 +699,15 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + p, p - addr, get_freepointer(s, p)); + + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, ++ print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, + s->red_left_pad); + else if (p > addr + 16) + print_section(KERN_ERR, "Bytes b4 ", p - 16, 16); + +- print_section(KERN_ERR, "Object ", p, ++ print_section(KERN_ERR, "Object ", p, + min_t(unsigned int, s->object_size, PAGE_SIZE)); + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p + s->object_size, ++ print_section(KERN_ERR, "Redzone ", p + s->object_size, + s->inuse - s->object_size); + + off = get_info_end(s); +@@ -718,7 +719,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + + if (off != size_from_object(s)) + /* Beginning of the filler is the free pointer */ +- print_section(KERN_ERR, "Padding ", p + off, ++ print_section(KERN_ERR, "Padding ", p + off, + size_from_object(s) - off); + + dump_stack(); +@@ -895,11 +896,11 @@ static int check_object(struct kmem_cache *s, struct page *page, + u8 *endobject = object + s->object_size; + + if (s->flags & SLAB_RED_ZONE) { +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Left Redzone", + object - s->red_left_pad, val, s->red_left_pad)) + return 0; + +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Right Redzone", + endobject, val, s->inuse - s->object_size)) + return 0; + } else { +@@ -914,7 +915,7 @@ static int check_object(struct kmem_cache *s, struct page *page, + if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) && + (!check_bytes_and_report(s, page, p, "Poison", p, + POISON_FREE, s->object_size - 1) || +- !check_bytes_and_report(s, page, p, "Poison", ++ !check_bytes_and_report(s, page, p, "End Poison", + p + s->object_size - 1, POISON_END, 1))) + return 0; + /* +@@ -3639,7 +3640,6 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + { + slab_flags_t flags = s->flags; + unsigned int size = s->object_size; +- unsigned int freepointer_area; + unsigned int order; + + /* +@@ -3648,13 +3648,6 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + * the possible location of the free pointer. + */ + size = ALIGN(size, sizeof(void *)); +- /* +- * This is the area of the object where a freepointer can be +- * safely written. If redzoning adds more to the inuse size, we +- * can't use that portion for writing the freepointer, so +- * s->offset must be limited within this for the general case. +- */ +- freepointer_area = size; + + #ifdef CONFIG_SLUB_DEBUG + /* +@@ -3680,19 +3673,21 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + + /* + * With that we have determined the number of bytes in actual use +- * by the object. This is the potential offset to the free pointer. ++ * by the object and redzoning. + */ + s->inuse = size; + +- if (((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || +- s->ctor)) { ++ if ((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || ++ ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) || ++ s->ctor) { + /* + * Relocate free pointer after the object if it is not + * permitted to overwrite the first word of the object on + * kmem_cache_free. + * + * This is the case if we do RCU, have a constructor or +- * destructor or are poisoning the objects. ++ * destructor, are poisoning the objects, or are ++ * redzoning an object smaller than sizeof(void *). + * + * The assumption that s->offset >= s->inuse means free + * pointer is outside of the object is used in the +@@ -3701,13 +3696,13 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + */ + s->offset = size; + size += sizeof(void *); +- } else if (freepointer_area > sizeof(void *)) { ++ } else { + /* + * Store freelist pointer near middle of object to keep + * it away from the edges of the object to avoid small + * sized over/underflows from neighboring allocations. + */ +- s->offset = ALIGN(freepointer_area / 2, sizeof(void *)); ++ s->offset = ALIGN_DOWN(s->object_size / 2, sizeof(void *)); + } + + #ifdef CONFIG_SLUB_DEBUG +diff --git a/mm/swapfile.c b/mm/swapfile.c +index 5256c10049b0f..5af6b0f770de6 100644 +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -1903,7 +1903,7 @@ unsigned int count_swap_pages(int type, int free) + + static inline int pte_same_as_swp(pte_t pte, pte_t swp_pte) + { +- return pte_same(pte_swp_clear_soft_dirty(pte), swp_pte); ++ return pte_same(pte_swp_clear_flags(pte), swp_pte); + } + + /* +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c +index 206d0b424712e..c0aa54d21c649 100644 +--- a/net/batman-adv/bat_iv_ogm.c ++++ b/net/batman-adv/bat_iv_ogm.c +@@ -410,8 +410,10 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet) + if (WARN_ON(!forw_packet->if_outgoing)) + return; + +- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface)) ++ if (forw_packet->if_outgoing->soft_iface != soft_iface) { ++ pr_warn("%s: soft interface switch for queued OGM\n", __func__); + return; ++ } + + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE) + return; +diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h +index 8424464186a6b..5e5726048a1af 100644 +--- a/net/bridge/br_private.h ++++ b/net/bridge/br_private.h +@@ -98,8 +98,8 @@ struct br_vlan_stats { + }; + + struct br_tunnel_info { +- __be64 tunnel_id; +- struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; ++ struct metadata_dst __rcu *tunnel_dst; + }; + + /* private vlan flags */ +diff --git a/net/bridge/br_vlan_tunnel.c b/net/bridge/br_vlan_tunnel.c +index 169e005fbda29..debe167202782 100644 +--- a/net/bridge/br_vlan_tunnel.c ++++ b/net/bridge/br_vlan_tunnel.c +@@ -41,26 +41,33 @@ static struct net_bridge_vlan *br_vlan_tunnel_lookup(struct rhashtable *tbl, + br_vlan_tunnel_rht_params); + } + ++static void vlan_tunnel_info_release(struct net_bridge_vlan *vlan) ++{ ++ struct metadata_dst *tdst = rtnl_dereference(vlan->tinfo.tunnel_dst); ++ ++ WRITE_ONCE(vlan->tinfo.tunnel_id, 0); ++ RCU_INIT_POINTER(vlan->tinfo.tunnel_dst, NULL); ++ dst_release(&tdst->dst); ++} ++ + void vlan_tunnel_info_del(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan) + { +- if (!vlan->tinfo.tunnel_dst) ++ if (!rcu_access_pointer(vlan->tinfo.tunnel_dst)) + return; + rhashtable_remove_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +- vlan->tinfo.tunnel_id = 0; +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; ++ vlan_tunnel_info_release(vlan); + } + + static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan, u32 tun_id) + { +- struct metadata_dst *metadata = NULL; ++ struct metadata_dst *metadata = rtnl_dereference(vlan->tinfo.tunnel_dst); + __be64 key = key32_to_tunnel_id(cpu_to_be32(tun_id)); + int err; + +- if (vlan->tinfo.tunnel_dst) ++ if (metadata) + return -EEXIST; + + metadata = __ip_tun_set_dst(0, 0, 0, 0, 0, TUNNEL_KEY, +@@ -69,8 +76,8 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + return -EINVAL; + + metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_BRIDGE; +- vlan->tinfo.tunnel_dst = metadata; +- vlan->tinfo.tunnel_id = key; ++ rcu_assign_pointer(vlan->tinfo.tunnel_dst, metadata); ++ WRITE_ONCE(vlan->tinfo.tunnel_id, key); + + err = rhashtable_lookup_insert_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +@@ -79,9 +86,7 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + + return 0; + out: +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; +- vlan->tinfo.tunnel_id = 0; ++ vlan_tunnel_info_release(vlan); + + return err; + } +@@ -182,12 +187,15 @@ int br_handle_ingress_vlan_tunnel(struct sk_buff *skb, + int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + struct net_bridge_vlan *vlan) + { ++ struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; + int err; + +- if (!vlan || !vlan->tinfo.tunnel_id) ++ if (!vlan) + return 0; + +- if (unlikely(!skb_vlan_tag_present(skb))) ++ tunnel_id = READ_ONCE(vlan->tinfo.tunnel_id); ++ if (!tunnel_id || unlikely(!skb_vlan_tag_present(skb))) + return 0; + + skb_dst_drop(skb); +@@ -195,7 +203,9 @@ int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + if (err) + return err; + +- skb_dst_set(skb, dst_clone(&vlan->tinfo.tunnel_dst->dst)); ++ tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst); ++ if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst)) ++ skb_dst_set(skb, &tunnel_dst->dst); + + return 0; + } +diff --git a/net/can/bcm.c b/net/can/bcm.c +index 909b9e684e043..f3e4d9528fa38 100644 +--- a/net/can/bcm.c ++++ b/net/can/bcm.c +@@ -125,7 +125,7 @@ struct bcm_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + struct list_head rx_ops; + struct list_head tx_ops; + unsigned long dropped_usr_msgs; +@@ -133,6 +133,10 @@ struct bcm_sock { + char procname [32]; /* inode number in decimal with \0 */ + }; + ++static LIST_HEAD(bcm_notifier_list); ++static DEFINE_SPINLOCK(bcm_notifier_lock); ++static struct bcm_sock *bcm_busy_notifier; ++ + static inline struct bcm_sock *bcm_sk(const struct sock *sk) + { + return (struct bcm_sock *)sk; +@@ -402,6 +406,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer) + if (!op->count && (op->flags & TX_COUNTEVT)) { + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = TX_EXPIRED; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -439,6 +444,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data) + /* this element is not throttled anymore */ + data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV); + ++ memset(&head, 0, sizeof(head)); + head.opcode = RX_CHANGED; + head.flags = op->flags; + head.count = op->count; +@@ -560,6 +566,7 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer) + } + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = RX_TIMEOUT; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -1378,20 +1385,15 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) + /* + * notification handler for netdevice status changes + */ +-static int bcm_notifier(struct notifier_block *nb, unsigned long msg, +- void *ptr) ++static void bcm_notify(struct bcm_sock *bo, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct bcm_sock *bo = container_of(nb, struct bcm_sock, notifier); + struct sock *sk = &bo->sk; + struct bcm_op *op; + int notify_enodev = 0; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + +@@ -1426,7 +1428,28 @@ static int bcm_notifier(struct notifier_block *nb, unsigned long msg, + sk->sk_error_report(sk); + } + } ++} + ++static int bcm_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(bcm_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; ++ ++ spin_lock(&bcm_notifier_lock); ++ list_for_each_entry(bcm_busy_notifier, &bcm_notifier_list, notifier) { ++ spin_unlock(&bcm_notifier_lock); ++ bcm_notify(bcm_busy_notifier, msg, dev); ++ spin_lock(&bcm_notifier_lock); ++ } ++ bcm_busy_notifier = NULL; ++ spin_unlock(&bcm_notifier_lock); + return NOTIFY_DONE; + } + +@@ -1446,9 +1469,9 @@ static int bcm_init(struct sock *sk) + INIT_LIST_HEAD(&bo->rx_ops); + + /* set notifier */ +- bo->notifier.notifier_call = bcm_notifier; +- +- register_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ list_add_tail(&bo->notifier, &bcm_notifier_list); ++ spin_unlock(&bcm_notifier_lock); + + return 0; + } +@@ -1471,7 +1494,14 @@ static int bcm_release(struct socket *sock) + + /* remove bcm_ops, timer, rx_unregister(), etc. */ + +- unregister_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ while (bcm_busy_notifier == bo) { ++ spin_unlock(&bcm_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&bcm_notifier_lock); ++ } ++ list_del(&bo->notifier); ++ spin_unlock(&bcm_notifier_lock); + + lock_sock(sk); + +@@ -1692,6 +1722,10 @@ static struct pernet_operations canbcm_pernet_ops __read_mostly = { + .exit = canbcm_pernet_exit, + }; + ++static struct notifier_block canbcm_notifier = { ++ .notifier_call = bcm_notifier ++}; ++ + static int __init bcm_module_init(void) + { + int err; +@@ -1705,12 +1739,14 @@ static int __init bcm_module_init(void) + } + + register_pernet_subsys(&canbcm_pernet_ops); ++ register_netdevice_notifier(&canbcm_notifier); + return 0; + } + + static void __exit bcm_module_exit(void) + { + can_proto_unregister(&bcm_can_proto); ++ unregister_netdevice_notifier(&canbcm_notifier); + unregister_pernet_subsys(&canbcm_pernet_ops); + } + +diff --git a/net/can/isotp.c b/net/can/isotp.c +index d5780ab29e098..1adefb14527d8 100644 +--- a/net/can/isotp.c ++++ b/net/can/isotp.c +@@ -143,10 +143,14 @@ struct isotp_sock { + u32 force_tx_stmin; + u32 force_rx_stmin; + struct tpcon rx, tx; +- struct notifier_block notifier; ++ struct list_head notifier; + wait_queue_head_t wait; + }; + ++static LIST_HEAD(isotp_notifier_list); ++static DEFINE_SPINLOCK(isotp_notifier_lock); ++static struct isotp_sock *isotp_busy_notifier; ++ + static inline struct isotp_sock *isotp_sk(const struct sock *sk) + { + return (struct isotp_sock *)sk; +@@ -1008,7 +1012,14 @@ static int isotp_release(struct socket *sock) + /* wait for complete transmission of current pdu */ + wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE); + +- unregister_netdevice_notifier(&so->notifier); ++ spin_lock(&isotp_notifier_lock); ++ while (isotp_busy_notifier == so) { ++ spin_unlock(&isotp_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&isotp_notifier_lock); ++ } ++ list_del(&so->notifier); ++ spin_unlock(&isotp_notifier_lock); + + lock_sock(sk); + +@@ -1284,21 +1295,16 @@ static int isotp_getsockopt(struct socket *sock, int level, int optname, + return 0; + } + +-static int isotp_notifier(struct notifier_block *nb, unsigned long msg, +- void *ptr) ++static void isotp_notify(struct isotp_sock *so, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct isotp_sock *so = container_of(nb, struct isotp_sock, notifier); + struct sock *sk = &so->sk; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + if (so->ifindex != dev->ifindex) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + case NETDEV_UNREGISTER: +@@ -1324,7 +1330,28 @@ static int isotp_notifier(struct notifier_block *nb, unsigned long msg, + sk->sk_error_report(sk); + break; + } ++} + ++static int isotp_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(isotp_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; ++ ++ spin_lock(&isotp_notifier_lock); ++ list_for_each_entry(isotp_busy_notifier, &isotp_notifier_list, notifier) { ++ spin_unlock(&isotp_notifier_lock); ++ isotp_notify(isotp_busy_notifier, msg, dev); ++ spin_lock(&isotp_notifier_lock); ++ } ++ isotp_busy_notifier = NULL; ++ spin_unlock(&isotp_notifier_lock); + return NOTIFY_DONE; + } + +@@ -1361,8 +1388,9 @@ static int isotp_init(struct sock *sk) + + init_waitqueue_head(&so->wait); + +- so->notifier.notifier_call = isotp_notifier; +- register_netdevice_notifier(&so->notifier); ++ spin_lock(&isotp_notifier_lock); ++ list_add_tail(&so->notifier, &isotp_notifier_list); ++ spin_unlock(&isotp_notifier_lock); + + return 0; + } +@@ -1409,6 +1437,10 @@ static const struct can_proto isotp_can_proto = { + .prot = &isotp_proto, + }; + ++static struct notifier_block canisotp_notifier = { ++ .notifier_call = isotp_notifier ++}; ++ + static __init int isotp_module_init(void) + { + int err; +@@ -1418,6 +1450,8 @@ static __init int isotp_module_init(void) + err = can_proto_register(&isotp_can_proto); + if (err < 0) + pr_err("can: registration of isotp protocol failed\n"); ++ else ++ register_netdevice_notifier(&canisotp_notifier); + + return err; + } +@@ -1425,6 +1459,7 @@ static __init int isotp_module_init(void) + static __exit void isotp_module_exit(void) + { + can_proto_unregister(&isotp_can_proto); ++ unregister_netdevice_notifier(&canisotp_notifier); + } + + module_init(isotp_module_init); +diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c +index e09d087ba2409..c3946c3558826 100644 +--- a/net/can/j1939/transport.c ++++ b/net/can/j1939/transport.c +@@ -330,6 +330,9 @@ static void j1939_session_skb_drop_old(struct j1939_session *session) + + if ((do_skcb->offset + do_skb->len) < offset_start) { + __skb_unlink(do_skb, &session->skb_queue); ++ /* drop ref taken in j1939_session_skb_queue() */ ++ skb_unref(do_skb); ++ + kfree_skb(do_skb); + } + spin_unlock_irqrestore(&session->skb_queue.lock, flags); +@@ -349,12 +352,13 @@ void j1939_session_skb_queue(struct j1939_session *session, + + skcb->flags |= J1939_ECU_LOCAL_SRC; + ++ skb_get(skb); + skb_queue_tail(&session->skb_queue, skb); + } + + static struct +-sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, +- unsigned int offset_start) ++sk_buff *j1939_session_skb_get_by_offset(struct j1939_session *session, ++ unsigned int offset_start) + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *do_skcb; +@@ -371,6 +375,10 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + skb = do_skb; + } + } ++ ++ if (skb) ++ skb_get(skb); ++ + spin_unlock_irqrestore(&session->skb_queue.lock, flags); + + if (!skb) +@@ -381,12 +389,12 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + return skb; + } + +-static struct sk_buff *j1939_session_skb_find(struct j1939_session *session) ++static struct sk_buff *j1939_session_skb_get(struct j1939_session *session) + { + unsigned int offset_start; + + offset_start = session->pkt.dpo * 7; +- return j1939_session_skb_find_by_offset(session, offset_start); ++ return j1939_session_skb_get_by_offset(session, offset_start); + } + + /* see if we are receiver +@@ -776,7 +784,7 @@ static int j1939_session_tx_dat(struct j1939_session *session) + int ret = 0; + u8 dat[8]; + +- se_skb = j1939_session_skb_find_by_offset(session, session->pkt.tx * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, session->pkt.tx * 7); + if (!se_skb) + return -ENOBUFS; + +@@ -801,7 +809,8 @@ static int j1939_session_tx_dat(struct j1939_session *session) + netdev_err_once(priv->ndev, + "%s: 0x%p: requested data outside of queued buffer: offset %i, len %i, pkt.tx: %i\n", + __func__, session, skcb->offset, se_skb->len , session->pkt.tx); +- return -EOVERFLOW; ++ ret = -EOVERFLOW; ++ goto out_free; + } + + if (!len) { +@@ -835,6 +844,12 @@ static int j1939_session_tx_dat(struct j1939_session *session) + if (pkt_done) + j1939_tp_set_rxtimeout(session, 250); + ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ + return ret; + } + +@@ -1007,7 +1022,7 @@ static int j1939_xtp_txnext_receiver(struct j1939_session *session) + static int j1939_simple_txnext(struct j1939_session *session) + { + struct j1939_priv *priv = session->priv; +- struct sk_buff *se_skb = j1939_session_skb_find(session); ++ struct sk_buff *se_skb = j1939_session_skb_get(session); + struct sk_buff *skb; + int ret; + +@@ -1015,8 +1030,10 @@ static int j1939_simple_txnext(struct j1939_session *session) + return 0; + + skb = skb_clone(se_skb, GFP_ATOMIC); +- if (!skb) +- return -ENOMEM; ++ if (!skb) { ++ ret = -ENOMEM; ++ goto out_free; ++ } + + can_skb_set_owner(skb, se_skb->sk); + +@@ -1024,12 +1041,18 @@ static int j1939_simple_txnext(struct j1939_session *session) + + ret = j1939_send_one(priv, skb); + if (ret) +- return ret; ++ goto out_free; + + j1939_sk_errqueue(session, J1939_ERRQUEUE_SCHED); + j1939_sk_queue_activate_next(session); + +- return 0; ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ ++ return ret; + } + + static bool j1939_session_deactivate_locked(struct j1939_session *session) +@@ -1170,9 +1193,10 @@ static void j1939_session_completed(struct j1939_session *session) + struct sk_buff *skb; + + if (!session->transmission) { +- skb = j1939_session_skb_find(session); ++ skb = j1939_session_skb_get(session); + /* distribute among j1939 receivers */ + j1939_sk_recv(session->priv, skb); ++ consume_skb(skb); + } + + j1939_session_deactivate_activate_next(session); +@@ -1744,7 +1768,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *skcb; +- struct sk_buff *se_skb; ++ struct sk_buff *se_skb = NULL; + const u8 *dat; + u8 *tpdat; + int offset; +@@ -1786,7 +1810,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + goto out_session_cancel; + } + +- se_skb = j1939_session_skb_find_by_offset(session, packet * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, packet * 7); + if (!se_skb) { + netdev_warn(priv->ndev, "%s: 0x%p: no skb found\n", __func__, + session); +@@ -1848,11 +1872,13 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + j1939_tp_set_rxtimeout(session, 250); + } + session->last_cmd = 0xff; ++ consume_skb(se_skb); + j1939_session_put(session); + + return; + + out_session_cancel: ++ kfree_skb(se_skb); + j1939_session_timers_cancel(session); + j1939_session_cancel(session, J1939_XTP_ABORT_FAULT); + j1939_session_put(session); +diff --git a/net/can/raw.c b/net/can/raw.c +index 95113b0898b24..4a7c063deb6ce 100644 +--- a/net/can/raw.c ++++ b/net/can/raw.c +@@ -83,7 +83,7 @@ struct raw_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + int loopback; + int recv_own_msgs; + int fd_frames; +@@ -95,6 +95,10 @@ struct raw_sock { + struct uniqframe __percpu *uniq; + }; + ++static LIST_HEAD(raw_notifier_list); ++static DEFINE_SPINLOCK(raw_notifier_lock); ++static struct raw_sock *raw_busy_notifier; ++ + /* Return pointer to store the extra msg flags for raw_recvmsg(). + * We use the space of one unsigned int beyond the 'struct sockaddr_can' + * in skb->cb. +@@ -263,21 +267,16 @@ static int raw_enable_allfilters(struct net *net, struct net_device *dev, + return err; + } + +-static int raw_notifier(struct notifier_block *nb, +- unsigned long msg, void *ptr) ++static void raw_notify(struct raw_sock *ro, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct raw_sock *ro = container_of(nb, struct raw_sock, notifier); + struct sock *sk = &ro->sk; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + if (ro->ifindex != dev->ifindex) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + case NETDEV_UNREGISTER: +@@ -305,7 +304,28 @@ static int raw_notifier(struct notifier_block *nb, + sk->sk_error_report(sk); + break; + } ++} ++ ++static int raw_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(raw_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; + ++ spin_lock(&raw_notifier_lock); ++ list_for_each_entry(raw_busy_notifier, &raw_notifier_list, notifier) { ++ spin_unlock(&raw_notifier_lock); ++ raw_notify(raw_busy_notifier, msg, dev); ++ spin_lock(&raw_notifier_lock); ++ } ++ raw_busy_notifier = NULL; ++ spin_unlock(&raw_notifier_lock); + return NOTIFY_DONE; + } + +@@ -334,9 +354,9 @@ static int raw_init(struct sock *sk) + return -ENOMEM; + + /* set notifier */ +- ro->notifier.notifier_call = raw_notifier; +- +- register_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ list_add_tail(&ro->notifier, &raw_notifier_list); ++ spin_unlock(&raw_notifier_lock); + + return 0; + } +@@ -351,7 +371,14 @@ static int raw_release(struct socket *sock) + + ro = raw_sk(sk); + +- unregister_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ while (raw_busy_notifier == ro) { ++ spin_unlock(&raw_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&raw_notifier_lock); ++ } ++ list_del(&ro->notifier); ++ spin_unlock(&raw_notifier_lock); + + lock_sock(sk); + +@@ -881,6 +908,10 @@ static const struct can_proto raw_can_proto = { + .prot = &raw_proto, + }; + ++static struct notifier_block canraw_notifier = { ++ .notifier_call = raw_notifier ++}; ++ + static __init int raw_module_init(void) + { + int err; +@@ -890,6 +921,8 @@ static __init int raw_module_init(void) + err = can_proto_register(&raw_can_proto); + if (err < 0) + pr_err("can: registration of raw protocol failed\n"); ++ else ++ register_netdevice_notifier(&canraw_notifier); + + return err; + } +@@ -897,6 +930,7 @@ static __init int raw_module_init(void) + static __exit void raw_module_exit(void) + { + can_proto_unregister(&raw_can_proto); ++ unregister_netdevice_notifier(&canraw_notifier); + } + + module_init(raw_module_init); +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c +index dbc66b896287a..5c9d95f30be60 100644 +--- a/net/core/net_namespace.c ++++ b/net/core/net_namespace.c +@@ -650,6 +650,18 @@ void __put_net(struct net *net) + } + EXPORT_SYMBOL_GPL(__put_net); + ++/** ++ * get_net_ns - increment the refcount of the network namespace ++ * @ns: common namespace (net) ++ * ++ * Returns the net's common namespace. ++ */ ++struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return &get_net(container_of(ns, struct net, ns))->ns; ++} ++EXPORT_SYMBOL_GPL(get_net_ns); ++ + struct net *get_net_ns_by_fd(int fd) + { + struct file *file; +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index 83894723ebeea..dd46592464058 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -4842,10 +4842,12 @@ static int rtnl_bridge_notify(struct net_device *dev) + if (err < 0) + goto errout; + +- if (!skb->len) { +- err = -EINVAL; ++ /* Notification info is only filled for bridge ports, not the bridge ++ * device itself. Therefore, a zero notification length is valid and ++ * should not result in an error. ++ */ ++ if (!skb->len) + goto errout; +- } + + rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); + return 0; +diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c +index c3a5489964cde..9908b922cce8d 100644 +--- a/net/ethtool/strset.c ++++ b/net/ethtool/strset.c +@@ -328,6 +328,8 @@ static int strset_reply_size(const struct ethnl_req_info *req_base, + int len = 0; + int ret; + ++ len += nla_total_size(0); /* ETHTOOL_A_STRSET_STRINGSETS */ ++ + for (i = 0; i < ETH_SS_COUNT; i++) { + const struct strset_info *set_info = &data->sets[i]; + +diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c +index be09c7669a799..ca217a6f488f6 100644 +--- a/net/ipv4/cipso_ipv4.c ++++ b/net/ipv4/cipso_ipv4.c +@@ -472,6 +472,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) + kfree(doi_def->map.std->lvl.local); + kfree(doi_def->map.std->cat.cipso); + kfree(doi_def->map.std->cat.local); ++ kfree(doi_def->map.std); + break; + } + kfree(doi_def); +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c +index ff3818333fcfb..b71b836cc7d19 100644 +--- a/net/ipv4/icmp.c ++++ b/net/ipv4/icmp.c +@@ -759,6 +759,13 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, + icmp_param.data_len = room; + icmp_param.head_len = sizeof(struct icmphdr); + ++ /* if we don't have a source address at this point, fall back to the ++ * dummy address instead of sending out a packet with a source address ++ * of 0.0.0.0 ++ */ ++ if (!fl4.saddr) ++ fl4.saddr = htonl(INADDR_DUMMY); ++ + icmp_push_reply(&icmp_param, &fl4, &ipc, &rt); + ende: + ip_rt_put(rt); +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c +index 7b272bbed2b43..6b3c558a4f232 100644 +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -1801,6 +1801,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) + while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) { + in_dev->mc_list = i->next_rcu; + in_dev->mc_count--; ++ ip_mc_clear_src(i); + ip_ma_put(i); + } + } +diff --git a/net/ipv4/route.c b/net/ipv4/route.c +index 798dc85bde5b7..e968bb47d5bd8 100644 +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -2076,6 +2076,19 @@ martian_source: + return err; + } + ++/* get device for dst_alloc with local routes */ ++static struct net_device *ip_rt_get_dev(struct net *net, ++ const struct fib_result *res) ++{ ++ struct fib_nh_common *nhc = res->fi ? res->nhc : NULL; ++ struct net_device *dev = NULL; ++ ++ if (nhc) ++ dev = l3mdev_master_dev_rcu(nhc->nhc_dev); ++ ++ return dev ? : net->loopback_dev; ++} ++ + /* + * NOTE. We drop all the packets that has local source + * addresses, because every properly looped back packet +@@ -2232,7 +2245,7 @@ local_input: + } + } + +- rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev, ++ rth = rt_dst_alloc(ip_rt_get_dev(net, res), + flags | RTCF_LOCAL, res->type, + IN_DEV_CONF_GET(in_dev, NOPOLICY), false); + if (!rth) +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index 9d28b2778e8fe..fbb9a11fe4a37 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -2569,6 +2569,9 @@ void udp_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + bool slow = lock_sock_fast(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_flush_pending_frames(sk); + unlock_sock_fast(sk, slow); + if (static_branch_unlikely(&udp_encap_needed_key)) { +@@ -2819,10 +2822,17 @@ int udp_abort(struct sock *sk, int err) + { + lock_sock(sk); + ++ /* udp{v6}_destroy_sock() sets it under the sk lock, avoid racing ++ * with close() ++ */ ++ if (sock_flag(sk, SOCK_DEAD)) ++ goto out; ++ + sk->sk_err = err; + sk->sk_error_report(sk); + __udp_disconnect(sk, 0); + ++out: + release_sock(sk); + + return 0; +diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c +index e204163c7036c..92f3235fa2874 100644 +--- a/net/ipv6/netfilter/nft_fib_ipv6.c ++++ b/net/ipv6/netfilter/nft_fib_ipv6.c +@@ -135,6 +135,17 @@ void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs, + } + EXPORT_SYMBOL_GPL(nft_fib6_eval_type); + ++static bool nft_fib_v6_skip_icmpv6(const struct sk_buff *skb, u8 next, const struct ipv6hdr *iph) ++{ ++ if (likely(next != IPPROTO_ICMPV6)) ++ return false; ++ ++ if (ipv6_addr_type(&iph->saddr) != IPV6_ADDR_ANY) ++ return false; ++ ++ return ipv6_addr_type(&iph->daddr) & IPV6_ADDR_LINKLOCAL; ++} ++ + void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, + const struct nft_pktinfo *pkt) + { +@@ -163,10 +174,13 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, + + lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif, iph); + +- if (nft_hook(pkt) == NF_INET_PRE_ROUTING && +- nft_fib_is_loopback(pkt->skb, nft_in(pkt))) { +- nft_fib_store_result(dest, priv, nft_in(pkt)); +- return; ++ if (nft_hook(pkt) == NF_INET_PRE_ROUTING || ++ nft_hook(pkt) == NF_INET_INGRESS) { ++ if (nft_fib_is_loopback(pkt->skb, nft_in(pkt)) || ++ nft_fib_v6_skip_icmpv6(pkt->skb, pkt->tprot, iph)) { ++ nft_fib_store_result(dest, priv, nft_in(pkt)); ++ return; ++ } + } + + *dest = 0; +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c +index 29d9691359b9c..e2de58d6cdce2 100644 +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -1596,6 +1596,9 @@ void udpv6_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + lock_sock(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_v6_flush_pending_frames(sk); + release_sock(sk); + +diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c +index d4cc9ac2d7033..6b50cb5e0e3cc 100644 +--- a/net/mac80211/scan.c ++++ b/net/mac80211/scan.c +@@ -251,13 +251,24 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) + struct ieee80211_mgmt *mgmt = (void *)skb->data; + struct ieee80211_bss *bss; + struct ieee80211_channel *channel; ++ size_t min_hdr_len = offsetof(struct ieee80211_mgmt, ++ u.probe_resp.variable); ++ ++ if (!ieee80211_is_probe_resp(mgmt->frame_control) && ++ !ieee80211_is_beacon(mgmt->frame_control) && ++ !ieee80211_is_s1g_beacon(mgmt->frame_control)) ++ return; + + if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { +- if (skb->len < 15) +- return; +- } else if (skb->len < 24 || +- (!ieee80211_is_probe_resp(mgmt->frame_control) && +- !ieee80211_is_beacon(mgmt->frame_control))) ++ if (ieee80211_is_s1g_short_beacon(mgmt->frame_control)) ++ min_hdr_len = offsetof(struct ieee80211_ext, ++ u.s1g_short_beacon.variable); ++ else ++ min_hdr_len = offsetof(struct ieee80211_ext, ++ u.s1g_beacon); ++ } ++ ++ if (skb->len < min_hdr_len) + return; + + sdata1 = rcu_dereference(local->scan_sdata); +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c +index 1d8526d89505f..20b3581a1c43f 100644 +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -2030,6 +2030,26 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, + ieee80211_tx(sdata, sta, skb, false); + } + ++static bool ieee80211_validate_radiotap_len(struct sk_buff *skb) ++{ ++ struct ieee80211_radiotap_header *rthdr = ++ (struct ieee80211_radiotap_header *)skb->data; ++ ++ /* check for not even having the fixed radiotap header part */ ++ if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) ++ return false; /* too short to be possibly valid */ ++ ++ /* is it a header version we can trust to find length from? */ ++ if (unlikely(rthdr->it_version)) ++ return false; /* only version 0 is supported */ ++ ++ /* does the skb contain enough to deliver on the alleged length? */ ++ if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) ++ return false; /* skb too short for claimed rt header extent */ ++ ++ return true; ++} ++ + bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + struct net_device *dev) + { +@@ -2038,8 +2058,6 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + struct ieee80211_radiotap_header *rthdr = + (struct ieee80211_radiotap_header *) skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- struct ieee80211_supported_band *sband = +- local->hw.wiphy->bands[info->band]; + int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, + NULL); + u16 txflags; +@@ -2052,17 +2070,8 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + u8 vht_mcs = 0, vht_nss = 0; + int i; + +- /* check for not even having the fixed radiotap header part */ +- if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) +- return false; /* too short to be possibly valid */ +- +- /* is it a header version we can trust to find length from? */ +- if (unlikely(rthdr->it_version)) +- return false; /* only version 0 is supported */ +- +- /* does the skb contain enough to deliver on the alleged length? */ +- if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) +- return false; /* skb too short for claimed rt header extent */ ++ if (!ieee80211_validate_radiotap_len(skb)) ++ return false; + + info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | + IEEE80211_TX_CTL_DONTFRAG; +@@ -2186,6 +2195,9 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + return false; + + if (rate_found) { ++ struct ieee80211_supported_band *sband = ++ local->hw.wiphy->bands[info->band]; ++ + info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; + + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { +@@ -2199,7 +2211,7 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) { + ieee80211_rate_set_vht(info->control.rates, vht_mcs, + vht_nss); +- } else { ++ } else if (sband) { + for (i = 0; i < sband->n_bitrates; i++) { + if (rate * 5 != sband->bitrates[i].bitrate) + continue; +@@ -2236,8 +2248,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, + info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | + IEEE80211_TX_CTL_INJECTED; + +- /* Sanity-check and process the injection radiotap header */ +- if (!ieee80211_parse_tx_radiotap(skb, dev)) ++ /* Sanity-check the length of the radiotap header */ ++ if (!ieee80211_validate_radiotap_len(skb)) + goto fail; + + /* we now know there is a radiotap header with a length we can use */ +@@ -2353,6 +2365,14 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, + + info->band = chandef->chan->band; + ++ /* ++ * Process the radiotap header. This will now take into account the ++ * selected chandef above to accurately set injection rates and ++ * retransmissions. ++ */ ++ if (!ieee80211_parse_tx_radiotap(skb, dev)) ++ goto fail_rcu; ++ + /* remove the injection radiotap header */ + skb_pull(skb, len_rthdr); + +diff --git a/net/mptcp/options.c b/net/mptcp/options.c +index 91034a221983c..ac0233c9cd349 100644 +--- a/net/mptcp/options.c ++++ b/net/mptcp/options.c +@@ -314,6 +314,8 @@ void mptcp_get_options(const struct sk_buff *skb, + length--; + continue; + default: ++ if (length < 2) ++ return; + opsize = *ptr++; + if (opsize < 2) /* "silly options" */ + return; +diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c +index 7832b20baac2e..3ca8b359e399a 100644 +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -276,11 +276,13 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, + + /* try to fetch required memory from subflow */ + if (!sk_rmem_schedule(sk, skb, skb->truesize)) { +- if (ssk->sk_forward_alloc < skb->truesize) +- goto drop; +- __sk_mem_reclaim(ssk, skb->truesize); +- if (!sk_rmem_schedule(sk, skb, skb->truesize)) ++ int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT; ++ ++ if (ssk->sk_forward_alloc < amount) + goto drop; ++ ++ ssk->sk_forward_alloc -= amount; ++ sk->sk_forward_alloc += amount; + } + + /* the skb map_seq accounts for the skb offset: +diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c +index 96b6aca9d0ae7..851fb3d8c791d 100644 +--- a/net/mptcp/subflow.c ++++ b/net/mptcp/subflow.c +@@ -655,10 +655,10 @@ static u64 expand_seq(u64 old_seq, u16 old_data_len, u64 seq) + return seq | ((old_seq + old_data_len + 1) & GENMASK_ULL(63, 32)); + } + +-static void warn_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) ++static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) + { +- WARN_ONCE(1, "Bad mapping: ssn=%d map_seq=%d map_data_len=%d", +- ssn, subflow->map_subflow_seq, subflow->map_data_len); ++ pr_debug("Bad mapping: ssn=%d map_seq=%d map_data_len=%d", ++ ssn, subflow->map_subflow_seq, subflow->map_data_len); + } + + static bool skb_is_fully_mapped(struct sock *ssk, struct sk_buff *skb) +@@ -683,13 +683,13 @@ static bool validate_mapping(struct sock *ssk, struct sk_buff *skb) + /* Mapping covers data later in the subflow stream, + * currently unsupported. + */ +- warn_bad_map(subflow, ssn); ++ dbg_bad_map(subflow, ssn); + return false; + } + if (unlikely(!before(ssn, subflow->map_subflow_seq + + subflow->map_data_len))) { + /* Mapping does covers past subflow data, invalid */ +- warn_bad_map(subflow, ssn + skb->len); ++ dbg_bad_map(subflow, ssn); + return false; + } + return true; +diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c +index d7d34a62d3bf5..2fc4ae960769d 100644 +--- a/net/netfilter/nf_synproxy_core.c ++++ b/net/netfilter/nf_synproxy_core.c +@@ -31,6 +31,9 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + int length = (th->doff * 4) - sizeof(*th); + u8 buf[40], *ptr; + ++ if (unlikely(length < 0)) ++ return false; ++ + ptr = skb_header_pointer(skb, doff + sizeof(*th), length, buf); + if (ptr == NULL) + return false; +@@ -47,6 +50,8 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + length--; + continue; + default: ++ if (length < 2) ++ return true; + opsize = *ptr++; + if (opsize < 2) + return true; +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c +index 93a7edcff11e7..0d9baddb9cd49 100644 +--- a/net/qrtr/qrtr.c ++++ b/net/qrtr/qrtr.c +@@ -429,7 +429,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) + struct qrtr_sock *ipc; + struct sk_buff *skb; + struct qrtr_cb *cb; +- unsigned int size; ++ size_t size; + unsigned int ver; + size_t hdrlen; + +diff --git a/net/rds/recv.c b/net/rds/recv.c +index aba4afe4dfedc..967d115f97efd 100644 +--- a/net/rds/recv.c ++++ b/net/rds/recv.c +@@ -714,7 +714,7 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, + + if (rds_cmsg_recv(inc, msg, rs)) { + ret = -EFAULT; +- goto out; ++ break; + } + rds_recvmsg_zcookie(rs, msg); + +diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c +index 315a5b2f3add8..7ef074c6dd160 100644 +--- a/net/sched/act_ct.c ++++ b/net/sched/act_ct.c +@@ -900,14 +900,19 @@ static int tcf_ct_act_nat(struct sk_buff *skb, + } + + err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); +- if (err == NF_ACCEPT && +- ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { +- if (maniptype == NF_NAT_MANIP_SRC) +- maniptype = NF_NAT_MANIP_DST; +- else +- maniptype = NF_NAT_MANIP_SRC; +- +- err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); ++ if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { ++ if (ct->status & IPS_SRC_NAT) { ++ if (maniptype == NF_NAT_MANIP_SRC) ++ maniptype = NF_NAT_MANIP_DST; ++ else ++ maniptype = NF_NAT_MANIP_SRC; ++ ++ err = ct_nat_execute(skb, ct, ctinfo, range, ++ maniptype); ++ } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) { ++ err = ct_nat_execute(skb, ct, ctinfo, NULL, ++ NF_NAT_MANIP_SRC); ++ } + } + return err; + #else +diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c +index 7d37638ee1c7a..5c15968b5155b 100644 +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -943,7 +943,7 @@ static struct tcphdr *cake_get_tcphdr(const struct sk_buff *skb, + } + + tcph = skb_header_pointer(skb, offset, sizeof(_tcph), &_tcph); +- if (!tcph) ++ if (!tcph || tcph->doff < 5) + return NULL; + + return skb_header_pointer(skb, offset, +@@ -967,6 +967,8 @@ static const void *cake_get_tcpopt(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +@@ -1104,6 +1106,8 @@ static bool cake_tcph_may_drop(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +diff --git a/net/socket.c b/net/socket.c +index 6e6cccc2104f7..002d5952ae5d8 100644 +--- a/net/socket.c ++++ b/net/socket.c +@@ -1080,19 +1080,6 @@ static long sock_do_ioctl(struct net *net, struct socket *sock, + * what to do with it - that's up to the protocol still. + */ + +-/** +- * get_net_ns - increment the refcount of the network namespace +- * @ns: common namespace (net) +- * +- * Returns the net's common namespace. +- */ +- +-struct ns_common *get_net_ns(struct ns_common *ns) +-{ +- return &get_net(container_of(ns, struct net, ns))->ns; +-} +-EXPORT_SYMBOL_GPL(get_net_ns); +- + static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) + { + struct socket *sock; +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c +index 41c3303c33577..39be4b52329b5 100644 +--- a/net/unix/af_unix.c ++++ b/net/unix/af_unix.c +@@ -535,12 +535,14 @@ static void unix_release_sock(struct sock *sk, int embrion) + u->path.mnt = NULL; + state = sk->sk_state; + sk->sk_state = TCP_CLOSE; ++ ++ skpair = unix_peer(sk); ++ unix_peer(sk) = NULL; ++ + unix_state_unlock(sk); + + wake_up_interruptible_all(&u->peer_wait); + +- skpair = unix_peer(sk); +- + if (skpair != NULL) { + if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { + unix_state_lock(skpair); +@@ -555,7 +557,6 @@ static void unix_release_sock(struct sock *sk, int embrion) + + unix_dgram_peer_wake_disconnect(sk, skpair); + sock_put(skpair); /* It may now die */ +- unix_peer(sk) = NULL; + } + + /* Try to flush out this socket. Throw out buffers at least */ +diff --git a/net/wireless/Makefile b/net/wireless/Makefile +index 2eee93985ab0d..af590ae606b69 100644 +--- a/net/wireless/Makefile ++++ b/net/wireless/Makefile +@@ -28,7 +28,7 @@ $(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.hex) + @$(kecho) " GEN $@" + @(echo '#include "reg.h"'; \ + echo 'const u8 shipped_regdb_certs[] = {'; \ +- cat $^ ; \ ++ echo | cat - $^ ; \ + echo '};'; \ + echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \ + ) > $@ +diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c +index a95c79d183492..a817d8e3e4b36 100644 +--- a/net/wireless/pmsr.c ++++ b/net/wireless/pmsr.c +@@ -324,6 +324,7 @@ void cfg80211_pmsr_complete(struct wireless_dev *wdev, + gfp_t gfp) + { + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); ++ struct cfg80211_pmsr_request *tmp, *prev, *to_free = NULL; + struct sk_buff *msg; + void *hdr; + +@@ -354,9 +355,20 @@ free_msg: + nlmsg_free(msg); + free_request: + spin_lock_bh(&wdev->pmsr_lock); +- list_del(&req->list); ++ /* ++ * cfg80211_pmsr_process_abort() may have already moved this request ++ * to the free list, and will free it later. In this case, don't free ++ * it here. ++ */ ++ list_for_each_entry_safe(tmp, prev, &wdev->pmsr_list, list) { ++ if (tmp == req) { ++ list_del(&req->list); ++ to_free = req; ++ break; ++ } ++ } + spin_unlock_bh(&wdev->pmsr_lock); +- kfree(req); ++ kfree(to_free); + } + EXPORT_SYMBOL_GPL(cfg80211_pmsr_complete); + +diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c +index 91a4ef7f620ca..a9b079d56fd69 100644 +--- a/sound/soc/codecs/rt5659.c ++++ b/sound/soc/codecs/rt5659.c +@@ -2433,13 +2433,18 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w, + return 0; + } + +-static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0, + NULL, 0), +- SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, +- NULL, 0), ++ SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, ++ 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL, + RT5659_PWR_MIC_DET_BIT, 0, NULL, 0), ++}; ++ ++static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++ SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, ++ NULL, 0), + SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1, + RT5659_PWR_VREF3_BIT, 0, NULL, 0), + +@@ -2464,8 +2469,6 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { + RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0), + + /* Input Side */ +- SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, +- 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT, + 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT, +@@ -3660,10 +3663,23 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, + + static int rt5659_probe(struct snd_soc_component *component) + { ++ struct snd_soc_dapm_context *dapm = ++ snd_soc_component_get_dapm(component); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); + + rt5659->component = component; + ++ switch (rt5659->pdata.jd_src) { ++ case RT5659_JD_HDA_HEADER: ++ break; ++ ++ default: ++ snd_soc_dapm_new_controls(dapm, ++ rt5659_particular_dapm_widgets, ++ ARRAY_SIZE(rt5659_particular_dapm_widgets)); ++ break; ++ } ++ + return 0; + } + +diff --git a/sound/soc/codecs/rt5682-sdw.c b/sound/soc/codecs/rt5682-sdw.c +index 58fb13132602c..aa6c325faeab2 100644 +--- a/sound/soc/codecs/rt5682-sdw.c ++++ b/sound/soc/codecs/rt5682-sdw.c +@@ -455,7 +455,8 @@ static int rt5682_io_init(struct device *dev, struct sdw_slave *slave) + + regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_2, + RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL); +- regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd042); ++ regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd142); ++ regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_5, 0x0700, 0x0600); + regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_3, + RT5682_CBJ_IN_BUF_EN, RT5682_CBJ_IN_BUF_EN); + regmap_update_bits(rt5682->regmap, RT5682_SAR_IL_CMD_1, +diff --git a/sound/soc/codecs/tas2562.h b/sound/soc/codecs/tas2562.h +index 81866aeb3fbfa..55b2a1f52ca37 100644 +--- a/sound/soc/codecs/tas2562.h ++++ b/sound/soc/codecs/tas2562.h +@@ -57,13 +57,13 @@ + #define TAS2562_TDM_CFG0_RAMPRATE_MASK BIT(5) + #define TAS2562_TDM_CFG0_RAMPRATE_44_1 BIT(5) + #define TAS2562_TDM_CFG0_SAMPRATE_MASK GENMASK(3, 1) +-#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ 0x0 +-#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ 0x1 +-#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ 0x2 +-#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ 0x3 +-#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ 0x4 +-#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ 0x5 +-#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ 0x6 ++#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ (0x0 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ (0x1 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ (0x2 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ (0x3 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ (0x4 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ (0x5 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ (0x6 << 1) + + #define TAS2562_TDM_CFG2_RIGHT_JUSTIFY BIT(6) + +diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c +index a2dd3b6b7fec1..7cd14d6b9436a 100644 +--- a/sound/soc/fsl/fsl-asoc-card.c ++++ b/sound/soc/fsl/fsl-asoc-card.c +@@ -720,6 +720,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) + /* Initialize sound card */ + priv->pdev = pdev; + priv->card.dev = &pdev->dev; ++ priv->card.owner = THIS_MODULE; + ret = snd_soc_of_parse_card_name(&priv->card, "model"); + if (ret) { + snprintf(priv->name, sizeof(priv->name), "%s-audio", +diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c +index 7a30a12519a70..e620a62ef534f 100644 +--- a/sound/soc/qcom/lpass-cpu.c ++++ b/sound/soc/qcom/lpass-cpu.c +@@ -93,8 +93,30 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) + { + struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); ++ struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; ++ unsigned int id = dai->driver->id; + + clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]); ++ /* ++ * Ensure LRCLK is disabled even in device node validation. ++ * Will not impact if disabled in lpass_cpu_daiops_trigger() ++ * suspend. ++ */ ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ++ regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_DISABLE); ++ else ++ regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_DISABLE); ++ ++ /* ++ * BCLK may not be enabled if lpass_cpu_daiops_prepare is called before ++ * lpass_cpu_daiops_shutdown. It's paired with the clk_enable in ++ * lpass_cpu_daiops_prepare. ++ */ ++ if (drvdata->mi2s_was_prepared[dai->driver->id]) { ++ drvdata->mi2s_was_prepared[dai->driver->id] = false; ++ clk_disable(drvdata->mi2s_bit_clk[dai->driver->id]); ++ } ++ + clk_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); + } + +@@ -275,6 +297,18 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: ++ /* ++ * Ensure lpass BCLK/LRCLK is enabled during ++ * device resume as lpass_cpu_daiops_prepare() is not called ++ * after the device resumes. We don't check mi2s_was_prepared before ++ * enable/disable BCLK in trigger events because: ++ * 1. These trigger events are paired, so the BCLK ++ * enable_count is balanced. ++ * 2. the BCLK can be shared (ex: headset and headset mic), ++ * we need to increase the enable_count so that we don't ++ * turn off the shared BCLK while other devices are using ++ * it. ++ */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = regmap_fields_write(i2sctl->spken, id, + LPAIF_I2SCTL_SPKEN_ENABLE); +@@ -296,6 +330,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: ++ /* ++ * To ensure lpass BCLK/LRCLK is disabled during ++ * device suspend. ++ */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = regmap_fields_write(i2sctl->spken, id, + LPAIF_I2SCTL_SPKEN_DISABLE); +@@ -315,12 +353,53 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + return ret; + } + ++static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); ++ struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; ++ unsigned int id = dai->driver->id; ++ int ret; ++ ++ /* ++ * Ensure lpass BCLK/LRCLK is enabled bit before playback/capture ++ * data flow starts. This allows other codec to have some delay before ++ * the data flow. ++ * (ex: to drop start up pop noise before capture starts). ++ */ ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ++ ret = regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_ENABLE); ++ else ++ ret = regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_ENABLE); ++ ++ if (ret) { ++ dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret); ++ return ret; ++ } ++ ++ /* ++ * Check mi2s_was_prepared before enabling BCLK as lpass_cpu_daiops_prepare can ++ * be called multiple times. It's paired with the clk_disable in ++ * lpass_cpu_daiops_shutdown. ++ */ ++ if (!drvdata->mi2s_was_prepared[dai->driver->id]) { ++ ret = clk_enable(drvdata->mi2s_bit_clk[id]); ++ if (ret) { ++ dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret); ++ return ret; ++ } ++ drvdata->mi2s_was_prepared[dai->driver->id] = true; ++ } ++ return 0; ++} ++ + const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { + .set_sysclk = lpass_cpu_daiops_set_sysclk, + .startup = lpass_cpu_daiops_startup, + .shutdown = lpass_cpu_daiops_shutdown, + .hw_params = lpass_cpu_daiops_hw_params, + .trigger = lpass_cpu_daiops_trigger, ++ .prepare = lpass_cpu_daiops_prepare, + }; + EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); + +diff --git a/sound/soc/qcom/lpass.h b/sound/soc/qcom/lpass.h +index 1d926dd5f5900..0484ad39b3dce 100644 +--- a/sound/soc/qcom/lpass.h ++++ b/sound/soc/qcom/lpass.h +@@ -67,6 +67,10 @@ struct lpass_data { + /* MI2S SD lines to use for playback/capture */ + unsigned int mi2s_playback_sd_mode[LPASS_MAX_MI2S_PORTS]; + unsigned int mi2s_capture_sd_mode[LPASS_MAX_MI2S_PORTS]; ++ ++ /* The state of MI2S prepare dai_ops was called */ ++ bool mi2s_was_prepared[LPASS_MAX_MI2S_PORTS]; ++ + int hdmi_port_enable; + + /* low-power audio interface (LPAIF) registers */ +diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h +index 7d6687618d808..d1b327036ae43 100644 +--- a/tools/include/uapi/linux/in.h ++++ b/tools/include/uapi/linux/in.h +@@ -289,6 +289,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c +index 7150e34cf2afb..3028f932e10c0 100644 +--- a/tools/lib/bpf/xsk.c ++++ b/tools/lib/bpf/xsk.c +@@ -779,7 +779,7 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr, + goto out_put_ctx; + } + if (xsk->fd == umem->fd) +- umem->rx_ring_setup_done = true; ++ umem->tx_ring_setup_done = true; + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); +diff --git a/tools/perf/trace/beauty/include/linux/socket.h b/tools/perf/trace/beauty/include/linux/socket.h +index e9cb30d8cbfb1..9aa530d497da8 100644 +--- a/tools/perf/trace/beauty/include/linux/socket.h ++++ b/tools/perf/trace/beauty/include/linux/socket.h +@@ -437,6 +437,4 @@ extern int __sys_getpeername(int fd, struct sockaddr __user *usockaddr, + extern int __sys_socketpair(int family, int type, int protocol, + int __user *usockvec); + extern int __sys_shutdown(int fd, int how); +- +-extern struct ns_common *get_net_ns(struct ns_common *ns); + #endif /* _LINUX_SOCKET_H */ +diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh +index 2b5707738609e..6fad54c7ecb4a 100755 +--- a/tools/testing/selftests/net/fib_tests.sh ++++ b/tools/testing/selftests/net/fib_tests.sh +@@ -1384,12 +1384,37 @@ ipv4_rt_replace() + ipv4_rt_replace_mpath + } + ++# checks that cached input route on VRF port is deleted ++# when VRF is deleted ++ipv4_local_rt_cache() ++{ ++ run_cmd "ip addr add 10.0.0.1/32 dev lo" ++ run_cmd "ip netns add test-ns" ++ run_cmd "ip link add veth-outside type veth peer name veth-inside" ++ run_cmd "ip link add vrf-100 type vrf table 1100" ++ run_cmd "ip link set veth-outside master vrf-100" ++ run_cmd "ip link set veth-inside netns test-ns" ++ run_cmd "ip link set veth-outside up" ++ run_cmd "ip link set vrf-100 up" ++ run_cmd "ip route add 10.1.1.1/32 dev veth-outside table 1100" ++ run_cmd "ip netns exec test-ns ip link set veth-inside up" ++ run_cmd "ip netns exec test-ns ip addr add 10.1.1.1/32 dev veth-inside" ++ run_cmd "ip netns exec test-ns ip route add 10.0.0.1/32 dev veth-inside" ++ run_cmd "ip netns exec test-ns ip route add default via 10.0.0.1" ++ run_cmd "ip netns exec test-ns ping 10.0.0.1 -c 1 -i 1" ++ run_cmd "ip link delete vrf-100" ++ ++ # if we do not hang test is a success ++ log_test $? 0 "Cached route removed from VRF port device" ++} ++ + ipv4_route_test() + { + route_setup + + ipv4_rt_add + ipv4_rt_replace ++ ipv4_local_rt_cache + + route_cleanup + } +diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +index e927df83efb91..987a914ee0df2 100755 +--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +@@ -195,9 +195,6 @@ ip -net "$ns4" link set ns4eth3 up + ip -net "$ns4" route add default via 10.0.3.2 + ip -net "$ns4" route add default via dead:beef:3::2 + +-# use TCP syn cookies, even if no flooding was detected. +-ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2 +- + set_ethtool_flags() { + local ns="$1" + local dev="$2" +@@ -666,6 +663,14 @@ for sender in $ns1 $ns2 $ns3 $ns4;do + exit $ret + fi + ++ # ns1<->ns2 is not subject to reordering/tc delays. Use it to test ++ # mptcp syncookie support. ++ if [ $sender = $ns1 ]; then ++ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2 ++ else ++ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1 ++ fi ++ + run_tests "$ns2" $sender 10.0.1.2 + run_tests "$ns2" $sender dead:beef:1::2 + run_tests "$ns2" $sender 10.0.2.1 diff --git a/patch/kernel/archive/sunxi-5.12/patch-5.12.12-13.patch b/patch/kernel/archive/sunxi-5.12/patch-5.12.12-13.patch new file mode 100644 index 000000000..ef75d5781 --- /dev/null +++ b/patch/kernel/archive/sunxi-5.12/patch-5.12.12-13.patch @@ -0,0 +1,6477 @@ +diff --git a/Documentation/vm/slub.rst b/Documentation/vm/slub.rst +index 03f294a638bd8..d3028554b1e9c 100644 +--- a/Documentation/vm/slub.rst ++++ b/Documentation/vm/slub.rst +@@ -181,7 +181,7 @@ SLUB Debug output + Here is a sample of slub debug output:: + + ==================================================================== +- BUG kmalloc-8: Redzone overwritten ++ BUG kmalloc-8: Right Redzone overwritten + -------------------------------------------------------------------- + + INFO: 0xc90f6d28-0xc90f6d2b. First byte 0x00 instead of 0xcc +@@ -189,10 +189,10 @@ Here is a sample of slub debug output:: + INFO: Object 0xc90f6d20 @offset=3360 fp=0xc90f6d58 + INFO: Allocated in get_modalias+0x61/0xf5 age=53 cpu=1 pid=554 + +- Bytes b4 0xc90f6d10: 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ +- Object 0xc90f6d20: 31 30 31 39 2e 30 30 35 1019.005 +- Redzone 0xc90f6d28: 00 cc cc cc . +- Padding 0xc90f6d50: 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ ++ Bytes b4 (0xc90f6d10): 00 00 00 00 00 00 00 00 5a 5a 5a 5a 5a 5a 5a 5a ........ZZZZZZZZ ++ Object (0xc90f6d20): 31 30 31 39 2e 30 30 35 1019.005 ++ Redzone (0xc90f6d28): 00 cc cc cc . ++ Padding (0xc90f6d50): 5a 5a 5a 5a 5a 5a 5a 5a ZZZZZZZZ + + [] dump_trace+0x63/0x1eb + [] show_trace_log_lvl+0x1a/0x2f +diff --git a/Makefile b/Makefile +index e0a252b644630..d2fe36db78aed 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 12 +-SUBLEVEL = 12 ++SUBLEVEL = 13 + EXTRAVERSION = + NAME = Frozen Wasteland + +@@ -913,11 +913,14 @@ CC_FLAGS_LTO += -fvisibility=hidden + # Limit inlining across translation units to reduce binary size + KBUILD_LDFLAGS += -mllvm -import-instr-limit=5 + +-# Check for frame size exceeding threshold during prolog/epilog insertion. ++# Check for frame size exceeding threshold during prolog/epilog insertion ++# when using lld < 13.0.0. + ifneq ($(CONFIG_FRAME_WARN),0) ++ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) + KBUILD_LDFLAGS += -plugin-opt=-warn-stack-size=$(CONFIG_FRAME_WARN) + endif + endif ++endif + + ifdef CONFIG_LTO + KBUILD_CFLAGS += -fno-lto $(CC_FLAGS_LTO) +diff --git a/arch/arc/include/uapi/asm/sigcontext.h b/arch/arc/include/uapi/asm/sigcontext.h +index 95f8a4380e110..7a5449dfcb290 100644 +--- a/arch/arc/include/uapi/asm/sigcontext.h ++++ b/arch/arc/include/uapi/asm/sigcontext.h +@@ -18,6 +18,7 @@ + */ + struct sigcontext { + struct user_regs_struct regs; ++ struct user_regs_arcv2 v2abi; + }; + + #endif /* _ASM_ARC_SIGCONTEXT_H */ +diff --git a/arch/arc/kernel/signal.c b/arch/arc/kernel/signal.c +index fdbe06c98895e..4868bdebf586d 100644 +--- a/arch/arc/kernel/signal.c ++++ b/arch/arc/kernel/signal.c +@@ -61,6 +61,41 @@ struct rt_sigframe { + unsigned int sigret_magic; + }; + ++static int save_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ v2abi.r30 = regs->r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ v2abi.r58 = regs->r58; ++ v2abi.r59 = regs->r59; ++#else ++ v2abi.r58 = v2abi.r59 = 0; ++#endif ++ err = __copy_to_user(&mctx->v2abi, &v2abi, sizeof(v2abi)); ++#endif ++ return err; ++} ++ ++static int restore_arcv2_regs(struct sigcontext *mctx, struct pt_regs *regs) ++{ ++ int err = 0; ++#ifndef CONFIG_ISA_ARCOMPACT ++ struct user_regs_arcv2 v2abi; ++ ++ err = __copy_from_user(&v2abi, &mctx->v2abi, sizeof(v2abi)); ++ ++ regs->r30 = v2abi.r30; ++#ifdef CONFIG_ARC_HAS_ACCL_REGS ++ regs->r58 = v2abi.r58; ++ regs->r59 = v2abi.r59; ++#endif ++#endif ++ return err; ++} ++ + static int + stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + sigset_t *set) +@@ -94,6 +129,10 @@ stash_usr_regs(struct rt_sigframe __user *sf, struct pt_regs *regs, + + err = __copy_to_user(&(sf->uc.uc_mcontext.regs.scratch), &uregs.scratch, + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= save_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + err |= __copy_to_user(&sf->uc.uc_sigmask, set, sizeof(sigset_t)); + + return err ? -EFAULT : 0; +@@ -109,6 +148,10 @@ static int restore_usr_regs(struct pt_regs *regs, struct rt_sigframe __user *sf) + err |= __copy_from_user(&uregs.scratch, + &(sf->uc.uc_mcontext.regs.scratch), + sizeof(sf->uc.uc_mcontext.regs.scratch)); ++ ++ if (is_isa_arcv2()) ++ err |= restore_arcv2_regs(&(sf->uc.uc_mcontext), regs); ++ + if (err) + return -EFAULT; + +diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c +index 766f064f00fbf..167fde7f2fce1 100644 +--- a/arch/powerpc/perf/core-book3s.c ++++ b/arch/powerpc/perf/core-book3s.c +@@ -2242,7 +2242,7 @@ unsigned long perf_instruction_pointer(struct pt_regs *regs) + bool use_siar = regs_use_siar(regs); + unsigned long siar = mfspr(SPRN_SIAR); + +- if (ppmu->flags & PPMU_P10_DD1) { ++ if (ppmu && (ppmu->flags & PPMU_P10_DD1)) { + if (siar) + return siar; + else +diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig +index d9522fc35ca5a..4f116be9152f5 100644 +--- a/arch/riscv/Kconfig ++++ b/arch/riscv/Kconfig +@@ -54,11 +54,11 @@ config RISCV + select GENERIC_TIME_VSYSCALL if MMU && 64BIT + select HANDLE_DOMAIN_IRQ + select HAVE_ARCH_AUDITSYSCALL +- select HAVE_ARCH_JUMP_LABEL +- select HAVE_ARCH_JUMP_LABEL_RELATIVE ++ select HAVE_ARCH_JUMP_LABEL if !XIP_KERNEL ++ select HAVE_ARCH_JUMP_LABEL_RELATIVE if !XIP_KERNEL + select HAVE_ARCH_KASAN if MMU && 64BIT + select HAVE_ARCH_KASAN_VMALLOC if MMU && 64BIT +- select HAVE_ARCH_KGDB ++ select HAVE_ARCH_KGDB if !XIP_KERNEL + select HAVE_ARCH_KGDB_QXFER_PKT + select HAVE_ARCH_MMAP_RND_BITS if MMU + select HAVE_ARCH_SECCOMP_FILTER +@@ -73,9 +73,9 @@ config RISCV + select HAVE_GCC_PLUGINS + select HAVE_GENERIC_VDSO if MMU && 64BIT + select HAVE_IRQ_TIME_ACCOUNTING +- select HAVE_KPROBES +- select HAVE_KPROBES_ON_FTRACE +- select HAVE_KRETPROBES ++ select HAVE_KPROBES if !XIP_KERNEL ++ select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL ++ select HAVE_KRETPROBES if !XIP_KERNEL + select HAVE_PCI + select HAVE_PERF_EVENTS + select HAVE_PERF_REGS +@@ -227,11 +227,11 @@ config ARCH_RV64I + bool "RV64I" + select 64BIT + select ARCH_SUPPORTS_INT128 if CC_HAS_INT128 && GCC_VERSION >= 50000 +- select HAVE_DYNAMIC_FTRACE if MMU && $(cc-option,-fpatchable-function-entry=8) ++ select HAVE_DYNAMIC_FTRACE if !XIP_KERNEL && MMU && $(cc-option,-fpatchable-function-entry=8) + select HAVE_DYNAMIC_FTRACE_WITH_REGS if HAVE_DYNAMIC_FTRACE +- select HAVE_FTRACE_MCOUNT_RECORD ++ select HAVE_FTRACE_MCOUNT_RECORD if !XIP_KERNEL + select HAVE_FUNCTION_GRAPH_TRACER +- select HAVE_FUNCTION_TRACER ++ select HAVE_FUNCTION_TRACER if !XIP_KERNEL + select SWIOTLB if MMU + + endchoice +diff --git a/arch/s390/kernel/entry.S b/arch/s390/kernel/entry.S +index 12de7a9c85b35..9cc71ca9a88f9 100644 +--- a/arch/s390/kernel/entry.S ++++ b/arch/s390/kernel/entry.S +@@ -651,9 +651,9 @@ ENDPROC(stack_overflow) + .Lcleanup_sie_mcck: + larl %r13,.Lsie_entry + slgr %r9,%r13 +- larl %r13,.Lsie_skip ++ lghi %r13,.Lsie_skip - .Lsie_entry + clgr %r9,%r13 +- jh .Lcleanup_sie_int ++ jhe .Lcleanup_sie_int + oi __LC_CPU_FLAGS+7, _CIF_MCCK_GUEST + .Lcleanup_sie_int: + BPENTER __SF_SIE_FLAGS(%r15),(_TIF_ISOLATE_BP|_TIF_ISOLATE_BP_GUEST) +diff --git a/arch/x86/include/asm/fpu/internal.h b/arch/x86/include/asm/fpu/internal.h +index ceeba9f631722..fdee23ea4e173 100644 +--- a/arch/x86/include/asm/fpu/internal.h ++++ b/arch/x86/include/asm/fpu/internal.h +@@ -578,10 +578,17 @@ static inline void switch_fpu_finish(struct fpu *new_fpu) + * PKRU state is switched eagerly because it needs to be valid before we + * return to userland e.g. for a copy_to_user() operation. + */ +- if (current->mm) { ++ if (!(current->flags & PF_KTHREAD)) { ++ /* ++ * If the PKRU bit in xsave.header.xfeatures is not set, ++ * then the PKRU component was in init state, which means ++ * XRSTOR will set PKRU to 0. If the bit is not set then ++ * get_xsave_addr() will return NULL because the PKRU value ++ * in memory is not valid. This means pkru_val has to be ++ * set to 0 and not to init_pkru_value. ++ */ + pk = get_xsave_addr(&new_fpu->state.xsave, XFEATURE_PKRU); +- if (pk) +- pkru_val = pk->pkru; ++ pkru_val = pk ? pk->pkru : 0; + } + __write_pkru(pkru_val); + } +diff --git a/arch/x86/kernel/fpu/signal.c b/arch/x86/kernel/fpu/signal.c +index a4ec65317a7fa..ec3ae30547920 100644 +--- a/arch/x86/kernel/fpu/signal.c ++++ b/arch/x86/kernel/fpu/signal.c +@@ -307,13 +307,17 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + return 0; + } + +- if (!access_ok(buf, size)) +- return -EACCES; ++ if (!access_ok(buf, size)) { ++ ret = -EACCES; ++ goto out; ++ } + +- if (!static_cpu_has(X86_FEATURE_FPU)) +- return fpregs_soft_set(current, NULL, +- 0, sizeof(struct user_i387_ia32_struct), +- NULL, buf) != 0; ++ if (!static_cpu_has(X86_FEATURE_FPU)) { ++ ret = fpregs_soft_set(current, NULL, 0, ++ sizeof(struct user_i387_ia32_struct), ++ NULL, buf); ++ goto out; ++ } + + if (use_xsave()) { + struct _fpx_sw_bytes fx_sw_user; +@@ -369,6 +373,25 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + fpregs_unlock(); + return 0; + } ++ ++ /* ++ * The above did an FPU restore operation, restricted to ++ * the user portion of the registers, and failed, but the ++ * microcode might have modified the FPU registers ++ * nevertheless. ++ * ++ * If the FPU registers do not belong to current, then ++ * invalidate the FPU register state otherwise the task might ++ * preempt current and return to user space with corrupted ++ * FPU registers. ++ * ++ * In case current owns the FPU registers then no further ++ * action is required. The fixup below will handle it ++ * correctly. ++ */ ++ if (test_thread_flag(TIF_NEED_FPU_LOAD)) ++ __cpu_invalidate_fpregs_state(); ++ + fpregs_unlock(); + } else { + /* +@@ -377,7 +400,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + */ + ret = __copy_from_user(&env, buf, sizeof(env)); + if (ret) +- goto err_out; ++ goto out; + envp = &env; + } + +@@ -405,16 +428,9 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + if (use_xsave() && !fx_only) { + u64 init_bv = xfeatures_mask_user() & ~user_xfeatures; + +- if (using_compacted_format()) { +- ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx); +- } else { +- ret = __copy_from_user(&fpu->state.xsave, buf_fx, state_size); +- +- if (!ret && state_size > offsetof(struct xregs_state, header)) +- ret = validate_user_xstate_header(&fpu->state.xsave.header); +- } ++ ret = copy_user_to_xstate(&fpu->state.xsave, buf_fx); + if (ret) +- goto err_out; ++ goto out; + + sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures, + fx_only); +@@ -434,7 +450,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + ret = __copy_from_user(&fpu->state.fxsave, buf_fx, state_size); + if (ret) { + ret = -EFAULT; +- goto err_out; ++ goto out; + } + + sanitize_restored_user_xstate(&fpu->state, envp, user_xfeatures, +@@ -452,7 +468,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + } else { + ret = __copy_from_user(&fpu->state.fsave, buf_fx, state_size); + if (ret) +- goto err_out; ++ goto out; + + fpregs_lock(); + ret = copy_kernel_to_fregs_err(&fpu->state.fsave); +@@ -463,7 +479,7 @@ static int __fpu__restore_sig(void __user *buf, void __user *buf_fx, int size) + fpregs_deactivate(fpu); + fpregs_unlock(); + +-err_out: ++out: + if (ret) + fpu__clear_user_states(fpu); + return ret; +diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c +index fa023f3feb25d..43013ac0fd4d9 100644 +--- a/arch/x86/kvm/lapic.c ++++ b/arch/x86/kvm/lapic.c +@@ -1410,6 +1410,9 @@ int kvm_lapic_reg_read(struct kvm_lapic *apic, u32 offset, int len, + if (!apic_x2apic_mode(apic)) + valid_reg_mask |= APIC_REG_MASK(APIC_ARBPRI); + ++ if (alignment + len > 4) ++ return 1; ++ + if (offset > 0x3f0 || !(valid_reg_mask & APIC_REG_MASK(offset))) + return 1; + +diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c +index cd0faa1876743..676ec0d1e6be4 100644 +--- a/arch/x86/kvm/mmu/mmu.c ++++ b/arch/x86/kvm/mmu/mmu.c +@@ -4726,9 +4726,33 @@ static void init_kvm_softmmu(struct kvm_vcpu *vcpu) + context->inject_page_fault = kvm_inject_page_fault; + } + ++static union kvm_mmu_role kvm_calc_nested_mmu_role(struct kvm_vcpu *vcpu) ++{ ++ union kvm_mmu_role role = kvm_calc_shadow_root_page_role_common(vcpu, false); ++ ++ /* ++ * Nested MMUs are used only for walking L2's gva->gpa, they never have ++ * shadow pages of their own and so "direct" has no meaning. Set it ++ * to "true" to try to detect bogus usage of the nested MMU. ++ */ ++ role.base.direct = true; ++ ++ if (!is_paging(vcpu)) ++ role.base.level = 0; ++ else if (is_long_mode(vcpu)) ++ role.base.level = is_la57_mode(vcpu) ? PT64_ROOT_5LEVEL : ++ PT64_ROOT_4LEVEL; ++ else if (is_pae(vcpu)) ++ role.base.level = PT32E_ROOT_LEVEL; ++ else ++ role.base.level = PT32_ROOT_LEVEL; ++ ++ return role; ++} ++ + static void init_kvm_nested_mmu(struct kvm_vcpu *vcpu) + { +- union kvm_mmu_role new_role = kvm_calc_mmu_role_common(vcpu, false); ++ union kvm_mmu_role new_role = kvm_calc_nested_mmu_role(vcpu); + struct kvm_mmu *g_context = &vcpu->arch.nested_mmu; + + if (new_role.as_u64 == g_context->mmu_role.as_u64) +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index cf37205784297..a6ca7e657af27 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -6991,7 +6991,10 @@ static unsigned emulator_get_hflags(struct x86_emulate_ctxt *ctxt) + + static void emulator_set_hflags(struct x86_emulate_ctxt *ctxt, unsigned emul_flags) + { +- emul_to_vcpu(ctxt)->arch.hflags = emul_flags; ++ struct kvm_vcpu *vcpu = emul_to_vcpu(ctxt); ++ ++ vcpu->arch.hflags = emul_flags; ++ kvm_mmu_reset_context(vcpu); + } + + static int emulator_pre_leave_smm(struct x86_emulate_ctxt *ctxt, +@@ -8147,6 +8150,7 @@ void kvm_arch_exit(void) + kvm_x86_ops.hardware_enable = NULL; + kvm_mmu_module_exit(); + free_percpu(user_return_msrs); ++ kmem_cache_destroy(x86_emulator_cache); + kmem_cache_destroy(x86_fpu_cache); + #ifdef CONFIG_KVM_XEN + static_key_deferred_flush(&kvm_xen_enabled); +diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c +index 9e5ccc56f8e07..356b746dfbe7a 100644 +--- a/arch/x86/mm/ioremap.c ++++ b/arch/x86/mm/ioremap.c +@@ -118,7 +118,9 @@ static void __ioremap_check_other(resource_size_t addr, struct ioremap_desc *des + if (!IS_ENABLED(CONFIG_EFI)) + return; + +- if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA) ++ if (efi_mem_type(addr) == EFI_RUNTIME_SERVICES_DATA || ++ (efi_mem_type(addr) == EFI_BOOT_SERVICES_DATA && ++ efi_mem_attributes(addr) & EFI_MEMORY_RUNTIME)) + desc->flags |= IORES_MAP_ENCRYPTED; + } + +diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c +index 5eb4dc2b97dac..e94da744386f3 100644 +--- a/arch/x86/mm/numa.c ++++ b/arch/x86/mm/numa.c +@@ -254,7 +254,13 @@ int __init numa_cleanup_meminfo(struct numa_meminfo *mi) + + /* make sure all non-reserved blocks are inside the limits */ + bi->start = max(bi->start, low); +- bi->end = min(bi->end, high); ++ ++ /* preserve info for non-RAM areas above 'max_pfn': */ ++ if (bi->end > high) { ++ numa_add_memblk_to(bi->nid, high, bi->end, ++ &numa_reserved_meminfo); ++ bi->end = high; ++ } + + /* and there's no empty block */ + if (bi->start >= bi->end) +diff --git a/drivers/dma/Kconfig b/drivers/dma/Kconfig +index 0c2827fd8c195..03b1b03349477 100644 +--- a/drivers/dma/Kconfig ++++ b/drivers/dma/Kconfig +@@ -59,6 +59,7 @@ config DMA_OF + #devices + config ALTERA_MSGDMA + tristate "Altera / Intel mSGDMA Engine" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for Altera / Intel mSGDMA controller. +diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c +index 4ec909e0b8106..4ae057922ef1f 100644 +--- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c ++++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c +@@ -332,6 +332,7 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev) + } + + if (priv->dpdmai_attr.version.major > DPDMAI_VER_MAJOR) { ++ err = -EINVAL; + dev_err(dev, "DPDMAI major version mismatch\n" + "Found %u.%u, supported version is %u.%u\n", + priv->dpdmai_attr.version.major, +@@ -341,6 +342,7 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev) + } + + if (priv->dpdmai_attr.version.minor > DPDMAI_VER_MINOR) { ++ err = -EINVAL; + dev_err(dev, "DPDMAI minor version mismatch\n" + "Found %u.%u, supported version is %u.%u\n", + priv->dpdmai_attr.version.major, +@@ -475,6 +477,7 @@ static int __cold dpaa2_qdma_dpio_setup(struct dpaa2_qdma_priv *priv) + ppriv->store = + dpaa2_io_store_create(DPAA2_QDMA_STORE_SIZE, dev); + if (!ppriv->store) { ++ err = -ENOMEM; + dev_err(dev, "dpaa2_io_store_create() failed\n"); + goto err_store; + } +diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c +index 59f2104ffc771..eb41bb9df0fd9 100644 +--- a/drivers/dma/idxd/init.c ++++ b/drivers/dma/idxd/init.c +@@ -218,6 +218,7 @@ static int idxd_setup_engines(struct idxd_device *idxd) + engine->idxd = idxd; + device_initialize(&engine->conf_dev); + engine->conf_dev.parent = &idxd->conf_dev; ++ engine->conf_dev.bus = &dsa_bus_type; + engine->conf_dev.type = &idxd_engine_device_type; + rc = dev_set_name(&engine->conf_dev, "engine%d.%d", idxd->id, engine->id); + if (rc < 0) { +@@ -718,6 +719,7 @@ module_init(idxd_init_module); + + static void __exit idxd_exit_module(void) + { ++ idxd_unregister_driver(); + pci_unregister_driver(&idxd_pci_driver); + idxd_cdev_remove(); + idxd_unregister_bus_type(); +diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c +index fd8d2bc3be9f5..110de8a600588 100644 +--- a/drivers/dma/pl330.c ++++ b/drivers/dma/pl330.c +@@ -2694,13 +2694,15 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + for (i = 0; i < len / period_len; i++) { + desc = pl330_get_desc(pch); + if (!desc) { ++ unsigned long iflags; ++ + dev_err(pch->dmac->ddma.dev, "%s:%d Unable to fetch desc\n", + __func__, __LINE__); + + if (!first) + return NULL; + +- spin_lock_irqsave(&pl330->pool_lock, flags); ++ spin_lock_irqsave(&pl330->pool_lock, iflags); + + while (!list_empty(&first->node)) { + desc = list_entry(first->node.next, +@@ -2710,7 +2712,7 @@ static struct dma_async_tx_descriptor *pl330_prep_dma_cyclic( + + list_move_tail(&first->node, &pl330->desc_pool); + +- spin_unlock_irqrestore(&pl330->pool_lock, flags); ++ spin_unlock_irqrestore(&pl330->pool_lock, iflags); + + return NULL; + } +diff --git a/drivers/dma/qcom/Kconfig b/drivers/dma/qcom/Kconfig +index 365f94eb3b081..3f926a653bd88 100644 +--- a/drivers/dma/qcom/Kconfig ++++ b/drivers/dma/qcom/Kconfig +@@ -33,6 +33,7 @@ config QCOM_GPI_DMA + + config QCOM_HIDMA_MGMT + tristate "Qualcomm Technologies HIDMA Management support" ++ depends on HAS_IOMEM + select DMA_ENGINE + help + Enable support for the Qualcomm Technologies HIDMA Management. +diff --git a/drivers/dma/sf-pdma/Kconfig b/drivers/dma/sf-pdma/Kconfig +index f8ffa02e279ff..ba46a0a15a936 100644 +--- a/drivers/dma/sf-pdma/Kconfig ++++ b/drivers/dma/sf-pdma/Kconfig +@@ -1,5 +1,6 @@ + config SF_PDMA + tristate "Sifive PDMA controller driver" ++ depends on HAS_IOMEM + select DMA_ENGINE + select DMA_VIRTUAL_CHANNELS + help +diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c +index 265d7c07b348e..e1827393143f1 100644 +--- a/drivers/dma/ste_dma40.c ++++ b/drivers/dma/ste_dma40.c +@@ -3675,6 +3675,9 @@ static int __init d40_probe(struct platform_device *pdev) + + kfree(base->lcla_pool.base_unaligned); + ++ if (base->lcpa_base) ++ iounmap(base->lcpa_base); ++ + if (base->phy_lcpa) + release_mem_region(base->phy_lcpa, + base->lcpa_size); +diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c +index 70b29bd079c9f..ff7dfb3fdeb47 100644 +--- a/drivers/dma/xilinx/xilinx_dpdma.c ++++ b/drivers/dma/xilinx/xilinx_dpdma.c +@@ -1459,7 +1459,7 @@ static void xilinx_dpdma_enable_irq(struct xilinx_dpdma_device *xdev) + */ + static void xilinx_dpdma_disable_irq(struct xilinx_dpdma_device *xdev) + { +- dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ERR_ALL); ++ dpdma_write(xdev->reg, XILINX_DPDMA_IDS, XILINX_DPDMA_INTR_ALL); + dpdma_write(xdev->reg, XILINX_DPDMA_EIDS, XILINX_DPDMA_EINTR_ALL); + } + +@@ -1596,6 +1596,26 @@ static struct dma_chan *of_dma_xilinx_xlate(struct of_phandle_args *dma_spec, + return dma_get_slave_channel(&xdev->chan[chan_id]->vchan.chan); + } + ++static void dpdma_hw_init(struct xilinx_dpdma_device *xdev) ++{ ++ unsigned int i; ++ void __iomem *reg; ++ ++ /* Disable all interrupts */ ++ xilinx_dpdma_disable_irq(xdev); ++ ++ /* Stop all channels */ ++ for (i = 0; i < ARRAY_SIZE(xdev->chan); i++) { ++ reg = xdev->reg + XILINX_DPDMA_CH_BASE ++ + XILINX_DPDMA_CH_OFFSET * i; ++ dpdma_clr(reg, XILINX_DPDMA_CH_CNTL, XILINX_DPDMA_CH_CNTL_ENABLE); ++ } ++ ++ /* Clear the interrupt status registers */ ++ dpdma_write(xdev->reg, XILINX_DPDMA_ISR, XILINX_DPDMA_INTR_ALL); ++ dpdma_write(xdev->reg, XILINX_DPDMA_EISR, XILINX_DPDMA_EINTR_ALL); ++} ++ + static int xilinx_dpdma_probe(struct platform_device *pdev) + { + struct xilinx_dpdma_device *xdev; +@@ -1622,6 +1642,8 @@ static int xilinx_dpdma_probe(struct platform_device *pdev) + if (IS_ERR(xdev->reg)) + return PTR_ERR(xdev->reg); + ++ dpdma_hw_init(xdev); ++ + xdev->irq = platform_get_irq(pdev, 0); + if (xdev->irq < 0) { + dev_err(xdev->dev, "failed to get platform irq\n"); +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +index 2342c5d216f9b..72d23651501d4 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c +@@ -6769,8 +6769,12 @@ static int gfx_v10_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +index d2c020a91c0be..1fdfb7783404e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c ++++ b/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +@@ -3623,8 +3623,12 @@ static int gfx_v9_0_kiq_init_register(struct amdgpu_ring *ring) + if (ring->use_doorbell) { + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_LOWER, + (adev->doorbell_index.kiq * 2) << 2); ++ /* If GC has entered CGPG, ringing doorbell > first page doesn't ++ * wakeup GC. Enlarge CP_MEC_DOORBELL_RANGE_UPPER to workaround ++ * this issue. ++ */ + WREG32_SOC15(GC, 0, mmCP_MEC_DOORBELL_RANGE_UPPER, +- (adev->doorbell_index.userqueue_end * 2) << 2); ++ (adev->doorbell.size - 4)); + } + + WREG32_SOC15_RLC(GC, 0, mmCP_HQD_PQ_DOORBELL_CONTROL, +diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c +index dfa9fdbe98da2..06bb24d7a9fee 100644 +--- a/drivers/gpu/drm/radeon/radeon_uvd.c ++++ b/drivers/gpu/drm/radeon/radeon_uvd.c +@@ -286,7 +286,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + if (rdev->uvd.vcpu_bo == NULL) + return -EINVAL; + +- memcpy(rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); ++ memcpy_toio((void __iomem *)rdev->uvd.cpu_addr, rdev->uvd_fw->data, rdev->uvd_fw->size); + + size = radeon_bo_size(rdev->uvd.vcpu_bo); + size -= rdev->uvd_fw->size; +@@ -294,7 +294,7 @@ int radeon_uvd_resume(struct radeon_device *rdev) + ptr = rdev->uvd.cpu_addr; + ptr += rdev->uvd_fw->size; + +- memset(ptr, 0, size); ++ memset_io((void __iomem *)ptr, 0, size); + + return 0; + } +diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +index bbdfd5e26ec88..f75fb157f2ff7 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c ++++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c +@@ -209,7 +209,7 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, + goto err_disable_clk_tmds; + } + +- ret = sun8i_hdmi_phy_probe(hdmi, phy_node); ++ ret = sun8i_hdmi_phy_get(hdmi, phy_node); + of_node_put(phy_node); + if (ret) { + dev_err(dev, "Couldn't get the HDMI PHY\n"); +@@ -242,7 +242,6 @@ static int sun8i_dw_hdmi_bind(struct device *dev, struct device *master, + + cleanup_encoder: + drm_encoder_cleanup(encoder); +- sun8i_hdmi_phy_remove(hdmi); + err_disable_clk_tmds: + clk_disable_unprepare(hdmi->clk_tmds); + err_assert_ctrl_reset: +@@ -263,7 +262,6 @@ static void sun8i_dw_hdmi_unbind(struct device *dev, struct device *master, + struct sun8i_dw_hdmi *hdmi = dev_get_drvdata(dev); + + dw_hdmi_unbind(hdmi->hdmi); +- sun8i_hdmi_phy_remove(hdmi); + clk_disable_unprepare(hdmi->clk_tmds); + reset_control_assert(hdmi->rst_ctrl); + gpiod_set_value(hdmi->ddc_en, 0); +@@ -320,7 +318,32 @@ static struct platform_driver sun8i_dw_hdmi_pltfm_driver = { + .of_match_table = sun8i_dw_hdmi_dt_ids, + }, + }; +-module_platform_driver(sun8i_dw_hdmi_pltfm_driver); ++ ++static int __init sun8i_dw_hdmi_init(void) ++{ ++ int ret; ++ ++ ret = platform_driver_register(&sun8i_dw_hdmi_pltfm_driver); ++ if (ret) ++ return ret; ++ ++ ret = platform_driver_register(&sun8i_hdmi_phy_driver); ++ if (ret) { ++ platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); ++ return ret; ++ } ++ ++ return ret; ++} ++ ++static void __exit sun8i_dw_hdmi_exit(void) ++{ ++ platform_driver_unregister(&sun8i_dw_hdmi_pltfm_driver); ++ platform_driver_unregister(&sun8i_hdmi_phy_driver); ++} ++ ++module_init(sun8i_dw_hdmi_init); ++module_exit(sun8i_dw_hdmi_exit); + + MODULE_AUTHOR("Jernej Skrabec "); + MODULE_DESCRIPTION("Allwinner DW HDMI bridge"); +diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +index d4b55af0592f8..74f6ed0e25709 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h ++++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.h +@@ -195,14 +195,15 @@ struct sun8i_dw_hdmi { + struct gpio_desc *ddc_en; + }; + ++extern struct platform_driver sun8i_hdmi_phy_driver; ++ + static inline struct sun8i_dw_hdmi * + encoder_to_sun8i_dw_hdmi(struct drm_encoder *encoder) + { + return container_of(encoder, struct sun8i_dw_hdmi, encoder); + } + +-int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node); +-void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi); ++int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node); + + void sun8i_hdmi_phy_init(struct sun8i_hdmi_phy *phy); + void sun8i_hdmi_phy_set_ops(struct sun8i_hdmi_phy *phy, +diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +index 9994edf675096..c9239708d398c 100644 +--- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c ++++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c +@@ -5,6 +5,7 @@ + + #include + #include ++#include + + #include "sun8i_dw_hdmi.h" + +@@ -597,10 +598,30 @@ static const struct of_device_id sun8i_hdmi_phy_of_table[] = { + { /* sentinel */ } + }; + +-int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) ++int sun8i_hdmi_phy_get(struct sun8i_dw_hdmi *hdmi, struct device_node *node) ++{ ++ struct platform_device *pdev = of_find_device_by_node(node); ++ struct sun8i_hdmi_phy *phy; ++ ++ if (!pdev) ++ return -EPROBE_DEFER; ++ ++ phy = platform_get_drvdata(pdev); ++ if (!phy) ++ return -EPROBE_DEFER; ++ ++ hdmi->phy = phy; ++ ++ put_device(&pdev->dev); ++ ++ return 0; ++} ++ ++static int sun8i_hdmi_phy_probe(struct platform_device *pdev) + { + const struct of_device_id *match; +- struct device *dev = hdmi->dev; ++ struct device *dev = &pdev->dev; ++ struct device_node *node = dev->of_node; + struct sun8i_hdmi_phy *phy; + struct resource res; + void __iomem *regs; +@@ -704,7 +725,7 @@ int sun8i_hdmi_phy_probe(struct sun8i_dw_hdmi *hdmi, struct device_node *node) + clk_prepare_enable(phy->clk_phy); + } + +- hdmi->phy = phy; ++ platform_set_drvdata(pdev, phy); + + return 0; + +@@ -728,9 +749,9 @@ err_put_clk_bus: + return ret; + } + +-void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) ++static int sun8i_hdmi_phy_remove(struct platform_device *pdev) + { +- struct sun8i_hdmi_phy *phy = hdmi->phy; ++ struct sun8i_hdmi_phy *phy = platform_get_drvdata(pdev); + + clk_disable_unprepare(phy->clk_mod); + clk_disable_unprepare(phy->clk_bus); +@@ -744,4 +765,14 @@ void sun8i_hdmi_phy_remove(struct sun8i_dw_hdmi *hdmi) + clk_put(phy->clk_pll1); + clk_put(phy->clk_mod); + clk_put(phy->clk_bus); ++ return 0; + } ++ ++struct platform_driver sun8i_hdmi_phy_driver = { ++ .probe = sun8i_hdmi_phy_probe, ++ .remove = sun8i_hdmi_phy_remove, ++ .driver = { ++ .name = "sun8i-hdmi-phy", ++ .of_match_table = sun8i_hdmi_phy_of_table, ++ }, ++}; +diff --git a/drivers/hwmon/scpi-hwmon.c b/drivers/hwmon/scpi-hwmon.c +index 25aac40f2764a..919877970ae3b 100644 +--- a/drivers/hwmon/scpi-hwmon.c ++++ b/drivers/hwmon/scpi-hwmon.c +@@ -99,6 +99,15 @@ scpi_show_sensor(struct device *dev, struct device_attribute *attr, char *buf) + + scpi_scale_reading(&value, sensor); + ++ /* ++ * Temperature sensor values are treated as signed values based on ++ * observation even though that is not explicitly specified, and ++ * because an unsigned u64 temperature does not really make practical ++ * sense especially when the temperature is below zero degrees Celsius. ++ */ ++ if (sensor->info.class == TEMPERATURE) ++ return sprintf(buf, "%lld\n", (s64)value); ++ + return sprintf(buf, "%llu\n", value); + } + +diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c +index 00404024d7cd5..fea237838bb0a 100644 +--- a/drivers/irqchip/irq-gic-v3.c ++++ b/drivers/irqchip/irq-gic-v3.c +@@ -642,11 +642,45 @@ static inline void gic_handle_nmi(u32 irqnr, struct pt_regs *regs) + nmi_exit(); + } + ++static u32 do_read_iar(struct pt_regs *regs) ++{ ++ u32 iar; ++ ++ if (gic_supports_nmi() && unlikely(!interrupts_enabled(regs))) { ++ u64 pmr; ++ ++ /* ++ * We were in a context with IRQs disabled. However, the ++ * entry code has set PMR to a value that allows any ++ * interrupt to be acknowledged, and not just NMIs. This can ++ * lead to surprising effects if the NMI has been retired in ++ * the meantime, and that there is an IRQ pending. The IRQ ++ * would then be taken in NMI context, something that nobody ++ * wants to debug twice. ++ * ++ * Until we sort this, drop PMR again to a level that will ++ * actually only allow NMIs before reading IAR, and then ++ * restore it to what it was. ++ */ ++ pmr = gic_read_pmr(); ++ gic_pmr_mask_irqs(); ++ isb(); ++ ++ iar = gic_read_iar(); ++ ++ gic_write_pmr(pmr); ++ } else { ++ iar = gic_read_iar(); ++ } ++ ++ return iar; ++} ++ + static asmlinkage void __exception_irq_entry gic_handle_irq(struct pt_regs *regs) + { + u32 irqnr; + +- irqnr = gic_read_iar(); ++ irqnr = do_read_iar(regs); + + /* Check for special IDs first */ + if ((irqnr >= 1020 && irqnr <= 1023)) +diff --git a/drivers/net/can/usb/mcba_usb.c b/drivers/net/can/usb/mcba_usb.c +index 1f649d1780107..4484f9c079b75 100644 +--- a/drivers/net/can/usb/mcba_usb.c ++++ b/drivers/net/can/usb/mcba_usb.c +@@ -82,6 +82,8 @@ struct mcba_priv { + bool can_ka_first_pass; + bool can_speed_check; + atomic_t free_ctx_cnt; ++ void *rxbuf[MCBA_MAX_RX_URBS]; ++ dma_addr_t rxbuf_dma[MCBA_MAX_RX_URBS]; + }; + + /* CAN frame */ +@@ -633,6 +635,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + for (i = 0; i < MCBA_MAX_RX_URBS; i++) { + struct urb *urb = NULL; + u8 *buf; ++ dma_addr_t buf_dma; + + /* create a URB, and a buffer for it */ + urb = usb_alloc_urb(0, GFP_KERNEL); +@@ -642,7 +645,7 @@ static int mcba_usb_start(struct mcba_priv *priv) + } + + buf = usb_alloc_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- GFP_KERNEL, &urb->transfer_dma); ++ GFP_KERNEL, &buf_dma); + if (!buf) { + netdev_err(netdev, "No memory left for USB buffer\n"); + usb_free_urb(urb); +@@ -661,11 +664,14 @@ static int mcba_usb_start(struct mcba_priv *priv) + if (err) { + usb_unanchor_urb(urb); + usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, +- buf, urb->transfer_dma); ++ buf, buf_dma); + usb_free_urb(urb); + break; + } + ++ priv->rxbuf[i] = buf; ++ priv->rxbuf_dma[i] = buf_dma; ++ + /* Drop reference, USB core will take care of freeing it */ + usb_free_urb(urb); + } +@@ -708,7 +714,14 @@ static int mcba_usb_open(struct net_device *netdev) + + static void mcba_urb_unlink(struct mcba_priv *priv) + { ++ int i; ++ + usb_kill_anchored_urbs(&priv->rx_submitted); ++ ++ for (i = 0; i < MCBA_MAX_RX_URBS; ++i) ++ usb_free_coherent(priv->udev, MCBA_USB_RX_BUFF_SIZE, ++ priv->rxbuf[i], priv->rxbuf_dma[i]); ++ + usb_kill_anchored_urbs(&priv->tx_submitted); + } + +diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c +index 102f2c91fdb85..20f8012bbe04a 100644 +--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c ++++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c +@@ -236,36 +236,48 @@ static int ena_xdp_io_poll(struct napi_struct *napi, int budget) + static int ena_xdp_tx_map_frame(struct ena_ring *xdp_ring, + struct ena_tx_buffer *tx_info, + struct xdp_frame *xdpf, +- void **push_hdr, +- u32 *push_len) ++ struct ena_com_tx_ctx *ena_tx_ctx) + { + struct ena_adapter *adapter = xdp_ring->adapter; + struct ena_com_buf *ena_buf; +- dma_addr_t dma = 0; ++ int push_len = 0; ++ dma_addr_t dma; ++ void *data; + u32 size; + + tx_info->xdpf = xdpf; ++ data = tx_info->xdpf->data; + size = tx_info->xdpf->len; +- ena_buf = tx_info->bufs; + +- /* llq push buffer */ +- *push_len = min_t(u32, size, xdp_ring->tx_max_header_size); +- *push_hdr = tx_info->xdpf->data; ++ if (xdp_ring->tx_mem_queue_type == ENA_ADMIN_PLACEMENT_POLICY_DEV) { ++ /* Designate part of the packet for LLQ */ ++ push_len = min_t(u32, size, xdp_ring->tx_max_header_size); ++ ++ ena_tx_ctx->push_header = data; ++ ++ size -= push_len; ++ data += push_len; ++ } ++ ++ ena_tx_ctx->header_len = push_len; + +- if (size - *push_len > 0) { ++ if (size > 0) { + dma = dma_map_single(xdp_ring->dev, +- *push_hdr + *push_len, +- size - *push_len, ++ data, ++ size, + DMA_TO_DEVICE); + if (unlikely(dma_mapping_error(xdp_ring->dev, dma))) + goto error_report_dma_error; + +- tx_info->map_linear_data = 1; +- tx_info->num_of_bufs = 1; +- } ++ tx_info->map_linear_data = 0; + +- ena_buf->paddr = dma; +- ena_buf->len = size; ++ ena_buf = tx_info->bufs; ++ ena_buf->paddr = dma; ++ ena_buf->len = size; ++ ++ ena_tx_ctx->ena_bufs = ena_buf; ++ ena_tx_ctx->num_bufs = tx_info->num_of_bufs = 1; ++ } + + return 0; + +@@ -274,10 +286,6 @@ error_report_dma_error: + &xdp_ring->syncp); + netif_warn(adapter, tx_queued, adapter->netdev, "Failed to map xdp buff\n"); + +- xdp_return_frame_rx_napi(tx_info->xdpf); +- tx_info->xdpf = NULL; +- tx_info->num_of_bufs = 0; +- + return -EINVAL; + } + +@@ -289,8 +297,6 @@ static int ena_xdp_xmit_frame(struct ena_ring *xdp_ring, + struct ena_com_tx_ctx ena_tx_ctx = {}; + struct ena_tx_buffer *tx_info; + u16 next_to_use, req_id; +- void *push_hdr; +- u32 push_len; + int rc; + + next_to_use = xdp_ring->next_to_use; +@@ -298,15 +304,11 @@ static int ena_xdp_xmit_frame(struct ena_ring *xdp_ring, + tx_info = &xdp_ring->tx_buffer_info[req_id]; + tx_info->num_of_bufs = 0; + +- rc = ena_xdp_tx_map_frame(xdp_ring, tx_info, xdpf, &push_hdr, &push_len); ++ rc = ena_xdp_tx_map_frame(xdp_ring, tx_info, xdpf, &ena_tx_ctx); + if (unlikely(rc)) + goto error_drop_packet; + +- ena_tx_ctx.ena_bufs = tx_info->bufs; +- ena_tx_ctx.push_header = push_hdr; +- ena_tx_ctx.num_bufs = tx_info->num_of_bufs; + ena_tx_ctx.req_id = req_id; +- ena_tx_ctx.header_len = push_len; + + rc = ena_xmit_common(dev, + xdp_ring, +diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c +index 9e02f88645931..5e90df42b2013 100644 +--- a/drivers/net/ethernet/atheros/alx/main.c ++++ b/drivers/net/ethernet/atheros/alx/main.c +@@ -1849,6 +1849,7 @@ out_free_netdev: + free_netdev(netdev); + out_pci_release: + pci_release_mem_regions(pdev); ++ pci_disable_pcie_error_reporting(pdev); + out_pci_disable: + pci_disable_device(pdev); + return err; +diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +index 027997c711aba..c118de27bc5c3 100644 +--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c ++++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c +@@ -7295,7 +7295,7 @@ skip_rdma: + entries_sp = ctx->vnic_max_vnic_entries + ctx->qp_max_l2_entries + + 2 * (extra_qps + ctx->qp_min_qp1_entries) + min; + entries_sp = roundup(entries_sp, ctx->tqm_entries_multiple); +- entries = ctx->qp_max_l2_entries + extra_qps + ctx->qp_min_qp1_entries; ++ entries = ctx->qp_max_l2_entries + 2 * (extra_qps + ctx->qp_min_qp1_entries); + entries = roundup(entries, ctx->tqm_entries_multiple); + entries = clamp_t(u32, entries, min, ctx->tqm_max_entries_per_ring); + for (i = 0; i < ctx->tqm_fp_rings_count + 1; i++) { +@@ -11573,6 +11573,8 @@ static void bnxt_fw_init_one_p3(struct bnxt *bp) + bnxt_hwrm_coal_params_qcaps(bp); + } + ++static int bnxt_probe_phy(struct bnxt *bp, bool fw_dflt); ++ + static int bnxt_fw_init_one(struct bnxt *bp) + { + int rc; +@@ -11587,6 +11589,9 @@ static int bnxt_fw_init_one(struct bnxt *bp) + netdev_err(bp->dev, "Firmware init phase 2 failed\n"); + return rc; + } ++ rc = bnxt_probe_phy(bp, false); ++ if (rc) ++ return rc; + rc = bnxt_approve_mac(bp, bp->dev->dev_addr, false); + if (rc) + return rc; +@@ -12976,6 +12981,7 @@ init_err_pci_clean: + bnxt_hwrm_func_drv_unrgtr(bp); + bnxt_free_hwrm_short_cmd_req(bp); + bnxt_free_hwrm_resources(bp); ++ bnxt_ethtool_free(bp); + kfree(bp->fw_health); + bp->fw_health = NULL; + bnxt_cleanup_pci(bp); +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +index 61ea3ec5c3fcc..83ed10ac86606 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_ethtool.c +@@ -1337,13 +1337,27 @@ static int cxgb4_ethtool_flash_phy(struct net_device *netdev, + return ret; + } + +- spin_lock_bh(&adap->win0_lock); ++ /* We have to RESET the chip/firmware because we need the ++ * chip in uninitialized state for loading new PHY image. ++ * Otherwise, the running firmware will only store the PHY ++ * image in local RAM which will be lost after next reset. ++ */ ++ ret = t4_fw_reset(adap, adap->mbox, PIORSTMODE_F | PIORST_F); ++ if (ret < 0) { ++ dev_err(adap->pdev_dev, ++ "Set FW to RESET for flashing PHY FW failed. ret: %d\n", ++ ret); ++ return ret; ++ } ++ + ret = t4_load_phy_fw(adap, MEMWIN_NIC, NULL, data, size); +- spin_unlock_bh(&adap->win0_lock); +- if (ret) +- dev_err(adap->pdev_dev, "Failed to load PHY FW\n"); ++ if (ret < 0) { ++ dev_err(adap->pdev_dev, "Failed to load PHY FW. ret: %d\n", ++ ret); ++ return ret; ++ } + +- return ret; ++ return 0; + } + + static int cxgb4_ethtool_flash_fw(struct net_device *netdev, +@@ -1610,16 +1624,14 @@ static struct filter_entry *cxgb4_get_filter_entry(struct adapter *adap, + u32 ftid) + { + struct tid_info *t = &adap->tids; +- struct filter_entry *f; + +- if (ftid < t->nhpftids) +- f = &adap->tids.hpftid_tab[ftid]; +- else if (ftid < t->nftids) +- f = &adap->tids.ftid_tab[ftid - t->nhpftids]; +- else +- f = lookup_tid(&adap->tids, ftid); ++ if (ftid >= t->hpftid_base && ftid < t->hpftid_base + t->nhpftids) ++ return &t->hpftid_tab[ftid - t->hpftid_base]; + +- return f; ++ if (ftid >= t->ftid_base && ftid < t->ftid_base + t->nftids) ++ return &t->ftid_tab[ftid - t->ftid_base]; ++ ++ return lookup_tid(t, ftid); + } + + static void cxgb4_fill_filter_rule(struct ethtool_rx_flow_spec *fs, +@@ -1826,6 +1838,11 @@ static int cxgb4_ntuple_del_filter(struct net_device *dev, + filter_id = filter_info->loc_array[cmd->fs.location]; + f = cxgb4_get_filter_entry(adapter, filter_id); + ++ if (f->fs.prio) ++ filter_id -= adapter->tids.hpftid_base; ++ else if (!f->fs.hash) ++ filter_id -= (adapter->tids.ftid_base - adapter->tids.nhpftids); ++ + ret = cxgb4_flow_rule_destroy(dev, f->fs.tc_prio, &f->fs, filter_id); + if (ret) + goto err; +@@ -1885,6 +1902,11 @@ static int cxgb4_ntuple_set_filter(struct net_device *netdev, + + filter_info = &adapter->ethtool_filters->port[pi->port_id]; + ++ if (fs.prio) ++ tid += adapter->tids.hpftid_base; ++ else if (!fs.hash) ++ tid += (adapter->tids.ftid_base - adapter->tids.nhpftids); ++ + filter_info->loc_array[cmd->fs.location] = tid; + set_bit(cmd->fs.location, filter_info->bmap); + filter_info->in_use++; +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +index e664e05b9f026..5fbc087268dbe 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_filter.c +@@ -198,7 +198,7 @@ static void set_nat_params(struct adapter *adap, struct filter_entry *f, + WORD_MASK, f->fs.nat_lip[3] | + f->fs.nat_lip[2] << 8 | + f->fs.nat_lip[1] << 16 | +- (u64)f->fs.nat_lip[0] << 25, 1); ++ (u64)f->fs.nat_lip[0] << 24, 1); + } + } + +diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +index 1f601de02e706..762113a04dde6 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +@@ -4424,10 +4424,8 @@ static int adap_init0_phy(struct adapter *adap) + + /* Load PHY Firmware onto adapter. + */ +- spin_lock_bh(&adap->win0_lock); + ret = t4_load_phy_fw(adap, MEMWIN_NIC, phy_info->phy_fw_version, + (u8 *)phyf->data, phyf->size); +- spin_unlock_bh(&adap->win0_lock); + if (ret < 0) + dev_err(adap->pdev_dev, "PHY Firmware transfer error %d\n", + -ret); +diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +index 80882cfc370f5..601853bb34c91 100644 +--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c ++++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c +@@ -3060,16 +3060,19 @@ int t4_read_flash(struct adapter *adapter, unsigned int addr, + * @addr: the start address to write + * @n: length of data to write in bytes + * @data: the data to write ++ * @byte_oriented: whether to store data as bytes or as words + * + * Writes up to a page of data (256 bytes) to the serial flash starting + * at the given address. All the data must be written to the same page. ++ * If @byte_oriented is set the write data is stored as byte stream ++ * (i.e. matches what on disk), otherwise in big-endian. + */ + static int t4_write_flash(struct adapter *adapter, unsigned int addr, +- unsigned int n, const u8 *data) ++ unsigned int n, const u8 *data, bool byte_oriented) + { +- int ret; +- u32 buf[64]; + unsigned int i, c, left, val, offset = addr & 0xff; ++ u32 buf[64]; ++ int ret; + + if (addr >= adapter->params.sf_size || offset + n > SF_PAGE_SIZE) + return -EINVAL; +@@ -3080,10 +3083,14 @@ static int t4_write_flash(struct adapter *adapter, unsigned int addr, + (ret = sf1_write(adapter, 4, 1, 1, val)) != 0) + goto unlock; + +- for (left = n; left; left -= c) { ++ for (left = n; left; left -= c, data += c) { + c = min(left, 4U); +- for (val = 0, i = 0; i < c; ++i) +- val = (val << 8) + *data++; ++ for (val = 0, i = 0; i < c; ++i) { ++ if (byte_oriented) ++ val = (val << 8) + data[i]; ++ else ++ val = (val << 8) + data[c - i - 1]; ++ } + + ret = sf1_write(adapter, c, c != left, 1, val); + if (ret) +@@ -3096,7 +3103,8 @@ static int t4_write_flash(struct adapter *adapter, unsigned int addr, + t4_write_reg(adapter, SF_OP_A, 0); /* unlock SF */ + + /* Read the page to verify the write succeeded */ +- ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, 1); ++ ret = t4_read_flash(adapter, addr & ~0xff, ARRAY_SIZE(buf), buf, ++ byte_oriented); + if (ret) + return ret; + +@@ -3692,7 +3700,7 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) + */ + memcpy(first_page, fw_data, SF_PAGE_SIZE); + ((struct fw_hdr *)first_page)->fw_ver = cpu_to_be32(0xffffffff); +- ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page); ++ ret = t4_write_flash(adap, fw_start, SF_PAGE_SIZE, first_page, true); + if (ret) + goto out; + +@@ -3700,14 +3708,14 @@ int t4_load_fw(struct adapter *adap, const u8 *fw_data, unsigned int size) + for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { + addr += SF_PAGE_SIZE; + fw_data += SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data); ++ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, fw_data, true); + if (ret) + goto out; + } + +- ret = t4_write_flash(adap, +- fw_start + offsetof(struct fw_hdr, fw_ver), +- sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver); ++ ret = t4_write_flash(adap, fw_start + offsetof(struct fw_hdr, fw_ver), ++ sizeof(hdr->fw_ver), (const u8 *)&hdr->fw_ver, ++ true); + out: + if (ret) + dev_err(adap->pdev_dev, "firmware download failed, error %d\n", +@@ -3812,9 +3820,11 @@ int t4_load_phy_fw(struct adapter *adap, int win, + /* Copy the supplied PHY Firmware image to the adapter memory location + * allocated by the adapter firmware. + */ ++ spin_lock_bh(&adap->win0_lock); + ret = t4_memory_rw(adap, win, mtype, maddr, + phy_fw_size, (__be32 *)phy_fw_data, + T4_MEMORY_WRITE); ++ spin_unlock_bh(&adap->win0_lock); + if (ret) + return ret; + +@@ -10208,7 +10218,7 @@ int t4_load_cfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + n = size - i; + else + n = SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, n, cfg_data); ++ ret = t4_write_flash(adap, addr, n, cfg_data, true); + if (ret) + goto out; + +@@ -10677,13 +10687,14 @@ int t4_load_boot(struct adapter *adap, u8 *boot_data, + for (size -= SF_PAGE_SIZE; size; size -= SF_PAGE_SIZE) { + addr += SF_PAGE_SIZE; + boot_data += SF_PAGE_SIZE; +- ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data); ++ ret = t4_write_flash(adap, addr, SF_PAGE_SIZE, boot_data, ++ false); + if (ret) + goto out; + } + + ret = t4_write_flash(adap, boot_sector, SF_PAGE_SIZE, +- (const u8 *)header); ++ (const u8 *)header, false); + + out: + if (ret) +@@ -10758,7 +10769,7 @@ int t4_load_bootcfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + for (i = 0; i < size; i += SF_PAGE_SIZE) { + n = min_t(u32, size - i, SF_PAGE_SIZE); + +- ret = t4_write_flash(adap, addr, n, cfg_data); ++ ret = t4_write_flash(adap, addr, n, cfg_data, false); + if (ret) + goto out; + +@@ -10770,7 +10781,8 @@ int t4_load_bootcfg(struct adapter *adap, const u8 *cfg_data, unsigned int size) + for (i = 0; i < npad; i++) { + u8 data = 0; + +- ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data); ++ ret = t4_write_flash(adap, cfg_addr + size + i, 1, &data, ++ false); + if (ret) + goto out; + } +diff --git a/drivers/net/ethernet/ec_bhf.c b/drivers/net/ethernet/ec_bhf.c +index 46b0dbab8aadc..7c992172933bc 100644 +--- a/drivers/net/ethernet/ec_bhf.c ++++ b/drivers/net/ethernet/ec_bhf.c +@@ -576,10 +576,12 @@ static void ec_bhf_remove(struct pci_dev *dev) + struct ec_bhf_priv *priv = netdev_priv(net_dev); + + unregister_netdev(net_dev); +- free_netdev(net_dev); + + pci_iounmap(dev, priv->dma_io); + pci_iounmap(dev, priv->io); ++ ++ free_netdev(net_dev); ++ + pci_release_regions(dev); + pci_clear_master(dev); + pci_disable_device(dev); +diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c +index b6eba29d8e99e..7968568bbe214 100644 +--- a/drivers/net/ethernet/emulex/benet/be_main.c ++++ b/drivers/net/ethernet/emulex/benet/be_main.c +@@ -5897,6 +5897,7 @@ drv_cleanup: + unmap_bars: + be_unmap_pci_bars(adapter); + free_netdev: ++ pci_disable_pcie_error_reporting(pdev); + free_netdev(netdev); + rel_reg: + pci_release_regions(pdev); +diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c +index 1753807cbf97e..d71eac7e19249 100644 +--- a/drivers/net/ethernet/freescale/fec_ptp.c ++++ b/drivers/net/ethernet/freescale/fec_ptp.c +@@ -215,15 +215,13 @@ static u64 fec_ptp_read(const struct cyclecounter *cc) + { + struct fec_enet_private *fep = + container_of(cc, struct fec_enet_private, cc); +- const struct platform_device_id *id_entry = +- platform_get_device_id(fep->pdev); + u32 tempval; + + tempval = readl(fep->hwp + FEC_ATIME_CTRL); + tempval |= FEC_T_CTRL_CAPTURE; + writel(tempval, fep->hwp + FEC_ATIME_CTRL); + +- if (id_entry->driver_data & FEC_QUIRK_BUG_CAPTURE) ++ if (fep->quirks & FEC_QUIRK_BUG_CAPTURE) + udelay(1); + + return readl(fep->hwp + FEC_ATIME); +@@ -604,6 +602,10 @@ void fec_ptp_init(struct platform_device *pdev, int irq_idx) + fep->ptp_caps.enable = fec_ptp_enable; + + fep->cycle_speed = clk_get_rate(fep->clk_ptp); ++ if (!fep->cycle_speed) { ++ fep->cycle_speed = NSEC_PER_SEC; ++ dev_err(&fep->pdev->dev, "clk_ptp clock rate is zero\n"); ++ } + fep->ptp_inc = NSEC_PER_SEC / fep->cycle_speed; + + spin_lock_init(&fep->tmreg_lock); +diff --git a/drivers/net/ethernet/intel/ice/ice_lib.c b/drivers/net/ethernet/intel/ice/ice_lib.c +index 27e439853c3b0..55432ea360ad4 100644 +--- a/drivers/net/ethernet/intel/ice/ice_lib.c ++++ b/drivers/net/ethernet/intel/ice/ice_lib.c +@@ -1715,12 +1715,13 @@ setup_rings: + * ice_vsi_cfg_txqs - Configure the VSI for Tx + * @vsi: the VSI being configured + * @rings: Tx ring array to be configured ++ * @count: number of Tx ring array elements + * + * Return 0 on success and a negative value on error + * Configure the Tx VSI for operation. + */ + static int +-ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings) ++ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings, u16 count) + { + struct ice_aqc_add_tx_qgrp *qg_buf; + u16 q_idx = 0; +@@ -1732,7 +1733,7 @@ ice_vsi_cfg_txqs(struct ice_vsi *vsi, struct ice_ring **rings) + + qg_buf->num_txqs = 1; + +- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) { ++ for (q_idx = 0; q_idx < count; q_idx++) { + err = ice_vsi_cfg_txq(vsi, rings[q_idx], qg_buf); + if (err) + goto err_cfg_txqs; +@@ -1752,7 +1753,7 @@ err_cfg_txqs: + */ + int ice_vsi_cfg_lan_txqs(struct ice_vsi *vsi) + { +- return ice_vsi_cfg_txqs(vsi, vsi->tx_rings); ++ return ice_vsi_cfg_txqs(vsi, vsi->tx_rings, vsi->num_txq); + } + + /** +@@ -1767,7 +1768,7 @@ int ice_vsi_cfg_xdp_txqs(struct ice_vsi *vsi) + int ret; + int i; + +- ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings); ++ ret = ice_vsi_cfg_txqs(vsi, vsi->xdp_rings, vsi->num_xdp_txq); + if (ret) + return ret; + +@@ -1965,17 +1966,18 @@ int ice_vsi_stop_all_rx_rings(struct ice_vsi *vsi) + * @rst_src: reset source + * @rel_vmvf_num: Relative ID of VF/VM + * @rings: Tx ring array to be stopped ++ * @count: number of Tx ring array elements + */ + static int + ice_vsi_stop_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, +- u16 rel_vmvf_num, struct ice_ring **rings) ++ u16 rel_vmvf_num, struct ice_ring **rings, u16 count) + { + u16 q_idx; + + if (vsi->num_txq > ICE_LAN_TXQ_MAX_QDIS) + return -EINVAL; + +- for (q_idx = 0; q_idx < vsi->num_txq; q_idx++) { ++ for (q_idx = 0; q_idx < count; q_idx++) { + struct ice_txq_meta txq_meta = { }; + int status; + +@@ -2003,7 +2005,7 @@ int + ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, + u16 rel_vmvf_num) + { +- return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings); ++ return ice_vsi_stop_tx_rings(vsi, rst_src, rel_vmvf_num, vsi->tx_rings, vsi->num_txq); + } + + /** +@@ -2012,7 +2014,7 @@ ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, + */ + int ice_vsi_stop_xdp_tx_rings(struct ice_vsi *vsi) + { +- return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings); ++ return ice_vsi_stop_tx_rings(vsi, ICE_NO_RESET, 0, vsi->xdp_rings, vsi->num_xdp_txq); + } + + /** +diff --git a/drivers/net/ethernet/intel/ice/ice_main.c b/drivers/net/ethernet/intel/ice/ice_main.c +index d821c687f239c..b61cd84be97fd 100644 +--- a/drivers/net/ethernet/intel/ice/ice_main.c ++++ b/drivers/net/ethernet/intel/ice/ice_main.c +@@ -2554,6 +2554,20 @@ ice_xdp_setup_prog(struct ice_vsi *vsi, struct bpf_prog *prog, + return (ret || xdp_ring_err) ? -ENOMEM : 0; + } + ++/** ++ * ice_xdp_safe_mode - XDP handler for safe mode ++ * @dev: netdevice ++ * @xdp: XDP command ++ */ ++static int ice_xdp_safe_mode(struct net_device __always_unused *dev, ++ struct netdev_bpf *xdp) ++{ ++ NL_SET_ERR_MSG_MOD(xdp->extack, ++ "Please provide working DDP firmware package in order to use XDP\n" ++ "Refer to Documentation/networking/device_drivers/ethernet/intel/ice.rst"); ++ return -EOPNOTSUPP; ++} ++ + /** + * ice_xdp - implements XDP handler + * @dev: netdevice +@@ -6805,6 +6819,7 @@ static const struct net_device_ops ice_netdev_safe_mode_ops = { + .ndo_change_mtu = ice_change_mtu, + .ndo_get_stats64 = ice_get_stats64, + .ndo_tx_timeout = ice_tx_timeout, ++ .ndo_bpf = ice_xdp_safe_mode, + }; + + static const struct net_device_ops ice_netdev_ops = { +diff --git a/drivers/net/ethernet/lantiq_xrx200.c b/drivers/net/ethernet/lantiq_xrx200.c +index 135ba5b6ae980..072075bc60ee9 100644 +--- a/drivers/net/ethernet/lantiq_xrx200.c ++++ b/drivers/net/ethernet/lantiq_xrx200.c +@@ -154,6 +154,7 @@ static int xrx200_close(struct net_device *net_dev) + + static int xrx200_alloc_skb(struct xrx200_chan *ch) + { ++ struct sk_buff *skb = ch->skb[ch->dma.desc]; + dma_addr_t mapping; + int ret = 0; + +@@ -168,6 +169,7 @@ static int xrx200_alloc_skb(struct xrx200_chan *ch) + XRX200_DMA_DATA_LEN, DMA_FROM_DEVICE); + if (unlikely(dma_mapping_error(ch->priv->dev, mapping))) { + dev_kfree_skb_any(ch->skb[ch->dma.desc]); ++ ch->skb[ch->dma.desc] = skb; + ret = -ENOMEM; + goto skip; + } +@@ -198,7 +200,6 @@ static int xrx200_hw_receive(struct xrx200_chan *ch) + ch->dma.desc %= LTQ_DESC_NUM; + + if (ret) { +- ch->skb[ch->dma.desc] = skb; + net_dev->stats.rx_dropped++; + netdev_err(net_dev, "failed to allocate new rx buffer\n"); + return ret; +@@ -352,8 +353,8 @@ static irqreturn_t xrx200_dma_irq(int irq, void *ptr) + struct xrx200_chan *ch = ptr; + + if (napi_schedule_prep(&ch->napi)) { +- __napi_schedule(&ch->napi); + ltq_dma_disable_irq(&ch->dma); ++ __napi_schedule(&ch->napi); + } + + ltq_dma_ack_irq(&ch->dma); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c +index 9153c9bda96fa..897853a68cd03 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c +@@ -306,6 +306,7 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) + int ret = 0, i; + + mutex_lock(&mlx5_intf_mutex); ++ priv->flags &= ~MLX5_PRIV_FLAGS_DETACH; + for (i = 0; i < ARRAY_SIZE(mlx5_adev_devices); i++) { + if (!priv->adev[i]) { + bool is_supported = false; +@@ -323,6 +324,16 @@ int mlx5_attach_device(struct mlx5_core_dev *dev) + } + } else { + adev = &priv->adev[i]->adev; ++ ++ /* Pay attention that this is not PCI driver that ++ * mlx5_core_dev is connected, but auxiliary driver. ++ * ++ * Here we can race of module unload with devlink ++ * reload, but we don't need to take extra lock because ++ * we are holding global mlx5_intf_mutex. ++ */ ++ if (!adev->dev.driver) ++ continue; + adrv = to_auxiliary_drv(adev->dev.driver); + + if (adrv->resume) +@@ -353,6 +364,10 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) + continue; + + adev = &priv->adev[i]->adev; ++ /* Auxiliary driver was unbind manually through sysfs */ ++ if (!adev->dev.driver) ++ goto skip_suspend; ++ + adrv = to_auxiliary_drv(adev->dev.driver); + + if (adrv->suspend) { +@@ -360,9 +375,11 @@ void mlx5_detach_device(struct mlx5_core_dev *dev) + continue; + } + ++skip_suspend: + del_adev(&priv->adev[i]->adev); + priv->adev[i] = NULL; + } ++ priv->flags |= MLX5_PRIV_FLAGS_DETACH; + mutex_unlock(&mlx5_intf_mutex); + } + +@@ -451,6 +468,8 @@ int mlx5_rescan_drivers_locked(struct mlx5_core_dev *dev) + struct mlx5_priv *priv = &dev->priv; + + lockdep_assert_held(&mlx5_intf_mutex); ++ if (priv->flags & MLX5_PRIV_FLAGS_DETACH) ++ return 0; + + delete_drivers(dev); + if (priv->flags & MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV) +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c +index be0ee03de7217..2e9bee4e5209b 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/neigh.c +@@ -129,10 +129,9 @@ static void mlx5e_rep_neigh_update(struct work_struct *work) + work); + struct mlx5e_neigh_hash_entry *nhe = update_work->nhe; + struct neighbour *n = update_work->n; ++ struct mlx5e_encap_entry *e = NULL; + bool neigh_connected, same_dev; +- struct mlx5e_encap_entry *e; + unsigned char ha[ETH_ALEN]; +- struct mlx5e_priv *priv; + u8 nud_state, dead; + + rtnl_lock(); +@@ -156,14 +155,12 @@ static void mlx5e_rep_neigh_update(struct work_struct *work) + if (!same_dev) + goto out; + +- list_for_each_entry(e, &nhe->encap_list, encap_list) { +- if (!mlx5e_encap_take(e)) +- continue; ++ /* mlx5e_get_next_init_encap() releases previous encap before returning ++ * the next one. ++ */ ++ while ((e = mlx5e_get_next_init_encap(nhe, e)) != NULL) ++ mlx5e_rep_update_flows(netdev_priv(e->out_dev), e, neigh_connected, ha); + +- priv = netdev_priv(e->out_dev); +- mlx5e_rep_update_flows(priv, e, neigh_connected, ha); +- mlx5e_encap_put(priv, e); +- } + out: + rtnl_unlock(); + mlx5e_release_neigh_update_work(update_work); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +index 96ba027dbef3d..9992f94f794b6 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/rep/tc.c +@@ -93,13 +93,9 @@ void mlx5e_rep_update_flows(struct mlx5e_priv *priv, + + ASSERT_RTNL(); + +- /* wait for encap to be fully initialized */ +- wait_for_completion(&e->res_ready); +- + mutex_lock(&esw->offloads.encap_tbl_lock); + encap_connected = !!(e->flags & MLX5_ENCAP_ENTRY_VALID); +- if (e->compl_result < 0 || (encap_connected == neigh_connected && +- ether_addr_equal(e->h_dest, ha))) ++ if (encap_connected == neigh_connected && ether_addr_equal(e->h_dest, ha)) + goto unlock; + + mlx5e_take_all_encap_flows(e, &flow_list); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +index 1560fcbf4ac7c..a17d79effa273 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_encap.c +@@ -250,9 +250,12 @@ static void mlx5e_take_all_route_decap_flows(struct mlx5e_route_entry *r, + mlx5e_take_tmp_flow(flow, flow_list, 0); + } + ++typedef bool (match_cb)(struct mlx5e_encap_entry *); ++ + static struct mlx5e_encap_entry * +-mlx5e_get_next_valid_encap(struct mlx5e_neigh_hash_entry *nhe, +- struct mlx5e_encap_entry *e) ++mlx5e_get_next_matching_encap(struct mlx5e_neigh_hash_entry *nhe, ++ struct mlx5e_encap_entry *e, ++ match_cb match) + { + struct mlx5e_encap_entry *next = NULL; + +@@ -287,7 +290,7 @@ retry: + /* wait for encap to be fully initialized */ + wait_for_completion(&next->res_ready); + /* continue searching if encap entry is not in valid state after completion */ +- if (!(next->flags & MLX5_ENCAP_ENTRY_VALID)) { ++ if (!match(next)) { + e = next; + goto retry; + } +@@ -295,6 +298,30 @@ retry: + return next; + } + ++static bool mlx5e_encap_valid(struct mlx5e_encap_entry *e) ++{ ++ return e->flags & MLX5_ENCAP_ENTRY_VALID; ++} ++ ++static struct mlx5e_encap_entry * ++mlx5e_get_next_valid_encap(struct mlx5e_neigh_hash_entry *nhe, ++ struct mlx5e_encap_entry *e) ++{ ++ return mlx5e_get_next_matching_encap(nhe, e, mlx5e_encap_valid); ++} ++ ++static bool mlx5e_encap_initialized(struct mlx5e_encap_entry *e) ++{ ++ return e->compl_result >= 0; ++} ++ ++struct mlx5e_encap_entry * ++mlx5e_get_next_init_encap(struct mlx5e_neigh_hash_entry *nhe, ++ struct mlx5e_encap_entry *e) ++{ ++ return mlx5e_get_next_matching_encap(nhe, e, mlx5e_encap_initialized); ++} ++ + void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe) + { + struct mlx5e_neigh *m_neigh = &nhe->m_neigh; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +index 3d45341e2216f..26f7fab109d97 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_accel/ipsec.c +@@ -532,9 +532,6 @@ void mlx5e_ipsec_build_netdev(struct mlx5e_priv *priv) + struct mlx5_core_dev *mdev = priv->mdev; + struct net_device *netdev = priv->netdev; + +- if (!priv->ipsec) +- return; +- + if (!(mlx5_accel_ipsec_device_caps(mdev) & MLX5_ACCEL_IPSEC_CAP_ESP) || + !MLX5_CAP_ETH(mdev, swp)) { + mlx5_core_dbg(mdev, "mlx5e: ESP and SWP offload not supported\n"); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +index 99dc9f2beed5b..16b8f52450329 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +@@ -5168,22 +5168,15 @@ static void mlx5e_build_nic_netdev(struct net_device *netdev) + } + + if (mlx5_vxlan_allowed(mdev->vxlan) || mlx5_geneve_tx_allowed(mdev)) { +- netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->gso_partial_features = NETIF_F_GSO_UDP_TUNNEL_CSUM; +- netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL | +- NETIF_F_GSO_UDP_TUNNEL_CSUM; ++ netdev->hw_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->hw_enc_features |= NETIF_F_GSO_UDP_TUNNEL; ++ netdev->vlan_features |= NETIF_F_GSO_UDP_TUNNEL; + } + + if (mlx5e_tunnel_proto_supported_tx(mdev, IPPROTO_GRE)) { +- netdev->hw_features |= NETIF_F_GSO_GRE | +- NETIF_F_GSO_GRE_CSUM; +- netdev->hw_enc_features |= NETIF_F_GSO_GRE | +- NETIF_F_GSO_GRE_CSUM; +- netdev->gso_partial_features |= NETIF_F_GSO_GRE | +- NETIF_F_GSO_GRE_CSUM; ++ netdev->hw_features |= NETIF_F_GSO_GRE; ++ netdev->hw_enc_features |= NETIF_F_GSO_GRE; ++ netdev->gso_partial_features |= NETIF_F_GSO_GRE; + } + + if (mlx5e_tunnel_proto_supported_tx(mdev, IPPROTO_IPIP)) { +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +index b633f669ea57f..b3b8e44540a5d 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.c +@@ -4622,7 +4622,7 @@ static void mlx5e_tc_hairpin_update_dead_peer(struct mlx5e_priv *priv, + list_for_each_entry_safe(hpe, tmp, &init_wait_list, dead_peer_wait_list) { + wait_for_completion(&hpe->res_ready); + if (!IS_ERR_OR_NULL(hpe->hp) && hpe->peer_vhca_id == peer_vhca_id) +- hpe->hp->pair->peer_gone = true; ++ mlx5_core_hairpin_clear_dead_peer(hpe->hp->pair); + + mlx5e_hairpin_put(priv, hpe); + } +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +index 25c091795bcd8..17027536efbaa 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_tc.h +@@ -178,6 +178,9 @@ void mlx5e_take_all_encap_flows(struct mlx5e_encap_entry *e, struct list_head *f + void mlx5e_put_flow_list(struct mlx5e_priv *priv, struct list_head *flow_list); + + struct mlx5e_neigh_hash_entry; ++struct mlx5e_encap_entry * ++mlx5e_get_next_init_encap(struct mlx5e_neigh_hash_entry *nhe, ++ struct mlx5e_encap_entry *e); + void mlx5e_tc_update_neigh_used_value(struct mlx5e_neigh_hash_entry *nhe); + + void mlx5e_tc_reoffload_flows_work(struct work_struct *work); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eq.c b/drivers/net/ethernet/mellanox/mlx5/core/eq.c +index 1fa9c18563da9..31c6a3b91f4a9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eq.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eq.c +@@ -136,7 +136,7 @@ static int mlx5_eq_comp_int(struct notifier_block *nb, + + eqe = next_eqe_sw(eq); + if (!eqe) +- return 0; ++ goto out; + + do { + struct mlx5_core_cq *cq; +@@ -161,6 +161,8 @@ static int mlx5_eq_comp_int(struct notifier_block *nb, + ++eq->cons_index; + + } while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq))); ++ ++out: + eq_update_ci(eq, 1); + + if (cqn != -1) +@@ -248,9 +250,9 @@ static int mlx5_eq_async_int(struct notifier_block *nb, + ++eq->cons_index; + + } while ((++num_eqes < MLX5_EQ_POLLING_BUDGET) && (eqe = next_eqe_sw(eq))); +- eq_update_ci(eq, 1); + + out: ++ eq_update_ci(eq, 1); + mlx5_eq_async_int_unlock(eq_async, recovery, &flags); + + return unlikely(recovery) ? num_eqes : 0; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +index 2c6d95900e3c9..a3edeea4ddd78 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/eswitch.c +@@ -1308,6 +1308,12 @@ int mlx5_esw_vport_enable(struct mlx5_eswitch *esw, u16 vport_num, + goto err_vhca_mapping; + } + ++ /* External controller host PF has factory programmed MAC. ++ * Read it from the device. ++ */ ++ if (mlx5_core_is_ecpf(esw->dev) && vport_num == MLX5_VPORT_PF) ++ mlx5_query_nic_vport_mac_address(esw->dev, vport_num, true, vport->info.mac); ++ + esw_vport_change_handle_locked(vport); + + esw->enabled_vports++; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c +index efb93d63e54cb..58b8f75d7a01e 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c +@@ -1157,7 +1157,7 @@ static int mlx5_load(struct mlx5_core_dev *dev) + err = mlx5_core_set_hca_defaults(dev); + if (err) { + mlx5_core_err(dev, "Failed to set hca defaults\n"); +- goto err_sriov; ++ goto err_set_hca; + } + + mlx5_vhca_event_start(dev); +@@ -1190,6 +1190,7 @@ err_ec: + mlx5_sf_hw_table_destroy(dev); + err_vhca: + mlx5_vhca_event_stop(dev); ++err_set_hca: + mlx5_cleanup_fs(dev); + err_fs: + mlx5_accel_tls_cleanup(dev); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/mr.c b/drivers/net/ethernet/mellanox/mlx5/core/mr.c +index 50af84e76fb6a..174f71ed52800 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/mr.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/mr.c +@@ -54,7 +54,7 @@ int mlx5_core_create_mkey(struct mlx5_core_dev *dev, + mkey_index = MLX5_GET(create_mkey_out, lout, mkey_index); + mkey->iova = MLX5_GET64(mkc, mkc, start_addr); + mkey->size = MLX5_GET64(mkc, mkc, len); +- mkey->key |= mlx5_idx_to_mkey(mkey_index); ++ mkey->key = (u32)mlx5_mkey_variant(mkey->key) | mlx5_idx_to_mkey(mkey_index); + mkey->pd = MLX5_GET(mkc, mkc, pd); + init_waitqueue_head(&mkey->wait); + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +index 8e0dddc6383f0..2389239acadc9 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/rdma.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/rdma.c +@@ -156,6 +156,9 @@ void mlx5_rdma_enable_roce(struct mlx5_core_dev *dev) + { + int err; + ++ if (!MLX5_CAP_GEN(dev, roce)) ++ return; ++ + err = mlx5_nic_vport_enable_roce(dev); + if (err) { + mlx5_core_err(dev, "Failed to enable RoCE: %d\n", err); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c +index 90b524c59f3c3..c4139f4648bf1 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/sf/dev/dev.c +@@ -153,6 +153,7 @@ mlx5_sf_dev_state_change_handler(struct notifier_block *nb, unsigned long event_ + sf_index = event->function_id - MLX5_CAP_GEN(table->dev, sf_base_id); + sf_dev = xa_load(&table->devices, sf_index); + switch (event->new_vhca_state) { ++ case MLX5_VHCA_STATE_INVALID: + case MLX5_VHCA_STATE_ALLOCATED: + if (sf_dev) + mlx5_sf_dev_del(table->dev, sf_dev, sf_index); +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +index f146c618a78e7..46ef45fa91675 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/dr_ste_v1.c +@@ -712,7 +712,11 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data, + if (hw_action_sz / DR_STE_ACTION_DOUBLE_SZ < DR_STE_DECAP_L3_ACTION_NUM) + return -EINVAL; + +- memcpy(padded_data, data, data_sz); ++ inline_data_sz = ++ MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data); ++ ++ /* Add an alignment padding */ ++ memcpy(padded_data + data_sz % inline_data_sz, data, data_sz); + + /* Remove L2L3 outer headers */ + MLX5_SET(ste_single_action_remove_header_v1, hw_action, action_id, +@@ -724,32 +728,34 @@ static int dr_ste_v1_set_action_decap_l3_list(void *data, + hw_action += DR_STE_ACTION_DOUBLE_SZ; + used_actions++; /* Remove and NOP are a single double action */ + +- inline_data_sz = +- MLX5_FLD_SZ_BYTES(ste_double_action_insert_with_inline_v1, inline_data); ++ /* Point to the last dword of the header */ ++ data_ptr += (data_sz / inline_data_sz) * inline_data_sz; + +- /* Add the new header inline + 2 extra bytes */ ++ /* Add the new header using inline action 4Byte at a time, the header ++ * is added in reversed order to the beginning of the packet to avoid ++ * incorrect parsing by the HW. Since header is 14B or 18B an extra ++ * two bytes are padded and later removed. ++ */ + for (i = 0; i < data_sz / inline_data_sz + 1; i++) { + void *addr_inline; + + MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, action_id, + DR_STE_V1_ACTION_ID_INSERT_INLINE); + /* The hardware expects here offset to words (2 bytes) */ +- MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, +- i * 2); ++ MLX5_SET(ste_double_action_insert_with_inline_v1, hw_action, start_offset, 0); + + /* Copy bytes one by one to avoid endianness problem */ + addr_inline = MLX5_ADDR_OF(ste_double_action_insert_with_inline_v1, + hw_action, inline_data); +- memcpy(addr_inline, data_ptr, inline_data_sz); ++ memcpy(addr_inline, data_ptr - i * inline_data_sz, inline_data_sz); + hw_action += DR_STE_ACTION_DOUBLE_SZ; +- data_ptr += inline_data_sz; + used_actions++; + } + +- /* Remove 2 extra bytes */ ++ /* Remove first 2 extra bytes */ + MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, action_id, + DR_STE_V1_ACTION_ID_REMOVE_BY_SIZE); +- MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, data_sz / 2); ++ MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, start_offset, 0); + /* The hardware expects here size in words (2 bytes) */ + MLX5_SET(ste_single_action_remove_header_size_v1, hw_action, remove_size, 1); + used_actions++; +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +index 612b0ac31db23..9737565cd8d43 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h ++++ b/drivers/net/ethernet/mellanox/mlx5/core/steering/mlx5dr.h +@@ -124,10 +124,11 @@ int mlx5dr_action_destroy(struct mlx5dr_action *action); + static inline bool + mlx5dr_is_supported(struct mlx5_core_dev *dev) + { +- return MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) || +- (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) && +- (MLX5_CAP_GEN(dev, steering_format_version) <= +- MLX5_STEERING_FORMAT_CONNECTX_6DX)); ++ return MLX5_CAP_GEN(dev, roce) && ++ (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner) || ++ (MLX5_CAP_ESW_FLOWTABLE_FDB(dev, sw_owner_v2) && ++ (MLX5_CAP_GEN(dev, steering_format_version) <= ++ MLX5_STEERING_FORMAT_CONNECTX_6DX))); + } + + /* buddy functions & structure */ +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +index 01cc00ad8acf2..b6931bbe52d29 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/transobj.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/transobj.c +@@ -424,6 +424,15 @@ err_modify_sq: + return err; + } + ++static void mlx5_hairpin_unpair_peer_sq(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, ++ MLX5_SQC_STATE_RST, 0, 0); ++} ++ + static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + { + int i; +@@ -432,13 +441,9 @@ static void mlx5_hairpin_unpair_queues(struct mlx5_hairpin *hp) + for (i = 0; i < hp->num_channels; i++) + mlx5_hairpin_modify_rq(hp->func_mdev, hp->rqn[i], MLX5_RQC_STATE_RDY, + MLX5_RQC_STATE_RST, 0, 0); +- + /* unset peer SQs */ +- if (hp->peer_gone) +- return; +- for (i = 0; i < hp->num_channels; i++) +- mlx5_hairpin_modify_sq(hp->peer_mdev, hp->sqn[i], MLX5_SQC_STATE_RDY, +- MLX5_SQC_STATE_RST, 0, 0); ++ if (!hp->peer_gone) ++ mlx5_hairpin_unpair_peer_sq(hp); + } + + struct mlx5_hairpin * +@@ -485,3 +490,16 @@ void mlx5_core_hairpin_destroy(struct mlx5_hairpin *hp) + mlx5_hairpin_destroy_queues(hp); + kfree(hp); + } ++ ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp) ++{ ++ int i; ++ ++ mlx5_hairpin_unpair_peer_sq(hp); ++ ++ /* destroy peer SQ */ ++ for (i = 0; i < hp->num_channels; i++) ++ mlx5_core_destroy_sq(hp->peer_mdev, hp->sqn[i]); ++ ++ hp->peer_gone = true; ++} +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/vport.c b/drivers/net/ethernet/mellanox/mlx5/core/vport.c +index e05c5c0f3ae1d..7d21fbb9192f6 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/vport.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/vport.c +@@ -465,8 +465,6 @@ int mlx5_modify_nic_vport_node_guid(struct mlx5_core_dev *mdev, + void *in; + int err; + +- if (!vport) +- return -EINVAL; + if (!MLX5_CAP_GEN(mdev, vport_group_manager)) + return -EACCES; + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +index bf85ce9835d7f..42e4437ac3c16 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/core_thermal.c +@@ -708,7 +708,8 @@ mlxsw_thermal_module_tz_init(struct mlxsw_thermal_module *module_tz) + MLXSW_THERMAL_TRIP_MASK, + module_tz, + &mlxsw_thermal_module_ops, +- NULL, 0, 0); ++ NULL, 0, ++ module_tz->parent->polling_delay); + if (IS_ERR(module_tz->tzdev)) { + err = PTR_ERR(module_tz->tzdev); + return err; +@@ -830,7 +831,8 @@ mlxsw_thermal_gearbox_tz_init(struct mlxsw_thermal_module *gearbox_tz) + MLXSW_THERMAL_TRIP_MASK, + gearbox_tz, + &mlxsw_thermal_gearbox_ops, +- NULL, 0, 0); ++ NULL, 0, ++ gearbox_tz->parent->polling_delay); + if (IS_ERR(gearbox_tz->tzdev)) + return PTR_ERR(gearbox_tz->tzdev); + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h +index c4adc7f740d3e..769386971ac3b 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/reg.h ++++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h +@@ -3863,7 +3863,7 @@ MLXSW_ITEM32(reg, qeec, max_shaper_bs, 0x1C, 0, 6); + #define MLXSW_REG_QEEC_HIGHEST_SHAPER_BS 25 + #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP1 5 + #define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP2 11 +-#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 5 ++#define MLXSW_REG_QEEC_LOWEST_SHAPER_BS_SP3 11 + + static inline void mlxsw_reg_qeec_pack(char *payload, u8 local_port, + enum mlxsw_reg_qeec_hr hr, u8 index, +diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c +index 46e5c9136bacd..0c4c976548c85 100644 +--- a/drivers/net/ethernet/mscc/ocelot.c ++++ b/drivers/net/ethernet/mscc/ocelot.c +@@ -378,6 +378,7 @@ static u32 ocelot_read_eq_avail(struct ocelot *ocelot, int port) + + int ocelot_port_flush(struct ocelot *ocelot, int port) + { ++ unsigned int pause_ena; + int err, val; + + /* Disable dequeuing from the egress queues */ +@@ -386,6 +387,7 @@ int ocelot_port_flush(struct ocelot *ocelot, int port) + QSYS_PORT_MODE, port); + + /* Disable flow control */ ++ ocelot_fields_read(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, &pause_ena); + ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, 0); + + /* Disable priority flow control */ +@@ -421,6 +423,9 @@ int ocelot_port_flush(struct ocelot *ocelot, int port) + /* Clear flushing again. */ + ocelot_rmw_gix(ocelot, 0, REW_PORT_CFG_FLUSH_ENA, REW_PORT_CFG, port); + ++ /* Re-enable flow control */ ++ ocelot_fields_write(ocelot, port, SYS_PAUSE_CFG_PAUSE_ENA, pause_ena); ++ + return err; + } + EXPORT_SYMBOL(ocelot_port_flush); +diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +index 7e6bac85495d3..344ea11434549 100644 +--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c ++++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c +@@ -1602,6 +1602,8 @@ err_out_free_netdev: + free_netdev(netdev); + + err_out_free_res: ++ if (NX_IS_REVISION_P3(pdev->revision)) ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +index 96b947fde646b..3beafc60747e6 100644 +--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c ++++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +@@ -2690,6 +2690,7 @@ err_out_free_hw_res: + kfree(ahw); + + err_out_free_res: ++ pci_disable_pcie_error_reporting(pdev); + pci_release_regions(pdev); + + err_out_disable_pdev: +diff --git a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +index 41fbd2ceeede4..ab1e0fcccabb6 100644 +--- a/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c ++++ b/drivers/net/ethernet/qualcomm/rmnet/rmnet_vnd.c +@@ -126,24 +126,24 @@ static void rmnet_get_stats64(struct net_device *dev, + struct rtnl_link_stats64 *s) + { + struct rmnet_priv *priv = netdev_priv(dev); +- struct rmnet_vnd_stats total_stats; ++ struct rmnet_vnd_stats total_stats = { }; + struct rmnet_pcpu_stats *pcpu_ptr; ++ struct rmnet_vnd_stats snapshot; + unsigned int cpu, start; + +- memset(&total_stats, 0, sizeof(struct rmnet_vnd_stats)); +- + for_each_possible_cpu(cpu) { + pcpu_ptr = per_cpu_ptr(priv->pcpu_stats, cpu); + + do { + start = u64_stats_fetch_begin_irq(&pcpu_ptr->syncp); +- total_stats.rx_pkts += pcpu_ptr->stats.rx_pkts; +- total_stats.rx_bytes += pcpu_ptr->stats.rx_bytes; +- total_stats.tx_pkts += pcpu_ptr->stats.tx_pkts; +- total_stats.tx_bytes += pcpu_ptr->stats.tx_bytes; ++ snapshot = pcpu_ptr->stats; /* struct assignment */ + } while (u64_stats_fetch_retry_irq(&pcpu_ptr->syncp, start)); + +- total_stats.tx_drops += pcpu_ptr->stats.tx_drops; ++ total_stats.rx_pkts += snapshot.rx_pkts; ++ total_stats.rx_bytes += snapshot.rx_bytes; ++ total_stats.tx_pkts += snapshot.tx_pkts; ++ total_stats.tx_bytes += snapshot.tx_bytes; ++ total_stats.tx_drops += snapshot.tx_drops; + } + + s->rx_packets = total_stats.rx_pkts; +@@ -354,4 +354,4 @@ int rmnet_vnd_update_dev_mtu(struct rmnet_port *port, + } + + return 0; +-} +\ No newline at end of file ++} +diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +index b70d44ac09906..3c73453725f94 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h ++++ b/drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +@@ -76,10 +76,10 @@ enum power_event { + #define LPI_CTRL_STATUS_TLPIEN 0x00000001 /* Transmit LPI Entry */ + + /* GMAC HW ADDR regs */ +-#define GMAC_ADDR_HIGH(reg) (((reg > 15) ? 0x00000800 : 0x00000040) + \ +- (reg * 8)) +-#define GMAC_ADDR_LOW(reg) (((reg > 15) ? 0x00000804 : 0x00000044) + \ +- (reg * 8)) ++#define GMAC_ADDR_HIGH(reg) ((reg > 15) ? 0x00000800 + (reg - 16) * 8 : \ ++ 0x00000040 + (reg * 8)) ++#define GMAC_ADDR_LOW(reg) ((reg > 15) ? 0x00000804 + (reg - 16) * 8 : \ ++ 0x00000044 + (reg * 8)) + #define GMAC_MAX_PERFECT_ADDRESSES 1 + + #define GMAC_PCS_BASE 0x000000c0 /* PCS register base */ +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +index 6dc9f10414e47..7e6bead6429c5 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +@@ -622,6 +622,8 @@ error_pclk_get: + void stmmac_remove_config_dt(struct platform_device *pdev, + struct plat_stmmacenet_data *plat) + { ++ clk_disable_unprepare(plat->stmmac_clk); ++ clk_disable_unprepare(plat->pclk); + of_node_put(plat->phy_node); + of_node_put(plat->mdio_node); + } +diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c +index 030185301014c..01bb36e7cff0a 100644 +--- a/drivers/net/ethernet/xilinx/ll_temac_main.c ++++ b/drivers/net/ethernet/xilinx/ll_temac_main.c +@@ -849,7 +849,7 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + smp_mb(); + + /* Space might have just been freed - check again */ +- if (temac_check_tx_bd_space(lp, num_frag)) ++ if (temac_check_tx_bd_space(lp, num_frag + 1)) + return NETDEV_TX_BUSY; + + netif_wake_queue(ndev); +@@ -876,7 +876,6 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + return NETDEV_TX_OK; + } + cur_p->phys = cpu_to_be32(skb_dma_addr); +- ptr_to_txbd((void *)skb, cur_p); + + for (ii = 0; ii < num_frag; ii++) { + if (++lp->tx_bd_tail >= lp->tx_bd_num) +@@ -915,6 +914,11 @@ temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) + } + cur_p->app0 |= cpu_to_be32(STS_CTRL_APP0_EOP); + ++ /* Mark last fragment with skb address, so it can be consumed ++ * in temac_start_xmit_done() ++ */ ++ ptr_to_txbd((void *)skb, cur_p); ++ + tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; + lp->tx_bd_tail++; + if (lp->tx_bd_tail >= lp->tx_bd_num) +diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c +index 17be2bb2985cd..920e9f888cc35 100644 +--- a/drivers/net/hamradio/mkiss.c ++++ b/drivers/net/hamradio/mkiss.c +@@ -799,6 +799,7 @@ static void mkiss_close(struct tty_struct *tty) + ax->tty = NULL; + + unregister_netdev(ax->dev); ++ free_netdev(ax->dev); + } + + /* Perform I/O control on an active ax25 channel. */ +diff --git a/drivers/net/mhi/net.c b/drivers/net/mhi/net.c +index f59960876083f..8e7f8728998f1 100644 +--- a/drivers/net/mhi/net.c ++++ b/drivers/net/mhi/net.c +@@ -49,7 +49,7 @@ static int mhi_ndo_stop(struct net_device *ndev) + return 0; + } + +-static int mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev) ++static netdev_tx_t mhi_ndo_xmit(struct sk_buff *skb, struct net_device *ndev) + { + struct mhi_net_dev *mhi_netdev = netdev_priv(ndev); + const struct mhi_net_proto *proto = mhi_netdev->proto; +diff --git a/drivers/net/usb/cdc_eem.c b/drivers/net/usb/cdc_eem.c +index 0eeec80bec311..e4a5703666461 100644 +--- a/drivers/net/usb/cdc_eem.c ++++ b/drivers/net/usb/cdc_eem.c +@@ -123,10 +123,10 @@ static struct sk_buff *eem_tx_fixup(struct usbnet *dev, struct sk_buff *skb, + } + + skb2 = skb_copy_expand(skb, EEM_HEAD, ETH_FCS_LEN + padlen, flags); ++ dev_kfree_skb_any(skb); + if (!skb2) + return NULL; + +- dev_kfree_skb_any(skb); + skb = skb2; + + done: +diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c +index 8acf301154282..dc3d84b43e4e8 100644 +--- a/drivers/net/usb/cdc_ncm.c ++++ b/drivers/net/usb/cdc_ncm.c +@@ -1902,7 +1902,7 @@ static void cdc_ncm_status(struct usbnet *dev, struct urb *urb) + static const struct driver_info cdc_ncm_info = { + .description = "CDC NCM", + .flags = FLAG_POINTTOPOINT | FLAG_NO_SETINT | FLAG_MULTI_PACKET +- | FLAG_LINK_INTR, ++ | FLAG_LINK_INTR | FLAG_ETHER, + .bind = cdc_ncm_bind, + .unbind = cdc_ncm_unbind, + .manage_power = usbnet_manage_power, +diff --git a/drivers/net/usb/smsc75xx.c b/drivers/net/usb/smsc75xx.c +index 76ed79bb1e3f1..5281291711aff 100644 +--- a/drivers/net/usb/smsc75xx.c ++++ b/drivers/net/usb/smsc75xx.c +@@ -1483,7 +1483,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_wait_ready(dev, 0); + if (ret < 0) { + netdev_warn(dev->net, "device not ready in smsc75xx_bind\n"); +- goto err; ++ goto free_pdata; + } + + smsc75xx_init_mac_address(dev); +@@ -1492,7 +1492,7 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + ret = smsc75xx_reset(dev); + if (ret < 0) { + netdev_warn(dev->net, "smsc75xx_reset error %d\n", ret); +- goto err; ++ goto cancel_work; + } + + dev->net->netdev_ops = &smsc75xx_netdev_ops; +@@ -1503,8 +1503,11 @@ static int smsc75xx_bind(struct usbnet *dev, struct usb_interface *intf) + dev->net->max_mtu = MAX_SINGLE_PACKET_SIZE; + return 0; + +-err: ++cancel_work: ++ cancel_work_sync(&pdata->set_multicast); ++free_pdata: + kfree(pdata); ++ dev->data[0] = 0; + return ret; + } + +@@ -1515,7 +1518,6 @@ static void smsc75xx_unbind(struct usbnet *dev, struct usb_interface *intf) + cancel_work_sync(&pdata->set_multicast); + netif_dbg(dev, ifdown, dev->net, "free pdata\n"); + kfree(pdata); +- pdata = NULL; + dev->data[0] = 0; + } + } +diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c +index 503e2fd7ce518..28a6c4cfe9b8c 100644 +--- a/drivers/net/vrf.c ++++ b/drivers/net/vrf.c +@@ -1183,9 +1183,6 @@ static int vrf_dev_init(struct net_device *dev) + + dev->flags = IFF_MASTER | IFF_NOARP; + +- /* MTU is irrelevant for VRF device; set to 64k similar to lo */ +- dev->mtu = 64 * 1024; +- + /* similarly, oper state is irrelevant; set to up to avoid confusion */ + dev->operstate = IF_OPER_UP; + netdev_lockdep_set_classes(dev); +@@ -1685,7 +1682,8 @@ static void vrf_setup(struct net_device *dev) + * which breaks networking. + */ + dev->min_mtu = IPV6_MIN_MTU; +- dev->max_mtu = ETH_MAX_MTU; ++ dev->max_mtu = IP6_MAX_MTU; ++ dev->mtu = dev->max_mtu; + } + + static int vrf_validate(struct nlattr *tb[], struct nlattr *data[], +diff --git a/drivers/pci/controller/pci-aardvark.c b/drivers/pci/controller/pci-aardvark.c +index 051b48bd7985d..e3f5e7ab76063 100644 +--- a/drivers/pci/controller/pci-aardvark.c ++++ b/drivers/pci/controller/pci-aardvark.c +@@ -514,7 +514,7 @@ static int advk_pcie_wait_pio(struct advk_pcie *pcie) + udelay(PIO_RETRY_DELAY); + } + +- dev_err(dev, "config read/write timed out\n"); ++ dev_err(dev, "PIO read/write transfer time out\n"); + return -ETIMEDOUT; + } + +@@ -657,6 +657,35 @@ static bool advk_pcie_valid_device(struct advk_pcie *pcie, struct pci_bus *bus, + return true; + } + ++static bool advk_pcie_pio_is_running(struct advk_pcie *pcie) ++{ ++ struct device *dev = &pcie->pdev->dev; ++ ++ /* ++ * Trying to start a new PIO transfer when previous has not completed ++ * cause External Abort on CPU which results in kernel panic: ++ * ++ * SError Interrupt on CPU0, code 0xbf000002 -- SError ++ * Kernel panic - not syncing: Asynchronous SError Interrupt ++ * ++ * Functions advk_pcie_rd_conf() and advk_pcie_wr_conf() are protected ++ * by raw_spin_lock_irqsave() at pci_lock_config() level to prevent ++ * concurrent calls at the same time. But because PIO transfer may take ++ * about 1.5s when link is down or card is disconnected, it means that ++ * advk_pcie_wait_pio() does not always have to wait for completion. ++ * ++ * Some versions of ARM Trusted Firmware handles this External Abort at ++ * EL3 level and mask it to prevent kernel panic. Relevant TF-A commit: ++ * https://git.trustedfirmware.org/TF-A/trusted-firmware-a.git/commit/?id=3c7dcdac5c50 ++ */ ++ if (advk_readl(pcie, PIO_START)) { ++ dev_err(dev, "Previous PIO read/write transfer is still running\n"); ++ return true; ++ } ++ ++ return false; ++} ++ + static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + int where, int size, u32 *val) + { +@@ -673,9 +702,10 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + return pci_bridge_emul_conf_read(&pcie->bridge, where, + size, val); + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) { ++ *val = 0xffffffff; ++ return PCIBIOS_SET_FAILED; ++ } + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -694,7 +724,8 @@ static int advk_pcie_rd_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, 0xf, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +@@ -734,9 +765,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + if (where % size) + return PCIBIOS_SET_FAILED; + +- /* Start PIO */ +- advk_writel(pcie, 0, PIO_START); +- advk_writel(pcie, 1, PIO_ISR); ++ if (advk_pcie_pio_is_running(pcie)) ++ return PCIBIOS_SET_FAILED; + + /* Program the control register */ + reg = advk_readl(pcie, PIO_CTRL); +@@ -763,7 +793,8 @@ static int advk_pcie_wr_conf(struct pci_bus *bus, u32 devfn, + /* Program the data strobe */ + advk_writel(pcie, data_strobe, PIO_WR_DATA_STRB); + +- /* Start the transfer */ ++ /* Clear PIO DONE ISR and start the transfer */ ++ advk_writel(pcie, 1, PIO_ISR); + advk_writel(pcie, 1, PIO_START); + + ret = advk_pcie_wait_pio(pcie); +diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c +index 653660e3ba9ef..7bf76bca888da 100644 +--- a/drivers/pci/quirks.c ++++ b/drivers/pci/quirks.c +@@ -3558,6 +3558,18 @@ static void quirk_no_bus_reset(struct pci_dev *dev) + dev->dev_flags |= PCI_DEV_FLAGS_NO_BUS_RESET; + } + ++/* ++ * Some NVIDIA GPU devices do not work with bus reset, SBR needs to be ++ * prevented for those affected devices. ++ */ ++static void quirk_nvidia_no_bus_reset(struct pci_dev *dev) ++{ ++ if ((dev->device & 0xffc0) == 0x2340) ++ quirk_no_bus_reset(dev); ++} ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, PCI_ANY_ID, ++ quirk_nvidia_no_bus_reset); ++ + /* + * Some Atheros AR9xxx and QCA988x chips do not behave after a bus reset. + * The device will throw a Link Down error on AER-capable systems and +@@ -3578,6 +3590,16 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATHEROS, 0x0034, quirk_no_bus_reset); + */ + DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_CAVIUM, 0xa100, quirk_no_bus_reset); + ++/* ++ * Some TI KeyStone C667X devices do not support bus/hot reset. The PCIESS ++ * automatically disables LTSSM when Secondary Bus Reset is received and ++ * the device stops working. Prevent bus reset for these devices. With ++ * this change, the device can be assigned to VMs with VFIO, but it will ++ * leak state between VMs. Reference ++ * https://e2e.ti.com/support/processors/f/791/t/954382 ++ */ ++DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TI, 0xb005, quirk_no_bus_reset); ++ + static void quirk_no_pm_reset(struct pci_dev *dev) + { + /* +@@ -3913,6 +3935,69 @@ static int delay_250ms_after_flr(struct pci_dev *dev, int probe) + return 0; + } + ++#define PCI_DEVICE_ID_HINIC_VF 0x375E ++#define HINIC_VF_FLR_TYPE 0x1000 ++#define HINIC_VF_FLR_CAP_BIT (1UL << 30) ++#define HINIC_VF_OP 0xE80 ++#define HINIC_VF_FLR_PROC_BIT (1UL << 18) ++#define HINIC_OPERATION_TIMEOUT 15000 /* 15 seconds */ ++ ++/* Device-specific reset method for Huawei Intelligent NIC virtual functions */ ++static int reset_hinic_vf_dev(struct pci_dev *pdev, int probe) ++{ ++ unsigned long timeout; ++ void __iomem *bar; ++ u32 val; ++ ++ if (probe) ++ return 0; ++ ++ bar = pci_iomap(pdev, 0, 0); ++ if (!bar) ++ return -ENOTTY; ++ ++ /* Get and check firmware capabilities */ ++ val = ioread32be(bar + HINIC_VF_FLR_TYPE); ++ if (!(val & HINIC_VF_FLR_CAP_BIT)) { ++ pci_iounmap(pdev, bar); ++ return -ENOTTY; ++ } ++ ++ /* Set HINIC_VF_FLR_PROC_BIT for the start of FLR */ ++ val = ioread32be(bar + HINIC_VF_OP); ++ val = val | HINIC_VF_FLR_PROC_BIT; ++ iowrite32be(val, bar + HINIC_VF_OP); ++ ++ pcie_flr(pdev); ++ ++ /* ++ * The device must recapture its Bus and Device Numbers after FLR ++ * in order generate Completions. Issue a config write to let the ++ * device capture this information. ++ */ ++ pci_write_config_word(pdev, PCI_VENDOR_ID, 0); ++ ++ /* Firmware clears HINIC_VF_FLR_PROC_BIT when reset is complete */ ++ timeout = jiffies + msecs_to_jiffies(HINIC_OPERATION_TIMEOUT); ++ do { ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ msleep(20); ++ } while (time_before(jiffies, timeout)); ++ ++ val = ioread32be(bar + HINIC_VF_OP); ++ if (!(val & HINIC_VF_FLR_PROC_BIT)) ++ goto reset_complete; ++ ++ pci_warn(pdev, "Reset dev timeout, FLR ack reg: %#010x\n", val); ++ ++reset_complete: ++ pci_iounmap(pdev, bar); ++ ++ return 0; ++} ++ + static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82599_SFP_VF, + reset_intel_82599_sfp_virtfn }, +@@ -3924,6 +4009,8 @@ static const struct pci_dev_reset_methods pci_dev_reset_methods[] = { + { PCI_VENDOR_ID_INTEL, 0x0953, delay_250ms_after_flr }, + { PCI_VENDOR_ID_CHELSIO, PCI_ANY_ID, + reset_chelsio_generic_dev }, ++ { PCI_VENDOR_ID_HUAWEI, PCI_DEVICE_ID_HINIC_VF, ++ reset_hinic_vf_dev }, + { 0 } + }; + +@@ -4764,6 +4851,8 @@ static const struct pci_dev_acs_enabled { + { PCI_VENDOR_ID_AMPERE, 0xE00A, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00B, pci_quirk_xgene_acs }, + { PCI_VENDOR_ID_AMPERE, 0xE00C, pci_quirk_xgene_acs }, ++ /* Broadcom multi-function device */ ++ { PCI_VENDOR_ID_BROADCOM, 0x16D7, pci_quirk_mf_endpoint_acs }, + { PCI_VENDOR_ID_BROADCOM, 0xD714, pci_quirk_brcm_acs }, + /* Amazon Annapurna Labs */ + { PCI_VENDOR_ID_AMAZON_ANNAPURNA_LABS, 0x0031, pci_quirk_al_acs }, +@@ -5165,7 +5254,8 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_SERVERWORKS, 0x0422, quirk_no_ext_tags); + static void quirk_amd_harvest_no_ats(struct pci_dev *pdev) + { + if ((pdev->device == 0x7312 && pdev->revision != 0x00) || +- (pdev->device == 0x7340 && pdev->revision != 0xc5)) ++ (pdev->device == 0x7340 && pdev->revision != 0xc5) || ++ (pdev->device == 0x7341 && pdev->revision != 0x00)) + return; + + if (pdev->device == 0x15d8) { +@@ -5192,6 +5282,7 @@ DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x6900, quirk_amd_harvest_no_ats); + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7312, quirk_amd_harvest_no_ats); + /* AMD Navi14 dGPU */ + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7340, quirk_amd_harvest_no_ats); ++DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x7341, quirk_amd_harvest_no_ats); + /* AMD Raven platform iGPU */ + DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_ATI, 0x15d8, quirk_amd_harvest_no_ats); + #endif /* CONFIG_PCI_ATS */ +diff --git a/drivers/phy/mediatek/phy-mtk-tphy.c b/drivers/phy/mediatek/phy-mtk-tphy.c +index cdbcc49f71152..731c483a04dea 100644 +--- a/drivers/phy/mediatek/phy-mtk-tphy.c ++++ b/drivers/phy/mediatek/phy-mtk-tphy.c +@@ -949,6 +949,8 @@ static int mtk_phy_init(struct phy *phy) + break; + default: + dev_err(tphy->dev, "incompatible PHY type\n"); ++ clk_disable_unprepare(instance->ref_clk); ++ clk_disable_unprepare(instance->da_ref_clk); + return -EINVAL; + } + +diff --git a/drivers/pinctrl/ralink/pinctrl-rt2880.c b/drivers/pinctrl/ralink/pinctrl-rt2880.c +index 1f4bca854add5..a9b511c7e8500 100644 +--- a/drivers/pinctrl/ralink/pinctrl-rt2880.c ++++ b/drivers/pinctrl/ralink/pinctrl-rt2880.c +@@ -127,7 +127,7 @@ static int rt2880_pmx_group_enable(struct pinctrl_dev *pctrldev, + if (p->groups[group].enabled) { + dev_err(p->dev, "%s is already enabled\n", + p->groups[group].name); +- return -EBUSY; ++ return 0; + } + + p->groups[group].enabled = 1; +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 61f1c91c62de2..3390168ac0793 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -8808,6 +8808,7 @@ static const struct tpacpi_quirk fan_quirk_table[] __initconst = { + TPACPI_Q_LNV3('N', '2', 'O', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (2nd gen) */ + TPACPI_Q_LNV3('N', '2', 'V', TPACPI_FAN_2CTL), /* P1 / X1 Extreme (3nd gen) */ + TPACPI_Q_LNV3('N', '3', '0', TPACPI_FAN_2CTL), /* P15 (1st gen) / P15v (1st gen) */ ++ TPACPI_Q_LNV3('N', '3', '2', TPACPI_FAN_2CTL), /* X1 Carbon (9th gen) */ + }; + + static int __init fan_init(struct ibm_init_struct *iibm) +diff --git a/drivers/ptp/ptp_clock.c b/drivers/ptp/ptp_clock.c +index 03a246e60fd98..21c4c34c52d8d 100644 +--- a/drivers/ptp/ptp_clock.c ++++ b/drivers/ptp/ptp_clock.c +@@ -63,7 +63,7 @@ static void enqueue_external_timestamp(struct timestamp_event_queue *queue, + spin_unlock_irqrestore(&queue->lock, flags); + } + +-s32 scaled_ppm_to_ppb(long ppm) ++long scaled_ppm_to_ppb(long ppm) + { + /* + * The 'freq' field in the 'struct timex' is in parts per +@@ -80,7 +80,7 @@ s32 scaled_ppm_to_ppb(long ppm) + s64 ppb = 1 + ppm; + ppb *= 125; + ppb >>= 13; +- return (s32) ppb; ++ return (long) ppb; + } + EXPORT_SYMBOL(scaled_ppm_to_ppb); + +@@ -138,7 +138,7 @@ static int ptp_clock_adjtime(struct posix_clock *pc, struct __kernel_timex *tx) + delta = ktime_to_ns(kt); + err = ops->adjtime(ops, delta); + } else if (tx->modes & ADJ_FREQUENCY) { +- s32 ppb = scaled_ppm_to_ppb(tx->freq); ++ long ppb = scaled_ppm_to_ppb(tx->freq); + if (ppb > ops->max_adj || ppb < -ops->max_adj) + return -ERANGE; + if (ops->adjfine) +diff --git a/drivers/regulator/cros-ec-regulator.c b/drivers/regulator/cros-ec-regulator.c +index eb3fc1db4edc8..c4754f3cf2337 100644 +--- a/drivers/regulator/cros-ec-regulator.c ++++ b/drivers/regulator/cros-ec-regulator.c +@@ -225,8 +225,9 @@ static int cros_ec_regulator_probe(struct platform_device *pdev) + + drvdata->dev = devm_regulator_register(dev, &drvdata->desc, &cfg); + if (IS_ERR(drvdata->dev)) { ++ ret = PTR_ERR(drvdata->dev); + dev_err(&pdev->dev, "Failed to register regulator: %d\n", ret); +- return PTR_ERR(drvdata->dev); ++ return ret; + } + + platform_set_drvdata(pdev, drvdata); +diff --git a/drivers/regulator/mt6315-regulator.c b/drivers/regulator/mt6315-regulator.c +index 9edc34981ee0a..6b8be52c3772a 100644 +--- a/drivers/regulator/mt6315-regulator.c ++++ b/drivers/regulator/mt6315-regulator.c +@@ -59,7 +59,7 @@ static const struct linear_range mt_volt_range1[] = { + REGULATOR_LINEAR_RANGE(0, 0, 0xbf, 6250), + }; + +-static unsigned int mt6315_map_mode(u32 mode) ++static unsigned int mt6315_map_mode(unsigned int mode) + { + switch (mode) { + case MT6315_BUCK_MODE_AUTO: +diff --git a/drivers/regulator/rt4801-regulator.c b/drivers/regulator/rt4801-regulator.c +index 2055a9cb13ba5..7a87788d3f092 100644 +--- a/drivers/regulator/rt4801-regulator.c ++++ b/drivers/regulator/rt4801-regulator.c +@@ -66,7 +66,7 @@ static int rt4801_enable(struct regulator_dev *rdev) + struct gpio_descs *gpios = priv->enable_gpios; + int id = rdev_get_id(rdev), ret; + +- if (gpios->ndescs <= id) { ++ if (!gpios || gpios->ndescs <= id) { + dev_warn(&rdev->dev, "no dedicated gpio can control\n"); + goto bypass_gpio; + } +@@ -88,7 +88,7 @@ static int rt4801_disable(struct regulator_dev *rdev) + struct gpio_descs *gpios = priv->enable_gpios; + int id = rdev_get_id(rdev); + +- if (gpios->ndescs <= id) { ++ if (!gpios || gpios->ndescs <= id) { + dev_warn(&rdev->dev, "no dedicated gpio can control\n"); + goto bypass_gpio; + } +diff --git a/drivers/regulator/rtmv20-regulator.c b/drivers/regulator/rtmv20-regulator.c +index 5adc552dffd58..4bca64de0f672 100644 +--- a/drivers/regulator/rtmv20-regulator.c ++++ b/drivers/regulator/rtmv20-regulator.c +@@ -27,6 +27,7 @@ + #define RTMV20_REG_LDIRQ 0x30 + #define RTMV20_REG_LDSTAT 0x40 + #define RTMV20_REG_LDMASK 0x50 ++#define RTMV20_MAX_REGS (RTMV20_REG_LDMASK + 1) + + #define RTMV20_VID_MASK GENMASK(7, 4) + #define RICHTEK_VID 0x80 +@@ -313,6 +314,7 @@ static const struct regmap_config rtmv20_regmap_config = { + .val_bits = 8, + .cache_type = REGCACHE_RBTREE, + .max_register = RTMV20_REG_LDMASK, ++ .num_reg_defaults_raw = RTMV20_MAX_REGS, + + .writeable_reg = rtmv20_is_accessible_reg, + .readable_reg = rtmv20_is_accessible_reg, +diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c +index ecefc25eff0c0..337353c9655ed 100644 +--- a/drivers/s390/crypto/ap_queue.c ++++ b/drivers/s390/crypto/ap_queue.c +@@ -135,12 +135,13 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) + { + struct ap_queue_status status; + struct ap_message *ap_msg; ++ bool found = false; + + status = ap_dqap(aq->qid, &aq->reply->psmid, + aq->reply->msg, aq->reply->len); + switch (status.response_code) { + case AP_RESPONSE_NORMAL: +- aq->queue_count--; ++ aq->queue_count = max_t(int, 0, aq->queue_count - 1); + if (aq->queue_count > 0) + mod_timer(&aq->timeout, + jiffies + aq->request_timeout); +@@ -150,8 +151,14 @@ static struct ap_queue_status ap_sm_recv(struct ap_queue *aq) + list_del_init(&ap_msg->list); + aq->pendingq_count--; + ap_msg->receive(aq, ap_msg, aq->reply); ++ found = true; + break; + } ++ if (!found) { ++ AP_DBF_WARN("%s unassociated reply psmid=0x%016llx on 0x%02x.%04x\n", ++ __func__, aq->reply->psmid, ++ AP_QID_CARD(aq->qid), AP_QID_QUEUE(aq->qid)); ++ } + fallthrough; + case AP_RESPONSE_NO_PENDING_REPLY: + if (!status.queue_empty || aq->queue_count <= 0) +@@ -232,7 +239,7 @@ static enum ap_sm_wait ap_sm_write(struct ap_queue *aq) + ap_msg->flags & AP_MSG_FLAG_SPECIAL); + switch (status.response_code) { + case AP_RESPONSE_NORMAL: +- aq->queue_count++; ++ aq->queue_count = max_t(int, 1, aq->queue_count + 1); + if (aq->queue_count == 1) + mod_timer(&aq->timeout, jiffies + aq->request_timeout); + list_move_tail(&ap_msg->list, &aq->pendingq); +diff --git a/drivers/spi/spi-stm32-qspi.c b/drivers/spi/spi-stm32-qspi.c +index 2786470a52011..4f24f63922126 100644 +--- a/drivers/spi/spi-stm32-qspi.c ++++ b/drivers/spi/spi-stm32-qspi.c +@@ -293,7 +293,7 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + int err = 0; + + if (!op->data.nbytes) +- return stm32_qspi_wait_nobusy(qspi); ++ goto wait_nobusy; + + if (readl_relaxed(qspi->io_base + QSPI_SR) & SR_TCF) + goto out; +@@ -314,6 +314,9 @@ static int stm32_qspi_wait_cmd(struct stm32_qspi *qspi, + out: + /* clear flags */ + writel_relaxed(FCR_CTCF | FCR_CTEF, qspi->io_base + QSPI_FCR); ++wait_nobusy: ++ if (!err) ++ err = stm32_qspi_wait_nobusy(qspi); + + return err; + } +diff --git a/drivers/spi/spi-zynq-qspi.c b/drivers/spi/spi-zynq-qspi.c +index 2765289028fae..68193db8b2e3c 100644 +--- a/drivers/spi/spi-zynq-qspi.c ++++ b/drivers/spi/spi-zynq-qspi.c +@@ -678,14 +678,14 @@ static int zynq_qspi_probe(struct platform_device *pdev) + xqspi->irq = platform_get_irq(pdev, 0); + if (xqspi->irq <= 0) { + ret = -ENXIO; +- goto remove_master; ++ goto clk_dis_all; + } + ret = devm_request_irq(&pdev->dev, xqspi->irq, zynq_qspi_irq, + 0, pdev->name, xqspi); + if (ret != 0) { + ret = -ENXIO; + dev_err(&pdev->dev, "request_irq failed\n"); +- goto remove_master; ++ goto clk_dis_all; + } + + ret = of_property_read_u32(np, "num-cs", +@@ -693,8 +693,9 @@ static int zynq_qspi_probe(struct platform_device *pdev) + if (ret < 0) { + ctlr->num_chipselect = 1; + } else if (num_cs > ZYNQ_QSPI_MAX_NUM_CS) { ++ ret = -EINVAL; + dev_err(&pdev->dev, "only 2 chip selects are available\n"); +- goto remove_master; ++ goto clk_dis_all; + } else { + ctlr->num_chipselect = num_cs; + } +diff --git a/drivers/staging/hikey9xx/hi6421v600-regulator.c b/drivers/staging/hikey9xx/hi6421v600-regulator.c +index f6a14e9c3cbfe..e10fe3058176d 100644 +--- a/drivers/staging/hikey9xx/hi6421v600-regulator.c ++++ b/drivers/staging/hikey9xx/hi6421v600-regulator.c +@@ -83,7 +83,7 @@ static const unsigned int ldo34_voltages[] = { + .owner = THIS_MODULE, \ + .volt_table = vtable, \ + .n_voltages = ARRAY_SIZE(vtable), \ +- .vsel_mask = (1 << (ARRAY_SIZE(vtable) - 1)) - 1, \ ++ .vsel_mask = ARRAY_SIZE(vtable) - 1, \ + .vsel_reg = vreg, \ + .enable_reg = ereg, \ + .enable_mask = emask, \ +diff --git a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +index cbec65e5a4645..62ea47f9fee5e 100644 +--- a/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c ++++ b/drivers/staging/rtl8723bs/os_dep/ioctl_cfg80211.c +@@ -2579,7 +2579,7 @@ static int rtw_cfg80211_add_monitor_if(struct adapter *padapter, char *name, str + mon_wdev->iftype = NL80211_IFTYPE_MONITOR; + mon_ndev->ieee80211_ptr = mon_wdev; + +- ret = register_netdevice(mon_ndev); ++ ret = cfg80211_register_netdevice(mon_ndev); + if (ret) { + goto out; + } +@@ -2661,7 +2661,7 @@ static int cfg80211_rtw_del_virtual_intf(struct wiphy *wiphy, + adapter = rtw_netdev_priv(ndev); + pwdev_priv = adapter_wdev_data(adapter); + +- unregister_netdevice(ndev); ++ cfg80211_unregister_netdevice(ndev); + + if (ndev == pwdev_priv->pmon_ndev) { + pwdev_priv->pmon_ndev = NULL; +diff --git a/drivers/usb/chipidea/usbmisc_imx.c b/drivers/usb/chipidea/usbmisc_imx.c +index 4545b23bda3f1..bac0f5458cab9 100644 +--- a/drivers/usb/chipidea/usbmisc_imx.c ++++ b/drivers/usb/chipidea/usbmisc_imx.c +@@ -686,6 +686,16 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) + int val; + unsigned long flags; + ++ /* Clear VDATSRCENB0 to disable VDP_SRC and IDM_SNK required by BC 1.2 spec */ ++ spin_lock_irqsave(&usbmisc->lock, flags); ++ val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); ++ val &= ~MX7D_USB_OTG_PHY_CFG2_CHRG_VDATSRCENB0; ++ writel(val, usbmisc->base + MX7D_USB_OTG_PHY_CFG2); ++ spin_unlock_irqrestore(&usbmisc->lock, flags); ++ ++ /* TVDMSRC_DIS */ ++ msleep(20); ++ + /* VDM_SRC is connected to D- and IDP_SINK is connected to D+ */ + spin_lock_irqsave(&usbmisc->lock, flags); + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_CFG2); +@@ -695,7 +705,8 @@ static int imx7d_charger_secondary_detection(struct imx_usbmisc_data *data) + usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + spin_unlock_irqrestore(&usbmisc->lock, flags); + +- usleep_range(1000, 2000); ++ /* TVDMSRC_ON */ ++ msleep(40); + + /* + * Per BC 1.2, check voltage of D+: +@@ -798,7 +809,8 @@ static int imx7d_charger_primary_detection(struct imx_usbmisc_data *data) + usbmisc->base + MX7D_USB_OTG_PHY_CFG2); + spin_unlock_irqrestore(&usbmisc->lock, flags); + +- usleep_range(1000, 2000); ++ /* TVDPSRC_ON */ ++ msleep(40); + + /* Check if D- is less than VDAT_REF to determine an SDP per BC 1.2 */ + val = readl(usbmisc->base + MX7D_USB_OTG_PHY_STATUS); +diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c +index 13fe37fbbd2c8..6ebb8bd92e9df 100644 +--- a/drivers/usb/core/hub.c ++++ b/drivers/usb/core/hub.c +@@ -40,6 +40,8 @@ + #define USB_VENDOR_GENESYS_LOGIC 0x05e3 + #define USB_VENDOR_SMSC 0x0424 + #define USB_PRODUCT_USB5534B 0x5534 ++#define USB_VENDOR_CYPRESS 0x04b4 ++#define USB_PRODUCT_CY7C65632 0x6570 + #define HUB_QUIRK_CHECK_PORT_AUTOSUSPEND 0x01 + #define HUB_QUIRK_DISABLE_AUTOSUSPEND 0x02 + +@@ -5644,6 +5646,11 @@ static const struct usb_device_id hub_id_table[] = { + .idProduct = USB_PRODUCT_USB5534B, + .bInterfaceClass = USB_CLASS_HUB, + .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, ++ { .match_flags = USB_DEVICE_ID_MATCH_VENDOR ++ | USB_DEVICE_ID_MATCH_PRODUCT, ++ .idVendor = USB_VENDOR_CYPRESS, ++ .idProduct = USB_PRODUCT_CY7C65632, ++ .driver_info = HUB_QUIRK_DISABLE_AUTOSUSPEND}, + { .match_flags = USB_DEVICE_ID_MATCH_VENDOR + | USB_DEVICE_ID_MATCH_INT_CLASS, + .idVendor = USB_VENDOR_GENESYS_LOGIC, +diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c +index 126f0e10b3ef4..0022039bc2355 100644 +--- a/drivers/usb/dwc3/core.c ++++ b/drivers/usb/dwc3/core.c +@@ -1657,8 +1657,8 @@ static int dwc3_remove(struct platform_device *pdev) + + pm_runtime_get_sync(&pdev->dev); + +- dwc3_debugfs_exit(dwc); + dwc3_core_exit_mode(dwc); ++ dwc3_debugfs_exit(dwc); + + dwc3_core_exit(dwc); + dwc3_ulpi_exit(dwc); +diff --git a/drivers/usb/dwc3/debug.h b/drivers/usb/dwc3/debug.h +index 8ab3949423604..74d9c2c38193d 100644 +--- a/drivers/usb/dwc3/debug.h ++++ b/drivers/usb/dwc3/debug.h +@@ -413,9 +413,12 @@ static inline const char *dwc3_gadget_generic_cmd_status_string(int status) + + + #ifdef CONFIG_DEBUG_FS ++extern void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep); + extern void dwc3_debugfs_init(struct dwc3 *d); + extern void dwc3_debugfs_exit(struct dwc3 *d); + #else ++static inline void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) ++{ } + static inline void dwc3_debugfs_init(struct dwc3 *d) + { } + static inline void dwc3_debugfs_exit(struct dwc3 *d) +diff --git a/drivers/usb/dwc3/debugfs.c b/drivers/usb/dwc3/debugfs.c +index 5da4f6082d930..3ebe3e6c284d2 100644 +--- a/drivers/usb/dwc3/debugfs.c ++++ b/drivers/usb/dwc3/debugfs.c +@@ -890,30 +890,14 @@ static void dwc3_debugfs_create_endpoint_files(struct dwc3_ep *dep, + } + } + +-static void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep, +- struct dentry *parent) ++void dwc3_debugfs_create_endpoint_dir(struct dwc3_ep *dep) + { + struct dentry *dir; + +- dir = debugfs_create_dir(dep->name, parent); ++ dir = debugfs_create_dir(dep->name, dep->dwc->root); + dwc3_debugfs_create_endpoint_files(dep, dir); + } + +-static void dwc3_debugfs_create_endpoint_dirs(struct dwc3 *dwc, +- struct dentry *parent) +-{ +- int i; +- +- for (i = 0; i < dwc->num_eps; i++) { +- struct dwc3_ep *dep = dwc->eps[i]; +- +- if (!dep) +- continue; +- +- dwc3_debugfs_create_endpoint_dir(dep, parent); +- } +-} +- + void dwc3_debugfs_init(struct dwc3 *dwc) + { + struct dentry *root; +@@ -944,7 +928,6 @@ void dwc3_debugfs_init(struct dwc3 *dwc) + &dwc3_testmode_fops); + debugfs_create_file("link_state", 0644, root, dwc, + &dwc3_link_state_fops); +- dwc3_debugfs_create_endpoint_dirs(dwc, root); + } + } + +diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c +index 1f9454e0d447b..755ab6fc0791f 100644 +--- a/drivers/usb/dwc3/gadget.c ++++ b/drivers/usb/dwc3/gadget.c +@@ -2719,6 +2719,8 @@ static int dwc3_gadget_init_endpoint(struct dwc3 *dwc, u8 epnum) + INIT_LIST_HEAD(&dep->started_list); + INIT_LIST_HEAD(&dep->cancelled_list); + ++ dwc3_debugfs_create_endpoint_dir(dep); ++ + return 0; + } + +@@ -2762,6 +2764,7 @@ static void dwc3_gadget_free_endpoints(struct dwc3 *dwc) + list_del(&dep->endpoint.ep_list); + } + ++ debugfs_remove_recursive(debugfs_lookup(dep->name, dwc->root)); + kfree(dep); + } + } +diff --git a/fs/afs/main.c b/fs/afs/main.c +index b2975256dadbd..179004b15566d 100644 +--- a/fs/afs/main.c ++++ b/fs/afs/main.c +@@ -203,8 +203,8 @@ static int __init afs_init(void) + goto error_fs; + + afs_proc_symlink = proc_symlink("fs/afs", NULL, "../self/net/afs"); +- if (IS_ERR(afs_proc_symlink)) { +- ret = PTR_ERR(afs_proc_symlink); ++ if (!afs_proc_symlink) { ++ ret = -ENOMEM; + goto error_proc; + } + +diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c +index a7d9e147dee62..595fd083c4ad1 100644 +--- a/fs/btrfs/block-group.c ++++ b/fs/btrfs/block-group.c +@@ -2347,16 +2347,16 @@ void btrfs_dec_block_group_ro(struct btrfs_block_group *cache) + spin_lock(&sinfo->lock); + spin_lock(&cache->lock); + if (!--cache->ro) { +- num_bytes = cache->length - cache->reserved - +- cache->pinned - cache->bytes_super - +- cache->zone_unusable - cache->used; +- sinfo->bytes_readonly -= num_bytes; + if (btrfs_is_zoned(cache->fs_info)) { + /* Migrate zone_unusable bytes back */ + cache->zone_unusable = cache->alloc_offset - cache->used; + sinfo->bytes_zone_unusable += cache->zone_unusable; + sinfo->bytes_readonly -= cache->zone_unusable; + } ++ num_bytes = cache->length - cache->reserved - ++ cache->pinned - cache->bytes_super - ++ cache->zone_unusable - cache->used; ++ sinfo->bytes_readonly -= num_bytes; + list_del_init(&cache->ro_list); + } + spin_unlock(&cache->lock); +diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c +index c63d0a7f7ba4f..527c972b562dd 100644 +--- a/fs/hugetlbfs/inode.c ++++ b/fs/hugetlbfs/inode.c +@@ -738,6 +738,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, + __SetPageUptodate(page); + error = huge_add_to_page_cache(page, mapping, index); + if (unlikely(error)) { ++ restore_reserve_on_error(h, &pseudo_vma, addr, page); + put_page(page); + mutex_unlock(&hugetlb_fault_mutex_table[hash]); + goto out; +diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c +index 9e0c1afac8bdf..c175523b0a2c1 100644 +--- a/fs/notify/fanotify/fanotify_user.c ++++ b/fs/notify/fanotify/fanotify_user.c +@@ -378,7 +378,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, + info_type, fanotify_info_name(info), + info->name_len, buf, count); + if (ret < 0) +- return ret; ++ goto out_close_fd; + + buf += ret; + count -= ret; +@@ -426,7 +426,7 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group, + fanotify_event_object_fh(event), + info_type, dot, dot_len, buf, count); + if (ret < 0) +- return ret; ++ goto out_close_fd; + + buf += ret; + count -= ret; +diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h +index cccd1aab69dd1..5dae4187210d9 100644 +--- a/include/linux/hugetlb.h ++++ b/include/linux/hugetlb.h +@@ -145,6 +145,7 @@ bool hugetlb_reserve_pages(struct inode *inode, long from, long to, + long hugetlb_unreserve_pages(struct inode *inode, long start, long end, + long freed); + bool isolate_huge_page(struct page *page, struct list_head *list); ++int get_hwpoison_huge_page(struct page *page, bool *hugetlb); + void putback_active_hugepage(struct page *page); + void move_hugetlb_state(struct page *oldpage, struct page *newpage, int reason); + void free_huge_page(struct page *page); +@@ -330,6 +331,11 @@ static inline bool isolate_huge_page(struct page *page, struct list_head *list) + return false; + } + ++static inline int get_hwpoison_huge_page(struct page *page, bool *hugetlb) ++{ ++ return 0; ++} ++ + static inline void putback_active_hugepage(struct page *page) + { + } +@@ -591,6 +597,8 @@ struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma, + unsigned long address); + int huge_add_to_page_cache(struct page *page, struct address_space *mapping, + pgoff_t idx); ++void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma, ++ unsigned long address, struct page *page); + + /* arch callback */ + int __init __alloc_bootmem_huge_page(struct hstate *h); +diff --git a/include/linux/mfd/rohm-bd70528.h b/include/linux/mfd/rohm-bd70528.h +index a57af878fd0cd..4a5966475a35a 100644 +--- a/include/linux/mfd/rohm-bd70528.h ++++ b/include/linux/mfd/rohm-bd70528.h +@@ -26,9 +26,7 @@ struct bd70528_data { + struct mutex rtc_timer_lock; + }; + +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 +-#define BD70528_BUCK_VOLTS 17 ++#define BD70528_BUCK_VOLTS 0x10 + #define BD70528_LDO_VOLTS 0x20 + + #define BD70528_REG_BUCK1_EN 0x0F +diff --git a/include/linux/mlx5/driver.h b/include/linux/mlx5/driver.h +index 133967c40214b..6a31bbba1b6f1 100644 +--- a/include/linux/mlx5/driver.h ++++ b/include/linux/mlx5/driver.h +@@ -541,6 +541,10 @@ struct mlx5_core_roce { + enum { + MLX5_PRIV_FLAGS_DISABLE_IB_ADEV = 1 << 0, + MLX5_PRIV_FLAGS_DISABLE_ALL_ADEV = 1 << 1, ++ /* Set during device detach to block any further devices ++ * creation/deletion on drivers rescan. Unset during device attach. ++ */ ++ MLX5_PRIV_FLAGS_DETACH = 1 << 2, + }; + + struct mlx5_adev { +diff --git a/include/linux/mlx5/transobj.h b/include/linux/mlx5/transobj.h +index 028f442530cf5..60ffeb6b67ae7 100644 +--- a/include/linux/mlx5/transobj.h ++++ b/include/linux/mlx5/transobj.h +@@ -85,4 +85,5 @@ mlx5_core_hairpin_create(struct mlx5_core_dev *func_mdev, + struct mlx5_hairpin_params *params); + + void mlx5_core_hairpin_destroy(struct mlx5_hairpin *pair); ++void mlx5_core_hairpin_clear_dead_peer(struct mlx5_hairpin *hp); + #endif /* __TRANSOBJ_H__ */ +diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h +index 5aacc1c10a45a..8f0fb62e8975c 100644 +--- a/include/linux/mm_types.h ++++ b/include/linux/mm_types.h +@@ -445,13 +445,6 @@ struct mm_struct { + */ + atomic_t has_pinned; + +- /** +- * @write_protect_seq: Locked when any thread is write +- * protecting pages mapped by this mm to enforce a later COW, +- * for instance during page table copying for fork(). +- */ +- seqcount_t write_protect_seq; +- + #ifdef CONFIG_MMU + atomic_long_t pgtables_bytes; /* PTE page table pages */ + #endif +@@ -460,6 +453,18 @@ struct mm_struct { + spinlock_t page_table_lock; /* Protects page tables and some + * counters + */ ++ /* ++ * With some kernel config, the current mmap_lock's offset ++ * inside 'mm_struct' is at 0x120, which is very optimal, as ++ * its two hot fields 'count' and 'owner' sit in 2 different ++ * cachelines, and when mmap_lock is highly contended, both ++ * of the 2 fields will be accessed frequently, current layout ++ * will help to reduce cache bouncing. ++ * ++ * So please be careful with adding new fields before ++ * mmap_lock, which can easily push the 2 fields into one ++ * cacheline. ++ */ + struct rw_semaphore mmap_lock; + + struct list_head mmlist; /* List of maybe swapped mm's. These +@@ -480,7 +485,15 @@ struct mm_struct { + unsigned long stack_vm; /* VM_STACK */ + unsigned long def_flags; + ++ /** ++ * @write_protect_seq: Locked when any thread is write ++ * protecting pages mapped by this mm to enforce a later COW, ++ * for instance during page table copying for fork(). ++ */ ++ seqcount_t write_protect_seq; ++ + spinlock_t arg_lock; /* protect the below fields */ ++ + unsigned long start_code, end_code, start_data, end_data; + unsigned long start_brk, brk, start_stack; + unsigned long arg_start, arg_end, env_start, env_end; +diff --git a/include/linux/ptp_clock_kernel.h b/include/linux/ptp_clock_kernel.h +index 0d47fd33b2285..51d7f1b8b32aa 100644 +--- a/include/linux/ptp_clock_kernel.h ++++ b/include/linux/ptp_clock_kernel.h +@@ -235,7 +235,7 @@ extern int ptp_clock_index(struct ptp_clock *ptp); + * @ppm: Parts per million, but with a 16 bit binary fractional field + */ + +-extern s32 scaled_ppm_to_ppb(long ppm); ++extern long scaled_ppm_to_ppb(long ppm); + + /** + * ptp_find_pin() - obtain the pin index of a given auxiliary function +diff --git a/include/linux/socket.h b/include/linux/socket.h +index 385894b4a8bba..42222a84167f3 100644 +--- a/include/linux/socket.h ++++ b/include/linux/socket.h +@@ -438,6 +438,4 @@ extern int __sys_socketpair(int family, int type, int protocol, + int __user *usockvec); + extern int __sys_shutdown_sock(struct socket *sock, int how); + extern int __sys_shutdown(int fd, int how); +- +-extern struct ns_common *get_net_ns(struct ns_common *ns); + #endif /* _LINUX_SOCKET_H */ +diff --git a/include/linux/swapops.h b/include/linux/swapops.h +index d9b7c9132c2f6..6430a94c69818 100644 +--- a/include/linux/swapops.h ++++ b/include/linux/swapops.h +@@ -23,6 +23,16 @@ + #define SWP_TYPE_SHIFT (BITS_PER_XA_VALUE - MAX_SWAPFILES_SHIFT) + #define SWP_OFFSET_MASK ((1UL << SWP_TYPE_SHIFT) - 1) + ++/* Clear all flags but only keep swp_entry_t related information */ ++static inline pte_t pte_swp_clear_flags(pte_t pte) ++{ ++ if (pte_swp_soft_dirty(pte)) ++ pte = pte_swp_clear_soft_dirty(pte); ++ if (pte_swp_uffd_wp(pte)) ++ pte = pte_swp_clear_uffd_wp(pte); ++ return pte; ++} ++ + /* + * Store a type+offset into a swp_entry_t in an arch-independent format + */ +@@ -66,10 +76,7 @@ static inline swp_entry_t pte_to_swp_entry(pte_t pte) + { + swp_entry_t arch_entry; + +- if (pte_swp_soft_dirty(pte)) +- pte = pte_swp_clear_soft_dirty(pte); +- if (pte_swp_uffd_wp(pte)) +- pte = pte_swp_clear_uffd_wp(pte); ++ pte = pte_swp_clear_flags(pte); + arch_entry = __pte_to_swp_entry(pte); + return swp_entry(__swp_type(arch_entry), __swp_offset(arch_entry)); + } +diff --git a/include/net/mac80211.h b/include/net/mac80211.h +index 2d1d629e5d14b..a5ca18cfdb6fb 100644 +--- a/include/net/mac80211.h ++++ b/include/net/mac80211.h +@@ -6388,7 +6388,12 @@ bool ieee80211_tx_prepare_skb(struct ieee80211_hw *hw, + + /** + * ieee80211_parse_tx_radiotap - Sanity-check and parse the radiotap header +- * of injected frames ++ * of injected frames. ++ * ++ * To accurately parse and take into account rate and retransmission fields, ++ * you must initialize the chandef field in the ieee80211_tx_info structure ++ * of the skb before calling this function. ++ * + * @skb: packet injected by userspace + * @dev: the &struct device of this 802.11 device + */ +diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h +index dcaee24a4d877..14b6f7f445322 100644 +--- a/include/net/net_namespace.h ++++ b/include/net/net_namespace.h +@@ -197,6 +197,8 @@ struct net *copy_net_ns(unsigned long flags, struct user_namespace *user_ns, + void net_ns_get_ownership(const struct net *net, kuid_t *uid, kgid_t *gid); + + void net_ns_barrier(void); ++ ++struct ns_common *get_net_ns(struct ns_common *ns); + #else /* CONFIG_NET_NS */ + #include + #include +@@ -216,6 +218,11 @@ static inline void net_ns_get_ownership(const struct net *net, + } + + static inline void net_ns_barrier(void) {} ++ ++static inline struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return ERR_PTR(-EINVAL); ++} + #endif /* CONFIG_NET_NS */ + + +diff --git a/include/uapi/linux/in.h b/include/uapi/linux/in.h +index 7d6687618d808..d1b327036ae43 100644 +--- a/include/uapi/linux/in.h ++++ b/include/uapi/linux/in.h +@@ -289,6 +289,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c +index 9e600767803b5..2423b4e918b90 100644 +--- a/kernel/bpf/verifier.c ++++ b/kernel/bpf/verifier.c +@@ -5937,6 +5937,27 @@ struct bpf_sanitize_info { + bool mask_to_left; + }; + ++static struct bpf_verifier_state * ++sanitize_speculative_path(struct bpf_verifier_env *env, ++ const struct bpf_insn *insn, ++ u32 next_idx, u32 curr_idx) ++{ ++ struct bpf_verifier_state *branch; ++ struct bpf_reg_state *regs; ++ ++ branch = push_stack(env, next_idx, curr_idx, true); ++ if (branch && insn) { ++ regs = branch->frame[branch->curframe]->regs; ++ if (BPF_SRC(insn->code) == BPF_K) { ++ mark_reg_unknown(env, regs, insn->dst_reg); ++ } else if (BPF_SRC(insn->code) == BPF_X) { ++ mark_reg_unknown(env, regs, insn->dst_reg); ++ mark_reg_unknown(env, regs, insn->src_reg); ++ } ++ } ++ return branch; ++} ++ + static int sanitize_ptr_alu(struct bpf_verifier_env *env, + struct bpf_insn *insn, + const struct bpf_reg_state *ptr_reg, +@@ -6020,12 +6041,26 @@ do_sim: + tmp = *dst_reg; + *dst_reg = *ptr_reg; + } +- ret = push_stack(env, env->insn_idx + 1, env->insn_idx, true); ++ ret = sanitize_speculative_path(env, NULL, env->insn_idx + 1, ++ env->insn_idx); + if (!ptr_is_dst_reg && ret) + *dst_reg = tmp; + return !ret ? REASON_STACK : 0; + } + ++static void sanitize_mark_insn_seen(struct bpf_verifier_env *env) ++{ ++ struct bpf_verifier_state *vstate = env->cur_state; ++ ++ /* If we simulate paths under speculation, we don't update the ++ * insn as 'seen' such that when we verify unreachable paths in ++ * the non-speculative domain, sanitize_dead_code() can still ++ * rewrite/sanitize them. ++ */ ++ if (!vstate->speculative) ++ env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++} ++ + static int sanitize_err(struct bpf_verifier_env *env, + const struct bpf_insn *insn, int reason, + const struct bpf_reg_state *off_reg, +@@ -8204,14 +8239,28 @@ static int check_cond_jmp_op(struct bpf_verifier_env *env, + if (err) + return err; + } ++ + if (pred == 1) { +- /* only follow the goto, ignore fall-through */ ++ /* Only follow the goto, ignore fall-through. If needed, push ++ * the fall-through branch for simulation under speculative ++ * execution. ++ */ ++ if (!env->bypass_spec_v1 && ++ !sanitize_speculative_path(env, insn, *insn_idx + 1, ++ *insn_idx)) ++ return -EFAULT; + *insn_idx += insn->off; + return 0; + } else if (pred == 0) { +- /* only follow fall-through branch, since +- * that's where the program will go ++ /* Only follow the fall-through branch, since that's where the ++ * program will go. If needed, push the goto branch for ++ * simulation under speculative execution. + */ ++ if (!env->bypass_spec_v1 && ++ !sanitize_speculative_path(env, insn, ++ *insn_idx + insn->off + 1, ++ *insn_idx)) ++ return -EFAULT; + return 0; + } + +@@ -10060,7 +10109,7 @@ static int do_check(struct bpf_verifier_env *env) + } + + regs = cur_regs(env); +- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++ sanitize_mark_insn_seen(env); + prev_insn_idx = env->insn_idx; + + if (class == BPF_ALU || class == BPF_ALU64) { +@@ -10285,7 +10334,7 @@ process_bpf_exit: + return err; + + env->insn_idx++; +- env->insn_aux_data[env->insn_idx].seen = env->pass_cnt; ++ sanitize_mark_insn_seen(env); + } else { + verbose(env, "invalid BPF_LD mode\n"); + return -EINVAL; +@@ -10784,6 +10833,7 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, + { + struct bpf_insn_aux_data *new_data, *old_data = env->insn_aux_data; + struct bpf_insn *insn = new_prog->insnsi; ++ u32 old_seen = old_data[off].seen; + u32 prog_len; + int i; + +@@ -10804,7 +10854,8 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, + memcpy(new_data + off + cnt - 1, old_data + off, + sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1)); + for (i = off; i < off + cnt - 1; i++) { +- new_data[i].seen = env->pass_cnt; ++ /* Expand insni[off]'s seen count to the patched range. */ ++ new_data[i].seen = old_seen; + new_data[i].zext_dst = insn_has_def32(env, insn + i); + } + env->insn_aux_data = new_data; +@@ -12060,6 +12111,9 @@ static void free_states(struct bpf_verifier_env *env) + * insn_aux_data was touched. These variables are compared to clear temporary + * data from failed pass. For testing and experiments do_check_common() can be + * run multiple times even when prior attempt to verify is unsuccessful. ++ * ++ * Note that special handling is needed on !env->bypass_spec_v1 if this is ++ * ever called outside of error path with subsequent program rejection. + */ + static void sanitize_insn_aux_data(struct bpf_verifier_env *env) + { +diff --git a/kernel/crash_core.c b/kernel/crash_core.c +index 825284baaf466..684a6061a13a4 100644 +--- a/kernel/crash_core.c ++++ b/kernel/crash_core.c +@@ -464,6 +464,7 @@ static int __init crash_save_vmcoreinfo_init(void) + VMCOREINFO_LENGTH(mem_section, NR_SECTION_ROOTS); + VMCOREINFO_STRUCT_SIZE(mem_section); + VMCOREINFO_OFFSET(mem_section, section_mem_map); ++ VMCOREINFO_NUMBER(SECTION_SIZE_BITS); + VMCOREINFO_NUMBER(MAX_PHYSMEM_BITS); + #endif + VMCOREINFO_STRUCT_SIZE(page); +diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c +index 487312a5ceabb..47fcc3fe9dc5a 100644 +--- a/kernel/sched/fair.c ++++ b/kernel/sched/fair.c +@@ -3760,11 +3760,17 @@ static void attach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *s + */ + static void detach_entity_load_avg(struct cfs_rq *cfs_rq, struct sched_entity *se) + { ++ /* ++ * cfs_rq->avg.period_contrib can be used for both cfs_rq and se. ++ * See ___update_load_avg() for details. ++ */ ++ u32 divider = get_pelt_divider(&cfs_rq->avg); ++ + dequeue_load_avg(cfs_rq, se); + sub_positive(&cfs_rq->avg.util_avg, se->avg.util_avg); +- sub_positive(&cfs_rq->avg.util_sum, se->avg.util_sum); ++ cfs_rq->avg.util_sum = cfs_rq->avg.util_avg * divider; + sub_positive(&cfs_rq->avg.runnable_avg, se->avg.runnable_avg); +- sub_positive(&cfs_rq->avg.runnable_sum, se->avg.runnable_sum); ++ cfs_rq->avg.runnable_sum = cfs_rq->avg.runnable_avg * divider; + + add_tg_cfs_propagate(cfs_rq, -se->avg.load_sum); + +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index f2d4ee80feb34..7c8151d74faf0 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2198,9 +2198,6 @@ struct saved_cmdlines_buffer { + }; + static struct saved_cmdlines_buffer *savedcmd; + +-/* temporary disable recording */ +-static atomic_t trace_record_taskinfo_disabled __read_mostly; +- + static inline char *get_saved_cmdlines(int idx) + { + return &savedcmd->saved_cmdlines[idx * TASK_COMM_LEN]; +@@ -2486,8 +2483,6 @@ static bool tracing_record_taskinfo_skip(int flags) + { + if (unlikely(!(flags & (TRACE_RECORD_CMDLINE | TRACE_RECORD_TGID)))) + return true; +- if (atomic_read(&trace_record_taskinfo_disabled) || !tracing_is_on()) +- return true; + if (!__this_cpu_read(trace_taskinfo_save)) + return true; + return false; +@@ -3742,9 +3737,6 @@ static void *s_start(struct seq_file *m, loff_t *pos) + return ERR_PTR(-EBUSY); + #endif + +- if (!iter->snapshot) +- atomic_inc(&trace_record_taskinfo_disabled); +- + if (*pos != iter->pos) { + iter->ent = NULL; + iter->cpu = 0; +@@ -3787,9 +3779,6 @@ static void s_stop(struct seq_file *m, void *p) + return; + #endif + +- if (!iter->snapshot) +- atomic_dec(&trace_record_taskinfo_disabled); +- + trace_access_unlock(iter->cpu_file); + trace_event_read_unlock(); + } +diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c +index c1637f90c8a38..4702efb00ff21 100644 +--- a/kernel/trace/trace_clock.c ++++ b/kernel/trace/trace_clock.c +@@ -115,9 +115,9 @@ u64 notrace trace_clock_global(void) + prev_time = READ_ONCE(trace_clock_struct.prev_time); + now = sched_clock_cpu(this_cpu); + +- /* Make sure that now is always greater than prev_time */ ++ /* Make sure that now is always greater than or equal to prev_time */ + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + /* + * If in an NMI context then dont risk lockups and simply return +@@ -131,7 +131,7 @@ u64 notrace trace_clock_global(void) + /* Reread prev_time in case it was already updated */ + prev_time = READ_ONCE(trace_clock_struct.prev_time); + if ((s64)(now - prev_time) < 0) +- now = prev_time + 1; ++ now = prev_time; + + trace_clock_struct.prev_time = now; + +diff --git a/mm/hugetlb.c b/mm/hugetlb.c +index ce63ec0187c55..3da4817190f3d 100644 +--- a/mm/hugetlb.c ++++ b/mm/hugetlb.c +@@ -2127,12 +2127,18 @@ out: + * be restored when a newly allocated huge page must be freed. It is + * to be called after calling vma_needs_reservation to determine if a + * reservation exists. ++ * ++ * vma_del_reservation is used in error paths where an entry in the reserve ++ * map was created during huge page allocation and must be removed. It is to ++ * be called after calling vma_needs_reservation to determine if a reservation ++ * exists. + */ + enum vma_resv_mode { + VMA_NEEDS_RESV, + VMA_COMMIT_RESV, + VMA_END_RESV, + VMA_ADD_RESV, ++ VMA_DEL_RESV, + }; + static long __vma_reservation_common(struct hstate *h, + struct vm_area_struct *vma, unsigned long addr, +@@ -2176,11 +2182,21 @@ static long __vma_reservation_common(struct hstate *h, + ret = region_del(resv, idx, idx + 1); + } + break; ++ case VMA_DEL_RESV: ++ if (vma->vm_flags & VM_MAYSHARE) { ++ region_abort(resv, idx, idx + 1, 1); ++ ret = region_del(resv, idx, idx + 1); ++ } else { ++ ret = region_add(resv, idx, idx + 1, 1, NULL, NULL); ++ /* region_add calls of range 1 should never fail. */ ++ VM_BUG_ON(ret < 0); ++ } ++ break; + default: + BUG(); + } + +- if (vma->vm_flags & VM_MAYSHARE) ++ if (vma->vm_flags & VM_MAYSHARE || mode == VMA_DEL_RESV) + return ret; + else if (is_vma_resv_set(vma, HPAGE_RESV_OWNER) && ret >= 0) { + /* +@@ -2229,25 +2245,39 @@ static long vma_add_reservation(struct hstate *h, + return __vma_reservation_common(h, vma, addr, VMA_ADD_RESV); + } + ++static long vma_del_reservation(struct hstate *h, ++ struct vm_area_struct *vma, unsigned long addr) ++{ ++ return __vma_reservation_common(h, vma, addr, VMA_DEL_RESV); ++} ++ + /* +- * This routine is called to restore a reservation on error paths. In the +- * specific error paths, a huge page was allocated (via alloc_huge_page) +- * and is about to be freed. If a reservation for the page existed, +- * alloc_huge_page would have consumed the reservation and set +- * HPageRestoreReserve in the newly allocated page. When the page is freed +- * via free_huge_page, the global reservation count will be incremented if +- * HPageRestoreReserve is set. However, free_huge_page can not adjust the +- * reserve map. Adjust the reserve map here to be consistent with global +- * reserve count adjustments to be made by free_huge_page. ++ * This routine is called to restore reservation information on error paths. ++ * It should ONLY be called for pages allocated via alloc_huge_page(), and ++ * the hugetlb mutex should remain held when calling this routine. ++ * ++ * It handles two specific cases: ++ * 1) A reservation was in place and the page consumed the reservation. ++ * HPageRestoreReserve is set in the page. ++ * 2) No reservation was in place for the page, so HPageRestoreReserve is ++ * not set. However, alloc_huge_page always updates the reserve map. ++ * ++ * In case 1, free_huge_page later in the error path will increment the ++ * global reserve count. But, free_huge_page does not have enough context ++ * to adjust the reservation map. This case deals primarily with private ++ * mappings. Adjust the reserve map here to be consistent with global ++ * reserve count adjustments to be made by free_huge_page. Make sure the ++ * reserve map indicates there is a reservation present. ++ * ++ * In case 2, simply undo reserve map modifications done by alloc_huge_page. + */ +-static void restore_reserve_on_error(struct hstate *h, +- struct vm_area_struct *vma, unsigned long address, +- struct page *page) ++void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma, ++ unsigned long address, struct page *page) + { +- if (unlikely(HPageRestoreReserve(page))) { +- long rc = vma_needs_reservation(h, vma, address); ++ long rc = vma_needs_reservation(h, vma, address); + +- if (unlikely(rc < 0)) { ++ if (HPageRestoreReserve(page)) { ++ if (unlikely(rc < 0)) + /* + * Rare out of memory condition in reserve map + * manipulation. Clear HPageRestoreReserve so that +@@ -2260,16 +2290,57 @@ static void restore_reserve_on_error(struct hstate *h, + * accounting of reserve counts. + */ + ClearHPageRestoreReserve(page); +- } else if (rc) { +- rc = vma_add_reservation(h, vma, address); +- if (unlikely(rc < 0)) ++ else if (rc) ++ (void)vma_add_reservation(h, vma, address); ++ else ++ vma_end_reservation(h, vma, address); ++ } else { ++ if (!rc) { ++ /* ++ * This indicates there is an entry in the reserve map ++ * added by alloc_huge_page. We know it was added ++ * before the alloc_huge_page call, otherwise ++ * HPageRestoreReserve would be set on the page. ++ * Remove the entry so that a subsequent allocation ++ * does not consume a reservation. ++ */ ++ rc = vma_del_reservation(h, vma, address); ++ if (rc < 0) + /* +- * See above comment about rare out of +- * memory condition. ++ * VERY rare out of memory condition. Since ++ * we can not delete the entry, set ++ * HPageRestoreReserve so that the reserve ++ * count will be incremented when the page ++ * is freed. This reserve will be consumed ++ * on a subsequent allocation. + */ +- ClearHPageRestoreReserve(page); ++ SetHPageRestoreReserve(page); ++ } else if (rc < 0) { ++ /* ++ * Rare out of memory condition from ++ * vma_needs_reservation call. Memory allocation is ++ * only attempted if a new entry is needed. Therefore, ++ * this implies there is not an entry in the ++ * reserve map. ++ * ++ * For shared mappings, no entry in the map indicates ++ * no reservation. We are done. ++ */ ++ if (!(vma->vm_flags & VM_MAYSHARE)) ++ /* ++ * For private mappings, no entry indicates ++ * a reservation is present. Since we can ++ * not add an entry, set SetHPageRestoreReserve ++ * on the page so reserve count will be ++ * incremented when freed. This reserve will ++ * be consumed on a subsequent allocation. ++ */ ++ SetHPageRestoreReserve(page); + } else +- vma_end_reservation(h, vma, address); ++ /* ++ * No reservation present, do nothing ++ */ ++ vma_end_reservation(h, vma, address); + } + } + +@@ -3886,6 +3957,8 @@ again: + spin_lock_nested(src_ptl, SINGLE_DEPTH_NESTING); + entry = huge_ptep_get(src_pte); + if (!pte_same(src_pte_old, entry)) { ++ restore_reserve_on_error(h, vma, addr, ++ new); + put_page(new); + /* dst_entry won't change as in child */ + goto again; +@@ -4820,6 +4893,7 @@ out_release_unlock: + if (vm_shared) + unlock_page(page); + out_release_nounlock: ++ restore_reserve_on_error(h, dst_vma, dst_addr, page); + put_page(page); + goto out; + } +@@ -5664,6 +5738,21 @@ unlock: + return ret; + } + ++int get_hwpoison_huge_page(struct page *page, bool *hugetlb) ++{ ++ int ret = 0; ++ ++ *hugetlb = false; ++ spin_lock_irq(&hugetlb_lock); ++ if (PageHeadHuge(page)) { ++ *hugetlb = true; ++ if (HPageFreed(page) || HPageMigratable(page)) ++ ret = get_page_unless_zero(page); ++ } ++ spin_unlock_irq(&hugetlb_lock); ++ return ret; ++} ++ + void putback_active_hugepage(struct page *page) + { + spin_lock(&hugetlb_lock); +diff --git a/mm/memory-failure.c b/mm/memory-failure.c +index bd3945446d47e..704d05057d8c3 100644 +--- a/mm/memory-failure.c ++++ b/mm/memory-failure.c +@@ -949,6 +949,17 @@ static int page_action(struct page_state *ps, struct page *p, + return (result == MF_RECOVERED || result == MF_DELAYED) ? 0 : -EBUSY; + } + ++/* ++ * Return true if a page type of a given page is supported by hwpoison ++ * mechanism (while handling could fail), otherwise false. This function ++ * does not return true for hugetlb or device memory pages, so it's assumed ++ * to be called only in the context where we never have such pages. ++ */ ++static inline bool HWPoisonHandlable(struct page *page) ++{ ++ return PageLRU(page) || __PageMovable(page); ++} ++ + /** + * __get_hwpoison_page() - Get refcount for memory error handling: + * @page: raw error page (hit by memory error) +@@ -959,8 +970,22 @@ static int page_action(struct page_state *ps, struct page *p, + static int __get_hwpoison_page(struct page *page) + { + struct page *head = compound_head(page); ++ int ret = 0; ++ bool hugetlb = false; ++ ++ ret = get_hwpoison_huge_page(head, &hugetlb); ++ if (hugetlb) ++ return ret; + +- if (!PageHuge(head) && PageTransHuge(head)) { ++ /* ++ * This check prevents from calling get_hwpoison_unless_zero() ++ * for any unsupported type of page in order to reduce the risk of ++ * unexpected races caused by taking a page refcount. ++ */ ++ if (!HWPoisonHandlable(head)) ++ return 0; ++ ++ if (PageTransHuge(head)) { + /* + * Non anonymous thp exists only in allocation/free time. We + * can't handle such a case correctly, so let's give it up. +@@ -1017,7 +1042,7 @@ try_again: + ret = -EIO; + } + } else { +- if (PageHuge(p) || PageLRU(p) || __PageMovable(p)) { ++ if (PageHuge(p) || HWPoisonHandlable(p)) { + ret = 1; + } else { + /* +@@ -1527,7 +1552,12 @@ try_again: + return 0; + } + +- if (!PageTransTail(p) && !PageLRU(p)) ++ /* ++ * __munlock_pagevec may clear a writeback page's LRU flag without ++ * page_lock. We need wait writeback completion for this page or it ++ * may trigger vfs BUG while evict inode. ++ */ ++ if (!PageTransTail(p) && !PageLRU(p) && !PageWriteback(p)) + goto identify_page_state; + + /* +diff --git a/mm/slab_common.c b/mm/slab_common.c +index 88e833986332e..ba2f4b01920fd 100644 +--- a/mm/slab_common.c ++++ b/mm/slab_common.c +@@ -89,8 +89,7 @@ EXPORT_SYMBOL(kmem_cache_size); + #ifdef CONFIG_DEBUG_VM + static int kmem_cache_sanity_check(const char *name, unsigned int size) + { +- if (!name || in_interrupt() || size < sizeof(void *) || +- size > KMALLOC_MAX_SIZE) { ++ if (!name || in_interrupt() || size > KMALLOC_MAX_SIZE) { + pr_err("kmem_cache_create(%s) integrity check failed\n", name); + return -EINVAL; + } +diff --git a/mm/slub.c b/mm/slub.c +index 3021ce9bf1b3d..602f9712ab53d 100644 +--- a/mm/slub.c ++++ b/mm/slub.c +@@ -15,6 +15,7 @@ + #include + #include + #include ++#include + #include + #include + #include "slab.h" +@@ -710,15 +711,15 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + p, p - addr, get_freepointer(s, p)); + + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, ++ print_section(KERN_ERR, "Redzone ", p - s->red_left_pad, + s->red_left_pad); + else if (p > addr + 16) + print_section(KERN_ERR, "Bytes b4 ", p - 16, 16); + +- print_section(KERN_ERR, "Object ", p, ++ print_section(KERN_ERR, "Object ", p, + min_t(unsigned int, s->object_size, PAGE_SIZE)); + if (s->flags & SLAB_RED_ZONE) +- print_section(KERN_ERR, "Redzone ", p + s->object_size, ++ print_section(KERN_ERR, "Redzone ", p + s->object_size, + s->inuse - s->object_size); + + off = get_info_end(s); +@@ -730,7 +731,7 @@ static void print_trailer(struct kmem_cache *s, struct page *page, u8 *p) + + if (off != size_from_object(s)) + /* Beginning of the filler is the free pointer */ +- print_section(KERN_ERR, "Padding ", p + off, ++ print_section(KERN_ERR, "Padding ", p + off, + size_from_object(s) - off); + + dump_stack(); +@@ -907,11 +908,11 @@ static int check_object(struct kmem_cache *s, struct page *page, + u8 *endobject = object + s->object_size; + + if (s->flags & SLAB_RED_ZONE) { +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Left Redzone", + object - s->red_left_pad, val, s->red_left_pad)) + return 0; + +- if (!check_bytes_and_report(s, page, object, "Redzone", ++ if (!check_bytes_and_report(s, page, object, "Right Redzone", + endobject, val, s->inuse - s->object_size)) + return 0; + } else { +@@ -926,7 +927,7 @@ static int check_object(struct kmem_cache *s, struct page *page, + if (val != SLUB_RED_ACTIVE && (s->flags & __OBJECT_POISON) && + (!check_bytes_and_report(s, page, p, "Poison", p, + POISON_FREE, s->object_size - 1) || +- !check_bytes_and_report(s, page, p, "Poison", ++ !check_bytes_and_report(s, page, p, "End Poison", + p + s->object_size - 1, POISON_END, 1))) + return 0; + /* +@@ -3687,7 +3688,6 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + { + slab_flags_t flags = s->flags; + unsigned int size = s->object_size; +- unsigned int freepointer_area; + unsigned int order; + + /* +@@ -3696,13 +3696,6 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + * the possible location of the free pointer. + */ + size = ALIGN(size, sizeof(void *)); +- /* +- * This is the area of the object where a freepointer can be +- * safely written. If redzoning adds more to the inuse size, we +- * can't use that portion for writing the freepointer, so +- * s->offset must be limited within this for the general case. +- */ +- freepointer_area = size; + + #ifdef CONFIG_SLUB_DEBUG + /* +@@ -3728,19 +3721,21 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + + /* + * With that we have determined the number of bytes in actual use +- * by the object. This is the potential offset to the free pointer. ++ * by the object and redzoning. + */ + s->inuse = size; + +- if (((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || +- s->ctor)) { ++ if ((flags & (SLAB_TYPESAFE_BY_RCU | SLAB_POISON)) || ++ ((flags & SLAB_RED_ZONE) && s->object_size < sizeof(void *)) || ++ s->ctor) { + /* + * Relocate free pointer after the object if it is not + * permitted to overwrite the first word of the object on + * kmem_cache_free. + * + * This is the case if we do RCU, have a constructor or +- * destructor or are poisoning the objects. ++ * destructor, are poisoning the objects, or are ++ * redzoning an object smaller than sizeof(void *). + * + * The assumption that s->offset >= s->inuse means free + * pointer is outside of the object is used in the +@@ -3749,13 +3744,13 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order) + */ + s->offset = size; + size += sizeof(void *); +- } else if (freepointer_area > sizeof(void *)) { ++ } else { + /* + * Store freelist pointer near middle of object to keep + * it away from the edges of the object to avoid small + * sized over/underflows from neighboring allocations. + */ +- s->offset = ALIGN(freepointer_area / 2, sizeof(void *)); ++ s->offset = ALIGN_DOWN(s->object_size / 2, sizeof(void *)); + } + + #ifdef CONFIG_SLUB_DEBUG +diff --git a/mm/swapfile.c b/mm/swapfile.c +index 084a5b9a18e5c..2097648df212d 100644 +--- a/mm/swapfile.c ++++ b/mm/swapfile.c +@@ -1900,7 +1900,7 @@ unsigned int count_swap_pages(int type, int free) + + static inline int pte_same_as_swp(pte_t pte, pte_t swp_pte) + { +- return pte_same(pte_swp_clear_soft_dirty(pte), swp_pte); ++ return pte_same(pte_swp_clear_flags(pte), swp_pte); + } + + /* +diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c +index a5e313cd6f447..b9dd150f6f01d 100644 +--- a/net/batman-adv/bat_iv_ogm.c ++++ b/net/batman-adv/bat_iv_ogm.c +@@ -409,8 +409,10 @@ static void batadv_iv_ogm_emit(struct batadv_forw_packet *forw_packet) + if (WARN_ON(!forw_packet->if_outgoing)) + return; + +- if (WARN_ON(forw_packet->if_outgoing->soft_iface != soft_iface)) ++ if (forw_packet->if_outgoing->soft_iface != soft_iface) { ++ pr_warn("%s: soft interface switch for queued OGM\n", __func__); + return; ++ } + + if (forw_packet->if_incoming->if_status != BATADV_IF_ACTIVE) + return; +diff --git a/net/bridge/br_private.h b/net/bridge/br_private.h +index af3430c2d6ea8..660dec6785ad9 100644 +--- a/net/bridge/br_private.h ++++ b/net/bridge/br_private.h +@@ -90,8 +90,8 @@ struct bridge_mcast_stats { + #endif + + struct br_tunnel_info { +- __be64 tunnel_id; +- struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; ++ struct metadata_dst __rcu *tunnel_dst; + }; + + /* private vlan flags */ +diff --git a/net/bridge/br_vlan_tunnel.c b/net/bridge/br_vlan_tunnel.c +index 169e005fbda29..debe167202782 100644 +--- a/net/bridge/br_vlan_tunnel.c ++++ b/net/bridge/br_vlan_tunnel.c +@@ -41,26 +41,33 @@ static struct net_bridge_vlan *br_vlan_tunnel_lookup(struct rhashtable *tbl, + br_vlan_tunnel_rht_params); + } + ++static void vlan_tunnel_info_release(struct net_bridge_vlan *vlan) ++{ ++ struct metadata_dst *tdst = rtnl_dereference(vlan->tinfo.tunnel_dst); ++ ++ WRITE_ONCE(vlan->tinfo.tunnel_id, 0); ++ RCU_INIT_POINTER(vlan->tinfo.tunnel_dst, NULL); ++ dst_release(&tdst->dst); ++} ++ + void vlan_tunnel_info_del(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan) + { +- if (!vlan->tinfo.tunnel_dst) ++ if (!rcu_access_pointer(vlan->tinfo.tunnel_dst)) + return; + rhashtable_remove_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +- vlan->tinfo.tunnel_id = 0; +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; ++ vlan_tunnel_info_release(vlan); + } + + static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + struct net_bridge_vlan *vlan, u32 tun_id) + { +- struct metadata_dst *metadata = NULL; ++ struct metadata_dst *metadata = rtnl_dereference(vlan->tinfo.tunnel_dst); + __be64 key = key32_to_tunnel_id(cpu_to_be32(tun_id)); + int err; + +- if (vlan->tinfo.tunnel_dst) ++ if (metadata) + return -EEXIST; + + metadata = __ip_tun_set_dst(0, 0, 0, 0, 0, TUNNEL_KEY, +@@ -69,8 +76,8 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + return -EINVAL; + + metadata->u.tun_info.mode |= IP_TUNNEL_INFO_TX | IP_TUNNEL_INFO_BRIDGE; +- vlan->tinfo.tunnel_dst = metadata; +- vlan->tinfo.tunnel_id = key; ++ rcu_assign_pointer(vlan->tinfo.tunnel_dst, metadata); ++ WRITE_ONCE(vlan->tinfo.tunnel_id, key); + + err = rhashtable_lookup_insert_fast(&vg->tunnel_hash, &vlan->tnode, + br_vlan_tunnel_rht_params); +@@ -79,9 +86,7 @@ static int __vlan_tunnel_info_add(struct net_bridge_vlan_group *vg, + + return 0; + out: +- dst_release(&vlan->tinfo.tunnel_dst->dst); +- vlan->tinfo.tunnel_dst = NULL; +- vlan->tinfo.tunnel_id = 0; ++ vlan_tunnel_info_release(vlan); + + return err; + } +@@ -182,12 +187,15 @@ int br_handle_ingress_vlan_tunnel(struct sk_buff *skb, + int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + struct net_bridge_vlan *vlan) + { ++ struct metadata_dst *tunnel_dst; ++ __be64 tunnel_id; + int err; + +- if (!vlan || !vlan->tinfo.tunnel_id) ++ if (!vlan) + return 0; + +- if (unlikely(!skb_vlan_tag_present(skb))) ++ tunnel_id = READ_ONCE(vlan->tinfo.tunnel_id); ++ if (!tunnel_id || unlikely(!skb_vlan_tag_present(skb))) + return 0; + + skb_dst_drop(skb); +@@ -195,7 +203,9 @@ int br_handle_egress_vlan_tunnel(struct sk_buff *skb, + if (err) + return err; + +- skb_dst_set(skb, dst_clone(&vlan->tinfo.tunnel_dst->dst)); ++ tunnel_dst = rcu_dereference(vlan->tinfo.tunnel_dst); ++ if (tunnel_dst && dst_hold_safe(&tunnel_dst->dst)) ++ skb_dst_set(skb, &tunnel_dst->dst); + + return 0; + } +diff --git a/net/can/bcm.c b/net/can/bcm.c +index 909b9e684e043..f3e4d9528fa38 100644 +--- a/net/can/bcm.c ++++ b/net/can/bcm.c +@@ -125,7 +125,7 @@ struct bcm_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + struct list_head rx_ops; + struct list_head tx_ops; + unsigned long dropped_usr_msgs; +@@ -133,6 +133,10 @@ struct bcm_sock { + char procname [32]; /* inode number in decimal with \0 */ + }; + ++static LIST_HEAD(bcm_notifier_list); ++static DEFINE_SPINLOCK(bcm_notifier_lock); ++static struct bcm_sock *bcm_busy_notifier; ++ + static inline struct bcm_sock *bcm_sk(const struct sock *sk) + { + return (struct bcm_sock *)sk; +@@ -402,6 +406,7 @@ static enum hrtimer_restart bcm_tx_timeout_handler(struct hrtimer *hrtimer) + if (!op->count && (op->flags & TX_COUNTEVT)) { + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = TX_EXPIRED; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -439,6 +444,7 @@ static void bcm_rx_changed(struct bcm_op *op, struct canfd_frame *data) + /* this element is not throttled anymore */ + data->flags &= (BCM_CAN_FLAGS_MASK|RX_RECV); + ++ memset(&head, 0, sizeof(head)); + head.opcode = RX_CHANGED; + head.flags = op->flags; + head.count = op->count; +@@ -560,6 +566,7 @@ static enum hrtimer_restart bcm_rx_timeout_handler(struct hrtimer *hrtimer) + } + + /* create notification to user */ ++ memset(&msg_head, 0, sizeof(msg_head)); + msg_head.opcode = RX_TIMEOUT; + msg_head.flags = op->flags; + msg_head.count = op->count; +@@ -1378,20 +1385,15 @@ static int bcm_sendmsg(struct socket *sock, struct msghdr *msg, size_t size) + /* + * notification handler for netdevice status changes + */ +-static int bcm_notifier(struct notifier_block *nb, unsigned long msg, +- void *ptr) ++static void bcm_notify(struct bcm_sock *bo, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct bcm_sock *bo = container_of(nb, struct bcm_sock, notifier); + struct sock *sk = &bo->sk; + struct bcm_op *op; + int notify_enodev = 0; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + +@@ -1426,7 +1428,28 @@ static int bcm_notifier(struct notifier_block *nb, unsigned long msg, + sk->sk_error_report(sk); + } + } ++} + ++static int bcm_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(bcm_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; ++ ++ spin_lock(&bcm_notifier_lock); ++ list_for_each_entry(bcm_busy_notifier, &bcm_notifier_list, notifier) { ++ spin_unlock(&bcm_notifier_lock); ++ bcm_notify(bcm_busy_notifier, msg, dev); ++ spin_lock(&bcm_notifier_lock); ++ } ++ bcm_busy_notifier = NULL; ++ spin_unlock(&bcm_notifier_lock); + return NOTIFY_DONE; + } + +@@ -1446,9 +1469,9 @@ static int bcm_init(struct sock *sk) + INIT_LIST_HEAD(&bo->rx_ops); + + /* set notifier */ +- bo->notifier.notifier_call = bcm_notifier; +- +- register_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ list_add_tail(&bo->notifier, &bcm_notifier_list); ++ spin_unlock(&bcm_notifier_lock); + + return 0; + } +@@ -1471,7 +1494,14 @@ static int bcm_release(struct socket *sock) + + /* remove bcm_ops, timer, rx_unregister(), etc. */ + +- unregister_netdevice_notifier(&bo->notifier); ++ spin_lock(&bcm_notifier_lock); ++ while (bcm_busy_notifier == bo) { ++ spin_unlock(&bcm_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&bcm_notifier_lock); ++ } ++ list_del(&bo->notifier); ++ spin_unlock(&bcm_notifier_lock); + + lock_sock(sk); + +@@ -1692,6 +1722,10 @@ static struct pernet_operations canbcm_pernet_ops __read_mostly = { + .exit = canbcm_pernet_exit, + }; + ++static struct notifier_block canbcm_notifier = { ++ .notifier_call = bcm_notifier ++}; ++ + static int __init bcm_module_init(void) + { + int err; +@@ -1705,12 +1739,14 @@ static int __init bcm_module_init(void) + } + + register_pernet_subsys(&canbcm_pernet_ops); ++ register_netdevice_notifier(&canbcm_notifier); + return 0; + } + + static void __exit bcm_module_exit(void) + { + can_proto_unregister(&bcm_can_proto); ++ unregister_netdevice_notifier(&canbcm_notifier); + unregister_pernet_subsys(&canbcm_pernet_ops); + } + +diff --git a/net/can/isotp.c b/net/can/isotp.c +index 253b24417c8e5..be6183f8ca110 100644 +--- a/net/can/isotp.c ++++ b/net/can/isotp.c +@@ -143,10 +143,14 @@ struct isotp_sock { + u32 force_tx_stmin; + u32 force_rx_stmin; + struct tpcon rx, tx; +- struct notifier_block notifier; ++ struct list_head notifier; + wait_queue_head_t wait; + }; + ++static LIST_HEAD(isotp_notifier_list); ++static DEFINE_SPINLOCK(isotp_notifier_lock); ++static struct isotp_sock *isotp_busy_notifier; ++ + static inline struct isotp_sock *isotp_sk(const struct sock *sk) + { + return (struct isotp_sock *)sk; +@@ -1013,7 +1017,14 @@ static int isotp_release(struct socket *sock) + /* wait for complete transmission of current pdu */ + wait_event_interruptible(so->wait, so->tx.state == ISOTP_IDLE); + +- unregister_netdevice_notifier(&so->notifier); ++ spin_lock(&isotp_notifier_lock); ++ while (isotp_busy_notifier == so) { ++ spin_unlock(&isotp_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&isotp_notifier_lock); ++ } ++ list_del(&so->notifier); ++ spin_unlock(&isotp_notifier_lock); + + lock_sock(sk); + +@@ -1317,21 +1328,16 @@ static int isotp_getsockopt(struct socket *sock, int level, int optname, + return 0; + } + +-static int isotp_notifier(struct notifier_block *nb, unsigned long msg, +- void *ptr) ++static void isotp_notify(struct isotp_sock *so, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct isotp_sock *so = container_of(nb, struct isotp_sock, notifier); + struct sock *sk = &so->sk; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + if (so->ifindex != dev->ifindex) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + case NETDEV_UNREGISTER: +@@ -1357,7 +1363,28 @@ static int isotp_notifier(struct notifier_block *nb, unsigned long msg, + sk->sk_error_report(sk); + break; + } ++} + ++static int isotp_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(isotp_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; ++ ++ spin_lock(&isotp_notifier_lock); ++ list_for_each_entry(isotp_busy_notifier, &isotp_notifier_list, notifier) { ++ spin_unlock(&isotp_notifier_lock); ++ isotp_notify(isotp_busy_notifier, msg, dev); ++ spin_lock(&isotp_notifier_lock); ++ } ++ isotp_busy_notifier = NULL; ++ spin_unlock(&isotp_notifier_lock); + return NOTIFY_DONE; + } + +@@ -1394,8 +1421,9 @@ static int isotp_init(struct sock *sk) + + init_waitqueue_head(&so->wait); + +- so->notifier.notifier_call = isotp_notifier; +- register_netdevice_notifier(&so->notifier); ++ spin_lock(&isotp_notifier_lock); ++ list_add_tail(&so->notifier, &isotp_notifier_list); ++ spin_unlock(&isotp_notifier_lock); + + return 0; + } +@@ -1442,6 +1470,10 @@ static const struct can_proto isotp_can_proto = { + .prot = &isotp_proto, + }; + ++static struct notifier_block canisotp_notifier = { ++ .notifier_call = isotp_notifier ++}; ++ + static __init int isotp_module_init(void) + { + int err; +@@ -1451,6 +1483,8 @@ static __init int isotp_module_init(void) + err = can_proto_register(&isotp_can_proto); + if (err < 0) + pr_err("can: registration of isotp protocol failed\n"); ++ else ++ register_netdevice_notifier(&canisotp_notifier); + + return err; + } +@@ -1458,6 +1492,7 @@ static __init int isotp_module_init(void) + static __exit void isotp_module_exit(void) + { + can_proto_unregister(&isotp_can_proto); ++ unregister_netdevice_notifier(&canisotp_notifier); + } + + module_init(isotp_module_init); +diff --git a/net/can/j1939/transport.c b/net/can/j1939/transport.c +index e09d087ba2409..c3946c3558826 100644 +--- a/net/can/j1939/transport.c ++++ b/net/can/j1939/transport.c +@@ -330,6 +330,9 @@ static void j1939_session_skb_drop_old(struct j1939_session *session) + + if ((do_skcb->offset + do_skb->len) < offset_start) { + __skb_unlink(do_skb, &session->skb_queue); ++ /* drop ref taken in j1939_session_skb_queue() */ ++ skb_unref(do_skb); ++ + kfree_skb(do_skb); + } + spin_unlock_irqrestore(&session->skb_queue.lock, flags); +@@ -349,12 +352,13 @@ void j1939_session_skb_queue(struct j1939_session *session, + + skcb->flags |= J1939_ECU_LOCAL_SRC; + ++ skb_get(skb); + skb_queue_tail(&session->skb_queue, skb); + } + + static struct +-sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, +- unsigned int offset_start) ++sk_buff *j1939_session_skb_get_by_offset(struct j1939_session *session, ++ unsigned int offset_start) + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *do_skcb; +@@ -371,6 +375,10 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + skb = do_skb; + } + } ++ ++ if (skb) ++ skb_get(skb); ++ + spin_unlock_irqrestore(&session->skb_queue.lock, flags); + + if (!skb) +@@ -381,12 +389,12 @@ sk_buff *j1939_session_skb_find_by_offset(struct j1939_session *session, + return skb; + } + +-static struct sk_buff *j1939_session_skb_find(struct j1939_session *session) ++static struct sk_buff *j1939_session_skb_get(struct j1939_session *session) + { + unsigned int offset_start; + + offset_start = session->pkt.dpo * 7; +- return j1939_session_skb_find_by_offset(session, offset_start); ++ return j1939_session_skb_get_by_offset(session, offset_start); + } + + /* see if we are receiver +@@ -776,7 +784,7 @@ static int j1939_session_tx_dat(struct j1939_session *session) + int ret = 0; + u8 dat[8]; + +- se_skb = j1939_session_skb_find_by_offset(session, session->pkt.tx * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, session->pkt.tx * 7); + if (!se_skb) + return -ENOBUFS; + +@@ -801,7 +809,8 @@ static int j1939_session_tx_dat(struct j1939_session *session) + netdev_err_once(priv->ndev, + "%s: 0x%p: requested data outside of queued buffer: offset %i, len %i, pkt.tx: %i\n", + __func__, session, skcb->offset, se_skb->len , session->pkt.tx); +- return -EOVERFLOW; ++ ret = -EOVERFLOW; ++ goto out_free; + } + + if (!len) { +@@ -835,6 +844,12 @@ static int j1939_session_tx_dat(struct j1939_session *session) + if (pkt_done) + j1939_tp_set_rxtimeout(session, 250); + ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ + return ret; + } + +@@ -1007,7 +1022,7 @@ static int j1939_xtp_txnext_receiver(struct j1939_session *session) + static int j1939_simple_txnext(struct j1939_session *session) + { + struct j1939_priv *priv = session->priv; +- struct sk_buff *se_skb = j1939_session_skb_find(session); ++ struct sk_buff *se_skb = j1939_session_skb_get(session); + struct sk_buff *skb; + int ret; + +@@ -1015,8 +1030,10 @@ static int j1939_simple_txnext(struct j1939_session *session) + return 0; + + skb = skb_clone(se_skb, GFP_ATOMIC); +- if (!skb) +- return -ENOMEM; ++ if (!skb) { ++ ret = -ENOMEM; ++ goto out_free; ++ } + + can_skb_set_owner(skb, se_skb->sk); + +@@ -1024,12 +1041,18 @@ static int j1939_simple_txnext(struct j1939_session *session) + + ret = j1939_send_one(priv, skb); + if (ret) +- return ret; ++ goto out_free; + + j1939_sk_errqueue(session, J1939_ERRQUEUE_SCHED); + j1939_sk_queue_activate_next(session); + +- return 0; ++ out_free: ++ if (ret) ++ kfree_skb(se_skb); ++ else ++ consume_skb(se_skb); ++ ++ return ret; + } + + static bool j1939_session_deactivate_locked(struct j1939_session *session) +@@ -1170,9 +1193,10 @@ static void j1939_session_completed(struct j1939_session *session) + struct sk_buff *skb; + + if (!session->transmission) { +- skb = j1939_session_skb_find(session); ++ skb = j1939_session_skb_get(session); + /* distribute among j1939 receivers */ + j1939_sk_recv(session->priv, skb); ++ consume_skb(skb); + } + + j1939_session_deactivate_activate_next(session); +@@ -1744,7 +1768,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + { + struct j1939_priv *priv = session->priv; + struct j1939_sk_buff_cb *skcb; +- struct sk_buff *se_skb; ++ struct sk_buff *se_skb = NULL; + const u8 *dat; + u8 *tpdat; + int offset; +@@ -1786,7 +1810,7 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + goto out_session_cancel; + } + +- se_skb = j1939_session_skb_find_by_offset(session, packet * 7); ++ se_skb = j1939_session_skb_get_by_offset(session, packet * 7); + if (!se_skb) { + netdev_warn(priv->ndev, "%s: 0x%p: no skb found\n", __func__, + session); +@@ -1848,11 +1872,13 @@ static void j1939_xtp_rx_dat_one(struct j1939_session *session, + j1939_tp_set_rxtimeout(session, 250); + } + session->last_cmd = 0xff; ++ consume_skb(se_skb); + j1939_session_put(session); + + return; + + out_session_cancel: ++ kfree_skb(se_skb); + j1939_session_timers_cancel(session); + j1939_session_cancel(session, J1939_XTP_ABORT_FAULT); + j1939_session_put(session); +diff --git a/net/can/raw.c b/net/can/raw.c +index 139d9471ddcf4..ac96fc2100253 100644 +--- a/net/can/raw.c ++++ b/net/can/raw.c +@@ -83,7 +83,7 @@ struct raw_sock { + struct sock sk; + int bound; + int ifindex; +- struct notifier_block notifier; ++ struct list_head notifier; + int loopback; + int recv_own_msgs; + int fd_frames; +@@ -95,6 +95,10 @@ struct raw_sock { + struct uniqframe __percpu *uniq; + }; + ++static LIST_HEAD(raw_notifier_list); ++static DEFINE_SPINLOCK(raw_notifier_lock); ++static struct raw_sock *raw_busy_notifier; ++ + /* Return pointer to store the extra msg flags for raw_recvmsg(). + * We use the space of one unsigned int beyond the 'struct sockaddr_can' + * in skb->cb. +@@ -263,21 +267,16 @@ static int raw_enable_allfilters(struct net *net, struct net_device *dev, + return err; + } + +-static int raw_notifier(struct notifier_block *nb, +- unsigned long msg, void *ptr) ++static void raw_notify(struct raw_sock *ro, unsigned long msg, ++ struct net_device *dev) + { +- struct net_device *dev = netdev_notifier_info_to_dev(ptr); +- struct raw_sock *ro = container_of(nb, struct raw_sock, notifier); + struct sock *sk = &ro->sk; + + if (!net_eq(dev_net(dev), sock_net(sk))) +- return NOTIFY_DONE; +- +- if (dev->type != ARPHRD_CAN) +- return NOTIFY_DONE; ++ return; + + if (ro->ifindex != dev->ifindex) +- return NOTIFY_DONE; ++ return; + + switch (msg) { + case NETDEV_UNREGISTER: +@@ -305,7 +304,28 @@ static int raw_notifier(struct notifier_block *nb, + sk->sk_error_report(sk); + break; + } ++} ++ ++static int raw_notifier(struct notifier_block *nb, unsigned long msg, ++ void *ptr) ++{ ++ struct net_device *dev = netdev_notifier_info_to_dev(ptr); ++ ++ if (dev->type != ARPHRD_CAN) ++ return NOTIFY_DONE; ++ if (msg != NETDEV_UNREGISTER && msg != NETDEV_DOWN) ++ return NOTIFY_DONE; ++ if (unlikely(raw_busy_notifier)) /* Check for reentrant bug. */ ++ return NOTIFY_DONE; + ++ spin_lock(&raw_notifier_lock); ++ list_for_each_entry(raw_busy_notifier, &raw_notifier_list, notifier) { ++ spin_unlock(&raw_notifier_lock); ++ raw_notify(raw_busy_notifier, msg, dev); ++ spin_lock(&raw_notifier_lock); ++ } ++ raw_busy_notifier = NULL; ++ spin_unlock(&raw_notifier_lock); + return NOTIFY_DONE; + } + +@@ -334,9 +354,9 @@ static int raw_init(struct sock *sk) + return -ENOMEM; + + /* set notifier */ +- ro->notifier.notifier_call = raw_notifier; +- +- register_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ list_add_tail(&ro->notifier, &raw_notifier_list); ++ spin_unlock(&raw_notifier_lock); + + return 0; + } +@@ -351,7 +371,14 @@ static int raw_release(struct socket *sock) + + ro = raw_sk(sk); + +- unregister_netdevice_notifier(&ro->notifier); ++ spin_lock(&raw_notifier_lock); ++ while (raw_busy_notifier == ro) { ++ spin_unlock(&raw_notifier_lock); ++ schedule_timeout_uninterruptible(1); ++ spin_lock(&raw_notifier_lock); ++ } ++ list_del(&ro->notifier); ++ spin_unlock(&raw_notifier_lock); + + lock_sock(sk); + +@@ -889,6 +916,10 @@ static const struct can_proto raw_can_proto = { + .prot = &raw_proto, + }; + ++static struct notifier_block canraw_notifier = { ++ .notifier_call = raw_notifier ++}; ++ + static __init int raw_module_init(void) + { + int err; +@@ -898,6 +929,8 @@ static __init int raw_module_init(void) + err = can_proto_register(&raw_can_proto); + if (err < 0) + pr_err("can: registration of raw protocol failed\n"); ++ else ++ register_netdevice_notifier(&canraw_notifier); + + return err; + } +@@ -905,6 +938,7 @@ static __init int raw_module_init(void) + static __exit void raw_module_exit(void) + { + can_proto_unregister(&raw_can_proto); ++ unregister_netdevice_notifier(&canraw_notifier); + } + + module_init(raw_module_init); +diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c +index 43b6ac4c44395..cc8dafb25d612 100644 +--- a/net/core/net_namespace.c ++++ b/net/core/net_namespace.c +@@ -641,6 +641,18 @@ void __put_net(struct net *net) + } + EXPORT_SYMBOL_GPL(__put_net); + ++/** ++ * get_net_ns - increment the refcount of the network namespace ++ * @ns: common namespace (net) ++ * ++ * Returns the net's common namespace. ++ */ ++struct ns_common *get_net_ns(struct ns_common *ns) ++{ ++ return &get_net(container_of(ns, struct net, ns))->ns; ++} ++EXPORT_SYMBOL_GPL(get_net_ns); ++ + struct net *get_net_ns_by_fd(int fd) + { + struct file *file; +diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c +index 9ad046917b340..2123427883baa 100644 +--- a/net/core/rtnetlink.c ++++ b/net/core/rtnetlink.c +@@ -4833,10 +4833,12 @@ static int rtnl_bridge_notify(struct net_device *dev) + if (err < 0) + goto errout; + +- if (!skb->len) { +- err = -EINVAL; ++ /* Notification info is only filled for bridge ports, not the bridge ++ * device itself. Therefore, a zero notification length is valid and ++ * should not result in an error. ++ */ ++ if (!skb->len) + goto errout; +- } + + rtnl_notify(skb, net, 0, RTNLGRP_LINK, NULL, GFP_ATOMIC); + return 0; +diff --git a/net/core/skbuff.c b/net/core/skbuff.c +index c421c8f809256..7997d99afbd8e 100644 +--- a/net/core/skbuff.c ++++ b/net/core/skbuff.c +@@ -1252,6 +1252,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg) + struct sock *sk = skb->sk; + struct sk_buff_head *q; + unsigned long flags; ++ bool is_zerocopy; + u32 lo, hi; + u16 len; + +@@ -1266,6 +1267,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg) + len = uarg->len; + lo = uarg->id; + hi = uarg->id + len - 1; ++ is_zerocopy = uarg->zerocopy; + + serr = SKB_EXT_ERR(skb); + memset(serr, 0, sizeof(*serr)); +@@ -1273,7 +1275,7 @@ static void __msg_zerocopy_callback(struct ubuf_info *uarg) + serr->ee.ee_origin = SO_EE_ORIGIN_ZEROCOPY; + serr->ee.ee_data = hi; + serr->ee.ee_info = lo; +- if (!uarg->zerocopy) ++ if (!is_zerocopy) + serr->ee.ee_code |= SO_EE_CODE_ZEROCOPY_COPIED; + + q = &sk->sk_error_queue; +diff --git a/net/ethtool/strset.c b/net/ethtool/strset.c +index c3a5489964cde..9908b922cce8d 100644 +--- a/net/ethtool/strset.c ++++ b/net/ethtool/strset.c +@@ -328,6 +328,8 @@ static int strset_reply_size(const struct ethnl_req_info *req_base, + int len = 0; + int ret; + ++ len += nla_total_size(0); /* ETHTOOL_A_STRSET_STRINGSETS */ ++ + for (i = 0; i < ETH_SS_COUNT; i++) { + const struct strset_info *set_info = &data->sets[i]; + +diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c +index bfaf327e9d121..e0480c6cebaad 100644 +--- a/net/ipv4/cipso_ipv4.c ++++ b/net/ipv4/cipso_ipv4.c +@@ -472,6 +472,7 @@ void cipso_v4_doi_free(struct cipso_v4_doi *doi_def) + kfree(doi_def->map.std->lvl.local); + kfree(doi_def->map.std->cat.cipso); + kfree(doi_def->map.std->cat.local); ++ kfree(doi_def->map.std); + break; + } + kfree(doi_def); +diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c +index 616e2dc1c8fa4..cd65d3146c300 100644 +--- a/net/ipv4/icmp.c ++++ b/net/ipv4/icmp.c +@@ -759,6 +759,13 @@ void __icmp_send(struct sk_buff *skb_in, int type, int code, __be32 info, + icmp_param.data_len = room; + icmp_param.head_len = sizeof(struct icmphdr); + ++ /* if we don't have a source address at this point, fall back to the ++ * dummy address instead of sending out a packet with a source address ++ * of 0.0.0.0 ++ */ ++ if (!fl4.saddr) ++ fl4.saddr = htonl(INADDR_DUMMY); ++ + icmp_push_reply(&icmp_param, &fl4, &ipc, &rt); + ende: + ip_rt_put(rt); +diff --git a/net/ipv4/igmp.c b/net/ipv4/igmp.c +index 7b272bbed2b43..6b3c558a4f232 100644 +--- a/net/ipv4/igmp.c ++++ b/net/ipv4/igmp.c +@@ -1801,6 +1801,7 @@ void ip_mc_destroy_dev(struct in_device *in_dev) + while ((i = rtnl_dereference(in_dev->mc_list)) != NULL) { + in_dev->mc_list = i->next_rcu; + in_dev->mc_count--; ++ ip_mc_clear_src(i); + ip_ma_put(i); + } + } +diff --git a/net/ipv4/route.c b/net/ipv4/route.c +index d635b4f32d348..09506203156d1 100644 +--- a/net/ipv4/route.c ++++ b/net/ipv4/route.c +@@ -2081,6 +2081,19 @@ martian_source: + return err; + } + ++/* get device for dst_alloc with local routes */ ++static struct net_device *ip_rt_get_dev(struct net *net, ++ const struct fib_result *res) ++{ ++ struct fib_nh_common *nhc = res->fi ? res->nhc : NULL; ++ struct net_device *dev = NULL; ++ ++ if (nhc) ++ dev = l3mdev_master_dev_rcu(nhc->nhc_dev); ++ ++ return dev ? : net->loopback_dev; ++} ++ + /* + * NOTE. We drop all the packets that has local source + * addresses, because every properly looped back packet +@@ -2237,7 +2250,7 @@ local_input: + } + } + +- rth = rt_dst_alloc(l3mdev_master_dev_rcu(dev) ? : net->loopback_dev, ++ rth = rt_dst_alloc(ip_rt_get_dev(net, res), + flags | RTCF_LOCAL, res->type, + IN_DEV_ORCONF(in_dev, NOPOLICY), false); + if (!rth) +diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c +index c586a6bb8c6d0..3dd340679d096 100644 +--- a/net/ipv4/udp.c ++++ b/net/ipv4/udp.c +@@ -2576,6 +2576,9 @@ void udp_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + bool slow = lock_sock_fast(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_flush_pending_frames(sk); + unlock_sock_fast(sk, slow); + if (static_branch_unlikely(&udp_encap_needed_key)) { +@@ -2826,10 +2829,17 @@ int udp_abort(struct sock *sk, int err) + { + lock_sock(sk); + ++ /* udp{v6}_destroy_sock() sets it under the sk lock, avoid racing ++ * with close() ++ */ ++ if (sock_flag(sk, SOCK_DEAD)) ++ goto out; ++ + sk->sk_err = err; + sk->sk_error_report(sk); + __udp_disconnect(sk, 0); + ++out: + release_sock(sk); + + return 0; +diff --git a/net/ipv6/netfilter/nft_fib_ipv6.c b/net/ipv6/netfilter/nft_fib_ipv6.c +index e204163c7036c..92f3235fa2874 100644 +--- a/net/ipv6/netfilter/nft_fib_ipv6.c ++++ b/net/ipv6/netfilter/nft_fib_ipv6.c +@@ -135,6 +135,17 @@ void nft_fib6_eval_type(const struct nft_expr *expr, struct nft_regs *regs, + } + EXPORT_SYMBOL_GPL(nft_fib6_eval_type); + ++static bool nft_fib_v6_skip_icmpv6(const struct sk_buff *skb, u8 next, const struct ipv6hdr *iph) ++{ ++ if (likely(next != IPPROTO_ICMPV6)) ++ return false; ++ ++ if (ipv6_addr_type(&iph->saddr) != IPV6_ADDR_ANY) ++ return false; ++ ++ return ipv6_addr_type(&iph->daddr) & IPV6_ADDR_LINKLOCAL; ++} ++ + void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, + const struct nft_pktinfo *pkt) + { +@@ -163,10 +174,13 @@ void nft_fib6_eval(const struct nft_expr *expr, struct nft_regs *regs, + + lookup_flags = nft_fib6_flowi_init(&fl6, priv, pkt, oif, iph); + +- if (nft_hook(pkt) == NF_INET_PRE_ROUTING && +- nft_fib_is_loopback(pkt->skb, nft_in(pkt))) { +- nft_fib_store_result(dest, priv, nft_in(pkt)); +- return; ++ if (nft_hook(pkt) == NF_INET_PRE_ROUTING || ++ nft_hook(pkt) == NF_INET_INGRESS) { ++ if (nft_fib_is_loopback(pkt->skb, nft_in(pkt)) || ++ nft_fib_v6_skip_icmpv6(pkt->skb, pkt->tprot, iph)) { ++ nft_fib_store_result(dest, priv, nft_in(pkt)); ++ return; ++ } + } + + *dest = 0; +diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c +index d25e5a9252fdb..29288f134d7ac 100644 +--- a/net/ipv6/udp.c ++++ b/net/ipv6/udp.c +@@ -1597,6 +1597,9 @@ void udpv6_destroy_sock(struct sock *sk) + { + struct udp_sock *up = udp_sk(sk); + lock_sock(sk); ++ ++ /* protects from races with udp_abort() */ ++ sock_set_flag(sk, SOCK_DEAD); + udp_v6_flush_pending_frames(sk); + release_sock(sk); + +diff --git a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c +index 5296898875ffb..223fbcafd6fce 100644 +--- a/net/mac80211/debugfs.c ++++ b/net/mac80211/debugfs.c +@@ -4,7 +4,7 @@ + * + * Copyright 2007 Johannes Berg + * Copyright 2013-2014 Intel Mobile Communications GmbH +- * Copyright (C) 2018 - 2019 Intel Corporation ++ * Copyright (C) 2018 - 2019, 2021 Intel Corporation + */ + + #include +@@ -387,10 +387,17 @@ static ssize_t reset_write(struct file *file, const char __user *user_buf, + size_t count, loff_t *ppos) + { + struct ieee80211_local *local = file->private_data; ++ int ret; + + rtnl_lock(); ++ wiphy_lock(local->hw.wiphy); + __ieee80211_suspend(&local->hw, NULL); +- __ieee80211_resume(&local->hw); ++ ret = __ieee80211_resume(&local->hw); ++ wiphy_unlock(local->hw.wiphy); ++ ++ if (ret) ++ cfg80211_shutdown_all_interfaces(local->hw.wiphy); ++ + rtnl_unlock(); + + return count; +diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c +index 6f8885766cbaa..6ebfd484e61d2 100644 +--- a/net/mac80211/iface.c ++++ b/net/mac80211/iface.c +@@ -475,14 +475,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata, bool going_do + GFP_KERNEL); + } + +- /* APs need special treatment */ + if (sdata->vif.type == NL80211_IFTYPE_AP) { +- struct ieee80211_sub_if_data *vlan, *tmpsdata; +- +- /* down all dependent devices, that is VLANs */ +- list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, +- u.vlan.list) +- dev_close(vlan->dev); + WARN_ON(!list_empty(&sdata->u.ap.vlans)); + } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) { + /* remove all packets in parent bc_buf pointing to this dev */ +@@ -640,6 +633,15 @@ static int ieee80211_stop(struct net_device *dev) + { + struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev); + ++ /* close all dependent VLAN interfaces before locking wiphy */ ++ if (sdata->vif.type == NL80211_IFTYPE_AP) { ++ struct ieee80211_sub_if_data *vlan, *tmpsdata; ++ ++ list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans, ++ u.vlan.list) ++ dev_close(vlan->dev); ++ } ++ + wiphy_lock(sdata->local->hw.wiphy); + ieee80211_do_stop(sdata, true); + wiphy_unlock(sdata->local->hw.wiphy); +@@ -1589,6 +1591,9 @@ static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata, + + switch (sdata->vif.type) { + case NL80211_IFTYPE_AP: ++ if (!list_empty(&sdata->u.ap.vlans)) ++ return -EBUSY; ++ break; + case NL80211_IFTYPE_STATION: + case NL80211_IFTYPE_ADHOC: + case NL80211_IFTYPE_OCB: +diff --git a/net/mac80211/main.c b/net/mac80211/main.c +index 0331f3a3c40e0..9dd741b68f268 100644 +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -252,6 +252,7 @@ static void ieee80211_restart_work(struct work_struct *work) + struct ieee80211_local *local = + container_of(work, struct ieee80211_local, restart_work); + struct ieee80211_sub_if_data *sdata; ++ int ret; + + /* wait for scan work complete */ + flush_workqueue(local->workqueue); +@@ -294,8 +295,12 @@ static void ieee80211_restart_work(struct work_struct *work) + /* wait for all packet processing to be done */ + synchronize_net(); + +- ieee80211_reconfig(local); ++ ret = ieee80211_reconfig(local); + wiphy_unlock(local->hw.wiphy); ++ ++ if (ret) ++ cfg80211_shutdown_all_interfaces(local->hw.wiphy); ++ + rtnl_unlock(); + } + +diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c +index ecad9b10984ff..e627a11844a9b 100644 +--- a/net/mac80211/rc80211_minstrel_ht.c ++++ b/net/mac80211/rc80211_minstrel_ht.c +@@ -1516,7 +1516,7 @@ minstrel_ht_get_rate(void *priv, struct ieee80211_sta *sta, void *priv_sta, + (info->control.flags & IEEE80211_TX_CTRL_PORT_CTRL_PROTO)) + return; + +- if (time_is_before_jiffies(mi->sample_time)) ++ if (time_is_after_jiffies(mi->sample_time)) + return; + + mi->sample_time = jiffies + MINSTREL_SAMPLE_INTERVAL; +diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c +index d4cc9ac2d7033..6b50cb5e0e3cc 100644 +--- a/net/mac80211/scan.c ++++ b/net/mac80211/scan.c +@@ -251,13 +251,24 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) + struct ieee80211_mgmt *mgmt = (void *)skb->data; + struct ieee80211_bss *bss; + struct ieee80211_channel *channel; ++ size_t min_hdr_len = offsetof(struct ieee80211_mgmt, ++ u.probe_resp.variable); ++ ++ if (!ieee80211_is_probe_resp(mgmt->frame_control) && ++ !ieee80211_is_beacon(mgmt->frame_control) && ++ !ieee80211_is_s1g_beacon(mgmt->frame_control)) ++ return; + + if (ieee80211_is_s1g_beacon(mgmt->frame_control)) { +- if (skb->len < 15) +- return; +- } else if (skb->len < 24 || +- (!ieee80211_is_probe_resp(mgmt->frame_control) && +- !ieee80211_is_beacon(mgmt->frame_control))) ++ if (ieee80211_is_s1g_short_beacon(mgmt->frame_control)) ++ min_hdr_len = offsetof(struct ieee80211_ext, ++ u.s1g_short_beacon.variable); ++ else ++ min_hdr_len = offsetof(struct ieee80211_ext, ++ u.s1g_beacon); ++ } ++ ++ if (skb->len < min_hdr_len) + return; + + sdata1 = rcu_dereference(local->scan_sdata); +diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c +index 28422d6870967..d33dc4e023715 100644 +--- a/net/mac80211/tx.c ++++ b/net/mac80211/tx.c +@@ -2002,6 +2002,26 @@ void ieee80211_xmit(struct ieee80211_sub_if_data *sdata, + ieee80211_tx(sdata, sta, skb, false); + } + ++static bool ieee80211_validate_radiotap_len(struct sk_buff *skb) ++{ ++ struct ieee80211_radiotap_header *rthdr = ++ (struct ieee80211_radiotap_header *)skb->data; ++ ++ /* check for not even having the fixed radiotap header part */ ++ if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) ++ return false; /* too short to be possibly valid */ ++ ++ /* is it a header version we can trust to find length from? */ ++ if (unlikely(rthdr->it_version)) ++ return false; /* only version 0 is supported */ ++ ++ /* does the skb contain enough to deliver on the alleged length? */ ++ if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) ++ return false; /* skb too short for claimed rt header extent */ ++ ++ return true; ++} ++ + bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + struct net_device *dev) + { +@@ -2010,8 +2030,6 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + struct ieee80211_radiotap_header *rthdr = + (struct ieee80211_radiotap_header *) skb->data; + struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); +- struct ieee80211_supported_band *sband = +- local->hw.wiphy->bands[info->band]; + int ret = ieee80211_radiotap_iterator_init(&iterator, rthdr, skb->len, + NULL); + u16 txflags; +@@ -2024,17 +2042,8 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + u8 vht_mcs = 0, vht_nss = 0; + int i; + +- /* check for not even having the fixed radiotap header part */ +- if (unlikely(skb->len < sizeof(struct ieee80211_radiotap_header))) +- return false; /* too short to be possibly valid */ +- +- /* is it a header version we can trust to find length from? */ +- if (unlikely(rthdr->it_version)) +- return false; /* only version 0 is supported */ +- +- /* does the skb contain enough to deliver on the alleged length? */ +- if (unlikely(skb->len < ieee80211_get_radiotap_len(skb->data))) +- return false; /* skb too short for claimed rt header extent */ ++ if (!ieee80211_validate_radiotap_len(skb)) ++ return false; + + info->flags |= IEEE80211_TX_INTFL_DONT_ENCRYPT | + IEEE80211_TX_CTL_DONTFRAG; +@@ -2174,6 +2183,9 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + return false; + + if (rate_found) { ++ struct ieee80211_supported_band *sband = ++ local->hw.wiphy->bands[info->band]; ++ + info->control.flags |= IEEE80211_TX_CTRL_RATE_INJECT; + + for (i = 0; i < IEEE80211_TX_MAX_RATES; i++) { +@@ -2187,7 +2199,7 @@ bool ieee80211_parse_tx_radiotap(struct sk_buff *skb, + } else if (rate_flags & IEEE80211_TX_RC_VHT_MCS) { + ieee80211_rate_set_vht(info->control.rates, vht_mcs, + vht_nss); +- } else { ++ } else if (sband) { + for (i = 0; i < sband->n_bitrates; i++) { + if (rate * 5 != sband->bitrates[i].bitrate) + continue; +@@ -2224,8 +2236,8 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, + info->flags = IEEE80211_TX_CTL_REQ_TX_STATUS | + IEEE80211_TX_CTL_INJECTED; + +- /* Sanity-check and process the injection radiotap header */ +- if (!ieee80211_parse_tx_radiotap(skb, dev)) ++ /* Sanity-check the length of the radiotap header */ ++ if (!ieee80211_validate_radiotap_len(skb)) + goto fail; + + /* we now know there is a radiotap header with a length we can use */ +@@ -2339,6 +2351,14 @@ netdev_tx_t ieee80211_monitor_start_xmit(struct sk_buff *skb, + ieee80211_select_queue_80211(sdata, skb, hdr); + skb_set_queue_mapping(skb, ieee80211_ac_from_tid(skb->priority)); + ++ /* ++ * Process the radiotap header. This will now take into account the ++ * selected chandef above to accurately set injection rates and ++ * retransmissions. ++ */ ++ if (!ieee80211_parse_tx_radiotap(skb, dev)) ++ goto fail_rcu; ++ + /* remove the injection radiotap header */ + skb_pull(skb, len_rthdr); + +diff --git a/net/mac80211/util.c b/net/mac80211/util.c +index c0fa526a45b4d..53755a05f73b5 100644 +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -2186,8 +2186,6 @@ static void ieee80211_handle_reconfig_failure(struct ieee80211_local *local) + list_for_each_entry(ctx, &local->chanctx_list, list) + ctx->driver_present = false; + mutex_unlock(&local->chanctx_mtx); +- +- cfg80211_shutdown_all_interfaces(local->hw.wiphy); + } + + static void ieee80211_assign_chanctx(struct ieee80211_local *local, +diff --git a/net/mptcp/options.c b/net/mptcp/options.c +index 8848a9e2a95b1..47d90cf31f125 100644 +--- a/net/mptcp/options.c ++++ b/net/mptcp/options.c +@@ -337,6 +337,8 @@ void mptcp_get_options(const struct sk_buff *skb, + length--; + continue; + default: ++ if (length < 2) ++ return; + opsize = *ptr++; + if (opsize < 2) /* "silly options" */ + return; +diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c +index 225b988215171..d8187ac065397 100644 +--- a/net/mptcp/protocol.c ++++ b/net/mptcp/protocol.c +@@ -287,11 +287,13 @@ static bool __mptcp_move_skb(struct mptcp_sock *msk, struct sock *ssk, + + /* try to fetch required memory from subflow */ + if (!sk_rmem_schedule(sk, skb, skb->truesize)) { +- if (ssk->sk_forward_alloc < skb->truesize) +- goto drop; +- __sk_mem_reclaim(ssk, skb->truesize); +- if (!sk_rmem_schedule(sk, skb, skb->truesize)) ++ int amount = sk_mem_pages(skb->truesize) << SK_MEM_QUANTUM_SHIFT; ++ ++ if (ssk->sk_forward_alloc < amount) + goto drop; ++ ++ ssk->sk_forward_alloc -= amount; ++ sk->sk_forward_alloc += amount; + } + + /* the skb map_seq accounts for the skb offset: +@@ -687,18 +689,22 @@ static bool __mptcp_ofo_queue(struct mptcp_sock *msk) + /* In most cases we will be able to lock the mptcp socket. If its already + * owned, we need to defer to the work queue to avoid ABBA deadlock. + */ +-static void move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk) ++static bool move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk) + { + struct sock *sk = (struct sock *)msk; + unsigned int moved = 0; + + if (inet_sk_state_load(sk) == TCP_CLOSE) +- return; +- +- mptcp_data_lock(sk); ++ return false; + + __mptcp_move_skbs_from_subflow(msk, ssk, &moved); + __mptcp_ofo_queue(msk); ++ if (unlikely(ssk->sk_err)) { ++ if (!sock_owned_by_user(sk)) ++ __mptcp_error_report(sk); ++ else ++ set_bit(MPTCP_ERROR_REPORT, &msk->flags); ++ } + + /* If the moves have caught up with the DATA_FIN sequence number + * it's time to ack the DATA_FIN and change socket state, but +@@ -707,7 +713,7 @@ static void move_skbs_to_msk(struct mptcp_sock *msk, struct sock *ssk) + */ + if (mptcp_pending_data_fin(sk, NULL)) + mptcp_schedule_work(sk); +- mptcp_data_unlock(sk); ++ return moved > 0; + } + + void mptcp_data_ready(struct sock *sk, struct sock *ssk) +@@ -715,7 +721,6 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk) + struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(ssk); + struct mptcp_sock *msk = mptcp_sk(sk); + int sk_rbuf, ssk_rbuf; +- bool wake; + + /* The peer can send data while we are shutting down this + * subflow at msk destruction time, but we must avoid enqueuing +@@ -724,28 +729,22 @@ void mptcp_data_ready(struct sock *sk, struct sock *ssk) + if (unlikely(subflow->disposable)) + return; + +- /* move_skbs_to_msk below can legitly clear the data_avail flag, +- * but we will need later to properly woke the reader, cache its +- * value +- */ +- wake = subflow->data_avail == MPTCP_SUBFLOW_DATA_AVAIL; +- if (wake) +- set_bit(MPTCP_DATA_READY, &msk->flags); +- + ssk_rbuf = READ_ONCE(ssk->sk_rcvbuf); + sk_rbuf = READ_ONCE(sk->sk_rcvbuf); + if (unlikely(ssk_rbuf > sk_rbuf)) + sk_rbuf = ssk_rbuf; + +- /* over limit? can't append more skbs to msk */ ++ /* over limit? can't append more skbs to msk, Also, no need to wake-up*/ + if (atomic_read(&sk->sk_rmem_alloc) > sk_rbuf) +- goto wake; +- +- move_skbs_to_msk(msk, ssk); ++ return; + +-wake: +- if (wake) ++ /* Wake-up the reader only for in-sequence data */ ++ mptcp_data_lock(sk); ++ if (move_skbs_to_msk(msk, ssk)) { ++ set_bit(MPTCP_DATA_READY, &msk->flags); + sk->sk_data_ready(sk); ++ } ++ mptcp_data_unlock(sk); + } + + void __mptcp_flush_join_list(struct mptcp_sock *msk) +@@ -848,7 +847,7 @@ static struct sock *mptcp_subflow_recv_lookup(const struct mptcp_sock *msk) + sock_owned_by_me(sk); + + mptcp_for_each_subflow(msk, subflow) { +- if (subflow->data_avail) ++ if (READ_ONCE(subflow->data_avail)) + return mptcp_subflow_tcp_sock(subflow); + } + +@@ -1939,6 +1938,9 @@ static bool __mptcp_move_skbs(struct mptcp_sock *msk) + done = __mptcp_move_skbs_from_subflow(msk, ssk, &moved); + mptcp_data_unlock(sk); + tcp_cleanup_rbuf(ssk, moved); ++ ++ if (unlikely(ssk->sk_err)) ++ __mptcp_error_report(sk); + unlock_sock_fast(ssk, slowpath); + } while (!done); + +diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h +index e21a5bc36cf08..14e89e4bd4a80 100644 +--- a/net/mptcp/protocol.h ++++ b/net/mptcp/protocol.h +@@ -372,7 +372,6 @@ mptcp_subflow_rsk(const struct request_sock *rsk) + enum mptcp_data_avail { + MPTCP_SUBFLOW_NODATA, + MPTCP_SUBFLOW_DATA_AVAIL, +- MPTCP_SUBFLOW_OOO_DATA + }; + + struct mptcp_delegated_action { +diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c +index 8425cd393bf3e..d6d8ad4f918e7 100644 +--- a/net/mptcp/subflow.c ++++ b/net/mptcp/subflow.c +@@ -754,10 +754,10 @@ static u64 expand_seq(u64 old_seq, u16 old_data_len, u64 seq) + return seq | ((old_seq + old_data_len + 1) & GENMASK_ULL(63, 32)); + } + +-static void warn_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) ++static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) + { +- WARN_ONCE(1, "Bad mapping: ssn=%d map_seq=%d map_data_len=%d", +- ssn, subflow->map_subflow_seq, subflow->map_data_len); ++ pr_debug("Bad mapping: ssn=%d map_seq=%d map_data_len=%d", ++ ssn, subflow->map_subflow_seq, subflow->map_data_len); + } + + static bool skb_is_fully_mapped(struct sock *ssk, struct sk_buff *skb) +@@ -782,13 +782,13 @@ static bool validate_mapping(struct sock *ssk, struct sk_buff *skb) + /* Mapping covers data later in the subflow stream, + * currently unsupported. + */ +- warn_bad_map(subflow, ssn); ++ dbg_bad_map(subflow, ssn); + return false; + } + if (unlikely(!before(ssn, subflow->map_subflow_seq + + subflow->map_data_len))) { + /* Mapping does covers past subflow data, invalid */ +- warn_bad_map(subflow, ssn + skb->len); ++ dbg_bad_map(subflow, ssn); + return false; + } + return true; +@@ -974,7 +974,7 @@ static bool subflow_check_data_avail(struct sock *ssk) + pr_debug("msk=%p ssk=%p data_avail=%d skb=%p", subflow->conn, ssk, + subflow->data_avail, skb_peek(&ssk->sk_receive_queue)); + if (!skb_peek(&ssk->sk_receive_queue)) +- subflow->data_avail = 0; ++ WRITE_ONCE(subflow->data_avail, 0); + if (subflow->data_avail) + return true; + +@@ -1012,18 +1012,13 @@ static bool subflow_check_data_avail(struct sock *ssk) + ack_seq = mptcp_subflow_get_mapped_dsn(subflow); + pr_debug("msk ack_seq=%llx subflow ack_seq=%llx", old_ack, + ack_seq); +- if (ack_seq == old_ack) { +- subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; +- break; +- } else if (after64(ack_seq, old_ack)) { +- subflow->data_avail = MPTCP_SUBFLOW_OOO_DATA; +- break; ++ if (unlikely(before64(ack_seq, old_ack))) { ++ mptcp_subflow_discard_data(ssk, skb, old_ack - ack_seq); ++ continue; + } + +- /* only accept in-sequence mapping. Old values are spurious +- * retransmission +- */ +- mptcp_subflow_discard_data(ssk, skb, old_ack - ack_seq); ++ WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL); ++ break; + } + return true; + +@@ -1038,10 +1033,9 @@ fallback: + * subflow_error_report() will introduce the appropriate barriers + */ + ssk->sk_err = EBADMSG; +- ssk->sk_error_report(ssk); + tcp_set_state(ssk, TCP_CLOSE); + tcp_send_active_reset(ssk, GFP_ATOMIC); +- subflow->data_avail = 0; ++ WRITE_ONCE(subflow->data_avail, 0); + return false; + } + +@@ -1051,7 +1045,7 @@ fallback: + subflow->map_seq = READ_ONCE(msk->ack_seq); + subflow->map_data_len = skb->len; + subflow->map_subflow_seq = tcp_sk(ssk)->copied_seq - subflow->ssn_offset; +- subflow->data_avail = MPTCP_SUBFLOW_DATA_AVAIL; ++ WRITE_ONCE(subflow->data_avail, MPTCP_SUBFLOW_DATA_AVAIL); + return true; + } + +@@ -1063,7 +1057,7 @@ bool mptcp_subflow_data_available(struct sock *sk) + if (subflow->map_valid && + mptcp_subflow_get_map_offset(subflow) >= subflow->map_data_len) { + subflow->map_valid = 0; +- subflow->data_avail = 0; ++ WRITE_ONCE(subflow->data_avail, 0); + + pr_debug("Done with mapping: seq=%u data_len=%u", + subflow->map_subflow_seq, +@@ -1091,41 +1085,6 @@ void mptcp_space(const struct sock *ssk, int *space, int *full_space) + *full_space = tcp_full_space(sk); + } + +-static void subflow_data_ready(struct sock *sk) +-{ +- struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); +- u16 state = 1 << inet_sk_state_load(sk); +- struct sock *parent = subflow->conn; +- struct mptcp_sock *msk; +- +- msk = mptcp_sk(parent); +- if (state & TCPF_LISTEN) { +- /* MPJ subflow are removed from accept queue before reaching here, +- * avoid stray wakeups +- */ +- if (reqsk_queue_empty(&inet_csk(sk)->icsk_accept_queue)) +- return; +- +- set_bit(MPTCP_DATA_READY, &msk->flags); +- parent->sk_data_ready(parent); +- return; +- } +- +- WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable && +- !subflow->mp_join && !(state & TCPF_CLOSE)); +- +- if (mptcp_subflow_data_available(sk)) +- mptcp_data_ready(parent, sk); +-} +- +-static void subflow_write_space(struct sock *ssk) +-{ +- struct sock *sk = mptcp_subflow_ctx(ssk)->conn; +- +- mptcp_propagate_sndbuf(sk, ssk); +- mptcp_write_space(sk); +-} +- + void __mptcp_error_report(struct sock *sk) + { + struct mptcp_subflow_context *subflow; +@@ -1166,6 +1125,43 @@ static void subflow_error_report(struct sock *ssk) + mptcp_data_unlock(sk); + } + ++static void subflow_data_ready(struct sock *sk) ++{ ++ struct mptcp_subflow_context *subflow = mptcp_subflow_ctx(sk); ++ u16 state = 1 << inet_sk_state_load(sk); ++ struct sock *parent = subflow->conn; ++ struct mptcp_sock *msk; ++ ++ msk = mptcp_sk(parent); ++ if (state & TCPF_LISTEN) { ++ /* MPJ subflow are removed from accept queue before reaching here, ++ * avoid stray wakeups ++ */ ++ if (reqsk_queue_empty(&inet_csk(sk)->icsk_accept_queue)) ++ return; ++ ++ set_bit(MPTCP_DATA_READY, &msk->flags); ++ parent->sk_data_ready(parent); ++ return; ++ } ++ ++ WARN_ON_ONCE(!__mptcp_check_fallback(msk) && !subflow->mp_capable && ++ !subflow->mp_join && !(state & TCPF_CLOSE)); ++ ++ if (mptcp_subflow_data_available(sk)) ++ mptcp_data_ready(parent, sk); ++ else if (unlikely(sk->sk_err)) ++ subflow_error_report(sk); ++} ++ ++static void subflow_write_space(struct sock *ssk) ++{ ++ struct sock *sk = mptcp_subflow_ctx(ssk)->conn; ++ ++ mptcp_propagate_sndbuf(sk, ssk); ++ mptcp_write_space(sk); ++} ++ + static struct inet_connection_sock_af_ops * + subflow_default_af_ops(struct sock *sk) + { +@@ -1474,6 +1470,8 @@ static void subflow_state_change(struct sock *sk) + */ + if (mptcp_subflow_data_available(sk)) + mptcp_data_ready(parent, sk); ++ else if (unlikely(sk->sk_err)) ++ subflow_error_report(sk); + + subflow_sched_work_if_closed(mptcp_sk(parent), sk); + +diff --git a/net/netfilter/nf_synproxy_core.c b/net/netfilter/nf_synproxy_core.c +index b100c04a0e435..3d6d49420db8b 100644 +--- a/net/netfilter/nf_synproxy_core.c ++++ b/net/netfilter/nf_synproxy_core.c +@@ -31,6 +31,9 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + int length = (th->doff * 4) - sizeof(*th); + u8 buf[40], *ptr; + ++ if (unlikely(length < 0)) ++ return false; ++ + ptr = skb_header_pointer(skb, doff + sizeof(*th), length, buf); + if (ptr == NULL) + return false; +@@ -47,6 +50,8 @@ synproxy_parse_options(const struct sk_buff *skb, unsigned int doff, + length--; + continue; + default: ++ if (length < 2) ++ return true; + opsize = *ptr++; + if (opsize < 2) + return true; +diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c +index 31016c144c48b..9d5ea23529657 100644 +--- a/net/netfilter/nf_tables_api.c ++++ b/net/netfilter/nf_tables_api.c +@@ -4317,13 +4317,44 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, + err = nf_tables_set_alloc_name(&ctx, set, name); + kfree(name); + if (err < 0) +- goto err_set_alloc_name; ++ goto err_set_name; ++ ++ udata = NULL; ++ if (udlen) { ++ udata = set->data + size; ++ nla_memcpy(udata, nla[NFTA_SET_USERDATA], udlen); ++ } ++ ++ INIT_LIST_HEAD(&set->bindings); ++ set->table = table; ++ write_pnet(&set->net, net); ++ set->ops = ops; ++ set->ktype = ktype; ++ set->klen = desc.klen; ++ set->dtype = dtype; ++ set->objtype = objtype; ++ set->dlen = desc.dlen; ++ set->flags = flags; ++ set->size = desc.size; ++ set->policy = policy; ++ set->udlen = udlen; ++ set->udata = udata; ++ set->timeout = timeout; ++ set->gc_int = gc_int; ++ ++ set->field_count = desc.field_count; ++ for (i = 0; i < desc.field_count; i++) ++ set->field_len[i] = desc.field_len[i]; ++ ++ err = ops->init(set, &desc, nla); ++ if (err < 0) ++ goto err_set_init; + + if (nla[NFTA_SET_EXPR]) { + expr = nft_set_elem_expr_alloc(&ctx, set, nla[NFTA_SET_EXPR]); + if (IS_ERR(expr)) { + err = PTR_ERR(expr); +- goto err_set_alloc_name; ++ goto err_set_expr_alloc; + } + set->exprs[0] = expr; + set->num_exprs++; +@@ -4334,74 +4365,44 @@ static int nf_tables_newset(struct net *net, struct sock *nlsk, + + if (!(flags & NFT_SET_EXPR)) { + err = -EINVAL; +- goto err_set_alloc_name; ++ goto err_set_expr_alloc; + } + i = 0; + nla_for_each_nested(tmp, nla[NFTA_SET_EXPRESSIONS], left) { + if (i == NFT_SET_EXPR_MAX) { + err = -E2BIG; +- goto err_set_init; ++ goto err_set_expr_alloc; + } + if (nla_type(tmp) != NFTA_LIST_ELEM) { + err = -EINVAL; +- goto err_set_init; ++ goto err_set_expr_alloc; + } + expr = nft_set_elem_expr_alloc(&ctx, set, tmp); + if (IS_ERR(expr)) { + err = PTR_ERR(expr); +- goto err_set_init; ++ goto err_set_expr_alloc; + } + set->exprs[i++] = expr; + set->num_exprs++; + } + } + +- udata = NULL; +- if (udlen) { +- udata = set->data + size; +- nla_memcpy(udata, nla[NFTA_SET_USERDATA], udlen); +- } +- +- INIT_LIST_HEAD(&set->bindings); +- set->table = table; +- write_pnet(&set->net, net); +- set->ops = ops; +- set->ktype = ktype; +- set->klen = desc.klen; +- set->dtype = dtype; +- set->objtype = objtype; +- set->dlen = desc.dlen; +- set->flags = flags; +- set->size = desc.size; +- set->policy = policy; +- set->udlen = udlen; +- set->udata = udata; +- set->timeout = timeout; +- set->gc_int = gc_int; + set->handle = nf_tables_alloc_handle(table); + +- set->field_count = desc.field_count; +- for (i = 0; i < desc.field_count; i++) +- set->field_len[i] = desc.field_len[i]; +- +- err = ops->init(set, &desc, nla); +- if (err < 0) +- goto err_set_init; +- + err = nft_trans_set_add(&ctx, NFT_MSG_NEWSET, set); + if (err < 0) +- goto err_set_trans; ++ goto err_set_expr_alloc; + + list_add_tail_rcu(&set->list, &table->sets); + table->use++; + return 0; + +-err_set_trans: +- ops->destroy(set); +-err_set_init: ++err_set_expr_alloc: + for (i = 0; i < set->num_exprs; i++) + nft_expr_destroy(&ctx, set->exprs[i]); +-err_set_alloc_name: ++ ++ ops->destroy(set); ++err_set_init: + kfree(set->name); + err_set_name: + kvfree(set); +diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c +index 1e4fb568fa841..24f10bf7d8a3f 100644 +--- a/net/qrtr/qrtr.c ++++ b/net/qrtr/qrtr.c +@@ -435,7 +435,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) + struct qrtr_sock *ipc; + struct sk_buff *skb; + struct qrtr_cb *cb; +- unsigned int size; ++ size_t size; + unsigned int ver; + size_t hdrlen; + +diff --git a/net/rds/recv.c b/net/rds/recv.c +index aba4afe4dfedc..967d115f97efd 100644 +--- a/net/rds/recv.c ++++ b/net/rds/recv.c +@@ -714,7 +714,7 @@ int rds_recvmsg(struct socket *sock, struct msghdr *msg, size_t size, + + if (rds_cmsg_recv(inc, msg, rs)) { + ret = -EFAULT; +- goto out; ++ break; + } + rds_recvmsg_zcookie(rs, msg); + +diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c +index ba7f57cb41c30..143786d8cde03 100644 +--- a/net/sched/act_ct.c ++++ b/net/sched/act_ct.c +@@ -904,14 +904,19 @@ static int tcf_ct_act_nat(struct sk_buff *skb, + } + + err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); +- if (err == NF_ACCEPT && +- ct->status & IPS_SRC_NAT && ct->status & IPS_DST_NAT) { +- if (maniptype == NF_NAT_MANIP_SRC) +- maniptype = NF_NAT_MANIP_DST; +- else +- maniptype = NF_NAT_MANIP_SRC; +- +- err = ct_nat_execute(skb, ct, ctinfo, range, maniptype); ++ if (err == NF_ACCEPT && ct->status & IPS_DST_NAT) { ++ if (ct->status & IPS_SRC_NAT) { ++ if (maniptype == NF_NAT_MANIP_SRC) ++ maniptype = NF_NAT_MANIP_DST; ++ else ++ maniptype = NF_NAT_MANIP_SRC; ++ ++ err = ct_nat_execute(skb, ct, ctinfo, range, ++ maniptype); ++ } else if (CTINFO2DIR(ctinfo) == IP_CT_DIR_ORIGINAL) { ++ err = ct_nat_execute(skb, ct, ctinfo, NULL, ++ NF_NAT_MANIP_SRC); ++ } + } + return err; + #else +diff --git a/net/sched/sch_cake.c b/net/sched/sch_cake.c +index 7d37638ee1c7a..5c15968b5155b 100644 +--- a/net/sched/sch_cake.c ++++ b/net/sched/sch_cake.c +@@ -943,7 +943,7 @@ static struct tcphdr *cake_get_tcphdr(const struct sk_buff *skb, + } + + tcph = skb_header_pointer(skb, offset, sizeof(_tcph), &_tcph); +- if (!tcph) ++ if (!tcph || tcph->doff < 5) + return NULL; + + return skb_header_pointer(skb, offset, +@@ -967,6 +967,8 @@ static const void *cake_get_tcpopt(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +@@ -1104,6 +1106,8 @@ static bool cake_tcph_may_drop(const struct tcphdr *tcph, + length--; + continue; + } ++ if (length < 2) ++ break; + opsize = *ptr++; + if (opsize < 2 || opsize > length) + break; +diff --git a/net/socket.c b/net/socket.c +index 84a8049c2b099..03259cb919f7e 100644 +--- a/net/socket.c ++++ b/net/socket.c +@@ -1072,19 +1072,6 @@ static long sock_do_ioctl(struct net *net, struct socket *sock, + * what to do with it - that's up to the protocol still. + */ + +-/** +- * get_net_ns - increment the refcount of the network namespace +- * @ns: common namespace (net) +- * +- * Returns the net's common namespace. +- */ +- +-struct ns_common *get_net_ns(struct ns_common *ns) +-{ +- return &get_net(container_of(ns, struct net, ns))->ns; +-} +-EXPORT_SYMBOL_GPL(get_net_ns); +- + static long sock_ioctl(struct file *file, unsigned cmd, unsigned long arg) + { + struct socket *sock; +diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c +index 5a31307ceb76d..5d1192ceb1397 100644 +--- a/net/unix/af_unix.c ++++ b/net/unix/af_unix.c +@@ -535,12 +535,14 @@ static void unix_release_sock(struct sock *sk, int embrion) + u->path.mnt = NULL; + state = sk->sk_state; + sk->sk_state = TCP_CLOSE; ++ ++ skpair = unix_peer(sk); ++ unix_peer(sk) = NULL; ++ + unix_state_unlock(sk); + + wake_up_interruptible_all(&u->peer_wait); + +- skpair = unix_peer(sk); +- + if (skpair != NULL) { + if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) { + unix_state_lock(skpair); +@@ -555,7 +557,6 @@ static void unix_release_sock(struct sock *sk, int embrion) + + unix_dgram_peer_wake_disconnect(sk, skpair); + sock_put(skpair); /* It may now die */ +- unix_peer(sk) = NULL; + } + + /* Try to flush out this socket. Throw out buffers at least */ +diff --git a/net/wireless/Makefile b/net/wireless/Makefile +index 2eee93985ab0d..af590ae606b69 100644 +--- a/net/wireless/Makefile ++++ b/net/wireless/Makefile +@@ -28,7 +28,7 @@ $(obj)/shipped-certs.c: $(wildcard $(srctree)/$(src)/certs/*.hex) + @$(kecho) " GEN $@" + @(echo '#include "reg.h"'; \ + echo 'const u8 shipped_regdb_certs[] = {'; \ +- cat $^ ; \ ++ echo | cat - $^ ; \ + echo '};'; \ + echo 'unsigned int shipped_regdb_certs_len = sizeof(shipped_regdb_certs);'; \ + ) > $@ +diff --git a/net/wireless/core.c b/net/wireless/core.c +index 589ee5a69a2e5..0e364f32794d3 100644 +--- a/net/wireless/core.c ++++ b/net/wireless/core.c +@@ -1339,6 +1339,11 @@ void cfg80211_register_wdev(struct cfg80211_registered_device *rdev, + rdev->devlist_generation++; + wdev->registered = true; + ++ if (wdev->netdev && ++ sysfs_create_link(&wdev->netdev->dev.kobj, &rdev->wiphy.dev.kobj, ++ "phy80211")) ++ pr_err("failed to add phy80211 symlink to netdev!\n"); ++ + nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE); + } + +@@ -1364,14 +1369,6 @@ int cfg80211_register_netdevice(struct net_device *dev) + if (ret) + goto out; + +- if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj, +- "phy80211")) { +- pr_err("failed to add phy80211 symlink to netdev!\n"); +- unregister_netdevice(dev); +- ret = -EINVAL; +- goto out; +- } +- + cfg80211_register_wdev(rdev, wdev); + ret = 0; + out: +diff --git a/net/wireless/pmsr.c b/net/wireless/pmsr.c +index a95c79d183492..a817d8e3e4b36 100644 +--- a/net/wireless/pmsr.c ++++ b/net/wireless/pmsr.c +@@ -324,6 +324,7 @@ void cfg80211_pmsr_complete(struct wireless_dev *wdev, + gfp_t gfp) + { + struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); ++ struct cfg80211_pmsr_request *tmp, *prev, *to_free = NULL; + struct sk_buff *msg; + void *hdr; + +@@ -354,9 +355,20 @@ free_msg: + nlmsg_free(msg); + free_request: + spin_lock_bh(&wdev->pmsr_lock); +- list_del(&req->list); ++ /* ++ * cfg80211_pmsr_process_abort() may have already moved this request ++ * to the free list, and will free it later. In this case, don't free ++ * it here. ++ */ ++ list_for_each_entry_safe(tmp, prev, &wdev->pmsr_list, list) { ++ if (tmp == req) { ++ list_del(&req->list); ++ to_free = req; ++ break; ++ } ++ } + spin_unlock_bh(&wdev->pmsr_lock); +- kfree(req); ++ kfree(to_free); + } + EXPORT_SYMBOL_GPL(cfg80211_pmsr_complete); + +diff --git a/net/wireless/sysfs.c b/net/wireless/sysfs.c +index 9b959e3b09c6d..0c3f05c9be27a 100644 +--- a/net/wireless/sysfs.c ++++ b/net/wireless/sysfs.c +@@ -133,6 +133,10 @@ static int wiphy_resume(struct device *dev) + if (rdev->wiphy.registered && rdev->ops->resume) + ret = rdev_resume(rdev); + wiphy_unlock(&rdev->wiphy); ++ ++ if (ret) ++ cfg80211_shutdown_all_interfaces(&rdev->wiphy); ++ + rtnl_unlock(); + + return ret; +diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c +index 91a4ef7f620ca..a9b079d56fd69 100644 +--- a/sound/soc/codecs/rt5659.c ++++ b/sound/soc/codecs/rt5659.c +@@ -2433,13 +2433,18 @@ static int set_dmic_power(struct snd_soc_dapm_widget *w, + return 0; + } + +-static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++static const struct snd_soc_dapm_widget rt5659_particular_dapm_widgets[] = { + SND_SOC_DAPM_SUPPLY("LDO2", RT5659_PWR_ANLG_3, RT5659_PWR_LDO2_BIT, 0, + NULL, 0), +- SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, +- NULL, 0), ++ SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, ++ 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("Mic Det Power", RT5659_PWR_VOL, + RT5659_PWR_MIC_DET_BIT, 0, NULL, 0), ++}; ++ ++static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { ++ SND_SOC_DAPM_SUPPLY("PLL", RT5659_PWR_ANLG_3, RT5659_PWR_PLL_BIT, 0, ++ NULL, 0), + SND_SOC_DAPM_SUPPLY("Mono Vref", RT5659_PWR_ANLG_1, + RT5659_PWR_VREF3_BIT, 0, NULL, 0), + +@@ -2464,8 +2469,6 @@ static const struct snd_soc_dapm_widget rt5659_dapm_widgets[] = { + RT5659_ADC_MONO_R_ASRC_SFT, 0, NULL, 0), + + /* Input Side */ +- SND_SOC_DAPM_SUPPLY("MICBIAS1", RT5659_PWR_ANLG_2, RT5659_PWR_MB1_BIT, +- 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS2", RT5659_PWR_ANLG_2, RT5659_PWR_MB2_BIT, + 0, NULL, 0), + SND_SOC_DAPM_SUPPLY("MICBIAS3", RT5659_PWR_ANLG_2, RT5659_PWR_MB3_BIT, +@@ -3660,10 +3663,23 @@ static int rt5659_set_bias_level(struct snd_soc_component *component, + + static int rt5659_probe(struct snd_soc_component *component) + { ++ struct snd_soc_dapm_context *dapm = ++ snd_soc_component_get_dapm(component); + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); + + rt5659->component = component; + ++ switch (rt5659->pdata.jd_src) { ++ case RT5659_JD_HDA_HEADER: ++ break; ++ ++ default: ++ snd_soc_dapm_new_controls(dapm, ++ rt5659_particular_dapm_widgets, ++ ARRAY_SIZE(rt5659_particular_dapm_widgets)); ++ break; ++ } ++ + return 0; + } + +diff --git a/sound/soc/codecs/rt5682-sdw.c b/sound/soc/codecs/rt5682-sdw.c +index b49f1e16125d4..d1dd7f720ba48 100644 +--- a/sound/soc/codecs/rt5682-sdw.c ++++ b/sound/soc/codecs/rt5682-sdw.c +@@ -462,7 +462,8 @@ static int rt5682_io_init(struct device *dev, struct sdw_slave *slave) + + regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_2, + RT5682_EXT_JD_SRC, RT5682_EXT_JD_SRC_MANUAL); +- regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd042); ++ regmap_write(rt5682->regmap, RT5682_CBJ_CTRL_1, 0xd142); ++ regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_5, 0x0700, 0x0600); + regmap_update_bits(rt5682->regmap, RT5682_CBJ_CTRL_3, + RT5682_CBJ_IN_BUF_EN, RT5682_CBJ_IN_BUF_EN); + regmap_update_bits(rt5682->regmap, RT5682_SAR_IL_CMD_1, +diff --git a/sound/soc/codecs/tas2562.h b/sound/soc/codecs/tas2562.h +index 81866aeb3fbfa..55b2a1f52ca37 100644 +--- a/sound/soc/codecs/tas2562.h ++++ b/sound/soc/codecs/tas2562.h +@@ -57,13 +57,13 @@ + #define TAS2562_TDM_CFG0_RAMPRATE_MASK BIT(5) + #define TAS2562_TDM_CFG0_RAMPRATE_44_1 BIT(5) + #define TAS2562_TDM_CFG0_SAMPRATE_MASK GENMASK(3, 1) +-#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ 0x0 +-#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ 0x1 +-#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ 0x2 +-#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ 0x3 +-#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ 0x4 +-#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ 0x5 +-#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ 0x6 ++#define TAS2562_TDM_CFG0_SAMPRATE_7305_8KHZ (0x0 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_14_7_16KHZ (0x1 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_22_05_24KHZ (0x2 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_29_4_32KHZ (0x3 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_44_1_48KHZ (0x4 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_88_2_96KHZ (0x5 << 1) ++#define TAS2562_TDM_CFG0_SAMPRATE_176_4_192KHZ (0x6 << 1) + + #define TAS2562_TDM_CFG2_RIGHT_JUSTIFY BIT(6) + +diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c +index f62f81ceab0d2..9dcbe5d5a428c 100644 +--- a/sound/soc/fsl/fsl-asoc-card.c ++++ b/sound/soc/fsl/fsl-asoc-card.c +@@ -732,6 +732,7 @@ static int fsl_asoc_card_probe(struct platform_device *pdev) + /* Initialize sound card */ + priv->pdev = pdev; + priv->card.dev = &pdev->dev; ++ priv->card.owner = THIS_MODULE; + ret = snd_soc_of_parse_card_name(&priv->card, "model"); + if (ret) { + snprintf(priv->name, sizeof(priv->name), "%s-audio", +diff --git a/sound/soc/qcom/lpass-cpu.c b/sound/soc/qcom/lpass-cpu.c +index 936384a94f25e..74d3d8c586080 100644 +--- a/sound/soc/qcom/lpass-cpu.c ++++ b/sound/soc/qcom/lpass-cpu.c +@@ -93,8 +93,30 @@ static void lpass_cpu_daiops_shutdown(struct snd_pcm_substream *substream, + struct snd_soc_dai *dai) + { + struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); ++ struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; ++ unsigned int id = dai->driver->id; + + clk_disable_unprepare(drvdata->mi2s_osr_clk[dai->driver->id]); ++ /* ++ * Ensure LRCLK is disabled even in device node validation. ++ * Will not impact if disabled in lpass_cpu_daiops_trigger() ++ * suspend. ++ */ ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ++ regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_DISABLE); ++ else ++ regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_DISABLE); ++ ++ /* ++ * BCLK may not be enabled if lpass_cpu_daiops_prepare is called before ++ * lpass_cpu_daiops_shutdown. It's paired with the clk_enable in ++ * lpass_cpu_daiops_prepare. ++ */ ++ if (drvdata->mi2s_was_prepared[dai->driver->id]) { ++ drvdata->mi2s_was_prepared[dai->driver->id] = false; ++ clk_disable(drvdata->mi2s_bit_clk[dai->driver->id]); ++ } ++ + clk_unprepare(drvdata->mi2s_bit_clk[dai->driver->id]); + } + +@@ -275,6 +297,18 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + case SNDRV_PCM_TRIGGER_START: + case SNDRV_PCM_TRIGGER_RESUME: + case SNDRV_PCM_TRIGGER_PAUSE_RELEASE: ++ /* ++ * Ensure lpass BCLK/LRCLK is enabled during ++ * device resume as lpass_cpu_daiops_prepare() is not called ++ * after the device resumes. We don't check mi2s_was_prepared before ++ * enable/disable BCLK in trigger events because: ++ * 1. These trigger events are paired, so the BCLK ++ * enable_count is balanced. ++ * 2. the BCLK can be shared (ex: headset and headset mic), ++ * we need to increase the enable_count so that we don't ++ * turn off the shared BCLK while other devices are using ++ * it. ++ */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = regmap_fields_write(i2sctl->spken, id, + LPAIF_I2SCTL_SPKEN_ENABLE); +@@ -296,6 +330,10 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + case SNDRV_PCM_TRIGGER_STOP: + case SNDRV_PCM_TRIGGER_SUSPEND: + case SNDRV_PCM_TRIGGER_PAUSE_PUSH: ++ /* ++ * To ensure lpass BCLK/LRCLK is disabled during ++ * device suspend. ++ */ + if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { + ret = regmap_fields_write(i2sctl->spken, id, + LPAIF_I2SCTL_SPKEN_DISABLE); +@@ -315,12 +353,53 @@ static int lpass_cpu_daiops_trigger(struct snd_pcm_substream *substream, + return ret; + } + ++static int lpass_cpu_daiops_prepare(struct snd_pcm_substream *substream, ++ struct snd_soc_dai *dai) ++{ ++ struct lpass_data *drvdata = snd_soc_dai_get_drvdata(dai); ++ struct lpaif_i2sctl *i2sctl = drvdata->i2sctl; ++ unsigned int id = dai->driver->id; ++ int ret; ++ ++ /* ++ * Ensure lpass BCLK/LRCLK is enabled bit before playback/capture ++ * data flow starts. This allows other codec to have some delay before ++ * the data flow. ++ * (ex: to drop start up pop noise before capture starts). ++ */ ++ if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) ++ ret = regmap_fields_write(i2sctl->spken, id, LPAIF_I2SCTL_SPKEN_ENABLE); ++ else ++ ret = regmap_fields_write(i2sctl->micen, id, LPAIF_I2SCTL_MICEN_ENABLE); ++ ++ if (ret) { ++ dev_err(dai->dev, "error writing to i2sctl reg: %d\n", ret); ++ return ret; ++ } ++ ++ /* ++ * Check mi2s_was_prepared before enabling BCLK as lpass_cpu_daiops_prepare can ++ * be called multiple times. It's paired with the clk_disable in ++ * lpass_cpu_daiops_shutdown. ++ */ ++ if (!drvdata->mi2s_was_prepared[dai->driver->id]) { ++ ret = clk_enable(drvdata->mi2s_bit_clk[id]); ++ if (ret) { ++ dev_err(dai->dev, "error in enabling mi2s bit clk: %d\n", ret); ++ return ret; ++ } ++ drvdata->mi2s_was_prepared[dai->driver->id] = true; ++ } ++ return 0; ++} ++ + const struct snd_soc_dai_ops asoc_qcom_lpass_cpu_dai_ops = { + .set_sysclk = lpass_cpu_daiops_set_sysclk, + .startup = lpass_cpu_daiops_startup, + .shutdown = lpass_cpu_daiops_shutdown, + .hw_params = lpass_cpu_daiops_hw_params, + .trigger = lpass_cpu_daiops_trigger, ++ .prepare = lpass_cpu_daiops_prepare, + }; + EXPORT_SYMBOL_GPL(asoc_qcom_lpass_cpu_dai_ops); + +diff --git a/sound/soc/qcom/lpass.h b/sound/soc/qcom/lpass.h +index 83b2e08ade060..7f72214404baf 100644 +--- a/sound/soc/qcom/lpass.h ++++ b/sound/soc/qcom/lpass.h +@@ -67,6 +67,10 @@ struct lpass_data { + /* MI2S SD lines to use for playback/capture */ + unsigned int mi2s_playback_sd_mode[LPASS_MAX_MI2S_PORTS]; + unsigned int mi2s_capture_sd_mode[LPASS_MAX_MI2S_PORTS]; ++ ++ /* The state of MI2S prepare dai_ops was called */ ++ bool mi2s_was_prepared[LPASS_MAX_MI2S_PORTS]; ++ + int hdmi_port_enable; + + /* low-power audio interface (LPAIF) registers */ +diff --git a/tools/include/uapi/linux/in.h b/tools/include/uapi/linux/in.h +index 7d6687618d808..d1b327036ae43 100644 +--- a/tools/include/uapi/linux/in.h ++++ b/tools/include/uapi/linux/in.h +@@ -289,6 +289,9 @@ struct sockaddr_in { + /* Address indicating an error return. */ + #define INADDR_NONE ((unsigned long int) 0xffffffff) + ++/* Dummy address for src of ICMP replies if no real address is set (RFC7600). */ ++#define INADDR_DUMMY ((unsigned long int) 0xc0000008) ++ + /* Network number for local host loopback. */ + #define IN_LOOPBACKNET 127 + +diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c +index 007fe5d594386..fe2bec500bf68 100644 +--- a/tools/lib/bpf/xsk.c ++++ b/tools/lib/bpf/xsk.c +@@ -928,7 +928,7 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr, + goto out_put_ctx; + } + if (xsk->fd == umem->fd) +- umem->rx_ring_setup_done = true; ++ umem->tx_ring_setup_done = true; + } + + err = xsk_get_mmap_offsets(xsk->fd, &off); +diff --git a/tools/perf/trace/beauty/include/linux/socket.h b/tools/perf/trace/beauty/include/linux/socket.h +index 385894b4a8bba..42222a84167f3 100644 +--- a/tools/perf/trace/beauty/include/linux/socket.h ++++ b/tools/perf/trace/beauty/include/linux/socket.h +@@ -438,6 +438,4 @@ extern int __sys_socketpair(int family, int type, int protocol, + int __user *usockvec); + extern int __sys_shutdown_sock(struct socket *sock, int how); + extern int __sys_shutdown(int fd, int how); +- +-extern struct ns_common *get_net_ns(struct ns_common *ns); + #endif /* _LINUX_SOCKET_H */ +diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c +index 26c990e323781..939aed36e0c2a 100644 +--- a/tools/perf/util/metricgroup.c ++++ b/tools/perf/util/metricgroup.c +@@ -162,10 +162,10 @@ static bool contains_event(struct evsel **metric_events, int num_events, + return false; + } + +-static bool evsel_same_pmu(struct evsel *ev1, struct evsel *ev2) ++static bool evsel_same_pmu_or_none(struct evsel *ev1, struct evsel *ev2) + { + if (!ev1->pmu_name || !ev2->pmu_name) +- return false; ++ return true; + + return !strcmp(ev1->pmu_name, ev2->pmu_name); + } +@@ -288,7 +288,7 @@ static struct evsel *find_evsel_group(struct evlist *perf_evlist, + */ + if (!has_constraint && + ev->leader != metric_events[i]->leader && +- evsel_same_pmu(ev->leader, metric_events[i]->leader)) ++ evsel_same_pmu_or_none(ev->leader, metric_events[i]->leader)) + break; + if (!strcmp(metric_events[i]->name, ev->name)) { + set_bit(ev->idx, evlist_used); +@@ -1072,16 +1072,18 @@ static int metricgroup__add_metric_sys_event_iter(struct pmu_event *pe, + + ret = add_metric(d->metric_list, pe, d->metric_no_group, &m, NULL, d->ids); + if (ret) +- return ret; ++ goto out; + + ret = resolve_metric(d->metric_no_group, + d->metric_list, NULL, d->ids); + if (ret) +- return ret; ++ goto out; + + *(d->has_match) = true; + +- return *d->ret; ++out: ++ *(d->ret) = ret; ++ return ret; + } + + static int metricgroup__add_metric(const char *metric, bool metric_no_group, +diff --git a/tools/testing/selftests/net/fib_tests.sh b/tools/testing/selftests/net/fib_tests.sh +index 2b5707738609e..6fad54c7ecb4a 100755 +--- a/tools/testing/selftests/net/fib_tests.sh ++++ b/tools/testing/selftests/net/fib_tests.sh +@@ -1384,12 +1384,37 @@ ipv4_rt_replace() + ipv4_rt_replace_mpath + } + ++# checks that cached input route on VRF port is deleted ++# when VRF is deleted ++ipv4_local_rt_cache() ++{ ++ run_cmd "ip addr add 10.0.0.1/32 dev lo" ++ run_cmd "ip netns add test-ns" ++ run_cmd "ip link add veth-outside type veth peer name veth-inside" ++ run_cmd "ip link add vrf-100 type vrf table 1100" ++ run_cmd "ip link set veth-outside master vrf-100" ++ run_cmd "ip link set veth-inside netns test-ns" ++ run_cmd "ip link set veth-outside up" ++ run_cmd "ip link set vrf-100 up" ++ run_cmd "ip route add 10.1.1.1/32 dev veth-outside table 1100" ++ run_cmd "ip netns exec test-ns ip link set veth-inside up" ++ run_cmd "ip netns exec test-ns ip addr add 10.1.1.1/32 dev veth-inside" ++ run_cmd "ip netns exec test-ns ip route add 10.0.0.1/32 dev veth-inside" ++ run_cmd "ip netns exec test-ns ip route add default via 10.0.0.1" ++ run_cmd "ip netns exec test-ns ping 10.0.0.1 -c 1 -i 1" ++ run_cmd "ip link delete vrf-100" ++ ++ # if we do not hang test is a success ++ log_test $? 0 "Cached route removed from VRF port device" ++} ++ + ipv4_route_test() + { + route_setup + + ipv4_rt_add + ipv4_rt_replace ++ ipv4_local_rt_cache + + route_cleanup + } +diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.sh b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +index 65b3b983efc26..8763706b0d047 100755 +--- a/tools/testing/selftests/net/mptcp/mptcp_connect.sh ++++ b/tools/testing/selftests/net/mptcp/mptcp_connect.sh +@@ -197,9 +197,6 @@ ip -net "$ns4" link set ns4eth3 up + ip -net "$ns4" route add default via 10.0.3.2 + ip -net "$ns4" route add default via dead:beef:3::2 + +-# use TCP syn cookies, even if no flooding was detected. +-ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2 +- + set_ethtool_flags() { + local ns="$1" + local dev="$2" +@@ -711,6 +708,14 @@ for sender in $ns1 $ns2 $ns3 $ns4;do + exit $ret + fi + ++ # ns1<->ns2 is not subject to reordering/tc delays. Use it to test ++ # mptcp syncookie support. ++ if [ $sender = $ns1 ]; then ++ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=2 ++ else ++ ip netns exec "$ns2" sysctl -q net.ipv4.tcp_syncookies=1 ++ fi ++ + run_tests "$ns2" $sender 10.0.1.2 + run_tests "$ns2" $sender dead:beef:1::2 + run_tests "$ns2" $sender 10.0.2.1