diff --git a/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.98-99.patch b/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.98-99.patch deleted file mode 100644 index e3c707b5e8..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.98-99.patch +++ /dev/null @@ -1,2513 +0,0 @@ -diff --git a/Makefile b/Makefile -index 4f6bfcf434e80..a0491ba1d7593 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 98 -+SUBLEVEL = 99 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm/boot/dts/lpc32xx.dtsi b/arch/arm/boot/dts/lpc32xx.dtsi -index 7b7ec7b1217b8..824393e1bcfb7 100644 ---- a/arch/arm/boot/dts/lpc32xx.dtsi -+++ b/arch/arm/boot/dts/lpc32xx.dtsi -@@ -329,9 +329,6 @@ - - clocks = <&xtal_32k>, <&xtal>; - clock-names = "xtal_32k", "xtal"; -- -- assigned-clocks = <&clk LPC32XX_CLK_HCLK_PLL>; -- assigned-clock-rates = <208000000>; - }; - }; - -diff --git a/arch/arm/include/asm/kexec-internal.h b/arch/arm/include/asm/kexec-internal.h -new file mode 100644 -index 0000000000000..ecc2322db7aa1 ---- /dev/null -+++ b/arch/arm/include/asm/kexec-internal.h -@@ -0,0 +1,12 @@ -+/* SPDX-License-Identifier: GPL-2.0 */ -+#ifndef _ARM_KEXEC_INTERNAL_H -+#define _ARM_KEXEC_INTERNAL_H -+ -+struct kexec_relocate_data { -+ unsigned long kexec_start_address; -+ unsigned long kexec_indirection_page; -+ unsigned long kexec_mach_type; -+ unsigned long kexec_r2; -+}; -+ -+#endif -diff --git a/arch/arm/kernel/asm-offsets.c b/arch/arm/kernel/asm-offsets.c -index c773b829ee8ee..bfb05c93494db 100644 ---- a/arch/arm/kernel/asm-offsets.c -+++ b/arch/arm/kernel/asm-offsets.c -@@ -15,6 +15,7 @@ - #include - #endif - #include -+#include - #include - #include - #include -@@ -190,5 +191,9 @@ int main(void) - DEFINE(MPU_RGN_PRBAR, offsetof(struct mpu_rgn, prbar)); - DEFINE(MPU_RGN_PRLAR, offsetof(struct mpu_rgn, prlar)); - #endif -+ DEFINE(KEXEC_START_ADDR, offsetof(struct kexec_relocate_data, kexec_start_address)); -+ DEFINE(KEXEC_INDIR_PAGE, offsetof(struct kexec_relocate_data, kexec_indirection_page)); -+ DEFINE(KEXEC_MACH_TYPE, offsetof(struct kexec_relocate_data, kexec_mach_type)); -+ DEFINE(KEXEC_R2, offsetof(struct kexec_relocate_data, kexec_r2)); - return 0; - } -diff --git a/arch/arm/kernel/machine_kexec.c b/arch/arm/kernel/machine_kexec.c -index 76300f3813e89..734adeb42df87 100644 ---- a/arch/arm/kernel/machine_kexec.c -+++ b/arch/arm/kernel/machine_kexec.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -24,11 +25,6 @@ - extern void relocate_new_kernel(void); - extern const unsigned int relocate_new_kernel_size; - --extern unsigned long kexec_start_address; --extern unsigned long kexec_indirection_page; --extern unsigned long kexec_mach_type; --extern unsigned long kexec_boot_atags; -- - static atomic_t waiting_for_crash_ipi; - - /* -@@ -161,6 +157,7 @@ void (*kexec_reinit)(void); - void machine_kexec(struct kimage *image) - { - unsigned long page_list, reboot_entry_phys; -+ struct kexec_relocate_data *data; - void (*reboot_entry)(void); - void *reboot_code_buffer; - -@@ -176,18 +173,17 @@ void machine_kexec(struct kimage *image) - - reboot_code_buffer = page_address(image->control_code_page); - -- /* Prepare parameters for reboot_code_buffer*/ -- set_kernel_text_rw(); -- kexec_start_address = image->start; -- kexec_indirection_page = page_list; -- kexec_mach_type = machine_arch_type; -- kexec_boot_atags = image->arch.kernel_r2; -- - /* copy our kernel relocation code to the control code page */ - reboot_entry = fncpy(reboot_code_buffer, - &relocate_new_kernel, - relocate_new_kernel_size); - -+ data = reboot_code_buffer + relocate_new_kernel_size; -+ data->kexec_start_address = image->start; -+ data->kexec_indirection_page = page_list; -+ data->kexec_mach_type = machine_arch_type; -+ data->kexec_r2 = image->arch.kernel_r2; -+ - /* get the identity mapping physical address for the reboot code */ - reboot_entry_phys = virt_to_idmap(reboot_entry); - -diff --git a/arch/arm/kernel/relocate_kernel.S b/arch/arm/kernel/relocate_kernel.S -index 7eaa2ae7aff58..5e15b5912cb05 100644 ---- a/arch/arm/kernel/relocate_kernel.S -+++ b/arch/arm/kernel/relocate_kernel.S -@@ -5,14 +5,16 @@ - - #include - #include -+#include - #include - - .align 3 /* not needed for this code, but keeps fncpy() happy */ - - ENTRY(relocate_new_kernel) - -- ldr r0,kexec_indirection_page -- ldr r1,kexec_start_address -+ adr r7, relocate_new_kernel_end -+ ldr r0, [r7, #KEXEC_INDIR_PAGE] -+ ldr r1, [r7, #KEXEC_START_ADDR] - - /* - * If there is no indirection page (we are doing crashdumps) -@@ -57,34 +59,16 @@ ENTRY(relocate_new_kernel) - - 2: - /* Jump to relocated kernel */ -- mov lr,r1 -- mov r0,#0 -- ldr r1,kexec_mach_type -- ldr r2,kexec_boot_atags -- ARM( ret lr ) -- THUMB( bx lr ) -- -- .align -- -- .globl kexec_start_address --kexec_start_address: -- .long 0x0 -- -- .globl kexec_indirection_page --kexec_indirection_page: -- .long 0x0 -- -- .globl kexec_mach_type --kexec_mach_type: -- .long 0x0 -- -- /* phy addr of the atags for the new kernel */ -- .globl kexec_boot_atags --kexec_boot_atags: -- .long 0x0 -+ mov lr, r1 -+ mov r0, #0 -+ ldr r1, [r7, #KEXEC_MACH_TYPE] -+ ldr r2, [r7, #KEXEC_R2] -+ ARM( ret lr ) -+ THUMB( bx lr ) - - ENDPROC(relocate_new_kernel) - -+ .align 3 - relocate_new_kernel_end: - - .globl relocate_new_kernel_size -diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c -index ab2568996ddb0..c01f76cd02422 100644 ---- a/arch/arm/kernel/signal.c -+++ b/arch/arm/kernel/signal.c -@@ -694,18 +694,20 @@ struct page *get_signal_page(void) - - addr = page_address(page); - -+ /* Poison the entire page */ -+ memset32(addr, __opcode_to_mem_arm(0xe7fddef1), -+ PAGE_SIZE / sizeof(u32)); -+ - /* Give the signal return code some randomness */ - offset = 0x200 + (get_random_int() & 0x7fc); - signal_return_offset = offset; - -- /* -- * Copy signal return handlers into the vector page, and -- * set sigreturn to be a pointer to these. -- */ -+ /* Copy signal return handlers into the page */ - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes)); - -- ptr = (unsigned long)addr + offset; -- flush_icache_range(ptr, ptr + sizeof(sigreturn_codes)); -+ /* Flush out all instructions in this page */ -+ ptr = (unsigned long)addr; -+ flush_icache_range(ptr, ptr + PAGE_SIZE); - - return page; - } -diff --git a/arch/arm/mach-omap2/cpuidle44xx.c b/arch/arm/mach-omap2/cpuidle44xx.c -index c8d317fafe2ea..de37027ad7587 100644 ---- a/arch/arm/mach-omap2/cpuidle44xx.c -+++ b/arch/arm/mach-omap2/cpuidle44xx.c -@@ -151,10 +151,10 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, - (cx->mpu_logic_state == PWRDM_POWER_OFF); - - /* Enter broadcast mode for periodic timers */ -- tick_broadcast_enable(); -+ RCU_NONIDLE(tick_broadcast_enable()); - - /* Enter broadcast mode for one-shot timers */ -- tick_broadcast_enter(); -+ RCU_NONIDLE(tick_broadcast_enter()); - - /* - * Call idle CPU PM enter notifier chain so that -@@ -166,7 +166,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, - - if (dev->cpu == 0) { - pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state); -- omap_set_pwrdm_state(mpu_pd, cx->mpu_state); -+ RCU_NONIDLE(omap_set_pwrdm_state(mpu_pd, cx->mpu_state)); - - /* - * Call idle CPU cluster PM enter notifier chain -@@ -178,7 +178,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, - index = 0; - cx = state_ptr + index; - pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state); -- omap_set_pwrdm_state(mpu_pd, cx->mpu_state); -+ RCU_NONIDLE(omap_set_pwrdm_state(mpu_pd, cx->mpu_state)); - mpuss_can_lose_context = 0; - } - } -@@ -194,9 +194,9 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, - mpuss_can_lose_context) - gic_dist_disable(); - -- clkdm_deny_idle(cpu_clkdm[1]); -- omap_set_pwrdm_state(cpu_pd[1], PWRDM_POWER_ON); -- clkdm_allow_idle(cpu_clkdm[1]); -+ RCU_NONIDLE(clkdm_deny_idle(cpu_clkdm[1])); -+ RCU_NONIDLE(omap_set_pwrdm_state(cpu_pd[1], PWRDM_POWER_ON)); -+ RCU_NONIDLE(clkdm_allow_idle(cpu_clkdm[1])); - - if (IS_PM44XX_ERRATUM(PM_OMAP4_ROM_SMP_BOOT_ERRATUM_GICD) && - mpuss_can_lose_context) { -@@ -222,7 +222,7 @@ static int omap_enter_idle_coupled(struct cpuidle_device *dev, - cpu_pm_exit(); - - cpu_pm_out: -- tick_broadcast_exit(); -+ RCU_NONIDLE(tick_broadcast_exit()); - - fail: - cpuidle_coupled_parallel_barrier(dev, &abort_barrier); -diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c -index f45bff158fc20..57dfc13b27529 100644 ---- a/arch/arm/xen/enlighten.c -+++ b/arch/arm/xen/enlighten.c -@@ -370,8 +370,6 @@ static int __init xen_guest_init(void) - return -ENOMEM; - } - gnttab_init(); -- if (!xen_initial_domain()) -- xenbus_probe(); - - /* - * Making sure board specific code will not set up ops for -diff --git a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts -index 751651a6cd819..bf4fde88011c8 100644 ---- a/arch/arm64/boot/dts/qcom/sdm845-db845c.dts -+++ b/arch/arm64/boot/dts/qcom/sdm845-db845c.dts -@@ -337,7 +337,9 @@ - &gcc { - protected-clocks = , - , -- ; -+ , -+ , -+ ; - }; - - &pm8998_gpio { -diff --git a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts -index e638f216dbfb3..840d6b9bbb598 100644 ---- a/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts -+++ b/arch/arm64/boot/dts/qcom/sdm850-lenovo-yoga-c630.dts -@@ -232,7 +232,9 @@ - &gcc { - protected-clocks = , - , -- ; -+ , -+ , -+ ; - }; - - &i2c1 { -diff --git a/arch/arm64/boot/dts/rockchip/rk3399.dtsi b/arch/arm64/boot/dts/rockchip/rk3399.dtsi -index bb7d0aac6b9db..9d6ed8cda2c86 100644 ---- a/arch/arm64/boot/dts/rockchip/rk3399.dtsi -+++ b/arch/arm64/boot/dts/rockchip/rk3399.dtsi -@@ -232,6 +232,7 @@ - reg = <0x0 0xf8000000 0x0 0x2000000>, - <0x0 0xfd000000 0x0 0x1000000>; - reg-names = "axi-base", "apb-base"; -+ device_type = "pci"; - #address-cells = <3>; - #size-cells = <2>; - #interrupt-cells = <1>; -@@ -250,7 +251,6 @@ - <0 0 0 2 &pcie0_intc 1>, - <0 0 0 3 &pcie0_intc 2>, - <0 0 0 4 &pcie0_intc 3>; -- linux,pci-domain = <0>; - max-link-speed = <1>; - msi-map = <0x0 &its 0x0 0x1000>; - phys = <&pcie_phy 0>, <&pcie_phy 1>, -diff --git a/arch/h8300/kernel/asm-offsets.c b/arch/h8300/kernel/asm-offsets.c -index 85e60509f0a83..d4b53af657c84 100644 ---- a/arch/h8300/kernel/asm-offsets.c -+++ b/arch/h8300/kernel/asm-offsets.c -@@ -63,6 +63,9 @@ int main(void) - OFFSET(TI_FLAGS, thread_info, flags); - OFFSET(TI_CPU, thread_info, cpu); - OFFSET(TI_PRE, thread_info, preempt_count); -+#ifdef CONFIG_PREEMPTION -+ DEFINE(TI_PRE_COUNT, offsetof(struct thread_info, preempt_count)); -+#endif - - return 0; - } -diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S -index a4e576019d79c..3ea360cad337b 100644 ---- a/arch/powerpc/kernel/vmlinux.lds.S -+++ b/arch/powerpc/kernel/vmlinux.lds.S -@@ -102,6 +102,7 @@ SECTIONS - #ifdef CONFIG_PPC64 - *(.tramp.ftrace.text); - #endif -+ NOINSTR_TEXT - SCHED_TEXT - CPUIDLE_TEXT - LOCK_TEXT -diff --git a/arch/riscv/include/asm/page.h b/arch/riscv/include/asm/page.h -index 3db261c4810fc..6a30794aa1eea 100644 ---- a/arch/riscv/include/asm/page.h -+++ b/arch/riscv/include/asm/page.h -@@ -119,7 +119,10 @@ extern unsigned long min_low_pfn; - - #endif /* __ASSEMBLY__ */ - --#define virt_addr_valid(vaddr) (pfn_valid(virt_to_pfn(vaddr))) -+#define virt_addr_valid(vaddr) ({ \ -+ unsigned long _addr = (unsigned long)vaddr; \ -+ (unsigned long)(_addr) >= PAGE_OFFSET && pfn_valid(virt_to_pfn(_addr)); \ -+}) - - #define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -diff --git a/arch/x86/Makefile b/arch/x86/Makefile -index b5e3bfd4facea..8ca3cf7c5ec97 100644 ---- a/arch/x86/Makefile -+++ b/arch/x86/Makefile -@@ -61,6 +61,9 @@ endif - KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow - KBUILD_CFLAGS += $(call cc-option,-mno-avx,) - -+# Intel CET isn't enabled in the kernel -+KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) -+ - ifeq ($(CONFIG_X86_32),y) - BITS := 32 - UTS_MACHINE := i386 -@@ -131,9 +134,6 @@ else - - KBUILD_CFLAGS += -mno-red-zone - KBUILD_CFLAGS += -mcmodel=kernel -- -- # Intel CET isn't enabled in the kernel -- KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) - endif - - ifdef CONFIG_X86_X32 -diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c -index 7d19aae015aeb..ba32adaeefdd0 100644 ---- a/block/bfq-iosched.c -+++ b/block/bfq-iosched.c -@@ -6320,13 +6320,13 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd, - * limit 'something'. - */ - /* no more than 50% of tags for async I/O */ -- bfqd->word_depths[0][0] = max(bt->sb.depth >> 1, 1U); -+ bfqd->word_depths[0][0] = max((1U << bt->sb.shift) >> 1, 1U); - /* - * no more than 75% of tags for sync writes (25% extra tags - * w.r.t. async I/O, to prevent async I/O from starving sync - * writes) - */ -- bfqd->word_depths[0][1] = max((bt->sb.depth * 3) >> 2, 1U); -+ bfqd->word_depths[0][1] = max(((1U << bt->sb.shift) * 3) >> 2, 1U); - - /* - * In-word depths in case some bfq_queue is being weight- -@@ -6336,9 +6336,9 @@ static unsigned int bfq_update_depths(struct bfq_data *bfqd, - * shortage. - */ - /* no more than ~18% of tags for async I/O */ -- bfqd->word_depths[1][0] = max((bt->sb.depth * 3) >> 4, 1U); -+ bfqd->word_depths[1][0] = max(((1U << bt->sb.shift) * 3) >> 4, 1U); - /* no more than ~37% of tags for sync writes (~20% extra tags) */ -- bfqd->word_depths[1][1] = max((bt->sb.depth * 6) >> 4, 1U); -+ bfqd->word_depths[1][1] = max(((1U << bt->sb.shift) * 6) >> 4, 1U); - - for (i = 0; i < 2; i++) - for (j = 0; j < 2; j++) -diff --git a/drivers/clk/sunxi-ng/ccu_mp.c b/drivers/clk/sunxi-ng/ccu_mp.c -index fa4ecb9155909..9d3a76604d94c 100644 ---- a/drivers/clk/sunxi-ng/ccu_mp.c -+++ b/drivers/clk/sunxi-ng/ccu_mp.c -@@ -108,7 +108,7 @@ static unsigned long ccu_mp_round_rate(struct ccu_mux_internal *mux, - max_m = cmp->m.max ?: 1 << cmp->m.width; - max_p = cmp->p.max ?: 1 << ((1 << cmp->p.width) - 1); - -- if (!(clk_hw_get_flags(hw) & CLK_SET_RATE_PARENT)) { -+ if (!clk_hw_can_set_rate_parent(&cmp->common.hw)) { - ccu_mp_find_best(*parent_rate, rate, max_m, max_p, &m, &p); - rate = *parent_rate / p / m; - } else { -diff --git a/drivers/gpio/gpio-ep93xx.c b/drivers/gpio/gpio-ep93xx.c -index 226da8df6f100..94d9fa0d6aa70 100644 ---- a/drivers/gpio/gpio-ep93xx.c -+++ b/drivers/gpio/gpio-ep93xx.c -@@ -25,6 +25,9 @@ - /* Maximum value for gpio line identifiers */ - #define EP93XX_GPIO_LINE_MAX 63 - -+/* Number of GPIO chips in EP93XX */ -+#define EP93XX_GPIO_CHIP_NUM 8 -+ - /* Maximum value for irq capable line identifiers */ - #define EP93XX_GPIO_LINE_MAX_IRQ 23 - -@@ -34,74 +37,75 @@ - */ - #define EP93XX_GPIO_F_IRQ_BASE 80 - --struct ep93xx_gpio { -- void __iomem *base; -- struct gpio_chip gc[8]; -+struct ep93xx_gpio_irq_chip { -+ struct irq_chip ic; -+ u8 irq_offset; -+ u8 int_unmasked; -+ u8 int_enabled; -+ u8 int_type1; -+ u8 int_type2; -+ u8 int_debounce; - }; - --/************************************************************************* -- * Interrupt handling for EP93xx on-chip GPIOs -- *************************************************************************/ --static unsigned char gpio_int_unmasked[3]; --static unsigned char gpio_int_enabled[3]; --static unsigned char gpio_int_type1[3]; --static unsigned char gpio_int_type2[3]; --static unsigned char gpio_int_debounce[3]; -- --/* Port ordering is: A B F */ --static const u8 int_type1_register_offset[3] = { 0x90, 0xac, 0x4c }; --static const u8 int_type2_register_offset[3] = { 0x94, 0xb0, 0x50 }; --static const u8 eoi_register_offset[3] = { 0x98, 0xb4, 0x54 }; --static const u8 int_en_register_offset[3] = { 0x9c, 0xb8, 0x58 }; --static const u8 int_debounce_register_offset[3] = { 0xa8, 0xc4, 0x64 }; -- --static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg, unsigned port) --{ -- BUG_ON(port > 2); -+struct ep93xx_gpio_chip { -+ struct gpio_chip gc; -+ struct ep93xx_gpio_irq_chip *eic; -+}; - -- writeb_relaxed(0, epg->base + int_en_register_offset[port]); -+struct ep93xx_gpio { -+ void __iomem *base; -+ struct ep93xx_gpio_chip gc[EP93XX_GPIO_CHIP_NUM]; -+}; - -- writeb_relaxed(gpio_int_type2[port], -- epg->base + int_type2_register_offset[port]); -+#define to_ep93xx_gpio_chip(x) container_of(x, struct ep93xx_gpio_chip, gc) - -- writeb_relaxed(gpio_int_type1[port], -- epg->base + int_type1_register_offset[port]); -+static struct ep93xx_gpio_irq_chip *to_ep93xx_gpio_irq_chip(struct gpio_chip *gc) -+{ -+ struct ep93xx_gpio_chip *egc = to_ep93xx_gpio_chip(gc); - -- writeb(gpio_int_unmasked[port] & gpio_int_enabled[port], -- epg->base + int_en_register_offset[port]); -+ return egc->eic; - } - --static int ep93xx_gpio_port(struct gpio_chip *gc) -+/************************************************************************* -+ * Interrupt handling for EP93xx on-chip GPIOs -+ *************************************************************************/ -+#define EP93XX_INT_TYPE1_OFFSET 0x00 -+#define EP93XX_INT_TYPE2_OFFSET 0x04 -+#define EP93XX_INT_EOI_OFFSET 0x08 -+#define EP93XX_INT_EN_OFFSET 0x0c -+#define EP93XX_INT_STATUS_OFFSET 0x10 -+#define EP93XX_INT_RAW_STATUS_OFFSET 0x14 -+#define EP93XX_INT_DEBOUNCE_OFFSET 0x18 -+ -+static void ep93xx_gpio_update_int_params(struct ep93xx_gpio *epg, -+ struct ep93xx_gpio_irq_chip *eic) - { -- struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = 0; -+ writeb_relaxed(0, epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET); - -- while (port < ARRAY_SIZE(epg->gc) && gc != &epg->gc[port]) -- port++; -+ writeb_relaxed(eic->int_type2, -+ epg->base + eic->irq_offset + EP93XX_INT_TYPE2_OFFSET); - -- /* This should not happen but is there as a last safeguard */ -- if (port == ARRAY_SIZE(epg->gc)) { -- pr_crit("can't find the GPIO port\n"); -- return 0; -- } -+ writeb_relaxed(eic->int_type1, -+ epg->base + eic->irq_offset + EP93XX_INT_TYPE1_OFFSET); - -- return port; -+ writeb_relaxed(eic->int_unmasked & eic->int_enabled, -+ epg->base + eic->irq_offset + EP93XX_INT_EN_OFFSET); - } - - static void ep93xx_gpio_int_debounce(struct gpio_chip *gc, - unsigned int offset, bool enable) - { - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - int port_mask = BIT(offset); - - if (enable) -- gpio_int_debounce[port] |= port_mask; -+ eic->int_debounce |= port_mask; - else -- gpio_int_debounce[port] &= ~port_mask; -+ eic->int_debounce &= ~port_mask; - -- writeb(gpio_int_debounce[port], -- epg->base + int_debounce_register_offset[port]); -+ writeb(eic->int_debounce, -+ epg->base + eic->irq_offset + EP93XX_INT_DEBOUNCE_OFFSET); - } - - static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc) -@@ -122,12 +126,12 @@ static void ep93xx_gpio_ab_irq_handler(struct irq_desc *desc) - */ - stat = readb(epg->base + EP93XX_GPIO_A_INT_STATUS); - for_each_set_bit(offset, &stat, 8) -- generic_handle_irq(irq_find_mapping(epg->gc[0].irq.domain, -+ generic_handle_irq(irq_find_mapping(epg->gc[0].gc.irq.domain, - offset)); - - stat = readb(epg->base + EP93XX_GPIO_B_INT_STATUS); - for_each_set_bit(offset, &stat, 8) -- generic_handle_irq(irq_find_mapping(epg->gc[1].irq.domain, -+ generic_handle_irq(irq_find_mapping(epg->gc[1].gc.irq.domain, - offset)); - - chained_irq_exit(irqchip, desc); -@@ -153,52 +157,52 @@ static void ep93xx_gpio_f_irq_handler(struct irq_desc *desc) - static void ep93xx_gpio_irq_ack(struct irq_data *d) - { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); - int port_mask = BIT(d->irq & 7); - - if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) { -- gpio_int_type2[port] ^= port_mask; /* switch edge direction */ -- ep93xx_gpio_update_int_params(epg, port); -+ eic->int_type2 ^= port_mask; /* switch edge direction */ -+ ep93xx_gpio_update_int_params(epg, eic); - } - -- writeb(port_mask, epg->base + eoi_register_offset[port]); -+ writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET); - } - - static void ep93xx_gpio_irq_mask_ack(struct irq_data *d) - { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); - int port_mask = BIT(d->irq & 7); - - if (irqd_get_trigger_type(d) == IRQ_TYPE_EDGE_BOTH) -- gpio_int_type2[port] ^= port_mask; /* switch edge direction */ -+ eic->int_type2 ^= port_mask; /* switch edge direction */ - -- gpio_int_unmasked[port] &= ~port_mask; -- ep93xx_gpio_update_int_params(epg, port); -+ eic->int_unmasked &= ~port_mask; -+ ep93xx_gpio_update_int_params(epg, eic); - -- writeb(port_mask, epg->base + eoi_register_offset[port]); -+ writeb(port_mask, epg->base + eic->irq_offset + EP93XX_INT_EOI_OFFSET); - } - - static void ep93xx_gpio_irq_mask(struct irq_data *d) - { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); - -- gpio_int_unmasked[port] &= ~BIT(d->irq & 7); -- ep93xx_gpio_update_int_params(epg, port); -+ eic->int_unmasked &= ~BIT(d->irq & 7); -+ ep93xx_gpio_update_int_params(epg, eic); - } - - static void ep93xx_gpio_irq_unmask(struct irq_data *d) - { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); - -- gpio_int_unmasked[port] |= BIT(d->irq & 7); -- ep93xx_gpio_update_int_params(epg, port); -+ eic->int_unmasked |= BIT(d->irq & 7); -+ ep93xx_gpio_update_int_params(epg, eic); - } - - /* -@@ -209,8 +213,8 @@ static void ep93xx_gpio_irq_unmask(struct irq_data *d) - static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) - { - struct gpio_chip *gc = irq_data_get_irq_chip_data(d); -+ struct ep93xx_gpio_irq_chip *eic = to_ep93xx_gpio_irq_chip(gc); - struct ep93xx_gpio *epg = gpiochip_get_data(gc); -- int port = ep93xx_gpio_port(gc); - int offset = d->irq & 7; - int port_mask = BIT(offset); - irq_flow_handler_t handler; -@@ -219,32 +223,32 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) - - switch (type) { - case IRQ_TYPE_EDGE_RISING: -- gpio_int_type1[port] |= port_mask; -- gpio_int_type2[port] |= port_mask; -+ eic->int_type1 |= port_mask; -+ eic->int_type2 |= port_mask; - handler = handle_edge_irq; - break; - case IRQ_TYPE_EDGE_FALLING: -- gpio_int_type1[port] |= port_mask; -- gpio_int_type2[port] &= ~port_mask; -+ eic->int_type1 |= port_mask; -+ eic->int_type2 &= ~port_mask; - handler = handle_edge_irq; - break; - case IRQ_TYPE_LEVEL_HIGH: -- gpio_int_type1[port] &= ~port_mask; -- gpio_int_type2[port] |= port_mask; -+ eic->int_type1 &= ~port_mask; -+ eic->int_type2 |= port_mask; - handler = handle_level_irq; - break; - case IRQ_TYPE_LEVEL_LOW: -- gpio_int_type1[port] &= ~port_mask; -- gpio_int_type2[port] &= ~port_mask; -+ eic->int_type1 &= ~port_mask; -+ eic->int_type2 &= ~port_mask; - handler = handle_level_irq; - break; - case IRQ_TYPE_EDGE_BOTH: -- gpio_int_type1[port] |= port_mask; -+ eic->int_type1 |= port_mask; - /* set initial polarity based on current input level */ - if (gc->get(gc, offset)) -- gpio_int_type2[port] &= ~port_mask; /* falling */ -+ eic->int_type2 &= ~port_mask; /* falling */ - else -- gpio_int_type2[port] |= port_mask; /* rising */ -+ eic->int_type2 |= port_mask; /* rising */ - handler = handle_edge_irq; - break; - default: -@@ -253,22 +257,13 @@ static int ep93xx_gpio_irq_type(struct irq_data *d, unsigned int type) - - irq_set_handler_locked(d, handler); - -- gpio_int_enabled[port] |= port_mask; -+ eic->int_enabled |= port_mask; - -- ep93xx_gpio_update_int_params(epg, port); -+ ep93xx_gpio_update_int_params(epg, eic); - - return 0; - } - --static struct irq_chip ep93xx_gpio_irq_chip = { -- .name = "GPIO", -- .irq_ack = ep93xx_gpio_irq_ack, -- .irq_mask_ack = ep93xx_gpio_irq_mask_ack, -- .irq_mask = ep93xx_gpio_irq_mask, -- .irq_unmask = ep93xx_gpio_irq_unmask, -- .irq_set_type = ep93xx_gpio_irq_type, --}; -- - /************************************************************************* - * gpiolib interface for EP93xx on-chip GPIOs - *************************************************************************/ -@@ -276,17 +271,19 @@ struct ep93xx_gpio_bank { - const char *label; - int data; - int dir; -+ int irq; - int base; - bool has_irq; - bool has_hierarchical_irq; - unsigned int irq_base; - }; - --#define EP93XX_GPIO_BANK(_label, _data, _dir, _base, _has_irq, _has_hier, _irq_base) \ -+#define EP93XX_GPIO_BANK(_label, _data, _dir, _irq, _base, _has_irq, _has_hier, _irq_base) \ - { \ - .label = _label, \ - .data = _data, \ - .dir = _dir, \ -+ .irq = _irq, \ - .base = _base, \ - .has_irq = _has_irq, \ - .has_hierarchical_irq = _has_hier, \ -@@ -295,16 +292,16 @@ struct ep93xx_gpio_bank { - - static struct ep93xx_gpio_bank ep93xx_gpio_banks[] = { - /* Bank A has 8 IRQs */ -- EP93XX_GPIO_BANK("A", 0x00, 0x10, 0, true, false, 64), -+ EP93XX_GPIO_BANK("A", 0x00, 0x10, 0x90, 0, true, false, 64), - /* Bank B has 8 IRQs */ -- EP93XX_GPIO_BANK("B", 0x04, 0x14, 8, true, false, 72), -- EP93XX_GPIO_BANK("C", 0x08, 0x18, 40, false, false, 0), -- EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 24, false, false, 0), -- EP93XX_GPIO_BANK("E", 0x20, 0x24, 32, false, false, 0), -+ EP93XX_GPIO_BANK("B", 0x04, 0x14, 0xac, 8, true, false, 72), -+ EP93XX_GPIO_BANK("C", 0x08, 0x18, 0x00, 40, false, false, 0), -+ EP93XX_GPIO_BANK("D", 0x0c, 0x1c, 0x00, 24, false, false, 0), -+ EP93XX_GPIO_BANK("E", 0x20, 0x24, 0x00, 32, false, false, 0), - /* Bank F has 8 IRQs */ -- EP93XX_GPIO_BANK("F", 0x30, 0x34, 16, false, true, 0), -- EP93XX_GPIO_BANK("G", 0x38, 0x3c, 48, false, false, 0), -- EP93XX_GPIO_BANK("H", 0x40, 0x44, 56, false, false, 0), -+ EP93XX_GPIO_BANK("F", 0x30, 0x34, 0x4c, 16, false, true, 0), -+ EP93XX_GPIO_BANK("G", 0x38, 0x3c, 0x00, 48, false, false, 0), -+ EP93XX_GPIO_BANK("H", 0x40, 0x44, 0x00, 56, false, false, 0), - }; - - static int ep93xx_gpio_set_config(struct gpio_chip *gc, unsigned offset, -@@ -326,13 +323,23 @@ static int ep93xx_gpio_f_to_irq(struct gpio_chip *gc, unsigned offset) - return EP93XX_GPIO_F_IRQ_BASE + offset; - } - --static int ep93xx_gpio_add_bank(struct gpio_chip *gc, -+static void ep93xx_init_irq_chip(struct device *dev, struct irq_chip *ic) -+{ -+ ic->irq_ack = ep93xx_gpio_irq_ack; -+ ic->irq_mask_ack = ep93xx_gpio_irq_mask_ack; -+ ic->irq_mask = ep93xx_gpio_irq_mask; -+ ic->irq_unmask = ep93xx_gpio_irq_unmask; -+ ic->irq_set_type = ep93xx_gpio_irq_type; -+} -+ -+static int ep93xx_gpio_add_bank(struct ep93xx_gpio_chip *egc, - struct platform_device *pdev, - struct ep93xx_gpio *epg, - struct ep93xx_gpio_bank *bank) - { - void __iomem *data = epg->base + bank->data; - void __iomem *dir = epg->base + bank->dir; -+ struct gpio_chip *gc = &egc->gc; - struct device *dev = &pdev->dev; - struct gpio_irq_chip *girq; - int err; -@@ -346,8 +353,21 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc, - - girq = &gc->irq; - if (bank->has_irq || bank->has_hierarchical_irq) { -+ struct irq_chip *ic; -+ - gc->set_config = ep93xx_gpio_set_config; -- girq->chip = &ep93xx_gpio_irq_chip; -+ egc->eic = devm_kcalloc(dev, 1, -+ sizeof(*egc->eic), -+ GFP_KERNEL); -+ if (!egc->eic) -+ return -ENOMEM; -+ egc->eic->irq_offset = bank->irq; -+ ic = &egc->eic->ic; -+ ic->name = devm_kasprintf(dev, GFP_KERNEL, "gpio-irq-%s", bank->label); -+ if (!ic->name) -+ return -ENOMEM; -+ ep93xx_init_irq_chip(dev, ic); -+ girq->chip = ic; - } - - if (bank->has_irq) { -@@ -389,7 +409,7 @@ static int ep93xx_gpio_add_bank(struct gpio_chip *gc, - gpio_irq = EP93XX_GPIO_F_IRQ_BASE + i; - irq_set_chip_data(gpio_irq, &epg->gc[5]); - irq_set_chip_and_handler(gpio_irq, -- &ep93xx_gpio_irq_chip, -+ girq->chip, - handle_level_irq); - irq_clear_status_flags(gpio_irq, IRQ_NOREQUEST); - } -@@ -415,7 +435,7 @@ static int ep93xx_gpio_probe(struct platform_device *pdev) - return PTR_ERR(epg->base); - - for (i = 0; i < ARRAY_SIZE(ep93xx_gpio_banks); i++) { -- struct gpio_chip *gc = &epg->gc[i]; -+ struct ep93xx_gpio_chip *gc = &epg->gc[i]; - struct ep93xx_gpio_bank *bank = &ep93xx_gpio_banks[i]; - - if (ep93xx_gpio_add_bank(gc, pdev, epg, bank)) -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 de06ee7d2ad46..fbbe611d4873f 100644 ---- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c -@@ -1093,8 +1093,8 @@ static void emulated_link_detect(struct dc_link *link) - link->type = dc_connection_none; - prev_sink = link->local_sink; - -- if (prev_sink != NULL) -- dc_sink_retain(prev_sink); -+ if (prev_sink) -+ dc_sink_release(prev_sink); - - switch (link->connector_signal) { - case SIGNAL_TYPE_HDMI_TYPE_A: { -@@ -1417,8 +1417,10 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector) - * TODO: check if we still need the S3 mode update workaround. - * If yes, put it here. - */ -- if (aconnector->dc_sink) -+ if (aconnector->dc_sink) { - amdgpu_dm_update_freesync_caps(connector, NULL); -+ dc_sink_release(aconnector->dc_sink); -+ } - - aconnector->dc_sink = sink; - dc_sink_retain(aconnector->dc_sink); -@@ -6463,14 +6465,14 @@ static int dm_force_atomic_commit(struct drm_connector *connector) - - ret = PTR_ERR_OR_ZERO(conn_state); - if (ret) -- goto err; -+ goto out; - - /* Attach crtc to drm_atomic_state*/ - crtc_state = drm_atomic_get_crtc_state(state, &disconnected_acrtc->base); - - ret = PTR_ERR_OR_ZERO(crtc_state); - if (ret) -- goto err; -+ goto out; - - /* force a restore */ - crtc_state->mode_changed = true; -@@ -6480,17 +6482,15 @@ static int dm_force_atomic_commit(struct drm_connector *connector) - - ret = PTR_ERR_OR_ZERO(plane_state); - if (ret) -- goto err; -- -+ goto out; - - /* Call commit internally with the state we just constructed */ - ret = drm_atomic_commit(state); -- if (!ret) -- return 0; - --err: -- DRM_ERROR("Restoring old state failed with %i\n", ret); -+out: - drm_atomic_state_put(state); -+ if (ret) -+ DRM_ERROR("Restoring old state failed with %i\n", ret); - - return ret; - } -diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -index a6d5beada6634..f63cbbee7b337 100644 ---- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -@@ -826,6 +826,8 @@ enum dcn20_clk_src_array_id { - DCN20_CLK_SRC_PLL0, - DCN20_CLK_SRC_PLL1, - DCN20_CLK_SRC_PLL2, -+ DCN20_CLK_SRC_PLL3, -+ DCN20_CLK_SRC_PLL4, - DCN20_CLK_SRC_TOTAL_DCN21 - }; - -@@ -1498,6 +1500,14 @@ static bool construct( - dcn21_clock_source_create(ctx, ctx->dc_bios, - CLOCK_SOURCE_COMBO_PHY_PLL2, - &clk_src_regs[2], false); -+ pool->base.clock_sources[DCN20_CLK_SRC_PLL3] = -+ dcn21_clock_source_create(ctx, ctx->dc_bios, -+ CLOCK_SOURCE_COMBO_PHY_PLL3, -+ &clk_src_regs[3], false); -+ pool->base.clock_sources[DCN20_CLK_SRC_PLL4] = -+ dcn21_clock_source_create(ctx, ctx->dc_bios, -+ CLOCK_SOURCE_COMBO_PHY_PLL4, -+ &clk_src_regs[4], false); - - pool->base.clk_src_count = DCN20_CLK_SRC_TOTAL_DCN21; - -diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c -index ae7ae432aa4ab..6bf1425e8b0ca 100644 ---- a/drivers/gpu/drm/sun4i/sun4i_tcon.c -+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c -@@ -665,6 +665,30 @@ static void sun4i_tcon1_mode_set(struct sun4i_tcon *tcon, - SUN4I_TCON1_BASIC5_V_SYNC(vsync) | - SUN4I_TCON1_BASIC5_H_SYNC(hsync)); - -+ /* Setup the polarity of multiple signals */ -+ if (tcon->quirks->polarity_in_ch0) { -+ val = 0; -+ -+ if (mode->flags & DRM_MODE_FLAG_PHSYNC) -+ val |= SUN4I_TCON0_IO_POL_HSYNC_POSITIVE; -+ -+ if (mode->flags & DRM_MODE_FLAG_PVSYNC) -+ val |= SUN4I_TCON0_IO_POL_VSYNC_POSITIVE; -+ -+ regmap_write(tcon->regs, SUN4I_TCON0_IO_POL_REG, val); -+ } else { -+ /* according to vendor driver, this bit must be always set */ -+ val = SUN4I_TCON1_IO_POL_UNKNOWN; -+ -+ if (mode->flags & DRM_MODE_FLAG_PHSYNC) -+ val |= SUN4I_TCON1_IO_POL_HSYNC_POSITIVE; -+ -+ if (mode->flags & DRM_MODE_FLAG_PVSYNC) -+ val |= SUN4I_TCON1_IO_POL_VSYNC_POSITIVE; -+ -+ regmap_write(tcon->regs, SUN4I_TCON1_IO_POL_REG, val); -+ } -+ - /* Map output pins to channel 1 */ - regmap_update_bits(tcon->regs, SUN4I_TCON_GCTL_REG, - SUN4I_TCON_GCTL_IOMAP_MASK, -@@ -1482,6 +1506,7 @@ static const struct sun4i_tcon_quirks sun8i_a83t_tv_quirks = { - - static const struct sun4i_tcon_quirks sun8i_r40_tv_quirks = { - .has_channel_1 = true, -+ .polarity_in_ch0 = true, - .set_mux = sun8i_r40_tcon_tv_set_mux, - }; - -diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h -index a62ec826ae71e..5bdbaf0847824 100644 ---- a/drivers/gpu/drm/sun4i/sun4i_tcon.h -+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h -@@ -153,6 +153,11 @@ - #define SUN4I_TCON1_BASIC5_V_SYNC(height) (((height) - 1) & 0x3ff) - - #define SUN4I_TCON1_IO_POL_REG 0xf0 -+/* there is no documentation about this bit */ -+#define SUN4I_TCON1_IO_POL_UNKNOWN BIT(26) -+#define SUN4I_TCON1_IO_POL_HSYNC_POSITIVE BIT(25) -+#define SUN4I_TCON1_IO_POL_VSYNC_POSITIVE BIT(24) -+ - #define SUN4I_TCON1_IO_TRI_REG 0xf4 - - #define SUN4I_TCON_ECC_FIFO_REG 0xf8 -@@ -224,6 +229,7 @@ struct sun4i_tcon_quirks { - bool needs_de_be_mux; /* sun6i needs mux to select backend */ - bool needs_edp_reset; /* a80 edp reset needed for tcon0 access */ - bool supports_lvds; /* Does the TCON support an LVDS output? */ -+ bool polarity_in_ch0; /* some tcon1 channels have polarity bits in tcon0 pol register */ - u8 dclk_min_div; /* minimum divider for TCON0 DCLK */ - - /* callback to handle tcon muxing options */ -diff --git a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c -index 12fe241956213..8f721be26477b 100644 ---- a/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c -+++ b/drivers/gpu/drm/sun4i/sun8i_dw_hdmi.c -@@ -49,11 +49,9 @@ sun8i_dw_hdmi_mode_valid_h6(struct drm_connector *connector, - { - /* - * Controller support maximum of 594 MHz, which correlates to -- * 4K@60Hz 4:4:4 or RGB. However, for frequencies greater than -- * 340 MHz scrambling has to be enabled. Because scrambling is -- * not yet implemented, just limit to 340 MHz for now. -+ * 4K@60Hz 4:4:4 or RGB. - */ -- if (mode->clock > 340000) -+ if (mode->clock > 594000) - return MODE_CLOCK_HIGH; - - return MODE_OK; -diff --git a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c -index 43643ad317306..a4012ec13d4b3 100644 ---- a/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c -+++ b/drivers/gpu/drm/sun4i/sun8i_hdmi_phy.c -@@ -104,29 +104,21 @@ static const struct dw_hdmi_mpll_config sun50i_h6_mpll_cfg[] = { - - static const struct dw_hdmi_curr_ctrl sun50i_h6_cur_ctr[] = { - /* pixelclk bpp8 bpp10 bpp12 */ -- { 25175000, { 0x0000, 0x0000, 0x0000 }, }, - { 27000000, { 0x0012, 0x0000, 0x0000 }, }, -- { 59400000, { 0x0008, 0x0008, 0x0008 }, }, -- { 72000000, { 0x0008, 0x0008, 0x001b }, }, -- { 74250000, { 0x0013, 0x0013, 0x0013 }, }, -- { 90000000, { 0x0008, 0x001a, 0x001b }, }, -- { 118800000, { 0x001b, 0x001a, 0x001b }, }, -- { 144000000, { 0x001b, 0x001a, 0x0034 }, }, -- { 180000000, { 0x001b, 0x0033, 0x0034 }, }, -- { 216000000, { 0x0036, 0x0033, 0x0034 }, }, -- { 237600000, { 0x0036, 0x0033, 0x001b }, }, -- { 288000000, { 0x0036, 0x001b, 0x001b }, }, -- { 297000000, { 0x0019, 0x001b, 0x0019 }, }, -- { 330000000, { 0x0036, 0x001b, 0x001b }, }, -- { 594000000, { 0x003f, 0x001b, 0x001b }, }, -+ { 74250000, { 0x0013, 0x001a, 0x001b }, }, -+ { 148500000, { 0x0019, 0x0033, 0x0034 }, }, -+ { 297000000, { 0x0019, 0x001b, 0x001b }, }, -+ { 594000000, { 0x0010, 0x001b, 0x001b }, }, - { ~0UL, { 0x0000, 0x0000, 0x0000 }, } - }; - - static const struct dw_hdmi_phy_config sun50i_h6_phy_config[] = { - /*pixelclk symbol term vlev*/ -- { 74250000, 0x8009, 0x0004, 0x0232}, -- { 148500000, 0x8029, 0x0004, 0x0273}, -- { 594000000, 0x8039, 0x0004, 0x014a}, -+ { 27000000, 0x8009, 0x0007, 0x02b0 }, -+ { 74250000, 0x8009, 0x0006, 0x022d }, -+ { 148500000, 0x8029, 0x0006, 0x0270 }, -+ { 297000000, 0x8039, 0x0005, 0x01ab }, -+ { 594000000, 0x8029, 0x0000, 0x008a }, - { ~0UL, 0x0000, 0x0000, 0x0000} - }; - -diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c -index 5e5f90810acaf..363f456ea7134 100644 ---- a/drivers/gpu/drm/vc4/vc4_plane.c -+++ b/drivers/gpu/drm/vc4/vc4_plane.c -@@ -205,7 +205,7 @@ static void vc4_plane_reset(struct drm_plane *plane) - __drm_atomic_helper_plane_reset(plane, &vc4_state->base); - } - --static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val) -+static void vc4_dlist_counter_increment(struct vc4_plane_state *vc4_state) - { - if (vc4_state->dlist_count == vc4_state->dlist_size) { - u32 new_size = max(4u, vc4_state->dlist_count * 2); -@@ -220,7 +220,15 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val) - vc4_state->dlist_size = new_size; - } - -- vc4_state->dlist[vc4_state->dlist_count++] = val; -+ vc4_state->dlist_count++; -+} -+ -+static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val) -+{ -+ unsigned int idx = vc4_state->dlist_count; -+ -+ vc4_dlist_counter_increment(vc4_state); -+ vc4_state->dlist[idx] = val; - } - - /* Returns the scl0/scl1 field based on whether the dimensions need to -@@ -871,8 +879,10 @@ static int vc4_plane_mode_set(struct drm_plane *plane, - * be set when calling vc4_plane_allocate_lbm(). - */ - if (vc4_state->y_scaling[0] != VC4_SCALING_NONE || -- vc4_state->y_scaling[1] != VC4_SCALING_NONE) -- vc4_state->lbm_offset = vc4_state->dlist_count++; -+ vc4_state->y_scaling[1] != VC4_SCALING_NONE) { -+ vc4_state->lbm_offset = vc4_state->dlist_count; -+ vc4_dlist_counter_increment(vc4_state); -+ } - - if (num_planes > 1) { - /* Emit Cb/Cr as channel 0 and Y as channel -diff --git a/drivers/i2c/busses/i2c-stm32f7.c b/drivers/i2c/busses/i2c-stm32f7.c -index b2634afe066d3..a7977eef2ead5 100644 ---- a/drivers/i2c/busses/i2c-stm32f7.c -+++ b/drivers/i2c/busses/i2c-stm32f7.c -@@ -53,6 +53,8 @@ - #define STM32F7_I2C_CR1_RXDMAEN BIT(15) - #define STM32F7_I2C_CR1_TXDMAEN BIT(14) - #define STM32F7_I2C_CR1_ANFOFF BIT(12) -+#define STM32F7_I2C_CR1_DNF_MASK GENMASK(11, 8) -+#define STM32F7_I2C_CR1_DNF(n) (((n) & 0xf) << 8) - #define STM32F7_I2C_CR1_ERRIE BIT(7) - #define STM32F7_I2C_CR1_TCIE BIT(6) - #define STM32F7_I2C_CR1_STOPIE BIT(5) -@@ -151,7 +153,7 @@ - #define STM32F7_I2C_MAX_SLAVE 0x2 - - #define STM32F7_I2C_DNF_DEFAULT 0 --#define STM32F7_I2C_DNF_MAX 16 -+#define STM32F7_I2C_DNF_MAX 15 - - #define STM32F7_I2C_ANALOG_FILTER_ENABLE 1 - #define STM32F7_I2C_ANALOG_FILTER_DELAY_MIN 50 /* ns */ -@@ -657,6 +659,13 @@ static void stm32f7_i2c_hw_config(struct stm32f7_i2c_dev *i2c_dev) - else - stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1, - STM32F7_I2C_CR1_ANFOFF); -+ -+ /* Program the Digital Filter */ -+ stm32f7_i2c_clr_bits(i2c_dev->base + STM32F7_I2C_CR1, -+ STM32F7_I2C_CR1_DNF_MASK); -+ stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1, -+ STM32F7_I2C_CR1_DNF(i2c_dev->setup.dnf)); -+ - stm32f7_i2c_set_bits(i2c_dev->base + STM32F7_I2C_CR1, - STM32F7_I2C_CR1_PE); - } -diff --git a/drivers/misc/lkdtm/Makefile b/drivers/misc/lkdtm/Makefile -index c70b3822013f4..30c8ac24635d4 100644 ---- a/drivers/misc/lkdtm/Makefile -+++ b/drivers/misc/lkdtm/Makefile -@@ -16,7 +16,7 @@ KCOV_INSTRUMENT_rodata.o := n - - OBJCOPYFLAGS := - OBJCOPYFLAGS_rodata_objcopy.o := \ -- --rename-section .text=.rodata,alloc,readonly,load -+ --rename-section .noinstr.text=.rodata,alloc,readonly,load - targets += rodata.o rodata_objcopy.o - $(obj)/rodata_objcopy.o: $(obj)/rodata.o FORCE - $(call if_changed,objcopy) -diff --git a/drivers/misc/lkdtm/rodata.c b/drivers/misc/lkdtm/rodata.c -index 58d180af72cf0..baacb876d1d94 100644 ---- a/drivers/misc/lkdtm/rodata.c -+++ b/drivers/misc/lkdtm/rodata.c -@@ -5,7 +5,7 @@ - */ - #include "lkdtm.h" - --void notrace lkdtm_rodata_do_nothing(void) -+void noinstr lkdtm_rodata_do_nothing(void) - { - /* Does nothing. We just want an architecture agnostic "return". */ - } -diff --git a/drivers/net/ethernet/freescale/enetc/enetc_hw.h b/drivers/net/ethernet/freescale/enetc/enetc_hw.h -index 7428f62408a20..fac80831d5327 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc_hw.h -+++ b/drivers/net/ethernet/freescale/enetc/enetc_hw.h -@@ -181,6 +181,8 @@ enum enetc_bdr_type {TX, RX}; - #define ENETC_PTCCBSR0(n) (0x1110 + (n) * 8) /* n = 0 to 7*/ - #define ENETC_PTCCBSR1(n) (0x1114 + (n) * 8) /* n = 0 to 7*/ - #define ENETC_RSSHASH_KEY_SIZE 40 -+#define ENETC_PRSSCAPR 0x1404 -+#define ENETC_PRSSCAPR_GET_NUM_RSS(val) (BIT((val) & 0xf) * 32) - #define ENETC_PRSSK(n) (0x1410 + (n) * 4) /* n = [0..9] */ - #define ENETC_PSIVLANFMR 0x1700 - #define ENETC_PSIVLANFMR_VS BIT(0) -diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -index 74847aa644f12..22f70638a4055 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c -+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -@@ -809,6 +809,51 @@ static void enetc_of_put_phy(struct enetc_ndev_priv *priv) - of_node_put(priv->phy_node); - } - -+/* Initialize the entire shared memory for the flow steering entries -+ * of this port (PF + VFs) -+ */ -+static int enetc_init_port_rfs_memory(struct enetc_si *si) -+{ -+ struct enetc_cmd_rfse rfse = {0}; -+ struct enetc_hw *hw = &si->hw; -+ int num_rfs, i, err = 0; -+ u32 val; -+ -+ val = enetc_port_rd(hw, ENETC_PRFSCAPR); -+ num_rfs = ENETC_PRFSCAPR_GET_NUM_RFS(val); -+ -+ for (i = 0; i < num_rfs; i++) { -+ err = enetc_set_fs_entry(si, &rfse, i); -+ if (err) -+ break; -+ } -+ -+ return err; -+} -+ -+static int enetc_init_port_rss_memory(struct enetc_si *si) -+{ -+ struct enetc_hw *hw = &si->hw; -+ int num_rss, err; -+ int *rss_table; -+ u32 val; -+ -+ val = enetc_port_rd(hw, ENETC_PRSSCAPR); -+ num_rss = ENETC_PRSSCAPR_GET_NUM_RSS(val); -+ if (!num_rss) -+ return 0; -+ -+ rss_table = kcalloc(num_rss, sizeof(*rss_table), GFP_KERNEL); -+ if (!rss_table) -+ return -ENOMEM; -+ -+ err = enetc_set_rss_table(si, rss_table, num_rss); -+ -+ kfree(rss_table); -+ -+ return err; -+} -+ - static int enetc_pf_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) - { -@@ -863,6 +908,18 @@ static int enetc_pf_probe(struct pci_dev *pdev, - goto err_alloc_si_res; - } - -+ err = enetc_init_port_rfs_memory(si); -+ if (err) { -+ dev_err(&pdev->dev, "Failed to initialize RFS memory\n"); -+ goto err_init_port_rfs; -+ } -+ -+ err = enetc_init_port_rss_memory(si); -+ if (err) { -+ dev_err(&pdev->dev, "Failed to initialize RSS memory\n"); -+ goto err_init_port_rss; -+ } -+ - err = enetc_alloc_msix(priv); - if (err) { - dev_err(&pdev->dev, "MSIX alloc failed\n"); -@@ -888,6 +945,8 @@ err_reg_netdev: - enetc_mdio_remove(pf); - enetc_of_put_phy(priv); - enetc_free_msix(priv); -+err_init_port_rss: -+err_init_port_rfs: - err_alloc_msix: - enetc_free_si_resources(priv); - err_alloc_si_res: -diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -index 6887b7fda6e07..08040cafc06bc 100644 ---- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -@@ -8563,12 +8563,19 @@ int hclge_reset_tqp(struct hnae3_handle *handle, u16 queue_id) - - void hclge_reset_vf_queue(struct hclge_vport *vport, u16 queue_id) - { -+ struct hnae3_handle *handle = &vport->nic; - struct hclge_dev *hdev = vport->back; - int reset_try_times = 0; - int reset_status; - u16 queue_gid; - int ret; - -+ if (queue_id >= handle->kinfo.num_tqps) { -+ dev_warn(&hdev->pdev->dev, "Invalid vf queue id(%u)\n", -+ queue_id); -+ return; -+ } -+ - queue_gid = hclge_covert_handle_qid_global(&vport->nic, queue_id); - - ret = hclge_send_reset_tqp_cmd(hdev, queue_gid, true); -diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c -index c3079f436f6d7..0f35eec967ae8 100644 ---- a/drivers/net/ethernet/ibm/ibmvnic.c -+++ b/drivers/net/ethernet/ibm/ibmvnic.c -@@ -4595,7 +4595,22 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq, - complete(&adapter->init_done); - adapter->init_done_rc = -EIO; - } -- ibmvnic_reset(adapter, VNIC_RESET_FAILOVER); -+ rc = ibmvnic_reset(adapter, VNIC_RESET_FAILOVER); -+ if (rc && rc != -EBUSY) { -+ /* We were unable to schedule the failover -+ * reset either because the adapter was still -+ * probing (eg: during kexec) or we could not -+ * allocate memory. Clear the failover_pending -+ * flag since no one else will. We ignore -+ * EBUSY because it means either FAILOVER reset -+ * is already scheduled or the adapter is -+ * being removed. -+ */ -+ netdev_err(netdev, -+ "Error %ld scheduling failover reset\n", -+ rc); -+ adapter->failover_pending = false; -+ } - break; - case IBMVNIC_CRQ_INIT_COMPLETE: - dev_info(dev, "Partner initialization complete\n"); -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c -index 1d135b02ea021..52b453b605979 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c -@@ -332,7 +332,12 @@ static int tc_setup_cbs(struct stmmac_priv *priv, - - priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_AVB; - } else if (!qopt->enable) { -- return stmmac_dma_qmode(priv, priv->ioaddr, queue, MTL_QUEUE_DCB); -+ ret = stmmac_dma_qmode(priv, priv->ioaddr, queue, -+ MTL_QUEUE_DCB); -+ if (ret) -+ return ret; -+ -+ priv->plat->tx_queues_cfg[queue].mode_to_use = MTL_QUEUE_DCB; - } - - /* Port Transmit Rate and Speed Divider */ -diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c -index 026d996612fbe..781952b686ed2 100644 ---- a/drivers/net/wireless/mediatek/mt76/dma.c -+++ b/drivers/net/wireless/mediatek/mt76/dma.c -@@ -452,15 +452,17 @@ static void - mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, - int len, bool more) - { -- struct page *page = virt_to_head_page(data); -- int offset = data - page_address(page); - struct sk_buff *skb = q->rx_head; - struct skb_shared_info *shinfo = skb_shinfo(skb); - - if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) { -- offset += q->buf_offset; -+ struct page *page = virt_to_head_page(data); -+ int offset = data - page_address(page) + q->buf_offset; -+ - skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len, - q->buf_size); -+ } else { -+ skb_free_frag(data); - } - - if (more) -diff --git a/drivers/net/xen-netback/rx.c b/drivers/net/xen-netback/rx.c -index 9b62f65b630e4..48e2006f96ce6 100644 ---- a/drivers/net/xen-netback/rx.c -+++ b/drivers/net/xen-netback/rx.c -@@ -38,10 +38,15 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) - RING_IDX prod, cons; - struct sk_buff *skb; - int needed; -+ unsigned long flags; -+ -+ spin_lock_irqsave(&queue->rx_queue.lock, flags); - - skb = skb_peek(&queue->rx_queue); -- if (!skb) -+ if (!skb) { -+ spin_unlock_irqrestore(&queue->rx_queue.lock, flags); - return false; -+ } - - needed = DIV_ROUND_UP(skb->len, XEN_PAGE_SIZE); - if (skb_is_gso(skb)) -@@ -49,6 +54,8 @@ static bool xenvif_rx_ring_slots_available(struct xenvif_queue *queue) - if (skb->sw_hash) - needed++; - -+ spin_unlock_irqrestore(&queue->rx_queue.lock, flags); -+ - do { - prod = queue->rx.sring->req_prod; - cons = queue->rx.req_cons; -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index 434d3f21f0e13..19e375b59f407 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -3147,6 +3147,8 @@ static const struct pci_device_id nvme_id_table[] = { - { PCI_DEVICE(0x144d, 0xa822), /* Samsung PM1725a */ - .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY | - NVME_QUIRK_IGNORE_DEV_SUBNQN, }, -+ { PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */ -+ .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, }, - { PCI_DEVICE(0x1d1d, 0x1f1f), /* LighNVM qemu device */ - .driver_data = NVME_QUIRK_LIGHTNVM, }, - { PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */ -diff --git a/drivers/platform/x86/hp-wmi.c b/drivers/platform/x86/hp-wmi.c -index a44a2ec332872..63a530a3d9feb 100644 ---- a/drivers/platform/x86/hp-wmi.c -+++ b/drivers/platform/x86/hp-wmi.c -@@ -32,6 +32,10 @@ MODULE_LICENSE("GPL"); - MODULE_ALIAS("wmi:95F24279-4D7B-4334-9387-ACCDC67EF61C"); - MODULE_ALIAS("wmi:5FB7F034-2C63-45e9-BE91-3D44E2C707E4"); - -+static int enable_tablet_mode_sw = -1; -+module_param(enable_tablet_mode_sw, int, 0444); -+MODULE_PARM_DESC(enable_tablet_mode_sw, "Enable SW_TABLET_MODE reporting (-1=auto, 0=no, 1=yes)"); -+ - #define HPWMI_EVENT_GUID "95F24279-4D7B-4334-9387-ACCDC67EF61C" - #define HPWMI_BIOS_GUID "5FB7F034-2C63-45e9-BE91-3D44E2C707E4" - -@@ -654,10 +658,12 @@ static int __init hp_wmi_input_setup(void) - } - - /* Tablet mode */ -- val = hp_wmi_hw_state(HPWMI_TABLET_MASK); -- if (!(val < 0)) { -- __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); -- input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); -+ if (enable_tablet_mode_sw > 0) { -+ val = hp_wmi_hw_state(HPWMI_TABLET_MASK); -+ if (val >= 0) { -+ __set_bit(SW_TABLET_MODE, hp_wmi_input_dev->swbit); -+ input_report_switch(hp_wmi_input_dev, SW_TABLET_MODE, val); -+ } - } - - err = sparse_keymap_setup(hp_wmi_input_dev, hp_wmi_keymap, NULL); -diff --git a/drivers/usb/dwc3/ulpi.c b/drivers/usb/dwc3/ulpi.c -index bb8271531da70..ffe3440abb74c 100644 ---- a/drivers/usb/dwc3/ulpi.c -+++ b/drivers/usb/dwc3/ulpi.c -@@ -7,6 +7,8 @@ - * Author: Heikki Krogerus - */ - -+#include -+#include - #include - - #include "core.h" -@@ -17,12 +19,22 @@ - DWC3_GUSB2PHYACC_ADDR(ULPI_ACCESS_EXTENDED) | \ - DWC3_GUSB2PHYACC_EXTEND_ADDR(a) : DWC3_GUSB2PHYACC_ADDR(a)) - --static int dwc3_ulpi_busyloop(struct dwc3 *dwc) -+#define DWC3_ULPI_BASE_DELAY DIV_ROUND_UP(NSEC_PER_SEC, 60000000L) -+ -+static int dwc3_ulpi_busyloop(struct dwc3 *dwc, u8 addr, bool read) - { -- unsigned count = 1000; -+ unsigned long ns = 5L * DWC3_ULPI_BASE_DELAY; -+ unsigned int count = 1000; - u32 reg; - -+ if (addr >= ULPI_EXT_VENDOR_SPECIFIC) -+ ns += DWC3_ULPI_BASE_DELAY; -+ -+ if (read) -+ ns += DWC3_ULPI_BASE_DELAY; -+ - while (count--) { -+ ndelay(ns); - reg = dwc3_readl(dwc->regs, DWC3_GUSB2PHYACC(0)); - if (reg & DWC3_GUSB2PHYACC_DONE) - return 0; -@@ -47,7 +59,7 @@ static int dwc3_ulpi_read(struct device *dev, u8 addr) - reg = DWC3_GUSB2PHYACC_NEWREGREQ | DWC3_ULPI_ADDR(addr); - dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg); - -- ret = dwc3_ulpi_busyloop(dwc); -+ ret = dwc3_ulpi_busyloop(dwc, addr, true); - if (ret) - return ret; - -@@ -71,7 +83,7 @@ static int dwc3_ulpi_write(struct device *dev, u8 addr, u8 val) - reg |= DWC3_GUSB2PHYACC_WRITE | val; - dwc3_writel(dwc->regs, DWC3_GUSB2PHYACC(0), reg); - -- return dwc3_ulpi_busyloop(dwc); -+ return dwc3_ulpi_busyloop(dwc, addr, false); - } - - static const struct ulpi_ops dwc3_ulpi_ops = { -diff --git a/drivers/xen/xenbus/xenbus.h b/drivers/xen/xenbus/xenbus.h -index a9bb5f91082d3..88516a8a9f932 100644 ---- a/drivers/xen/xenbus/xenbus.h -+++ b/drivers/xen/xenbus/xenbus.h -@@ -115,7 +115,6 @@ int xenbus_probe_node(struct xen_bus_type *bus, - const char *type, - const char *nodename); - int xenbus_probe_devices(struct xen_bus_type *bus); --void xenbus_probe(void); - - void xenbus_dev_changed(const char *node, struct xen_bus_type *bus); - -diff --git a/drivers/xen/xenbus/xenbus_probe.c b/drivers/xen/xenbus/xenbus_probe.c -index 786494bb7f20b..652894d619677 100644 ---- a/drivers/xen/xenbus/xenbus_probe.c -+++ b/drivers/xen/xenbus/xenbus_probe.c -@@ -683,7 +683,7 @@ void unregister_xenstore_notifier(struct notifier_block *nb) - } - EXPORT_SYMBOL_GPL(unregister_xenstore_notifier); - --void xenbus_probe(void) -+static void xenbus_probe(void) - { - xenstored_ready = 1; - -diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c -index ec5eca5a96f41..7b758d623b5bd 100644 ---- a/fs/overlayfs/copy_up.c -+++ b/fs/overlayfs/copy_up.c -@@ -76,6 +76,14 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new) - - if (ovl_is_private_xattr(name)) - continue; -+ -+ error = security_inode_copy_up_xattr(name); -+ if (error < 0 && error != -EOPNOTSUPP) -+ break; -+ if (error == 1) { -+ error = 0; -+ continue; /* Discard */ -+ } - retry: - size = vfs_getxattr(old, name, value, value_size); - if (size == -ERANGE) -@@ -99,13 +107,6 @@ retry: - goto retry; - } - -- error = security_inode_copy_up_xattr(name); -- if (error < 0 && error != -EOPNOTSUPP) -- break; -- if (error == 1) { -- error = 0; -- continue; /* Discard */ -- } - error = vfs_setxattr(new, name, value, size, 0); - if (error) - break; -diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c -index bb980721502dd..56b55397a7a00 100644 ---- a/fs/overlayfs/inode.c -+++ b/fs/overlayfs/inode.c -@@ -337,7 +337,9 @@ int ovl_xattr_set(struct dentry *dentry, struct inode *inode, const char *name, - goto out; - - if (!value && !upperdentry) { -+ old_cred = ovl_override_creds(dentry->d_sb); - err = vfs_getxattr(realdentry, name, NULL, 0); -+ revert_creds(old_cred); - if (err < 0) - goto out_drop_write; - } -diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c -index d6b724beb304c..87cf9b1d2eca3 100644 ---- a/fs/overlayfs/super.c -+++ b/fs/overlayfs/super.c -@@ -79,7 +79,7 @@ static void ovl_dentry_release(struct dentry *dentry) - static struct dentry *ovl_d_real(struct dentry *dentry, - const struct inode *inode) - { -- struct dentry *real; -+ struct dentry *real = NULL, *lower; - - /* It's an overlay file */ - if (inode && d_inode(dentry) == inode) -@@ -98,9 +98,10 @@ static struct dentry *ovl_d_real(struct dentry *dentry, - if (real && !inode && ovl_has_upperdata(d_inode(dentry))) - return real; - -- real = ovl_dentry_lowerdata(dentry); -- if (!real) -+ lower = ovl_dentry_lowerdata(dentry); -+ if (!lower) - goto bug; -+ real = lower; - - /* Handle recursion */ - real = d_real(real, inode); -@@ -108,8 +109,10 @@ static struct dentry *ovl_d_real(struct dentry *dentry, - if (!inode || inode == d_inode(real)) - return real; - bug: -- WARN(1, "ovl_d_real(%pd4, %s:%lu): real dentry not found\n", dentry, -- inode ? inode->i_sb->s_id : "NULL", inode ? inode->i_ino : 0); -+ WARN(1, "%s(%pd4, %s:%lu): real dentry (%p/%lu) not found\n", -+ __func__, dentry, inode ? inode->i_sb->s_id : "NULL", -+ inode ? inode->i_ino : 0, real, -+ real && d_inode(real) ? d_inode(real)->i_ino : 0); - return dentry; - } - -diff --git a/include/asm-generic/sections.h b/include/asm-generic/sections.h -index d1779d442aa51..66397ed10acb7 100644 ---- a/include/asm-generic/sections.h -+++ b/include/asm-generic/sections.h -@@ -53,6 +53,9 @@ extern char __ctors_start[], __ctors_end[]; - /* Start and end of .opd section - used for function descriptors. */ - extern char __start_opd[], __end_opd[]; - -+/* Start and end of instrumentation protected text section */ -+extern char __noinstr_text_start[], __noinstr_text_end[]; -+ - extern __visible const void __nosave_begin, __nosave_end; - - /* Function descriptor handling (if any). Override in asm/sections.h */ -diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h -index 130f16cc0b86d..2267b7c763c64 100644 ---- a/include/asm-generic/vmlinux.lds.h -+++ b/include/asm-generic/vmlinux.lds.h -@@ -396,7 +396,7 @@ - } \ - \ - /* Built-in firmware blobs */ \ -- .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) { \ -+ .builtin_fw : AT(ADDR(.builtin_fw) - LOAD_OFFSET) ALIGN(8) { \ - __start_builtin_fw = .; \ - KEEP(*(.builtin_fw)) \ - __end_builtin_fw = .; \ -@@ -510,6 +510,15 @@ - #define RODATA RO_DATA_SECTION(4096) - #define RO_DATA(align) RO_DATA_SECTION(align) - -+/* -+ * Non-instrumentable text section -+ */ -+#define NOINSTR_TEXT \ -+ ALIGN_FUNCTION(); \ -+ __noinstr_text_start = .; \ -+ *(.noinstr.text) \ -+ __noinstr_text_end = .; -+ - /* - * .text section. Map to function alignment to avoid address changes - * during second ld run in second ld pass when generating System.map -@@ -524,6 +533,7 @@ - *(TEXT_MAIN .text.fixup) \ - *(.text.unlikely .text.unlikely.*) \ - *(.text.unknown .text.unknown.*) \ -+ NOINSTR_TEXT \ - *(.text..refcount) \ - *(.ref.text) \ - MEM_KEEP(init.text*) \ -diff --git a/include/linux/compiler.h b/include/linux/compiler.h -index f164a9b12813f..9446e8fbe55c5 100644 ---- a/include/linux/compiler.h -+++ b/include/linux/compiler.h -@@ -134,12 +134,65 @@ void ftrace_likely_update(struct ftrace_likely_data *f, int val, - /* Annotate a C jump table to allow objtool to follow the code flow */ - #define __annotate_jump_table __section(.rodata..c_jump_table) - -+#ifdef CONFIG_DEBUG_ENTRY -+/* Begin/end of an instrumentation safe region */ -+#define instrumentation_begin() ({ \ -+ asm volatile("%c0:\n\t" \ -+ ".pushsection .discard.instr_begin\n\t" \ -+ ".long %c0b - .\n\t" \ -+ ".popsection\n\t" : : "i" (__COUNTER__)); \ -+}) -+ -+/* -+ * Because instrumentation_{begin,end}() can nest, objtool validation considers -+ * _begin() a +1 and _end() a -1 and computes a sum over the instructions. -+ * When the value is greater than 0, we consider instrumentation allowed. -+ * -+ * There is a problem with code like: -+ * -+ * noinstr void foo() -+ * { -+ * instrumentation_begin(); -+ * ... -+ * if (cond) { -+ * instrumentation_begin(); -+ * ... -+ * instrumentation_end(); -+ * } -+ * bar(); -+ * instrumentation_end(); -+ * } -+ * -+ * If instrumentation_end() would be an empty label, like all the other -+ * annotations, the inner _end(), which is at the end of a conditional block, -+ * would land on the instruction after the block. -+ * -+ * If we then consider the sum of the !cond path, we'll see that the call to -+ * bar() is with a 0-value, even though, we meant it to happen with a positive -+ * value. -+ * -+ * To avoid this, have _end() be a NOP instruction, this ensures it will be -+ * part of the condition block and does not escape. -+ */ -+#define instrumentation_end() ({ \ -+ asm volatile("%c0: nop\n\t" \ -+ ".pushsection .discard.instr_end\n\t" \ -+ ".long %c0b - .\n\t" \ -+ ".popsection\n\t" : : "i" (__COUNTER__)); \ -+}) -+#endif /* CONFIG_DEBUG_ENTRY */ -+ - #else - #define annotate_reachable() - #define annotate_unreachable() - #define __annotate_jump_table - #endif - -+#ifndef instrumentation_begin -+#define instrumentation_begin() do { } while(0) -+#define instrumentation_end() do { } while(0) -+#endif -+ - #ifndef ASM_UNREACHABLE - # define ASM_UNREACHABLE - #endif -diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h -index 77433633572e4..b94d08d055ff5 100644 ---- a/include/linux/compiler_types.h -+++ b/include/linux/compiler_types.h -@@ -118,6 +118,10 @@ struct ftrace_likely_data { - #define notrace __attribute__((__no_instrument_function__)) - #endif - -+/* Section for code which can't be instrumented at all */ -+#define noinstr \ -+ noinline notrace __attribute((__section__(".noinstr.text"))) -+ - /* - * it doesn't make sense on ARM (currently the only user of __naked) - * to trace naked functions because then mcount is called without -diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h -index ec3081ab04c01..3e0692fd6282c 100644 ---- a/include/linux/netdevice.h -+++ b/include/linux/netdevice.h -@@ -4044,6 +4044,7 @@ static inline void netif_tx_disable(struct net_device *dev) - - local_bh_disable(); - cpu = smp_processor_id(); -+ spin_lock(&dev->tx_global_lock); - for (i = 0; i < dev->num_tx_queues; i++) { - struct netdev_queue *txq = netdev_get_tx_queue(dev, i); - -@@ -4051,6 +4052,7 @@ static inline void netif_tx_disable(struct net_device *dev) - netif_tx_stop_queue(txq); - __netif_tx_unlock(txq); - } -+ spin_unlock(&dev->tx_global_lock); - local_bh_enable(); - } - -diff --git a/include/linux/uio.h b/include/linux/uio.h -index ab5f523bc0df9..b74d292b9960e 100644 ---- a/include/linux/uio.h -+++ b/include/linux/uio.h -@@ -261,7 +261,13 @@ static inline void iov_iter_reexpand(struct iov_iter *i, size_t count) - { - i->count = count; - } --size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump, struct iov_iter *i); -+ -+struct csum_state { -+ __wsum csum; -+ size_t off; -+}; -+ -+size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csstate, struct iov_iter *i); - size_t csum_and_copy_from_iter(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); - bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, struct iov_iter *i); - size_t hash_and_copy_to_iter(const void *addr, size_t bytes, void *hashp, -diff --git a/include/xen/xenbus.h b/include/xen/xenbus.h -index fe9a9fa2ebc45..14d47ed4114fd 100644 ---- a/include/xen/xenbus.h -+++ b/include/xen/xenbus.h -@@ -187,8 +187,6 @@ void xs_suspend_cancel(void); - - struct work_struct; - --void xenbus_probe(void); -- - #define XENBUS_IS_ERR_READ(str) ({ \ - if (!IS_ERR(str) && strlen(str) == 0) { \ - kfree(str); \ -diff --git a/kernel/bpf/stackmap.c b/kernel/bpf/stackmap.c -index 173e983619d77..fba2ade28fb3a 100644 ---- a/kernel/bpf/stackmap.c -+++ b/kernel/bpf/stackmap.c -@@ -112,6 +112,8 @@ static struct bpf_map *stack_map_alloc(union bpf_attr *attr) - - /* hash table size must be power of 2 */ - n_buckets = roundup_pow_of_two(attr->max_entries); -+ if (!n_buckets) -+ return ERR_PTR(-E2BIG); - - cost = n_buckets * sizeof(struct stack_map_bucket *) + sizeof(*smap); - cost += n_buckets * (value_size + sizeof(struct stack_map_bucket)); -diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c -index 35faf082a709c..37db8eba149ac 100644 ---- a/kernel/cgroup/cgroup.c -+++ b/kernel/cgroup/cgroup.c -@@ -3627,6 +3627,7 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, - { - struct psi_trigger *new; - struct cgroup *cgrp; -+ struct psi_group *psi; - - cgrp = cgroup_kn_lock_live(of->kn, false); - if (!cgrp) -@@ -3635,7 +3636,8 @@ static ssize_t cgroup_pressure_write(struct kernfs_open_file *of, char *buf, - cgroup_get(cgrp); - cgroup_kn_unlock(of->kn); - -- new = psi_trigger_create(&cgrp->psi, buf, nbytes, res); -+ psi = cgroup_ino(cgrp) == 1 ? &psi_system : &cgrp->psi; -+ new = psi_trigger_create(psi, buf, nbytes, res); - if (IS_ERR(new)) { - cgroup_put(cgrp); - return PTR_ERR(new); -diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c -index 67af28f03cf41..1a75610f5f57b 100644 ---- a/kernel/trace/trace.c -+++ b/kernel/trace/trace.c -@@ -2498,7 +2498,7 @@ trace_event_buffer_lock_reserve(struct ring_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 (val == 1) { -+ if ((len < (PAGE_SIZE - sizeof(*entry))) && val == 1) { - trace_event_setup(entry, type, flags, pc); - entry->array[0] = len; - return entry; -diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c -index 309b2b3c5349e..e31ee325dad16 100644 ---- a/kernel/trace/trace_events.c -+++ b/kernel/trace/trace_events.c -@@ -1107,7 +1107,8 @@ system_enable_read(struct file *filp, char __user *ubuf, size_t cnt, - mutex_lock(&event_mutex); - list_for_each_entry(file, &tr->events, list) { - call = file->event_call; -- if (!trace_event_name(call) || !call->class || !call->class->reg) -+ if ((call->flags & TRACE_EVENT_FL_IGNORE_ENABLE) || -+ !trace_event_name(call) || !call->class || !call->class->reg) - continue; - - if (system && strcmp(call->class->system, system->name) != 0) -diff --git a/lib/iov_iter.c b/lib/iov_iter.c -index 639d5e7014c1e..9ea6f7bb83095 100644 ---- a/lib/iov_iter.c -+++ b/lib/iov_iter.c -@@ -570,12 +570,13 @@ static __wsum csum_and_memcpy(void *to, const void *from, size_t len, - } - - static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes, -- __wsum *csum, struct iov_iter *i) -+ struct csum_state *csstate, -+ struct iov_iter *i) - { - struct pipe_inode_info *pipe = i->pipe; -+ __wsum sum = csstate->csum; -+ size_t off = csstate->off; - size_t n, r; -- size_t off = 0; -- __wsum sum = *csum; - int idx; - - if (!sanity(i)) -@@ -596,7 +597,8 @@ static size_t csum_and_copy_to_pipe_iter(const void *addr, size_t bytes, - addr += chunk; - } - i->count -= bytes; -- *csum = sum; -+ csstate->csum = sum; -+ csstate->off = off; - return bytes; - } - -@@ -1484,18 +1486,19 @@ bool csum_and_copy_from_iter_full(void *addr, size_t bytes, __wsum *csum, - } - EXPORT_SYMBOL(csum_and_copy_from_iter_full); - --size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump, -+size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *_csstate, - struct iov_iter *i) - { -+ struct csum_state *csstate = _csstate; - const char *from = addr; -- __wsum *csum = csump; - __wsum sum, next; -- size_t off = 0; -+ size_t off; - - if (unlikely(iov_iter_is_pipe(i))) -- return csum_and_copy_to_pipe_iter(addr, bytes, csum, i); -+ return csum_and_copy_to_pipe_iter(addr, bytes, _csstate, i); - -- sum = *csum; -+ sum = csstate->csum; -+ off = csstate->off; - if (unlikely(iov_iter_is_discard(i))) { - WARN_ON(1); /* for now */ - return 0; -@@ -1524,7 +1527,8 @@ size_t csum_and_copy_to_iter(const void *addr, size_t bytes, void *csump, - off += v.iov_len; - }) - ) -- *csum = sum; -+ csstate->csum = sum; -+ csstate->off = off; - return bytes; - } - EXPORT_SYMBOL(csum_and_copy_to_iter); -diff --git a/net/core/datagram.c b/net/core/datagram.c -index 189ad4c73a3fe..b0488f30f2c4e 100644 ---- a/net/core/datagram.c -+++ b/net/core/datagram.c -@@ -700,8 +700,16 @@ static int skb_copy_and_csum_datagram(const struct sk_buff *skb, int offset, - struct iov_iter *to, int len, - __wsum *csump) - { -- return __skb_datagram_iter(skb, offset, to, len, true, -- csum_and_copy_to_iter, csump); -+ struct csum_state csdata = { .csum = *csump }; -+ int ret; -+ -+ ret = __skb_datagram_iter(skb, offset, to, len, true, -+ csum_and_copy_to_iter, &csdata); -+ if (ret) -+ return ret; -+ -+ *csump = csdata.csum; -+ return 0; - } - - /** -diff --git a/net/core/dev.c b/net/core/dev.c -index ec66d13d2bdad..d90e8bd87df83 100644 ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -5275,10 +5275,11 @@ static void gro_normal_list(struct napi_struct *napi) - /* Queue one GRO_NORMAL SKB up for list processing. If batch size exceeded, - * pass the whole batch up to the stack. - */ --static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb) -+static void gro_normal_one(struct napi_struct *napi, struct sk_buff *skb, int segs) - { - list_add_tail(&skb->list, &napi->rx_list); -- if (++napi->rx_count >= gro_normal_batch) -+ napi->rx_count += segs; -+ if (napi->rx_count >= gro_normal_batch) - gro_normal_list(napi); - } - -@@ -5317,7 +5318,7 @@ static int napi_gro_complete(struct napi_struct *napi, struct sk_buff *skb) - } - - out: -- gro_normal_one(napi, skb); -+ gro_normal_one(napi, skb, NAPI_GRO_CB(skb)->count); - return NET_RX_SUCCESS; - } - -@@ -5608,7 +5609,7 @@ static gro_result_t napi_skb_finish(struct napi_struct *napi, - { - switch (ret) { - case GRO_NORMAL: -- gro_normal_one(napi, skb); -+ gro_normal_one(napi, skb, 1); - break; - - case GRO_DROP: -@@ -5696,7 +5697,7 @@ static gro_result_t napi_frags_finish(struct napi_struct *napi, - __skb_push(skb, ETH_HLEN); - skb->protocol = eth_type_trans(skb, skb->dev); - if (ret == GRO_NORMAL) -- gro_normal_one(napi, skb); -+ gro_normal_one(napi, skb, 1); - break; - - case GRO_DROP: -diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c -index 0f7f38c295799..70e6fc2edd304 100644 ---- a/net/dsa/dsa2.c -+++ b/net/dsa/dsa2.c -@@ -399,18 +399,21 @@ static int dsa_switch_setup(struct dsa_switch *ds) - ds->slave_mii_bus = devm_mdiobus_alloc(ds->dev); - if (!ds->slave_mii_bus) { - err = -ENOMEM; -- goto unregister_notifier; -+ goto teardown; - } - - dsa_slave_mii_bus_init(ds); - - err = mdiobus_register(ds->slave_mii_bus); - if (err < 0) -- goto unregister_notifier; -+ goto teardown; - } - - return 0; - -+teardown: -+ if (ds->ops->teardown) -+ ds->ops->teardown(ds); - unregister_notifier: - dsa_switch_unregister_notifier(ds); - unregister_devlink: -diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c -index 200cdad3ff3ab..9a40312b1f161 100644 ---- a/net/netfilter/nf_conntrack_core.c -+++ b/net/netfilter/nf_conntrack_core.c -@@ -1091,7 +1091,8 @@ nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple, - * Let nf_ct_resolve_clash() deal with this later. - */ - if (nf_ct_tuple_equal(&ignored_conntrack->tuplehash[IP_CT_DIR_ORIGINAL].tuple, -- &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple)) -+ &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple) && -+ nf_ct_zone_equal(ct, zone, IP_CT_DIR_ORIGINAL)) - continue; - - NF_CT_STAT_INC_ATOMIC(net, found); -diff --git a/net/netfilter/nf_flow_table_core.c b/net/netfilter/nf_flow_table_core.c -index 128245efe84ab..e05e5df803d68 100644 ---- a/net/netfilter/nf_flow_table_core.c -+++ b/net/netfilter/nf_flow_table_core.c -@@ -354,7 +354,7 @@ static int nf_flow_nat_port_tcp(struct sk_buff *skb, unsigned int thoff, - return -1; - - tcph = (void *)(skb_network_header(skb) + thoff); -- inet_proto_csum_replace2(&tcph->check, skb, port, new_port, true); -+ inet_proto_csum_replace2(&tcph->check, skb, port, new_port, false); - - return 0; - } -@@ -371,7 +371,7 @@ static int nf_flow_nat_port_udp(struct sk_buff *skb, unsigned int thoff, - udph = (void *)(skb_network_header(skb) + thoff); - if (udph->check || skb->ip_summed == CHECKSUM_PARTIAL) { - inet_proto_csum_replace2(&udph->check, skb, port, -- new_port, true); -+ new_port, false); - if (!udph->check) - udph->check = CSUM_MANGLED_0; - } -diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c -index 40216c2a7dd72..373ea0e49f12d 100644 ---- a/net/netfilter/nf_tables_api.c -+++ b/net/netfilter/nf_tables_api.c -@@ -7696,6 +7696,17 @@ int __nft_release_basechain(struct nft_ctx *ctx) - } - EXPORT_SYMBOL_GPL(__nft_release_basechain); - -+static void __nft_release_hooks(struct net *net) -+{ -+ struct nft_table *table; -+ struct nft_chain *chain; -+ -+ list_for_each_entry(table, &net->nft.tables, list) { -+ list_for_each_entry(chain, &table->chains, list) -+ nf_tables_unregister_hook(net, table, chain); -+ } -+} -+ - static void __nft_release_tables(struct net *net) - { - struct nft_flowtable *flowtable, *nf; -@@ -7711,10 +7722,6 @@ static void __nft_release_tables(struct net *net) - - list_for_each_entry_safe(table, nt, &net->nft.tables, list) { - ctx.family = table->family; -- -- list_for_each_entry(chain, &table->chains, list) -- nf_tables_unregister_hook(net, table, chain); -- /* No packets are walking on these chains anymore. */ - ctx.table = table; - list_for_each_entry(chain, &table->chains, list) { - ctx.chain = chain; -@@ -7762,6 +7769,11 @@ static int __net_init nf_tables_init_net(struct net *net) - return 0; - } - -+static void __net_exit nf_tables_pre_exit_net(struct net *net) -+{ -+ __nft_release_hooks(net); -+} -+ - static void __net_exit nf_tables_exit_net(struct net *net) - { - mutex_lock(&net->nft.commit_mutex); -@@ -7774,8 +7786,9 @@ static void __net_exit nf_tables_exit_net(struct net *net) - } - - static struct pernet_operations nf_tables_net_ops = { -- .init = nf_tables_init_net, -- .exit = nf_tables_exit_net, -+ .init = nf_tables_init_net, -+ .pre_exit = nf_tables_pre_exit_net, -+ .exit = nf_tables_exit_net, - }; - - static int __init nf_tables_module_init(void) -diff --git a/net/netfilter/xt_recent.c b/net/netfilter/xt_recent.c -index 6c2582a197667..3469b60736103 100644 ---- a/net/netfilter/xt_recent.c -+++ b/net/netfilter/xt_recent.c -@@ -152,7 +152,8 @@ static void recent_entry_remove(struct recent_table *t, struct recent_entry *e) - /* - * Drop entries with timestamps older then 'time'. - */ --static void recent_entry_reap(struct recent_table *t, unsigned long time) -+static void recent_entry_reap(struct recent_table *t, unsigned long time, -+ struct recent_entry *working, bool update) - { - struct recent_entry *e; - -@@ -161,6 +162,12 @@ static void recent_entry_reap(struct recent_table *t, unsigned long time) - */ - e = list_entry(t->lru_list.next, struct recent_entry, lru_list); - -+ /* -+ * Do not reap the entry which are going to be updated. -+ */ -+ if (e == working && update) -+ return; -+ - /* - * The last time stamp is the most recent. - */ -@@ -303,7 +310,8 @@ recent_mt(const struct sk_buff *skb, struct xt_action_param *par) - - /* info->seconds must be non-zero */ - if (info->check_set & XT_RECENT_REAP) -- recent_entry_reap(t, time); -+ recent_entry_reap(t, time, e, -+ info->check_set & XT_RECENT_UPDATE && ret); - } - - if (info->check_set & XT_RECENT_SET || -diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c -index e35869e81766e..997af345ce374 100644 ---- a/net/qrtr/tun.c -+++ b/net/qrtr/tun.c -@@ -80,6 +80,12 @@ static ssize_t qrtr_tun_write_iter(struct kiocb *iocb, struct iov_iter *from) - ssize_t ret; - void *kbuf; - -+ if (!len) -+ return -EINVAL; -+ -+ if (len > KMALLOC_MAX_SIZE) -+ return -ENOMEM; -+ - kbuf = kzalloc(len, GFP_KERNEL); - if (!kbuf) - return -ENOMEM; -diff --git a/net/rds/rdma.c b/net/rds/rdma.c -index 8e10f954a22fe..1c42a600fe7fa 100644 ---- a/net/rds/rdma.c -+++ b/net/rds/rdma.c -@@ -532,6 +532,9 @@ int rds_rdma_extra_size(struct rds_rdma_args *args, - if (args->nr_local == 0) - return -EINVAL; - -+ if (args->nr_local > UIO_MAXIOV) -+ return -EMSGSIZE; -+ - iov->iov = kcalloc(args->nr_local, - sizeof(struct rds_iovec), - GFP_KERNEL); -diff --git a/net/rxrpc/call_object.c b/net/rxrpc/call_object.c -index 38a46167523fa..f8233bc76c0ea 100644 ---- a/net/rxrpc/call_object.c -+++ b/net/rxrpc/call_object.c -@@ -507,8 +507,6 @@ void rxrpc_release_call(struct rxrpc_sock *rx, struct rxrpc_call *call) - rxrpc_disconnect_call(call); - if (call->security) - call->security->free_call_crypto(call); -- -- rxrpc_cleanup_ring(call); - _leave(""); - } - -diff --git a/net/sctp/proc.c b/net/sctp/proc.c -index f7da88ae20a57..982a87b3e11f8 100644 ---- a/net/sctp/proc.c -+++ b/net/sctp/proc.c -@@ -215,6 +215,12 @@ static void sctp_transport_seq_stop(struct seq_file *seq, void *v) - { - struct sctp_ht_iter *iter = seq->private; - -+ if (v && v != SEQ_START_TOKEN) { -+ struct sctp_transport *transport = v; -+ -+ sctp_transport_put(transport); -+ } -+ - sctp_transport_walk_stop(&iter->hti); - } - -@@ -222,6 +228,12 @@ static void *sctp_transport_seq_next(struct seq_file *seq, void *v, loff_t *pos) - { - struct sctp_ht_iter *iter = seq->private; - -+ if (v && v != SEQ_START_TOKEN) { -+ struct sctp_transport *transport = v; -+ -+ sctp_transport_put(transport); -+ } -+ - ++*pos; - - return sctp_transport_get_next(seq_file_net(seq), &iter->hti); -@@ -277,8 +289,6 @@ static int sctp_assocs_seq_show(struct seq_file *seq, void *v) - sk->sk_rcvbuf); - seq_printf(seq, "\n"); - -- sctp_transport_put(transport); -- - return 0; - } - -@@ -354,8 +364,6 @@ static int sctp_remaddr_seq_show(struct seq_file *seq, void *v) - seq_printf(seq, "\n"); - } - -- sctp_transport_put(transport); -- - return 0; - } - -diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c -index 3a074a03d3820..5d323574d04fe 100644 ---- a/net/vmw_vsock/af_vsock.c -+++ b/net/vmw_vsock/af_vsock.c -@@ -808,10 +808,12 @@ static int vsock_shutdown(struct socket *sock, int mode) - */ - - sk = sock->sk; -+ -+ lock_sock(sk); - if (sock->state == SS_UNCONNECTED) { - err = -ENOTCONN; - if (sk->sk_type == SOCK_STREAM) -- return err; -+ goto out; - } else { - sock->state = SS_DISCONNECTING; - err = 0; -@@ -820,10 +822,8 @@ static int vsock_shutdown(struct socket *sock, int mode) - /* Receive and send shutdowns are treated alike. */ - mode = mode & (RCV_SHUTDOWN | SEND_SHUTDOWN); - if (mode) { -- lock_sock(sk); - sk->sk_shutdown |= mode; - sk->sk_state_change(sk); -- release_sock(sk); - - if (sk->sk_type == SOCK_STREAM) { - sock_reset_flag(sk, SOCK_DONE); -@@ -831,6 +831,8 @@ static int vsock_shutdown(struct socket *sock, int mode) - } - } - -+out: -+ release_sock(sk); - return err; - } - -@@ -1099,7 +1101,6 @@ static void vsock_connect_timeout(struct work_struct *work) - { - struct sock *sk; - struct vsock_sock *vsk; -- int cancel = 0; - - vsk = container_of(work, struct vsock_sock, connect_work.work); - sk = sk_vsock(vsk); -@@ -1110,11 +1111,9 @@ static void vsock_connect_timeout(struct work_struct *work) - sk->sk_state = TCP_CLOSE; - sk->sk_err = ETIMEDOUT; - sk->sk_error_report(sk); -- cancel = 1; -+ vsock_transport_cancel_pkt(vsk); - } - release_sock(sk); -- if (cancel) -- vsock_transport_cancel_pkt(vsk); - - sock_put(sk); - } -diff --git a/net/vmw_vsock/hyperv_transport.c b/net/vmw_vsock/hyperv_transport.c -index 463cefc1e5ae2..a3c57c048cbd8 100644 ---- a/net/vmw_vsock/hyperv_transport.c -+++ b/net/vmw_vsock/hyperv_transport.c -@@ -464,14 +464,10 @@ static void hvs_shutdown_lock_held(struct hvsock *hvs, int mode) - - static int hvs_shutdown(struct vsock_sock *vsk, int mode) - { -- struct sock *sk = sk_vsock(vsk); -- - if (!(mode & SEND_SHUTDOWN)) - return 0; - -- lock_sock(sk); - hvs_shutdown_lock_held(vsk->trans, mode); -- release_sock(sk); - return 0; - } - -diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c -index efbb521bff135..dde16a033a09d 100644 ---- a/net/vmw_vsock/virtio_transport_common.c -+++ b/net/vmw_vsock/virtio_transport_common.c -@@ -1100,10 +1100,10 @@ void virtio_transport_recv_pkt(struct virtio_transport *t, - - vsk = vsock_sk(sk); - -- space_available = virtio_transport_space_update(sk, pkt); -- - lock_sock(sk); - -+ space_available = virtio_transport_space_update(sk, pkt); -+ - /* Update CID in case it has changed after a transport reset event */ - vsk->local_addr.svm_cid = dst.svm_cid; - -diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c -index 52f1152c98389..13cda6aa26880 100644 ---- a/scripts/mod/modpost.c -+++ b/scripts/mod/modpost.c -@@ -960,7 +960,7 @@ static void check_section(const char *modname, struct elf_info *elf, - - #define DATA_SECTIONS ".data", ".data.rel" - #define TEXT_SECTIONS ".text", ".text.unlikely", ".sched.text", \ -- ".kprobes.text", ".cpuidle.text" -+ ".kprobes.text", ".cpuidle.text", ".noinstr.text" - #define OTHER_TEXT_SECTIONS ".ref.text", ".head.text", ".spinlock.text", \ - ".fixup", ".entry.text", ".exception.text", ".text.*", \ - ".coldtext" -diff --git a/security/commoncap.c b/security/commoncap.c -index 0ca31c8bc0b13..28a6939bcc4e5 100644 ---- a/security/commoncap.c -+++ b/security/commoncap.c -@@ -371,10 +371,11 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer, - { - int size, ret; - kuid_t kroot; -+ u32 nsmagic, magic; - uid_t root, mappedroot; - char *tmpbuf = NULL; - struct vfs_cap_data *cap; -- struct vfs_ns_cap_data *nscap; -+ struct vfs_ns_cap_data *nscap = NULL; - struct dentry *dentry; - struct user_namespace *fs_ns; - -@@ -396,46 +397,61 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer, - fs_ns = inode->i_sb->s_user_ns; - cap = (struct vfs_cap_data *) tmpbuf; - if (is_v2header((size_t) ret, cap)) { -- /* If this is sizeof(vfs_cap_data) then we're ok with the -- * on-disk value, so return that. */ -- if (alloc) -- *buffer = tmpbuf; -- else -- kfree(tmpbuf); -- return ret; -- } else if (!is_v3header((size_t) ret, cap)) { -- kfree(tmpbuf); -- return -EINVAL; -+ root = 0; -+ } else if (is_v3header((size_t) ret, cap)) { -+ nscap = (struct vfs_ns_cap_data *) tmpbuf; -+ root = le32_to_cpu(nscap->rootid); -+ } else { -+ size = -EINVAL; -+ goto out_free; - } - -- nscap = (struct vfs_ns_cap_data *) tmpbuf; -- root = le32_to_cpu(nscap->rootid); - kroot = make_kuid(fs_ns, root); - - /* If the root kuid maps to a valid uid in current ns, then return - * this as a nscap. */ - mappedroot = from_kuid(current_user_ns(), kroot); - if (mappedroot != (uid_t)-1 && mappedroot != (uid_t)0) { -+ size = sizeof(struct vfs_ns_cap_data); - if (alloc) { -- *buffer = tmpbuf; -+ if (!nscap) { -+ /* v2 -> v3 conversion */ -+ nscap = kzalloc(size, GFP_ATOMIC); -+ if (!nscap) { -+ size = -ENOMEM; -+ goto out_free; -+ } -+ nsmagic = VFS_CAP_REVISION_3; -+ magic = le32_to_cpu(cap->magic_etc); -+ if (magic & VFS_CAP_FLAGS_EFFECTIVE) -+ nsmagic |= VFS_CAP_FLAGS_EFFECTIVE; -+ memcpy(&nscap->data, &cap->data, sizeof(__le32) * 2 * VFS_CAP_U32); -+ nscap->magic_etc = cpu_to_le32(nsmagic); -+ } else { -+ /* use allocated v3 buffer */ -+ tmpbuf = NULL; -+ } - nscap->rootid = cpu_to_le32(mappedroot); -- } else -- kfree(tmpbuf); -- return size; -+ *buffer = nscap; -+ } -+ goto out_free; - } - - if (!rootid_owns_currentns(kroot)) { -- kfree(tmpbuf); -- return -EOPNOTSUPP; -+ size = -EOVERFLOW; -+ goto out_free; - } - - /* This comes from a parent namespace. Return as a v2 capability */ - size = sizeof(struct vfs_cap_data); - if (alloc) { -- *buffer = kmalloc(size, GFP_ATOMIC); -- if (*buffer) { -- struct vfs_cap_data *cap = *buffer; -- __le32 nsmagic, magic; -+ if (nscap) { -+ /* v3 -> v2 conversion */ -+ cap = kzalloc(size, GFP_ATOMIC); -+ if (!cap) { -+ size = -ENOMEM; -+ goto out_free; -+ } - magic = VFS_CAP_REVISION_2; - nsmagic = le32_to_cpu(nscap->magic_etc); - if (nsmagic & VFS_CAP_FLAGS_EFFECTIVE) -@@ -443,9 +459,12 @@ int cap_inode_getsecurity(struct inode *inode, const char *name, void **buffer, - memcpy(&cap->data, &nscap->data, sizeof(__le32) * 2 * VFS_CAP_U32); - cap->magic_etc = cpu_to_le32(magic); - } else { -- size = -ENOMEM; -+ /* use unconverted v2 */ -+ tmpbuf = NULL; - } -+ *buffer = cap; - } -+out_free: - kfree(tmpbuf); - return size; - } -diff --git a/tools/testing/selftests/networking/timestamping/txtimestamp.c b/tools/testing/selftests/networking/timestamping/txtimestamp.c -index 7e386be471201..2fce2e8f47f55 100644 ---- a/tools/testing/selftests/networking/timestamping/txtimestamp.c -+++ b/tools/testing/selftests/networking/timestamping/txtimestamp.c -@@ -26,6 +26,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -34,7 +35,6 @@ - #include - #include - #include --#include - #include - #include - #include -@@ -396,12 +396,12 @@ static void do_test(int family, unsigned int report_opt) - total_len = cfg_payload_len; - if (cfg_use_pf_packet || cfg_proto == SOCK_RAW) { - total_len += sizeof(struct udphdr); -- if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) -+ if (cfg_use_pf_packet || cfg_ipproto == IPPROTO_RAW) { - if (family == PF_INET) - total_len += sizeof(struct iphdr); - else - total_len += sizeof(struct ipv6hdr); -- -+ } - /* special case, only rawv6_sendmsg: - * pass proto in sin6_port if not connected - * also see ANK comment in net/ipv4/raw.c diff --git a/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.99-100.patch b/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.99-100.patch deleted file mode 100644 index 66ef005570..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0001-patch-5.4.99-100.patch +++ /dev/null @@ -1,403 +0,0 @@ -diff --git a/Makefile b/Makefile -index a0491ba1d7593..d0d4beb4f8373 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 99 -+SUBLEVEL = 100 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c -index e52950a43f2ed..fd6e3aafe2724 100644 ---- a/arch/arm/xen/p2m.c -+++ b/arch/arm/xen/p2m.c -@@ -95,8 +95,10 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, - for (i = 0; i < count; i++) { - if (map_ops[i].status) - continue; -- set_phys_to_machine(map_ops[i].host_addr >> XEN_PAGE_SHIFT, -- map_ops[i].dev_bus_addr >> XEN_PAGE_SHIFT); -+ if (unlikely(!set_phys_to_machine(map_ops[i].host_addr >> XEN_PAGE_SHIFT, -+ map_ops[i].dev_bus_addr >> XEN_PAGE_SHIFT))) { -+ return -ENOMEM; -+ } - } - - return 0; -diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c -index 296b0d7570d06..1da558f28aa57 100644 ---- a/arch/x86/kvm/svm.c -+++ b/arch/x86/kvm/svm.c -@@ -7104,7 +7104,6 @@ static int svm_register_enc_region(struct kvm *kvm, - region->uaddr = range->addr; - region->size = range->size; - -- mutex_lock(&kvm->lock); - list_add_tail(®ion->list, &sev->regions_list); - mutex_unlock(&kvm->lock); - -diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c -index 0acba2c712ab8..7fe5be8e6d3db 100644 ---- a/arch/x86/xen/p2m.c -+++ b/arch/x86/xen/p2m.c -@@ -716,7 +716,8 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, - unsigned long mfn, pfn; - - /* Do not add to override if the map failed. */ -- if (map_ops[i].status) -+ if (map_ops[i].status != GNTST_okay || -+ (kmap_ops && kmap_ops[i].status != GNTST_okay)) - continue; - - if (map_ops[i].flags & GNTMAP_contains_pte) { -@@ -754,17 +755,15 @@ int clear_foreign_p2m_mapping(struct gnttab_unmap_grant_ref *unmap_ops, - unsigned long mfn = __pfn_to_mfn(page_to_pfn(pages[i])); - unsigned long pfn = page_to_pfn(pages[i]); - -- if (mfn == INVALID_P2M_ENTRY || !(mfn & FOREIGN_FRAME_BIT)) { -+ if (mfn != INVALID_P2M_ENTRY && (mfn & FOREIGN_FRAME_BIT)) -+ set_phys_to_machine(pfn, INVALID_P2M_ENTRY); -+ else - ret = -EINVAL; -- goto out; -- } -- -- set_phys_to_machine(pfn, INVALID_P2M_ENTRY); - } - if (kunmap_ops) - ret = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, -- kunmap_ops, count); --out: -+ kunmap_ops, count) ?: ret; -+ - return ret; - } - EXPORT_SYMBOL_GPL(clear_foreign_p2m_mapping); -diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c -index b18f0162cb9c4..208f3eea3641f 100644 ---- a/drivers/block/xen-blkback/blkback.c -+++ b/drivers/block/xen-blkback/blkback.c -@@ -850,8 +850,11 @@ again: - pages[i]->page = persistent_gnt->page; - pages[i]->persistent_gnt = persistent_gnt; - } else { -- if (get_free_page(ring, &pages[i]->page)) -- goto out_of_memory; -+ if (get_free_page(ring, &pages[i]->page)) { -+ put_free_pages(ring, pages_to_gnt, segs_to_map); -+ ret = -ENOMEM; -+ goto out; -+ } - addr = vaddr(pages[i]->page); - pages_to_gnt[segs_to_map] = pages[i]->page; - pages[i]->persistent_gnt = NULL; -@@ -867,10 +870,8 @@ again: - break; - } - -- if (segs_to_map) { -+ if (segs_to_map) - ret = gnttab_map_refs(map, NULL, pages_to_gnt, segs_to_map); -- BUG_ON(ret); -- } - - /* - * Now swizzle the MFN in our domain with the MFN from the other domain -@@ -885,7 +886,7 @@ again: - pr_debug("invalid buffer -- could not remap it\n"); - put_free_pages(ring, &pages[seg_idx]->page, 1); - pages[seg_idx]->handle = BLKBACK_INVALID_HANDLE; -- ret |= 1; -+ ret |= !ret; - goto next; - } - pages[seg_idx]->handle = map[new_map_idx].handle; -@@ -937,17 +938,18 @@ next: - } - segs_to_map = 0; - last_map = map_until; -- if (map_until != num) -+ if (!ret && map_until != num) - goto again; - -- return ret; -- --out_of_memory: -- pr_alert("%s: out of memory\n", __func__); -- put_free_pages(ring, pages_to_gnt, segs_to_map); -- for (i = last_map; i < num; i++) -+out: -+ for (i = last_map; i < num; i++) { -+ /* Don't zap current batch's valid persistent grants. */ -+ if(i >= last_map + segs_to_map) -+ pages[i]->persistent_gnt = NULL; - pages[i]->handle = BLKBACK_INVALID_HANDLE; -- return -ENOMEM; -+ } -+ -+ return ret; - } - - static int xen_blkbk_map_seg(struct pending_req *pending_req) -diff --git a/drivers/media/usb/pwc/pwc-if.c b/drivers/media/usb/pwc/pwc-if.c -index 9b76cf133d524..3df7ca2357da8 100644 ---- a/drivers/media/usb/pwc/pwc-if.c -+++ b/drivers/media/usb/pwc/pwc-if.c -@@ -147,16 +147,17 @@ static const struct video_device pwc_template = { - /***************************************************************************/ - /* Private functions */ - --static void *pwc_alloc_urb_buffer(struct device *dev, -+static void *pwc_alloc_urb_buffer(struct usb_device *dev, - size_t size, dma_addr_t *dma_handle) - { -+ struct device *dmadev = dev->bus->sysdev; - void *buffer = kmalloc(size, GFP_KERNEL); - - if (!buffer) - return NULL; - -- *dma_handle = dma_map_single(dev, buffer, size, DMA_FROM_DEVICE); -- if (dma_mapping_error(dev, *dma_handle)) { -+ *dma_handle = dma_map_single(dmadev, buffer, size, DMA_FROM_DEVICE); -+ if (dma_mapping_error(dmadev, *dma_handle)) { - kfree(buffer); - return NULL; - } -@@ -164,12 +165,14 @@ static void *pwc_alloc_urb_buffer(struct device *dev, - return buffer; - } - --static void pwc_free_urb_buffer(struct device *dev, -+static void pwc_free_urb_buffer(struct usb_device *dev, - size_t size, - void *buffer, - dma_addr_t dma_handle) - { -- dma_unmap_single(dev, dma_handle, size, DMA_FROM_DEVICE); -+ struct device *dmadev = dev->bus->sysdev; -+ -+ dma_unmap_single(dmadev, dma_handle, size, DMA_FROM_DEVICE); - kfree(buffer); - } - -@@ -274,6 +277,7 @@ static void pwc_frame_complete(struct pwc_device *pdev) - static void pwc_isoc_handler(struct urb *urb) - { - struct pwc_device *pdev = (struct pwc_device *)urb->context; -+ struct device *dmadev = urb->dev->bus->sysdev; - int i, fst, flen; - unsigned char *iso_buf = NULL; - -@@ -320,7 +324,7 @@ static void pwc_isoc_handler(struct urb *urb) - /* Reset ISOC error counter. We did get here, after all. */ - pdev->visoc_errors = 0; - -- dma_sync_single_for_cpu(&urb->dev->dev, -+ dma_sync_single_for_cpu(dmadev, - urb->transfer_dma, - urb->transfer_buffer_length, - DMA_FROM_DEVICE); -@@ -371,7 +375,7 @@ static void pwc_isoc_handler(struct urb *urb) - pdev->vlast_packet_size = flen; - } - -- dma_sync_single_for_device(&urb->dev->dev, -+ dma_sync_single_for_device(dmadev, - urb->transfer_dma, - urb->transfer_buffer_length, - DMA_FROM_DEVICE); -@@ -453,7 +457,7 @@ retry: - urb->pipe = usb_rcvisocpipe(udev, pdev->vendpoint); - urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; - urb->transfer_buffer_length = ISO_BUFFER_SIZE; -- urb->transfer_buffer = pwc_alloc_urb_buffer(&udev->dev, -+ urb->transfer_buffer = pwc_alloc_urb_buffer(udev, - urb->transfer_buffer_length, - &urb->transfer_dma); - if (urb->transfer_buffer == NULL) { -@@ -516,7 +520,7 @@ static void pwc_iso_free(struct pwc_device *pdev) - if (urb) { - PWC_DEBUG_MEMORY("Freeing URB\n"); - if (urb->transfer_buffer) -- pwc_free_urb_buffer(&urb->dev->dev, -+ pwc_free_urb_buffer(urb->dev, - urb->transfer_buffer_length, - urb->transfer_buffer, - urb->transfer_dma); -diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c -index fa1ac0abc924b..4bfafcd6317f4 100644 ---- a/drivers/net/xen-netback/netback.c -+++ b/drivers/net/xen-netback/netback.c -@@ -1335,13 +1335,11 @@ int xenvif_tx_action(struct xenvif_queue *queue, int budget) - return 0; - - gnttab_batch_copy(queue->tx_copy_ops, nr_cops); -- if (nr_mops != 0) { -+ if (nr_mops != 0) - ret = gnttab_map_refs(queue->tx_map_ops, - NULL, - queue->pages_to_map, - nr_mops); -- BUG_ON(ret); -- } - - work_done = xenvif_tx_submit(queue); - -diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c -index 246864bbb3e4e..e953ea34b3e43 100644 ---- a/drivers/xen/gntdev.c -+++ b/drivers/xen/gntdev.c -@@ -319,44 +319,47 @@ int gntdev_map_grant_pages(struct gntdev_grant_map *map) - * to the kernel linear addresses of the struct pages. - * These ptes are completely different from the user ptes dealt - * with find_grant_ptes. -+ * Note that GNTMAP_device_map isn't needed here: The -+ * dev_bus_addr output field gets consumed only from ->map_ops, -+ * and by not requesting it when mapping we also avoid needing -+ * to mirror dev_bus_addr into ->unmap_ops (and holding an extra -+ * reference to the page in the hypervisor). - */ -+ unsigned int flags = (map->flags & ~GNTMAP_device_map) | -+ GNTMAP_host_map; -+ - for (i = 0; i < map->count; i++) { - unsigned long address = (unsigned long) - pfn_to_kaddr(page_to_pfn(map->pages[i])); - BUG_ON(PageHighMem(map->pages[i])); - -- gnttab_set_map_op(&map->kmap_ops[i], address, -- map->flags | GNTMAP_host_map, -+ gnttab_set_map_op(&map->kmap_ops[i], address, flags, - map->grants[i].ref, - map->grants[i].domid); - gnttab_set_unmap_op(&map->kunmap_ops[i], address, -- map->flags | GNTMAP_host_map, -1); -+ flags, -1); - } - } - - pr_debug("map %d+%d\n", map->index, map->count); - err = gnttab_map_refs(map->map_ops, use_ptemod ? map->kmap_ops : NULL, - map->pages, map->count); -- if (err) -- return err; - - for (i = 0; i < map->count; i++) { -- if (map->map_ops[i].status) { -+ if (map->map_ops[i].status == GNTST_okay) -+ map->unmap_ops[i].handle = map->map_ops[i].handle; -+ else if (!err) - err = -EINVAL; -- continue; -- } - -- map->unmap_ops[i].handle = map->map_ops[i].handle; -- if (use_ptemod) -- map->kunmap_ops[i].handle = map->kmap_ops[i].handle; --#ifdef CONFIG_XEN_GRANT_DMA_ALLOC -- else if (map->dma_vaddr) { -- unsigned long bfn; -+ if (map->flags & GNTMAP_device_map) -+ map->unmap_ops[i].dev_bus_addr = map->map_ops[i].dev_bus_addr; - -- bfn = pfn_to_bfn(page_to_pfn(map->pages[i])); -- map->unmap_ops[i].dev_bus_addr = __pfn_to_phys(bfn); -+ if (use_ptemod) { -+ if (map->kmap_ops[i].status == GNTST_okay) -+ map->kunmap_ops[i].handle = map->kmap_ops[i].handle; -+ else if (!err) -+ err = -EINVAL; - } --#endif - } - return err; - } -diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c -index 33d6499d84724..32aba2e8c075f 100644 ---- a/drivers/xen/xen-scsiback.c -+++ b/drivers/xen/xen-scsiback.c -@@ -422,12 +422,12 @@ static int scsiback_gnttab_data_map_batch(struct gnttab_map_grant_ref *map, - return 0; - - err = gnttab_map_refs(map, NULL, pg, cnt); -- BUG_ON(err); - for (i = 0; i < cnt; i++) { - if (unlikely(map[i].status != GNTST_okay)) { - pr_err("invalid buffer -- could not remap it\n"); - map[i].handle = SCSIBACK_INVALID_HANDLE; -- err = -ENOMEM; -+ if (!err) -+ err = -ENOMEM; - } else { - get_page(pg[i]); - } -diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h -index cda5534d3d0e3..7960359dbc700 100644 ---- a/fs/btrfs/ctree.h -+++ b/fs/btrfs/ctree.h -@@ -136,9 +136,6 @@ enum { - BTRFS_FS_STATE_DEV_REPLACING, - /* The btrfs_fs_info created for self-tests */ - BTRFS_FS_STATE_DUMMY_FS_INFO, -- -- /* Indicate that we can't trust the free space tree for caching yet */ -- BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, - }; - - #define BTRFS_BACKREF_REV_MAX 256 -@@ -527,6 +524,9 @@ enum { - * so we don't need to offload checksums to workqueues. - */ - BTRFS_FS_CSUM_IMPL_FAST, -+ -+ /* Indicate that we can't trust the free space tree for caching yet */ -+ BTRFS_FS_FREE_SPACE_TREE_UNTRUSTED, - }; - - struct btrfs_fs_info { -diff --git a/include/xen/grant_table.h b/include/xen/grant_table.h -index 9bc5bc07d4d3f..a9978350b45b0 100644 ---- a/include/xen/grant_table.h -+++ b/include/xen/grant_table.h -@@ -157,6 +157,7 @@ gnttab_set_map_op(struct gnttab_map_grant_ref *map, phys_addr_t addr, - map->flags = flags; - map->ref = ref; - map->dom = domid; -+ map->status = 1; /* arbitrary positive value */ - } - - static inline void -diff --git a/net/bridge/br.c b/net/bridge/br.c -index 8a8f9e5f264f2..cccbb9bf3ca4e 100644 ---- a/net/bridge/br.c -+++ b/net/bridge/br.c -@@ -43,7 +43,10 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v - - if (event == NETDEV_REGISTER) { - /* register of bridge completed, add sysfs entries */ -- br_sysfs_addbr(dev); -+ err = br_sysfs_addbr(dev); -+ if (err) -+ return notifier_from_errno(err); -+ - return NOTIFY_DONE; - } - } -diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c -index d6d2736ec9273..ef602976bb2c8 100644 ---- a/net/qrtr/qrtr.c -+++ b/net/qrtr/qrtr.c -@@ -187,7 +187,7 @@ static int qrtr_node_enqueue(struct qrtr_node *node, struct sk_buff *skb, - hdr->src_port_id = cpu_to_le32(from->sq_port); - if (to->sq_port == QRTR_PORT_CTRL) { - hdr->dst_node_id = cpu_to_le32(node->nid); -- hdr->dst_port_id = cpu_to_le32(QRTR_NODE_BCAST); -+ hdr->dst_port_id = cpu_to_le32(QRTR_PORT_CTRL); - } else { - hdr->dst_node_id = cpu_to_le32(to->sq_node); - hdr->dst_port_id = cpu_to_le32(to->sq_port); diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.100-101.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.100-101.patch deleted file mode 100644 index 87f0074637..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.100-101.patch +++ /dev/null @@ -1,397 +0,0 @@ -diff --git a/Makefile b/Makefile -index d0d4beb4f8373..f56442751d2c3 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 100 -+SUBLEVEL = 101 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm64/boot/dts/nvidia/tegra210.dtsi b/arch/arm64/boot/dts/nvidia/tegra210.dtsi -index 078d2506365c0..8a02b26d07cd4 100644 ---- a/arch/arm64/boot/dts/nvidia/tegra210.dtsi -+++ b/arch/arm64/boot/dts/nvidia/tegra210.dtsi -@@ -917,6 +917,7 @@ - <&tegra_car 128>, /* hda2hdmi */ - <&tegra_car 111>; /* hda2codec_2x */ - reset-names = "hda", "hda2hdmi", "hda2codec_2x"; -+ power-domains = <&pd_sor>; - status = "disabled"; - }; - -diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c -index d2ecc9c452554..263eca119ff0f 100644 ---- a/drivers/hid/hid-core.c -+++ b/drivers/hid/hid-core.c -@@ -90,7 +90,7 @@ EXPORT_SYMBOL_GPL(hid_register_report); - * Register a new field for this report. - */ - --static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages, unsigned values) -+static struct hid_field *hid_register_field(struct hid_report *report, unsigned usages) - { - struct hid_field *field; - -@@ -101,7 +101,7 @@ static struct hid_field *hid_register_field(struct hid_report *report, unsigned - - field = kzalloc((sizeof(struct hid_field) + - usages * sizeof(struct hid_usage) + -- values * sizeof(unsigned)), GFP_KERNEL); -+ usages * sizeof(unsigned)), GFP_KERNEL); - if (!field) - return NULL; - -@@ -300,7 +300,7 @@ static int hid_add_field(struct hid_parser *parser, unsigned report_type, unsign - usages = max_t(unsigned, parser->local.usage_index, - parser->global.report_count); - -- field = hid_register_field(report, usages, parser->global.report_count); -+ field = hid_register_field(report, usages); - if (!field) - return 0; - -diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h -index 0c5373462cedb..0b1b5f9c67d47 100644 ---- a/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h -+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_pci_id_tbl.h -@@ -219,6 +219,7 @@ CH_PCI_DEVICE_ID_TABLE_DEFINE_BEGIN - CH_PCI_ID_TABLE_FENTRY(0x6089), /* Custom T62100-KR */ - CH_PCI_ID_TABLE_FENTRY(0x608a), /* Custom T62100-CR */ - CH_PCI_ID_TABLE_FENTRY(0x608b), /* Custom T6225-CR */ -+ CH_PCI_ID_TABLE_FENTRY(0x6092), /* Custom T62100-CR-LOM */ - CH_PCI_DEVICE_ID_TABLE_DEFINE_END; - - #endif /* __T4_PCI_ID_TBL_H__ */ -diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c -index 72a3a5dc51319..5a1d21aae2a9e 100644 ---- a/drivers/net/usb/qmi_wwan.c -+++ b/drivers/net/usb/qmi_wwan.c -@@ -1354,6 +1354,7 @@ static const struct usb_device_id products[] = { - {QMI_FIXED_INTF(0x1e2d, 0x0082, 5)}, /* Cinterion PHxx,PXxx (2 RmNet) */ - {QMI_FIXED_INTF(0x1e2d, 0x0083, 4)}, /* Cinterion PHxx,PXxx (1 RmNet + USB Audio)*/ - {QMI_QUIRK_SET_DTR(0x1e2d, 0x00b0, 4)}, /* Cinterion CLS8 */ -+ {QMI_FIXED_INTF(0x1e2d, 0x00b7, 0)}, /* Cinterion MV31 RmNet */ - {QMI_FIXED_INTF(0x413c, 0x81a2, 8)}, /* Dell Wireless 5806 Gobi(TM) 4G LTE Mobile Broadband Card */ - {QMI_FIXED_INTF(0x413c, 0x81a3, 8)}, /* Dell Wireless 5570 HSPA+ (42Mbps) Mobile Broadband Card */ - {QMI_FIXED_INTF(0x413c, 0x81a4, 8)}, /* Dell Wireless 5570e HSPA+ (42Mbps) Mobile Broadband Card */ -diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c -index c1592403222f5..239443ce52001 100644 ---- a/drivers/usb/core/quirks.c -+++ b/drivers/usb/core/quirks.c -@@ -391,6 +391,9 @@ static const struct usb_device_id usb_quirk_list[] = { - /* X-Rite/Gretag-Macbeth Eye-One Pro display colorimeter */ - { USB_DEVICE(0x0971, 0x2000), .driver_info = USB_QUIRK_NO_SET_INTF }, - -+ /* ELMO L-12F document camera */ -+ { USB_DEVICE(0x09a1, 0x0028), .driver_info = USB_QUIRK_DELAY_CTRL_MSG }, -+ - /* Broadcom BCM92035DGROM BT dongle */ - { USB_DEVICE(0x0a5c, 0x2021), .driver_info = USB_QUIRK_RESET_RESUME }, - -@@ -415,6 +418,9 @@ static const struct usb_device_id usb_quirk_list[] = { - { USB_DEVICE(0x10d6, 0x2200), .driver_info = - USB_QUIRK_STRING_FETCH_255 }, - -+ /* novation SoundControl XL */ -+ { USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME }, -+ - /* Huawei 4G LTE module */ - { USB_DEVICE(0x12d1, 0x15bb), .driver_info = - USB_QUIRK_DISCONNECT_SUSPEND }, -@@ -495,9 +501,6 @@ static const struct usb_device_id usb_quirk_list[] = { - /* INTEL VALUE SSD */ - { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, - -- /* novation SoundControl XL */ -- { USB_DEVICE(0x1235, 0x0061), .driver_info = USB_QUIRK_RESET_RESUME }, -- - { } /* terminating entry must be last */ - }; - -diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c -index ab9eeb5ff8e57..67c2e6487479a 100644 ---- a/fs/cifs/connect.c -+++ b/fs/cifs/connect.c -@@ -4198,6 +4198,7 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, - cifs_sb->prepath = kstrdup(pvolume_info->prepath, GFP_KERNEL); - if (cifs_sb->prepath == NULL) - return -ENOMEM; -+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; - } - - return 0; -diff --git a/fs/dax.c b/fs/dax.c -index cc56313c6b3b9..3b0e5da96d541 100644 ---- a/fs/dax.c -+++ b/fs/dax.c -@@ -794,12 +794,12 @@ static void dax_entry_mkclean(struct address_space *mapping, pgoff_t index, - address = pgoff_address(index, vma); - - /* -- * Note because we provide range to follow_pte_pmd it will -- * call mmu_notifier_invalidate_range_start() on our behalf -- * before taking any lock. -+ * follow_invalidate_pte() will use the range to call -+ * mmu_notifier_invalidate_range_start() on our behalf before -+ * taking any lock. - */ -- if (follow_pte_pmd(vma->vm_mm, address, &range, -- &ptep, &pmdp, &ptl)) -+ if (follow_invalidate_pte(vma->vm_mm, address, &range, &ptep, -+ &pmdp, &ptl)) - continue; - - /* -diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c -index 84933a0af49b6..672feb96e250e 100644 ---- a/fs/ntfs/inode.c -+++ b/fs/ntfs/inode.c -@@ -628,6 +628,12 @@ static int ntfs_read_locked_inode(struct inode *vi) - } - a = ctx->attr; - /* Get the standard information attribute value. */ -+ if ((u8 *)a + le16_to_cpu(a->data.resident.value_offset) -+ + le32_to_cpu(a->data.resident.value_length) > -+ (u8 *)ctx->mrec + vol->mft_record_size) { -+ ntfs_error(vi->i_sb, "Corrupt standard information attribute in inode."); -+ goto unm_err_out; -+ } - si = (STANDARD_INFORMATION*)((u8*)a + - le16_to_cpu(a->data.resident.value_offset)); - -diff --git a/include/linux/mm.h b/include/linux/mm.h -index 7249cf58f78d1..c63e4b38b7fe0 100644 ---- a/include/linux/mm.h -+++ b/include/linux/mm.h -@@ -1466,9 +1466,11 @@ void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, - unsigned long end, unsigned long floor, unsigned long ceiling); - int copy_page_range(struct mm_struct *dst, struct mm_struct *src, - struct vm_area_struct *vma); --int follow_pte_pmd(struct mm_struct *mm, unsigned long address, -- struct mmu_notifier_range *range, -- pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp); -+int follow_invalidate_pte(struct mm_struct *mm, unsigned long address, -+ struct mmu_notifier_range *range, pte_t **ptepp, -+ pmd_t **pmdpp, spinlock_t **ptlp); -+int follow_pte(struct mm_struct *mm, unsigned long address, -+ pte_t **ptepp, spinlock_t **ptlp); - int follow_pfn(struct vm_area_struct *vma, unsigned long address, - unsigned long *pfn); - int follow_phys(struct vm_area_struct *vma, unsigned long address, -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c -index 2c248c4f6419c..e6a43c0fdee88 100644 ---- a/kernel/bpf/verifier.c -+++ b/kernel/bpf/verifier.c -@@ -9005,7 +9005,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) - bool isdiv = BPF_OP(insn->code) == BPF_DIV; - struct bpf_insn *patchlet; - struct bpf_insn chk_and_div[] = { -- /* Rx div 0 -> 0 */ -+ /* [R,W]x div 0 -> 0 */ - BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) | - BPF_JNE | BPF_K, insn->src_reg, - 0, 2, 0), -@@ -9014,16 +9014,18 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) - *insn, - }; - struct bpf_insn chk_and_mod[] = { -- /* Rx mod 0 -> Rx */ -+ /* [R,W]x mod 0 -> [R,W]x */ - BPF_RAW_INSN((is64 ? BPF_JMP : BPF_JMP32) | - BPF_JEQ | BPF_K, insn->src_reg, -- 0, 1, 0), -+ 0, 1 + (is64 ? 0 : 1), 0), - *insn, -+ BPF_JMP_IMM(BPF_JA, 0, 0, 1), -+ BPF_MOV32_REG(insn->dst_reg, insn->dst_reg), - }; - - patchlet = isdiv ? chk_and_div : chk_and_mod; - cnt = isdiv ? ARRAY_SIZE(chk_and_div) : -- ARRAY_SIZE(chk_and_mod); -+ ARRAY_SIZE(chk_and_mod) - (is64 ? 2 : 0); - - new_prog = bpf_patch_insn_data(env, i + delta, patchlet, cnt); - if (!new_prog) -diff --git a/mm/memory.c b/mm/memory.c -index 2157bb28117ac..b23831132933a 100644 ---- a/mm/memory.c -+++ b/mm/memory.c -@@ -4222,9 +4222,9 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address) - } - #endif /* __PAGETABLE_PMD_FOLDED */ - --static int __follow_pte_pmd(struct mm_struct *mm, unsigned long address, -- struct mmu_notifier_range *range, -- pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp) -+int follow_invalidate_pte(struct mm_struct *mm, unsigned long address, -+ struct mmu_notifier_range *range, pte_t **ptepp, -+ pmd_t **pmdpp, spinlock_t **ptlp) - { - pgd_t *pgd; - p4d_t *p4d; -@@ -4289,31 +4289,33 @@ out: - return -EINVAL; - } - --static inline int follow_pte(struct mm_struct *mm, unsigned long address, -- pte_t **ptepp, spinlock_t **ptlp) --{ -- int res; -- -- /* (void) is needed to make gcc happy */ -- (void) __cond_lock(*ptlp, -- !(res = __follow_pte_pmd(mm, address, NULL, -- ptepp, NULL, ptlp))); -- return res; --} -- --int follow_pte_pmd(struct mm_struct *mm, unsigned long address, -- struct mmu_notifier_range *range, -- pte_t **ptepp, pmd_t **pmdpp, spinlock_t **ptlp) -+/** -+ * follow_pte - look up PTE at a user virtual address -+ * @mm: the mm_struct of the target address space -+ * @address: user virtual address -+ * @ptepp: location to store found PTE -+ * @ptlp: location to store the lock for the PTE -+ * -+ * On a successful return, the pointer to the PTE is stored in @ptepp; -+ * the corresponding lock is taken and its location is stored in @ptlp. -+ * The contents of the PTE are only stable until @ptlp is released; -+ * any further use, if any, must be protected against invalidation -+ * with MMU notifiers. -+ * -+ * Only IO mappings and raw PFN mappings are allowed. The mmap semaphore -+ * should be taken for read. -+ * -+ * KVM uses this function. While it is arguably less bad than ``follow_pfn``, -+ * it is not a good general-purpose API. -+ * -+ * Return: zero on success, -ve otherwise. -+ */ -+int follow_pte(struct mm_struct *mm, unsigned long address, -+ pte_t **ptepp, spinlock_t **ptlp) - { -- int res; -- -- /* (void) is needed to make gcc happy */ -- (void) __cond_lock(*ptlp, -- !(res = __follow_pte_pmd(mm, address, range, -- ptepp, pmdpp, ptlp))); -- return res; -+ return follow_invalidate_pte(mm, address, NULL, ptepp, NULL, ptlp); - } --EXPORT_SYMBOL(follow_pte_pmd); -+EXPORT_SYMBOL_GPL(follow_pte); - - /** - * follow_pfn - look up PFN at a user virtual address -@@ -4323,6 +4325,9 @@ EXPORT_SYMBOL(follow_pte_pmd); - * - * Only IO mappings and raw PFN mappings are allowed. - * -+ * This function does not allow the caller to read the permissions -+ * of the PTE. Do not use it. -+ * - * Return: zero and the pfn at @pfn on success, -ve otherwise. - */ - int follow_pfn(struct vm_area_struct *vma, unsigned long address, -diff --git a/scripts/Makefile b/scripts/Makefile -index 3e86b300f5a10..b4b7d8b58cd68 100644 ---- a/scripts/Makefile -+++ b/scripts/Makefile -@@ -10,6 +10,9 @@ - - HOST_EXTRACFLAGS += -I$(srctree)/tools/include - -+CRYPTO_LIBS = $(shell pkg-config --libs libcrypto 2> /dev/null || echo -lcrypto) -+CRYPTO_CFLAGS = $(shell pkg-config --cflags libcrypto 2> /dev/null) -+ - hostprogs-$(CONFIG_BUILD_BIN2C) += bin2c - hostprogs-$(CONFIG_KALLSYMS) += kallsyms - hostprogs-$(CONFIG_LOGO) += pnmtologo -@@ -23,8 +26,10 @@ hostprogs-$(CONFIG_SYSTEM_EXTRA_CERTIFICATE) += insert-sys-cert - - HOSTCFLAGS_sortextable.o = -I$(srctree)/tools/include - HOSTCFLAGS_asn1_compiler.o = -I$(srctree)/include --HOSTLDLIBS_sign-file = -lcrypto --HOSTLDLIBS_extract-cert = -lcrypto -+HOSTCFLAGS_sign-file.o = $(CRYPTO_CFLAGS) -+HOSTLDLIBS_sign-file = $(CRYPTO_LIBS) -+HOSTCFLAGS_extract-cert.o = $(CRYPTO_CFLAGS) -+HOSTLDLIBS_extract-cert = $(CRYPTO_LIBS) - - always := $(hostprogs-y) $(hostprogs-m) - -diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl -index 3f77a5d695c13..0bafed857e171 100755 ---- a/scripts/recordmcount.pl -+++ b/scripts/recordmcount.pl -@@ -268,7 +268,11 @@ if ($arch eq "x86_64") { - - # force flags for this arch - $ld .= " -m shlelf_linux"; -- $objcopy .= " -O elf32-sh-linux"; -+ if ($endian eq "big") { -+ $objcopy .= " -O elf32-shbig-linux"; -+ } else { -+ $objcopy .= " -O elf32-sh-linux"; -+ } - - } elsif ($arch eq "powerpc") { - my $ldemulation; -diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c -index f25b5043cbcae..048b555c5acc9 100644 ---- a/virt/kvm/kvm_main.c -+++ b/virt/kvm/kvm_main.c -@@ -1598,10 +1598,12 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, - bool write_fault, bool *writable, - kvm_pfn_t *p_pfn) - { -- unsigned long pfn; -+ kvm_pfn_t pfn; -+ pte_t *ptep; -+ spinlock_t *ptl; - int r; - -- r = follow_pfn(vma, addr, &pfn); -+ r = follow_pte(vma->vm_mm, addr, &ptep, &ptl); - if (r) { - /* - * get_user_pages fails for VM_IO and VM_PFNMAP vmas and does -@@ -1616,14 +1618,19 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, - if (r) - return r; - -- r = follow_pfn(vma, addr, &pfn); -+ r = follow_pte(vma->vm_mm, addr, &ptep, &ptl); - if (r) - return r; -+ } - -+ if (write_fault && !pte_write(*ptep)) { -+ pfn = KVM_PFN_ERR_RO_FAULT; -+ goto out; - } - - if (writable) -- *writable = true; -+ *writable = pte_write(*ptep); -+ pfn = pte_pfn(*ptep); - - /* - * Get a reference here because callers of *hva_to_pfn* and -@@ -1638,6 +1645,8 @@ static int hva_to_pfn_remapped(struct vm_area_struct *vma, - */ - kvm_get_pfn(pfn); - -+out: -+ pte_unmap_unlock(ptep, ptl); - *p_pfn = pfn; - return 0; - } diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.101-102.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.101-102.patch deleted file mode 100644 index cb9e27154b..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.101-102.patch +++ /dev/null @@ -1,11908 +0,0 @@ -diff --git a/Documentation/filesystems/seq_file.txt b/Documentation/filesystems/seq_file.txt -index d412b236a9d6f..7cf7143921a1f 100644 ---- a/Documentation/filesystems/seq_file.txt -+++ b/Documentation/filesystems/seq_file.txt -@@ -192,6 +192,12 @@ between the calls to start() and stop(), so holding a lock during that time - is a reasonable thing to do. The seq_file code will also avoid taking any - other locks while the iterator is active. - -+The iterater value returned by start() or next() is guaranteed to be -+passed to a subsequent next() or stop() call. This allows resources -+such as locks that were taken to be reliably released. There is *no* -+guarantee that the iterator will be passed to show(), though in practice -+it often will be. -+ - - Formatted output - -diff --git a/Makefile b/Makefile -index f56442751d2c3..80ff67e5f73a6 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 101 -+SUBLEVEL = 102 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S -index 93dffed0ac6e0..cbe126297f549 100644 ---- a/arch/arm/boot/compressed/head.S -+++ b/arch/arm/boot/compressed/head.S -@@ -1142,9 +1142,9 @@ __armv4_mmu_cache_off: - __armv7_mmu_cache_off: - mrc p15, 0, r0, c1, c0 - #ifdef CONFIG_MMU -- bic r0, r0, #0x000d -+ bic r0, r0, #0x0005 - #else -- bic r0, r0, #0x000c -+ bic r0, r0, #0x0004 - #endif - mcr p15, 0, r0, c1, c0 @ turn MMU and cache off - mov r12, lr -diff --git a/arch/arm/boot/dts/armada-388-helios4.dts b/arch/arm/boot/dts/armada-388-helios4.dts -index 705adfa8c680f..a94758090fb0d 100644 ---- a/arch/arm/boot/dts/armada-388-helios4.dts -+++ b/arch/arm/boot/dts/armada-388-helios4.dts -@@ -70,6 +70,9 @@ - - system-leds { - compatible = "gpio-leds"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&helios_system_led_pins>; -+ - status-led { - label = "helios4:green:status"; - gpios = <&gpio0 24 GPIO_ACTIVE_LOW>; -@@ -86,6 +89,9 @@ - - io-leds { - compatible = "gpio-leds"; -+ pinctrl-names = "default"; -+ pinctrl-0 = <&helios_io_led_pins>; -+ - sata1-led { - label = "helios4:green:ata1"; - gpios = <&gpio1 17 GPIO_ACTIVE_LOW>; -@@ -121,11 +127,15 @@ - fan1: j10-pwm { - compatible = "pwm-fan"; - pwms = <&gpio1 9 40000>; /* Target freq:25 kHz */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&helios_fan1_pins>; - }; - - fan2: j17-pwm { - compatible = "pwm-fan"; - pwms = <&gpio1 23 40000>; /* Target freq:25 kHz */ -+ pinctrl-names = "default"; -+ pinctrl-0 = <&helios_fan2_pins>; - }; - - usb2_phy: usb2-phy { -@@ -291,16 +301,22 @@ - "mpp39", "mpp40"; - marvell,function = "sd0"; - }; -- helios_led_pins: helios-led-pins { -- marvell,pins = "mpp24", "mpp25", -- "mpp49", "mpp50", -+ helios_system_led_pins: helios-system-led-pins { -+ marvell,pins = "mpp24", "mpp25"; -+ marvell,function = "gpio"; -+ }; -+ helios_io_led_pins: helios-io-led-pins { -+ marvell,pins = "mpp49", "mpp50", - "mpp52", "mpp53", - "mpp54"; - marvell,function = "gpio"; - }; -- helios_fan_pins: helios-fan-pins { -- marvell,pins = "mpp41", "mpp43", -- "mpp48", "mpp55"; -+ helios_fan1_pins: helios_fan1_pins { -+ marvell,pins = "mpp41", "mpp43"; -+ marvell,function = "gpio"; -+ }; -+ helios_fan2_pins: helios_fan2_pins { -+ marvell,pins = "mpp48", "mpp55"; - marvell,function = "gpio"; - }; - microsom_spi1_cs_pins: spi1-cs-pins { -diff --git a/arch/arm/boot/dts/aspeed-g4.dtsi b/arch/arm/boot/dts/aspeed-g4.dtsi -index dffb595d30e40..679d04d585a4a 100644 ---- a/arch/arm/boot/dts/aspeed-g4.dtsi -+++ b/arch/arm/boot/dts/aspeed-g4.dtsi -@@ -371,6 +371,7 @@ - compatible = "aspeed,ast2400-ibt-bmc"; - reg = <0xc0 0x18>; - interrupts = <8>; -+ clocks = <&syscon ASPEED_CLK_GATE_LCLK>; - status = "disabled"; - }; - }; -diff --git a/arch/arm/boot/dts/aspeed-g5.dtsi b/arch/arm/boot/dts/aspeed-g5.dtsi -index e8feb8b66a2f7..412c96b3c3ac0 100644 ---- a/arch/arm/boot/dts/aspeed-g5.dtsi -+++ b/arch/arm/boot/dts/aspeed-g5.dtsi -@@ -464,6 +464,7 @@ - compatible = "aspeed,ast2500-ibt-bmc"; - reg = <0xc0 0x18>; - interrupts = <8>; -+ clocks = <&syscon ASPEED_CLK_GATE_LCLK>; - status = "disabled"; - }; - }; -diff --git a/arch/arm/boot/dts/exynos3250-artik5.dtsi b/arch/arm/boot/dts/exynos3250-artik5.dtsi -index dee35e3a5c4ba..69d134db6e94e 100644 ---- a/arch/arm/boot/dts/exynos3250-artik5.dtsi -+++ b/arch/arm/boot/dts/exynos3250-artik5.dtsi -@@ -75,7 +75,7 @@ - s2mps14_pmic@66 { - compatible = "samsung,s2mps14-pmic"; - interrupt-parent = <&gpx3>; -- interrupts = <5 IRQ_TYPE_NONE>; -+ interrupts = <5 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&s2mps14_irq>; - reg = <0x66>; -diff --git a/arch/arm/boot/dts/exynos3250-monk.dts b/arch/arm/boot/dts/exynos3250-monk.dts -index 248bd372fe705..a23a8749c94e4 100644 ---- a/arch/arm/boot/dts/exynos3250-monk.dts -+++ b/arch/arm/boot/dts/exynos3250-monk.dts -@@ -195,7 +195,7 @@ - s2mps14_pmic@66 { - compatible = "samsung,s2mps14-pmic"; - interrupt-parent = <&gpx0>; -- interrupts = <7 IRQ_TYPE_NONE>; -+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>; - reg = <0x66>; - wakeup-source; - -diff --git a/arch/arm/boot/dts/exynos3250-rinato.dts b/arch/arm/boot/dts/exynos3250-rinato.dts -index 86c26a4edfd72..468932f452895 100644 ---- a/arch/arm/boot/dts/exynos3250-rinato.dts -+++ b/arch/arm/boot/dts/exynos3250-rinato.dts -@@ -260,7 +260,7 @@ - s2mps14_pmic@66 { - compatible = "samsung,s2mps14-pmic"; - interrupt-parent = <&gpx0>; -- interrupts = <7 IRQ_TYPE_NONE>; -+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>; - reg = <0x66>; - wakeup-source; - -diff --git a/arch/arm/boot/dts/exynos5250-spring.dts b/arch/arm/boot/dts/exynos5250-spring.dts -index 3d501926c2278..2355c53164840 100644 ---- a/arch/arm/boot/dts/exynos5250-spring.dts -+++ b/arch/arm/boot/dts/exynos5250-spring.dts -@@ -108,7 +108,7 @@ - compatible = "samsung,s5m8767-pmic"; - reg = <0x66>; - interrupt-parent = <&gpx3>; -- interrupts = <2 IRQ_TYPE_NONE>; -+ interrupts = <2 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&s5m8767_irq &s5m8767_dvs &s5m8767_ds>; - wakeup-source; -diff --git a/arch/arm/boot/dts/exynos5420-arndale-octa.dts b/arch/arm/boot/dts/exynos5420-arndale-octa.dts -index 592d7b45ecc87..53bf988855e0d 100644 ---- a/arch/arm/boot/dts/exynos5420-arndale-octa.dts -+++ b/arch/arm/boot/dts/exynos5420-arndale-octa.dts -@@ -349,7 +349,7 @@ - reg = <0x66>; - - interrupt-parent = <&gpx3>; -- interrupts = <2 IRQ_TYPE_EDGE_FALLING>; -+ interrupts = <2 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&s2mps11_irq>; - -diff --git a/arch/arm/boot/dts/exynos5422-odroid-core.dtsi b/arch/arm/boot/dts/exynos5422-odroid-core.dtsi -index 829147e320e08..9e64a4ab94940 100644 ---- a/arch/arm/boot/dts/exynos5422-odroid-core.dtsi -+++ b/arch/arm/boot/dts/exynos5422-odroid-core.dtsi -@@ -141,7 +141,7 @@ - samsung,s2mps11-acokb-ground; - - interrupt-parent = <&gpx0>; -- interrupts = <4 IRQ_TYPE_EDGE_FALLING>; -+ interrupts = <4 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&s2mps11_irq>; - -diff --git a/arch/arm/boot/dts/omap443x.dtsi b/arch/arm/boot/dts/omap443x.dtsi -index 86b9caf461dfa..6e320efd9fc1d 100644 ---- a/arch/arm/boot/dts/omap443x.dtsi -+++ b/arch/arm/boot/dts/omap443x.dtsi -@@ -33,10 +33,12 @@ - }; - - ocp { -+ /* 4430 has only gpio_86 tshut and no talert interrupt */ - bandgap: bandgap@4a002260 { - reg = <0x4a002260 0x4 - 0x4a00232C 0x4>; - compatible = "ti,omap4430-bandgap"; -+ gpios = <&gpio3 22 GPIO_ACTIVE_HIGH>; - - #thermal-sensor-cells = <0>; - }; -diff --git a/arch/arm/mach-ixp4xx/Kconfig b/arch/arm/mach-ixp4xx/Kconfig -index f7211b57b1e78..165c184801e19 100644 ---- a/arch/arm/mach-ixp4xx/Kconfig -+++ b/arch/arm/mach-ixp4xx/Kconfig -@@ -13,7 +13,6 @@ config MACH_IXP4XX_OF - select I2C - select I2C_IOP3XX - select PCI -- select TIMER_OF - select USE_OF - help - Say 'Y' here to support Device Tree-based IXP4xx platforms. -diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig -index a0bc9bbb92f34..9c8ea59398658 100644 ---- a/arch/arm64/Kconfig -+++ b/arch/arm64/Kconfig -@@ -489,7 +489,7 @@ config ARM64_ERRATUM_1024718 - help - This option adds a workaround for ARM Cortex-A55 Erratum 1024718. - -- Affected Cortex-A55 cores (r0p0, r0p1, r1p0) could cause incorrect -+ Affected Cortex-A55 cores (all revisions) could cause incorrect - update of the hardware dirty bit when the DBM/AP bits are updated - without a break-before-make. The workaround is to disable the usage - of hardware DBM locally on the affected cores. CPUs not affected by -diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts -index 78c82a665c84a..bb1de8217b86d 100644 ---- a/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts -+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-pinebook.dts -@@ -103,8 +103,6 @@ - }; - - &ehci0 { -- phys = <&usbphy 0>; -- phy-names = "usb"; - status = "okay"; - }; - -@@ -142,6 +140,7 @@ - pinctrl-0 = <&mmc2_pins>, <&mmc2_ds_pin>; - vmmc-supply = <®_dcdc1>; - vqmmc-supply = <®_eldo1>; -+ max-frequency = <200000000>; - bus-width = <8>; - non-removable; - cap-mmc-hw-reset; -@@ -150,8 +149,6 @@ - }; - - &ohci0 { -- phys = <&usbphy 0>; -- phy-names = "usb"; - status = "okay"; - }; - -diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi -index 9d20e13f0c02b..d935e3028fcb6 100644 ---- a/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64-sopine.dtsi -@@ -55,7 +55,6 @@ - pinctrl-names = "default"; - pinctrl-0 = <&mmc0_pins>; - vmmc-supply = <®_dcdc1>; -- non-removable; - disable-wp; - bus-width = <4>; - cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */ -diff --git a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi -index 367699c8c9028..cf9e3234afaf8 100644 ---- a/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-a64.dtsi -@@ -476,7 +476,7 @@ - resets = <&ccu RST_BUS_MMC2>; - reset-names = "ahb"; - interrupts = ; -- max-frequency = <200000000>; -+ max-frequency = <150000000>; - status = "disabled"; - #address-cells = <1>; - #size-cells = <0>; -@@ -530,6 +530,8 @@ - <&ccu CLK_USB_OHCI0>; - resets = <&ccu RST_BUS_OHCI0>, - <&ccu RST_BUS_EHCI0>; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; - status = "disabled"; - }; - -@@ -540,6 +542,8 @@ - clocks = <&ccu CLK_BUS_OHCI0>, - <&ccu CLK_USB_OHCI0>; - resets = <&ccu RST_BUS_OHCI0>; -+ phys = <&usbphy 0>; -+ phy-names = "usb"; - status = "disabled"; - }; - -diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi -index ab081efd59718..1583cd5915214 100644 ---- a/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi -+++ b/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi -@@ -332,6 +332,7 @@ - interrupts = ; - pinctrl-names = "default"; - pinctrl-0 = <&mmc0_pins>; -+ max-frequency = <150000000>; - status = "disabled"; - #address-cells = <1>; - #size-cells = <0>; -@@ -348,6 +349,7 @@ - interrupts = ; - pinctrl-names = "default"; - pinctrl-0 = <&mmc1_pins>; -+ max-frequency = <150000000>; - status = "disabled"; - #address-cells = <1>; - #size-cells = <0>; -@@ -364,6 +366,7 @@ - interrupts = ; - pinctrl-names = "default"; - pinctrl-0 = <&mmc2_pins>; -+ max-frequency = <150000000>; - status = "disabled"; - #address-cells = <1>; - #size-cells = <0>; -@@ -533,6 +536,8 @@ - <&ccu CLK_USB_OHCI0>; - resets = <&ccu RST_BUS_OHCI0>, - <&ccu RST_BUS_EHCI0>; -+ phys = <&usb2phy 0>; -+ phy-names = "usb"; - status = "disabled"; - }; - -@@ -543,6 +548,8 @@ - clocks = <&ccu CLK_BUS_OHCI0>, - <&ccu CLK_USB_OHCI0>; - resets = <&ccu RST_BUS_OHCI0>; -+ phys = <&usb2phy 0>; -+ phy-names = "usb"; - status = "disabled"; - }; - -diff --git a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi -index 6f90b0e62cba6..148bdca8d9c96 100644 ---- a/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi -+++ b/arch/arm64/boot/dts/exynos/exynos5433-tm2-common.dtsi -@@ -389,7 +389,7 @@ - s2mps13-pmic@66 { - compatible = "samsung,s2mps13-pmic"; - interrupt-parent = <&gpa0>; -- interrupts = <7 IRQ_TYPE_NONE>; -+ interrupts = <7 IRQ_TYPE_LEVEL_LOW>; - reg = <0x66>; - samsung,s2mps11-wrstbi-ground; - -diff --git a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts -index 61ee7b6a31594..09aead2be000c 100644 ---- a/arch/arm64/boot/dts/exynos/exynos7-espresso.dts -+++ b/arch/arm64/boot/dts/exynos/exynos7-espresso.dts -@@ -90,7 +90,7 @@ - s2mps15_pmic@66 { - compatible = "samsung,s2mps15-pmic"; - reg = <0x66>; -- interrupts = <2 IRQ_TYPE_NONE>; -+ interrupts = <2 IRQ_TYPE_LEVEL_LOW>; - interrupt-parent = <&gpa0>; - pinctrl-names = "default"; - pinctrl-0 = <&pmic_irq>; -diff --git a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -index aa52927e2e9c2..fad70c2df7bc0 100644 ---- a/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -+++ b/arch/arm64/boot/dts/marvell/armada-3720-turris-mox.dts -@@ -202,7 +202,7 @@ - }; - - partition@20000 { -- label = "u-boot"; -+ label = "a53-firmware"; - reg = <0x20000 0x160000>; - }; - -diff --git a/arch/arm64/boot/dts/mediatek/mt7622.dtsi b/arch/arm64/boot/dts/mediatek/mt7622.dtsi -index 7cd8c3f52b471..e7e002d8b1089 100644 ---- a/arch/arm64/boot/dts/mediatek/mt7622.dtsi -+++ b/arch/arm64/boot/dts/mediatek/mt7622.dtsi -@@ -698,6 +698,8 @@ - clocks = <&pericfg CLK_PERI_MSDC30_1_PD>, - <&topckgen CLK_TOP_AXI_SEL>; - clock-names = "source", "hclk"; -+ resets = <&pericfg MT7622_PERI_MSDC1_SW_RST>; -+ reset-names = "hrst"; - status = "disabled"; - }; - -diff --git a/arch/arm64/boot/dts/qcom/msm8916.dtsi b/arch/arm64/boot/dts/qcom/msm8916.dtsi -index d95273af9f1e4..449843f2184d8 100644 ---- a/arch/arm64/boot/dts/qcom/msm8916.dtsi -+++ b/arch/arm64/boot/dts/qcom/msm8916.dtsi -@@ -53,7 +53,7 @@ - no-map; - }; - -- reserved@8668000 { -+ reserved@86680000 { - reg = <0x0 0x86680000 0x0 0x80000>; - no-map; - }; -@@ -66,7 +66,7 @@ - qcom,client-id = <1>; - }; - -- rfsa@867e00000 { -+ rfsa@867e0000 { - reg = <0x0 0x867e0000 0x0 0x20000>; - no-map; - }; -diff --git a/arch/arm64/crypto/aes-glue.c b/arch/arm64/crypto/aes-glue.c -index aa57dc639f77f..aa13344a3a5e8 100644 ---- a/arch/arm64/crypto/aes-glue.c -+++ b/arch/arm64/crypto/aes-glue.c -@@ -55,7 +55,7 @@ MODULE_DESCRIPTION("AES-ECB/CBC/CTR/XTS using ARMv8 Crypto Extensions"); - #define aes_mac_update neon_aes_mac_update - MODULE_DESCRIPTION("AES-ECB/CBC/CTR/XTS using ARMv8 NEON"); - #endif --#if defined(USE_V8_CRYPTO_EXTENSIONS) || !defined(CONFIG_CRYPTO_AES_ARM64_BS) -+#if defined(USE_V8_CRYPTO_EXTENSIONS) || !IS_ENABLED(CONFIG_CRYPTO_AES_ARM64_BS) - MODULE_ALIAS_CRYPTO("ecb(aes)"); - MODULE_ALIAS_CRYPTO("cbc(aes)"); - MODULE_ALIAS_CRYPTO("ctr(aes)"); -@@ -668,7 +668,7 @@ static int __maybe_unused xts_decrypt(struct skcipher_request *req) - } - - static struct skcipher_alg aes_algs[] = { { --#if defined(USE_V8_CRYPTO_EXTENSIONS) || !defined(CONFIG_CRYPTO_AES_ARM64_BS) -+#if defined(USE_V8_CRYPTO_EXTENSIONS) || !IS_ENABLED(CONFIG_CRYPTO_AES_ARM64_BS) - .base = { - .cra_name = "__ecb(aes)", - .cra_driver_name = "__ecb-aes-" MODE, -diff --git a/arch/arm64/crypto/sha1-ce-glue.c b/arch/arm64/crypto/sha1-ce-glue.c -index bdc1b6d7aff79..05cdad31b0225 100644 ---- a/arch/arm64/crypto/sha1-ce-glue.c -+++ b/arch/arm64/crypto/sha1-ce-glue.c -@@ -19,6 +19,7 @@ - MODULE_DESCRIPTION("SHA1 secure hash using ARMv8 Crypto Extensions"); - MODULE_AUTHOR("Ard Biesheuvel "); - MODULE_LICENSE("GPL v2"); -+MODULE_ALIAS_CRYPTO("sha1"); - - struct sha1_ce_state { - struct sha1_state sst; -diff --git a/arch/arm64/crypto/sha2-ce-glue.c b/arch/arm64/crypto/sha2-ce-glue.c -index 604a01a4ede6f..1de80293ac312 100644 ---- a/arch/arm64/crypto/sha2-ce-glue.c -+++ b/arch/arm64/crypto/sha2-ce-glue.c -@@ -19,6 +19,8 @@ - MODULE_DESCRIPTION("SHA-224/SHA-256 secure hash using ARMv8 Crypto Extensions"); - MODULE_AUTHOR("Ard Biesheuvel "); - MODULE_LICENSE("GPL v2"); -+MODULE_ALIAS_CRYPTO("sha224"); -+MODULE_ALIAS_CRYPTO("sha256"); - - struct sha256_ce_state { - struct sha256_state sst; -diff --git a/arch/arm64/crypto/sha3-ce-glue.c b/arch/arm64/crypto/sha3-ce-glue.c -index 9a4bbfc45f407..ddf7aca9ff459 100644 ---- a/arch/arm64/crypto/sha3-ce-glue.c -+++ b/arch/arm64/crypto/sha3-ce-glue.c -@@ -23,6 +23,10 @@ - MODULE_DESCRIPTION("SHA3 secure hash using ARMv8 Crypto Extensions"); - MODULE_AUTHOR("Ard Biesheuvel "); - MODULE_LICENSE("GPL v2"); -+MODULE_ALIAS_CRYPTO("sha3-224"); -+MODULE_ALIAS_CRYPTO("sha3-256"); -+MODULE_ALIAS_CRYPTO("sha3-384"); -+MODULE_ALIAS_CRYPTO("sha3-512"); - - asmlinkage void sha3_ce_transform(u64 *st, const u8 *data, int blocks, - int md_len); -diff --git a/arch/arm64/crypto/sha512-ce-glue.c b/arch/arm64/crypto/sha512-ce-glue.c -index 2369540040aa9..6dfcb4f3e7768 100644 ---- a/arch/arm64/crypto/sha512-ce-glue.c -+++ b/arch/arm64/crypto/sha512-ce-glue.c -@@ -23,6 +23,8 @@ - MODULE_DESCRIPTION("SHA-384/SHA-512 secure hash using ARMv8 Crypto Extensions"); - MODULE_AUTHOR("Ard Biesheuvel "); - MODULE_LICENSE("GPL v2"); -+MODULE_ALIAS_CRYPTO("sha384"); -+MODULE_ALIAS_CRYPTO("sha512"); - - asmlinkage void sha512_ce_transform(struct sha512_state *sst, u8 const *src, - int blocks); -diff --git a/arch/arm64/kernel/cpufeature.c b/arch/arm64/kernel/cpufeature.c -index f2ec845404149..79caab15ccbf7 100644 ---- a/arch/arm64/kernel/cpufeature.c -+++ b/arch/arm64/kernel/cpufeature.c -@@ -1092,7 +1092,7 @@ static bool cpu_has_broken_dbm(void) - /* List of CPUs which have broken DBM support. */ - static const struct midr_range cpus[] = { - #ifdef CONFIG_ARM64_ERRATUM_1024718 -- MIDR_RANGE(MIDR_CORTEX_A55, 0, 0, 1, 0), // A55 r0p0 -r1p0 -+ MIDR_ALL_VERSIONS(MIDR_CORTEX_A55), - #endif - {}, - }; -diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S -index bdb5ec3419006..438de2301cfe3 100644 ---- a/arch/arm64/kernel/head.S -+++ b/arch/arm64/kernel/head.S -@@ -970,6 +970,7 @@ __primary_switch: - - tlbi vmalle1 // Remove any stale TLB entries - dsb nsh -+ isb - - msr sctlr_el1, x19 // re-enable the MMU - isb -diff --git a/arch/arm64/kernel/machine_kexec_file.c b/arch/arm64/kernel/machine_kexec_file.c -index 7b08bf9499b6b..d2a62dd17d79d 100644 ---- a/arch/arm64/kernel/machine_kexec_file.c -+++ b/arch/arm64/kernel/machine_kexec_file.c -@@ -150,8 +150,10 @@ static int create_dtb(struct kimage *image, - - /* duplicate a device tree blob */ - ret = fdt_open_into(initial_boot_params, buf, buf_size); -- if (ret) -+ if (ret) { -+ vfree(buf); - return -EINVAL; -+ } - - ret = setup_dtb(image, initrd_load_addr, initrd_len, - cmdline, buf); -diff --git a/arch/arm64/kernel/probes/uprobes.c b/arch/arm64/kernel/probes/uprobes.c -index a412d8edbcd24..2c247634552b1 100644 ---- a/arch/arm64/kernel/probes/uprobes.c -+++ b/arch/arm64/kernel/probes/uprobes.c -@@ -38,7 +38,7 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, struct mm_struct *mm, - - /* TODO: Currently we do not support AARCH32 instruction probing */ - if (mm->context.flags & MMCF_AARCH32) -- return -ENOTSUPP; -+ return -EOPNOTSUPP; - else if (!IS_ALIGNED(addr, AARCH64_INSN_SIZE)) - return -EINVAL; - -diff --git a/arch/mips/include/asm/asm.h b/arch/mips/include/asm/asm.h -index c23527ba65d09..64bffc1f75e0c 100644 ---- a/arch/mips/include/asm/asm.h -+++ b/arch/mips/include/asm/asm.h -@@ -20,10 +20,27 @@ - #include - #include - -+#ifndef __VDSO__ -+/* -+ * Emit CFI data in .debug_frame sections, not .eh_frame sections. -+ * We don't do DWARF unwinding at runtime, so only the offline DWARF -+ * information is useful to anyone. Note we should change this if we -+ * ever decide to enable DWARF unwinding at runtime. -+ */ -+#define CFI_SECTIONS .cfi_sections .debug_frame -+#else -+ /* -+ * For the vDSO, emit both runtime unwind information and debug -+ * symbols for the .dbg file. -+ */ -+#define CFI_SECTIONS -+#endif -+ - /* - * LEAF - declare leaf routine - */ - #define LEAF(symbol) \ -+ CFI_SECTIONS; \ - .globl symbol; \ - .align 2; \ - .type symbol, @function; \ -@@ -36,6 +53,7 @@ symbol: .frame sp, 0, ra; \ - * NESTED - declare nested routine entry point - */ - #define NESTED(symbol, framesize, rpc) \ -+ CFI_SECTIONS; \ - .globl symbol; \ - .align 2; \ - .type symbol, @function; \ -diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S -index eb9d7af938365..faf98f209b3f4 100644 ---- a/arch/mips/kernel/vmlinux.lds.S -+++ b/arch/mips/kernel/vmlinux.lds.S -@@ -93,6 +93,7 @@ SECTIONS - - INIT_TASK_DATA(THREAD_SIZE) - NOSAVE_DATA -+ PAGE_ALIGNED_DATA(PAGE_SIZE) - CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) - READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT) - DATA_DATA -@@ -225,6 +226,5 @@ SECTIONS - *(.options) - *(.pdr) - *(.reginfo) -- *(.eh_frame) - } - } -diff --git a/arch/mips/lantiq/irq.c b/arch/mips/lantiq/irq.c -index 115b417dfb8e3..9fcc118312cb9 100644 ---- a/arch/mips/lantiq/irq.c -+++ b/arch/mips/lantiq/irq.c -@@ -302,7 +302,7 @@ static void ltq_hw_irq_handler(struct irq_desc *desc) - generic_handle_irq(irq_linear_revmap(ltq_domain, hwirq)); - - /* if this is a EBU irq, we need to ack it or get a deadlock */ -- if ((irq == LTQ_ICU_EBU_IRQ) && (module == 0) && LTQ_EBU_PCC_ISTAT) -+ if (irq == LTQ_ICU_EBU_IRQ && !module && LTQ_EBU_PCC_ISTAT != 0) - ltq_ebu_w32(ltq_ebu_r32(LTQ_EBU_PCC_ISTAT) | 0x10, - LTQ_EBU_PCC_ISTAT); - } -diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c -index 504fd61592405..3375bbe63284e 100644 ---- a/arch/mips/mm/c-r4k.c -+++ b/arch/mips/mm/c-r4k.c -@@ -1560,7 +1560,7 @@ static int probe_scache(void) - return 1; - } - --static void __init loongson2_sc_init(void) -+static void loongson2_sc_init(void) - { - struct cpuinfo_mips *c = ¤t_cpu_data; - -diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig -index cb285e474c880..c4cbb65e742f4 100644 ---- a/arch/powerpc/Kconfig -+++ b/arch/powerpc/Kconfig -@@ -723,7 +723,7 @@ config PPC_64K_PAGES - - config PPC_256K_PAGES - bool "256k page size" -- depends on 44x && !STDBINUTILS -+ depends on 44x && !STDBINUTILS && !PPC_47x - help - Make the page size 256k. - -diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S -index f29bb176381f1..c72894ff9d614 100644 ---- a/arch/powerpc/kernel/entry_32.S -+++ b/arch/powerpc/kernel/entry_32.S -@@ -336,6 +336,9 @@ trace_syscall_entry_irq_off: - - .globl transfer_to_syscall - transfer_to_syscall: -+#ifdef CONFIG_PPC_BOOK3S_32 -+ kuep_lock r11, r12 -+#endif - #ifdef CONFIG_TRACE_IRQFLAGS - andi. r12,r9,MSR_EE - beq- trace_syscall_entry_irq_off -diff --git a/arch/powerpc/kernel/head_8xx.S b/arch/powerpc/kernel/head_8xx.S -index f6428b90a6c77..6f3e417f55a35 100644 ---- a/arch/powerpc/kernel/head_8xx.S -+++ b/arch/powerpc/kernel/head_8xx.S -@@ -191,7 +191,7 @@ SystemCall: - /* On the MPC8xx, this is a software emulation interrupt. It occurs - * for all unimplemented and illegal instructions. - */ -- EXCEPTION(0x1000, SoftEmu, program_check_exception, EXC_XFER_STD) -+ EXCEPTION(0x1000, SoftEmu, emulation_assist_interrupt, EXC_XFER_STD) - - /* Called from DataStoreTLBMiss when perf TLB misses events are activated */ - #ifdef CONFIG_PERF_EVENTS -diff --git a/arch/powerpc/kernel/prom_init.c b/arch/powerpc/kernel/prom_init.c -index 689664cd4e79b..1b65fb7c0bdaa 100644 ---- a/arch/powerpc/kernel/prom_init.c -+++ b/arch/powerpc/kernel/prom_init.c -@@ -1305,14 +1305,10 @@ static void __init prom_check_platform_support(void) - if (prop_len > sizeof(vec)) - prom_printf("WARNING: ibm,arch-vec-5-platform-support longer than expected (len: %d)\n", - prop_len); -- prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support", -- &vec, sizeof(vec)); -- for (i = 0; i < sizeof(vec); i += 2) { -- prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2 -- , vec[i] -- , vec[i + 1]); -- prom_parse_platform_support(vec[i], vec[i + 1], -- &supported); -+ prom_getprop(prom.chosen, "ibm,arch-vec-5-platform-support", &vec, sizeof(vec)); -+ for (i = 0; i < prop_len; i += 2) { -+ prom_debug("%d: index = 0x%x val = 0x%x\n", i / 2, vec[i], vec[i + 1]); -+ prom_parse_platform_support(vec[i], vec[i + 1], &supported); - } - } - -diff --git a/arch/powerpc/kvm/powerpc.c b/arch/powerpc/kvm/powerpc.c -index 3a77bb6434521..e03c064716789 100644 ---- a/arch/powerpc/kvm/powerpc.c -+++ b/arch/powerpc/kvm/powerpc.c -@@ -1513,7 +1513,7 @@ int kvmppc_handle_vmx_load(struct kvm_run *run, struct kvm_vcpu *vcpu, - return emulated; - } - --int kvmppc_get_vmx_dword(struct kvm_vcpu *vcpu, int index, u64 *val) -+static int kvmppc_get_vmx_dword(struct kvm_vcpu *vcpu, int index, u64 *val) - { - union kvmppc_one_reg reg; - int vmx_offset = 0; -@@ -1531,7 +1531,7 @@ int kvmppc_get_vmx_dword(struct kvm_vcpu *vcpu, int index, u64 *val) - return result; - } - --int kvmppc_get_vmx_word(struct kvm_vcpu *vcpu, int index, u64 *val) -+static int kvmppc_get_vmx_word(struct kvm_vcpu *vcpu, int index, u64 *val) - { - union kvmppc_one_reg reg; - int vmx_offset = 0; -@@ -1549,7 +1549,7 @@ int kvmppc_get_vmx_word(struct kvm_vcpu *vcpu, int index, u64 *val) - return result; - } - --int kvmppc_get_vmx_hword(struct kvm_vcpu *vcpu, int index, u64 *val) -+static int kvmppc_get_vmx_hword(struct kvm_vcpu *vcpu, int index, u64 *val) - { - union kvmppc_one_reg reg; - int vmx_offset = 0; -@@ -1567,7 +1567,7 @@ int kvmppc_get_vmx_hword(struct kvm_vcpu *vcpu, int index, u64 *val) - return result; - } - --int kvmppc_get_vmx_byte(struct kvm_vcpu *vcpu, int index, u64 *val) -+static int kvmppc_get_vmx_byte(struct kvm_vcpu *vcpu, int index, u64 *val) - { - union kvmppc_one_reg reg; - int vmx_offset = 0; -diff --git a/arch/powerpc/platforms/pseries/dlpar.c b/arch/powerpc/platforms/pseries/dlpar.c -index 16e86ba8aa209..f6b7749d6ada7 100644 ---- a/arch/powerpc/platforms/pseries/dlpar.c -+++ b/arch/powerpc/platforms/pseries/dlpar.c -@@ -127,7 +127,6 @@ void dlpar_free_cc_nodes(struct device_node *dn) - #define NEXT_PROPERTY 3 - #define PREV_PARENT 4 - #define MORE_MEMORY 5 --#define CALL_AGAIN -2 - #define ERR_CFG_USE -9003 - - struct device_node *dlpar_configure_connector(__be32 drc_index, -@@ -168,6 +167,9 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, - - spin_unlock(&rtas_data_buf_lock); - -+ if (rtas_busy_delay(rc)) -+ continue; -+ - switch (rc) { - case COMPLETE: - break; -@@ -216,9 +218,6 @@ struct device_node *dlpar_configure_connector(__be32 drc_index, - last_dn = last_dn->parent; - break; - -- case CALL_AGAIN: -- break; -- - case MORE_MEMORY: - case ERR_CFG_USE: - default: -diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c -index c475ca49cfc6b..3e72f955bff7f 100644 ---- a/arch/s390/kernel/vtime.c -+++ b/arch/s390/kernel/vtime.c -@@ -136,7 +136,8 @@ static int do_account_vtime(struct task_struct *tsk) - " stck %1" /* Store current tod clock value */ - #endif - : "=Q" (S390_lowcore.last_update_timer), -- "=Q" (S390_lowcore.last_update_clock)); -+ "=Q" (S390_lowcore.last_update_clock) -+ : : "cc"); - clock = S390_lowcore.last_update_clock - clock; - timer -= S390_lowcore.last_update_timer; - -diff --git a/arch/sparc/Kconfig b/arch/sparc/Kconfig -index 18e9fb6fcf1bf..349e27771ceaf 100644 ---- a/arch/sparc/Kconfig -+++ b/arch/sparc/Kconfig -@@ -524,7 +524,7 @@ config COMPAT - bool - depends on SPARC64 - default y -- select COMPAT_BINFMT_ELF -+ select COMPAT_BINFMT_ELF if BINFMT_ELF - select HAVE_UID16 - select ARCH_WANT_OLD_COMPAT_IPC - select COMPAT_OLD_SIGACTION -diff --git a/arch/sparc/lib/memset.S b/arch/sparc/lib/memset.S -index b89d42b29e344..f427f34b8b79b 100644 ---- a/arch/sparc/lib/memset.S -+++ b/arch/sparc/lib/memset.S -@@ -142,6 +142,7 @@ __bzero: - ZERO_LAST_BLOCKS(%o0, 0x48, %g2) - ZERO_LAST_BLOCKS(%o0, 0x08, %g2) - 13: -+ EXT(12b, 13b, 21f) - be 8f - andcc %o1, 4, %g0 - -diff --git a/arch/um/kernel/tlb.c b/arch/um/kernel/tlb.c -index b7eaf655635cd..11499136720d8 100644 ---- a/arch/um/kernel/tlb.c -+++ b/arch/um/kernel/tlb.c -@@ -126,6 +126,9 @@ static int add_mmap(unsigned long virt, unsigned long phys, unsigned long len, - struct host_vm_op *last; - int fd = -1, ret = 0; - -+ if (virt + len > STUB_START && virt < STUB_END) -+ return -EINVAL; -+ - if (hvc->userspace) - fd = phys_mapping(phys, &offset); - else -@@ -163,7 +166,7 @@ static int add_munmap(unsigned long addr, unsigned long len, - struct host_vm_op *last; - int ret = 0; - -- if ((addr >= STUB_START) && (addr < STUB_END)) -+ if (addr + len > STUB_START && addr < STUB_END) - return -EINVAL; - - if (hvc->index != 0) { -@@ -193,6 +196,9 @@ static int add_mprotect(unsigned long addr, unsigned long len, - struct host_vm_op *last; - int ret = 0; - -+ if (addr + len > STUB_START && addr < STUB_END) -+ return -EINVAL; -+ - if (hvc->index != 0) { - last = &hvc->ops[hvc->index - 1]; - if ((last->type == MPROTECT) && -@@ -433,6 +439,10 @@ void flush_tlb_page(struct vm_area_struct *vma, unsigned long address) - struct mm_id *mm_id; - - address &= PAGE_MASK; -+ -+ if (address >= STUB_START && address < STUB_END) -+ goto kill; -+ - pgd = pgd_offset(mm, address); - if (!pgd_present(*pgd)) - goto kill; -diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c -index 3e707e81afdb4..88ad272aa2b46 100644 ---- a/arch/x86/crypto/aesni-intel_glue.c -+++ b/arch/x86/crypto/aesni-intel_glue.c -@@ -707,7 +707,8 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req, - struct crypto_aead *tfm = crypto_aead_reqtfm(req); - unsigned long auth_tag_len = crypto_aead_authsize(tfm); - const struct aesni_gcm_tfm_s *gcm_tfm = aesni_gcm_tfm; -- struct gcm_context_data data AESNI_ALIGN_ATTR; -+ u8 databuf[sizeof(struct gcm_context_data) + (AESNI_ALIGN - 8)] __aligned(8); -+ struct gcm_context_data *data = PTR_ALIGN((void *)databuf, AESNI_ALIGN); - struct scatter_walk dst_sg_walk = {}; - unsigned long left = req->cryptlen; - unsigned long len, srclen, dstlen; -@@ -760,8 +761,7 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req, - } - - kernel_fpu_begin(); -- gcm_tfm->init(aes_ctx, &data, iv, -- hash_subkey, assoc, assoclen); -+ gcm_tfm->init(aes_ctx, data, iv, hash_subkey, assoc, assoclen); - if (req->src != req->dst) { - while (left) { - src = scatterwalk_map(&src_sg_walk); -@@ -771,10 +771,10 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req, - len = min(srclen, dstlen); - if (len) { - if (enc) -- gcm_tfm->enc_update(aes_ctx, &data, -+ gcm_tfm->enc_update(aes_ctx, data, - dst, src, len); - else -- gcm_tfm->dec_update(aes_ctx, &data, -+ gcm_tfm->dec_update(aes_ctx, data, - dst, src, len); - } - left -= len; -@@ -792,10 +792,10 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req, - len = scatterwalk_clamp(&src_sg_walk, left); - if (len) { - if (enc) -- gcm_tfm->enc_update(aes_ctx, &data, -+ gcm_tfm->enc_update(aes_ctx, data, - src, src, len); - else -- gcm_tfm->dec_update(aes_ctx, &data, -+ gcm_tfm->dec_update(aes_ctx, data, - src, src, len); - } - left -= len; -@@ -804,7 +804,7 @@ static int gcmaes_crypt_by_sg(bool enc, struct aead_request *req, - scatterwalk_done(&src_sg_walk, 1, left); - } - } -- gcm_tfm->finalize(aes_ctx, &data, authTag, auth_tag_len); -+ gcm_tfm->finalize(aes_ctx, data, authTag, auth_tag_len); - kernel_fpu_end(); - - if (!assocmem) -@@ -853,7 +853,8 @@ static int helper_rfc4106_encrypt(struct aead_request *req) - struct crypto_aead *tfm = crypto_aead_reqtfm(req); - struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); - void *aes_ctx = &(ctx->aes_key_expanded); -- u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); -+ u8 ivbuf[16 + (AESNI_ALIGN - 8)] __aligned(8); -+ u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN); - unsigned int i; - __be32 counter = cpu_to_be32(1); - -@@ -880,7 +881,8 @@ static int helper_rfc4106_decrypt(struct aead_request *req) - struct crypto_aead *tfm = crypto_aead_reqtfm(req); - struct aesni_rfc4106_gcm_ctx *ctx = aesni_rfc4106_gcm_ctx_get(tfm); - void *aes_ctx = &(ctx->aes_key_expanded); -- u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); -+ u8 ivbuf[16 + (AESNI_ALIGN - 8)] __aligned(8); -+ u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN); - unsigned int i; - - if (unlikely(req->assoclen != 16 && req->assoclen != 20)) -@@ -1010,7 +1012,8 @@ static int generic_gcmaes_encrypt(struct aead_request *req) - struct crypto_aead *tfm = crypto_aead_reqtfm(req); - struct generic_gcmaes_ctx *ctx = generic_gcmaes_ctx_get(tfm); - void *aes_ctx = &(ctx->aes_key_expanded); -- u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); -+ u8 ivbuf[16 + (AESNI_ALIGN - 8)] __aligned(8); -+ u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN); - __be32 counter = cpu_to_be32(1); - - memcpy(iv, req->iv, 12); -@@ -1026,7 +1029,8 @@ static int generic_gcmaes_decrypt(struct aead_request *req) - struct crypto_aead *tfm = crypto_aead_reqtfm(req); - struct generic_gcmaes_ctx *ctx = generic_gcmaes_ctx_get(tfm); - void *aes_ctx = &(ctx->aes_key_expanded); -- u8 iv[16] __attribute__ ((__aligned__(AESNI_ALIGN))); -+ u8 ivbuf[16 + (AESNI_ALIGN - 8)] __aligned(8); -+ u8 *iv = PTR_ALIGN(&ivbuf[0], AESNI_ALIGN); - - memcpy(iv, req->iv, 12); - *((__be32 *)(iv+12)) = counter; -diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h -index 9aad0e0876fba..fda3e7747c223 100644 ---- a/arch/x86/include/asm/virtext.h -+++ b/arch/x86/include/asm/virtext.h -@@ -30,15 +30,22 @@ static inline int cpu_has_vmx(void) - } - - --/** Disable VMX on the current CPU -+/** -+ * cpu_vmxoff() - Disable VMX on the current CPU - * -- * vmxoff causes a undefined-opcode exception if vmxon was not run -- * on the CPU previously. Only call this function if you know VMX -- * is enabled. -+ * Disable VMX and clear CR4.VMXE (even if VMXOFF faults) -+ * -+ * Note, VMXOFF causes a #UD if the CPU is !post-VMXON, but it's impossible to -+ * atomically track post-VMXON state, e.g. this may be called in NMI context. -+ * Eat all faults as all other faults on VMXOFF faults are mode related, i.e. -+ * faults are guaranteed to be due to the !post-VMXON check unless the CPU is -+ * magically in RM, VM86, compat mode, or at CPL>0. - */ - static inline void cpu_vmxoff(void) - { -- asm volatile ("vmxoff"); -+ asm_volatile_goto("1: vmxoff\n\t" -+ _ASM_EXTABLE(1b, %l[fault]) :::: fault); -+fault: - cr4_clear_bits(X86_CR4_VMXE); - } - -diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c -index 762f5c1465a6f..835b6fc0c1bbf 100644 ---- a/arch/x86/kernel/reboot.c -+++ b/arch/x86/kernel/reboot.c -@@ -538,29 +538,20 @@ static void emergency_vmx_disable_all(void) - local_irq_disable(); - - /* -- * We need to disable VMX on all CPUs before rebooting, otherwise -- * we risk hanging up the machine, because the CPU ignore INIT -- * signals when VMX is enabled. -+ * Disable VMX on all CPUs before rebooting, otherwise we risk hanging -+ * the machine, because the CPU blocks INIT when it's in VMX root. - * -- * We can't take any locks and we may be on an inconsistent -- * state, so we use NMIs as IPIs to tell the other CPUs to disable -- * VMX and halt. -+ * We can't take any locks and we may be on an inconsistent state, so -+ * use NMIs as IPIs to tell the other CPUs to exit VMX root and halt. - * -- * For safety, we will avoid running the nmi_shootdown_cpus() -- * stuff unnecessarily, but we don't have a way to check -- * if other CPUs have VMX enabled. So we will call it only if the -- * CPU we are running on has VMX enabled. -- * -- * We will miss cases where VMX is not enabled on all CPUs. This -- * shouldn't do much harm because KVM always enable VMX on all -- * CPUs anyway. But we can miss it on the small window where KVM -- * is still enabling VMX. -+ * Do the NMI shootdown even if VMX if off on _this_ CPU, as that -+ * doesn't prevent a different CPU from being in VMX root operation. - */ -- if (cpu_has_vmx() && cpu_vmx_enabled()) { -- /* Disable VMX on this CPU. */ -- cpu_vmxoff(); -+ if (cpu_has_vmx()) { -+ /* Safely force _this_ CPU out of VMX root operation. */ -+ __cpu_emergency_vmxoff(); - -- /* Halt and disable VMX on the other CPUs */ -+ /* Halt and exit VMX root operation on the other CPUs. */ - nmi_shootdown_cpus(vmxoff_nmi); - - } -diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c -index 1da558f28aa57..b9d14fdbd2d81 100644 ---- a/arch/x86/kvm/svm.c -+++ b/arch/x86/kvm/svm.c -@@ -4327,7 +4327,7 @@ static int svm_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr) - !guest_has_spec_ctrl_msr(vcpu)) - return 1; - -- if (data & ~kvm_spec_ctrl_valid_bits(vcpu)) -+ if (kvm_spec_ctrl_test_value(data)) - return 1; - - svm->spec_ctrl = data; -diff --git a/arch/x86/kvm/vmx/vmx.c b/arch/x86/kvm/vmx/vmx.c -index e7fd2f00edc11..e177848a36313 100644 ---- a/arch/x86/kvm/vmx/vmx.c -+++ b/arch/x86/kvm/vmx/vmx.c -@@ -1974,7 +1974,7 @@ static int vmx_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info) - !guest_has_spec_ctrl_msr(vcpu)) - return 1; - -- if (data & ~kvm_spec_ctrl_valid_bits(vcpu)) -+ if (kvm_spec_ctrl_test_value(data)) - return 1; - - vmx->spec_ctrl = data; -diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c -index 73095d7213993..153659e8f4039 100644 ---- a/arch/x86/kvm/x86.c -+++ b/arch/x86/kvm/x86.c -@@ -10374,28 +10374,32 @@ bool kvm_arch_no_poll(struct kvm_vcpu *vcpu) - } - EXPORT_SYMBOL_GPL(kvm_arch_no_poll); - --u64 kvm_spec_ctrl_valid_bits(struct kvm_vcpu *vcpu) -+ -+int kvm_spec_ctrl_test_value(u64 value) - { -- uint64_t bits = SPEC_CTRL_IBRS | SPEC_CTRL_STIBP | SPEC_CTRL_SSBD; -+ /* -+ * test that setting IA32_SPEC_CTRL to given value -+ * is allowed by the host processor -+ */ -+ -+ u64 saved_value; -+ unsigned long flags; -+ int ret = 0; - -- /* The STIBP bit doesn't fault even if it's not advertised */ -- if (!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL) && -- !guest_cpuid_has(vcpu, X86_FEATURE_AMD_IBRS)) -- bits &= ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP); -- if (!boot_cpu_has(X86_FEATURE_SPEC_CTRL) && -- !boot_cpu_has(X86_FEATURE_AMD_IBRS)) -- bits &= ~(SPEC_CTRL_IBRS | SPEC_CTRL_STIBP); -+ local_irq_save(flags); - -- if (!guest_cpuid_has(vcpu, X86_FEATURE_SPEC_CTRL_SSBD) && -- !guest_cpuid_has(vcpu, X86_FEATURE_AMD_SSBD)) -- bits &= ~SPEC_CTRL_SSBD; -- if (!boot_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) && -- !boot_cpu_has(X86_FEATURE_AMD_SSBD)) -- bits &= ~SPEC_CTRL_SSBD; -+ if (rdmsrl_safe(MSR_IA32_SPEC_CTRL, &saved_value)) -+ ret = 1; -+ else if (wrmsrl_safe(MSR_IA32_SPEC_CTRL, value)) -+ ret = 1; -+ else -+ wrmsrl(MSR_IA32_SPEC_CTRL, saved_value); - -- return bits; -+ local_irq_restore(flags); -+ -+ return ret; - } --EXPORT_SYMBOL_GPL(kvm_spec_ctrl_valid_bits); -+EXPORT_SYMBOL_GPL(kvm_spec_ctrl_test_value); - - EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit); - EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_fast_mmio); -diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h -index 301286d924320..c520d373790a2 100644 ---- a/arch/x86/kvm/x86.h -+++ b/arch/x86/kvm/x86.h -@@ -368,6 +368,6 @@ static inline bool kvm_pat_valid(u64 data) - - void kvm_load_guest_xcr0(struct kvm_vcpu *vcpu); - void kvm_put_guest_xcr0(struct kvm_vcpu *vcpu); --u64 kvm_spec_ctrl_valid_bits(struct kvm_vcpu *vcpu); -+int kvm_spec_ctrl_test_value(u64 value); - - #endif -diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c -index d9fbd4f699202..35b2e35c22035 100644 ---- a/arch/x86/mm/pat.c -+++ b/arch/x86/mm/pat.c -@@ -1132,12 +1132,14 @@ static void *memtype_seq_start(struct seq_file *seq, loff_t *pos) - - static void *memtype_seq_next(struct seq_file *seq, void *v, loff_t *pos) - { -+ kfree(v); - ++*pos; - return memtype_get_idx(*pos); - } - - static void memtype_seq_stop(struct seq_file *seq, void *v) - { -+ kfree(v); - } - - static int memtype_seq_show(struct seq_file *seq, void *v) -@@ -1146,7 +1148,6 @@ static int memtype_seq_show(struct seq_file *seq, void *v) - - seq_printf(seq, "%s @ 0x%Lx-0x%Lx\n", cattr_name(print_entry->type), - print_entry->start, print_entry->end); -- kfree(print_entry); - - return 0; - } -diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c -index ba32adaeefdd0..c19006d59b791 100644 ---- a/block/bfq-iosched.c -+++ b/block/bfq-iosched.c -@@ -2937,6 +2937,7 @@ static void __bfq_set_in_service_queue(struct bfq_data *bfqd, - } - - bfqd->in_service_queue = bfqq; -+ bfqd->in_serv_last_pos = 0; - } - - /* -diff --git a/block/blk-settings.c b/block/blk-settings.c -index be1dca0103a45..13be635300a85 100644 ---- a/block/blk-settings.c -+++ b/block/blk-settings.c -@@ -473,6 +473,14 @@ void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b) - } - EXPORT_SYMBOL(blk_queue_stack_limits); - -+static unsigned int blk_round_down_sectors(unsigned int sectors, unsigned int lbs) -+{ -+ sectors = round_down(sectors, lbs >> SECTOR_SHIFT); -+ if (sectors < PAGE_SIZE >> SECTOR_SHIFT) -+ sectors = PAGE_SIZE >> SECTOR_SHIFT; -+ return sectors; -+} -+ - /** - * blk_stack_limits - adjust queue_limits for stacked devices - * @t: the stacking driver limits (top device) -@@ -586,6 +594,10 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, - ret = -1; - } - -+ t->max_sectors = blk_round_down_sectors(t->max_sectors, t->logical_block_size); -+ t->max_hw_sectors = blk_round_down_sectors(t->max_hw_sectors, t->logical_block_size); -+ t->max_dev_sectors = blk_round_down_sectors(t->max_dev_sectors, t->logical_block_size); -+ - /* Discard alignment and granularity */ - if (b->discard_granularity) { - alignment = queue_limit_discard_alignment(b, start); -diff --git a/block/bsg.c b/block/bsg.c -index 833c44b3d458e..0d012efef5274 100644 ---- a/block/bsg.c -+++ b/block/bsg.c -@@ -157,8 +157,10 @@ static int bsg_sg_io(struct request_queue *q, fmode_t mode, void __user *uarg) - return PTR_ERR(rq); - - ret = q->bsg_dev.ops->fill_hdr(rq, &hdr, mode); -- if (ret) -+ if (ret) { -+ blk_put_request(rq); - return ret; -+ } - - rq->timeout = msecs_to_jiffies(hdr.timeout); - if (!rq->timeout) -diff --git a/certs/blacklist.c b/certs/blacklist.c -index ec00bf337eb67..025a41de28fda 100644 ---- a/certs/blacklist.c -+++ b/certs/blacklist.c -@@ -153,7 +153,7 @@ static int __init blacklist_init(void) - KEY_USR_VIEW | KEY_USR_READ | - KEY_USR_SEARCH, - KEY_ALLOC_NOT_IN_QUOTA | -- KEY_FLAG_KEEP, -+ KEY_ALLOC_SET_KEEP, - NULL, NULL); - if (IS_ERR(blacklist_keyring)) - panic("Can't allocate system blacklist keyring\n"); -diff --git a/crypto/ecdh_helper.c b/crypto/ecdh_helper.c -index 66fcb2ea81544..fca63b559f655 100644 ---- a/crypto/ecdh_helper.c -+++ b/crypto/ecdh_helper.c -@@ -67,6 +67,9 @@ int crypto_ecdh_decode_key(const char *buf, unsigned int len, - if (secret.type != CRYPTO_KPP_SECRET_TYPE_ECDH) - return -EINVAL; - -+ if (unlikely(len < secret.len)) -+ return -EINVAL; -+ - ptr = ecdh_unpack_data(¶ms->curve_id, ptr, sizeof(params->curve_id)); - ptr = ecdh_unpack_data(¶ms->key_size, ptr, sizeof(params->key_size)); - if (secret.len != crypto_ecdh_key_len(params)) -diff --git a/drivers/acpi/acpi_configfs.c b/drivers/acpi/acpi_configfs.c -index 01738d8e888e3..06c756651425e 100644 ---- a/drivers/acpi/acpi_configfs.c -+++ b/drivers/acpi/acpi_configfs.c -@@ -267,7 +267,12 @@ static int __init acpi_configfs_init(void) - - acpi_table_group = configfs_register_default_group(root, "table", - &acpi_tables_type); -- return PTR_ERR_OR_ZERO(acpi_table_group); -+ if (IS_ERR(acpi_table_group)) { -+ configfs_unregister_subsystem(&acpi_configfs); -+ return PTR_ERR(acpi_table_group); -+ } -+ -+ return 0; - } - module_init(acpi_configfs_init); - -diff --git a/drivers/acpi/property.c b/drivers/acpi/property.c -index 3eacf474e1e39..a08e3eb2a6f9f 100644 ---- a/drivers/acpi/property.c -+++ b/drivers/acpi/property.c -@@ -794,9 +794,6 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, - const union acpi_object *obj; - int ret; - -- if (!val) -- return -EINVAL; -- - if (proptype >= DEV_PROP_U8 && proptype <= DEV_PROP_U64) { - ret = acpi_data_get_property(data, propname, ACPI_TYPE_INTEGER, &obj); - if (ret) -@@ -806,28 +803,43 @@ static int acpi_data_prop_read_single(const struct acpi_device_data *data, - case DEV_PROP_U8: - if (obj->integer.value > U8_MAX) - return -EOVERFLOW; -- *(u8 *)val = obj->integer.value; -+ -+ if (val) -+ *(u8 *)val = obj->integer.value; -+ - break; - case DEV_PROP_U16: - if (obj->integer.value > U16_MAX) - return -EOVERFLOW; -- *(u16 *)val = obj->integer.value; -+ -+ if (val) -+ *(u16 *)val = obj->integer.value; -+ - break; - case DEV_PROP_U32: - if (obj->integer.value > U32_MAX) - return -EOVERFLOW; -- *(u32 *)val = obj->integer.value; -+ -+ if (val) -+ *(u32 *)val = obj->integer.value; -+ - break; - default: -- *(u64 *)val = obj->integer.value; -+ if (val) -+ *(u64 *)val = obj->integer.value; -+ - break; - } -+ -+ if (!val) -+ return 1; - } else if (proptype == DEV_PROP_STRING) { - ret = acpi_data_get_property(data, propname, ACPI_TYPE_STRING, &obj); - if (ret) - return ret; - -- *(char **)val = obj->string.pointer; -+ if (val) -+ *(char **)val = obj->string.pointer; - - return 1; - } else { -@@ -841,7 +853,7 @@ int acpi_dev_prop_read_single(struct acpi_device *adev, const char *propname, - { - int ret; - -- if (!adev) -+ if (!adev || !val) - return -EINVAL; - - ret = acpi_data_prop_read_single(&adev->data, propname, proptype, val); -@@ -935,10 +947,20 @@ static int acpi_data_prop_read(const struct acpi_device_data *data, - const union acpi_object *items; - int ret; - -- if (val && nval == 1) { -+ if (nval == 1 || !val) { - ret = acpi_data_prop_read_single(data, propname, proptype, val); -- if (ret >= 0) -+ /* -+ * The overflow error means that the property is there and it is -+ * single-value, but its type does not match, so return. -+ */ -+ if (ret >= 0 || ret == -EOVERFLOW) - return ret; -+ -+ /* -+ * Reading this property as a single-value one failed, but its -+ * value may still be represented as one-element array, so -+ * continue. -+ */ - } - - ret = acpi_data_get_property_array(data, propname, ACPI_TYPE_ANY, &obj); -diff --git a/drivers/amba/bus.c b/drivers/amba/bus.c -index fe1523664816a..af58768a03937 100644 ---- a/drivers/amba/bus.c -+++ b/drivers/amba/bus.c -@@ -299,10 +299,11 @@ static int amba_remove(struct device *dev) - { - struct amba_device *pcdev = to_amba_device(dev); - struct amba_driver *drv = to_amba_driver(dev->driver); -- int ret; -+ int ret = 0; - - pm_runtime_get_sync(dev); -- ret = drv->remove(pcdev); -+ if (drv->remove) -+ ret = drv->remove(pcdev); - pm_runtime_put_noidle(dev); - - /* Undo the runtime PM settings in amba_probe() */ -@@ -319,7 +320,9 @@ static int amba_remove(struct device *dev) - static void amba_shutdown(struct device *dev) - { - struct amba_driver *drv = to_amba_driver(dev->driver); -- drv->shutdown(to_amba_device(dev)); -+ -+ if (drv->shutdown) -+ drv->shutdown(to_amba_device(dev)); - } - - /** -@@ -332,12 +335,13 @@ static void amba_shutdown(struct device *dev) - */ - int amba_driver_register(struct amba_driver *drv) - { -- drv->drv.bus = &amba_bustype; -+ if (!drv->probe) -+ return -EINVAL; - --#define SETFN(fn) if (drv->fn) drv->drv.fn = amba_##fn -- SETFN(probe); -- SETFN(remove); -- SETFN(shutdown); -+ drv->drv.bus = &amba_bustype; -+ drv->drv.probe = amba_probe; -+ drv->drv.remove = amba_remove; -+ drv->drv.shutdown = amba_shutdown; - - return driver_register(&drv->drv); - } -diff --git a/drivers/ata/ahci_brcm.c b/drivers/ata/ahci_brcm.c -index 66a570d0da837..067b55cc157ef 100644 ---- a/drivers/ata/ahci_brcm.c -+++ b/drivers/ata/ahci_brcm.c -@@ -361,6 +361,10 @@ static int brcm_ahci_resume(struct device *dev) - if (ret) - return ret; - -+ ret = ahci_platform_enable_regulators(hpriv); -+ if (ret) -+ goto out_disable_clks; -+ - brcm_sata_init(priv); - brcm_sata_phys_enable(priv); - brcm_sata_alpm_init(hpriv); -@@ -390,6 +394,8 @@ out_disable_platform_phys: - ahci_platform_disable_phys(hpriv); - out_disable_phys: - brcm_sata_phys_disable(priv); -+ ahci_platform_disable_regulators(hpriv); -+out_disable_clks: - ahci_platform_disable_clks(hpriv); - return ret; - } -@@ -463,6 +469,10 @@ static int brcm_ahci_probe(struct platform_device *pdev) - if (ret) - goto out_reset; - -+ ret = ahci_platform_enable_regulators(hpriv); -+ if (ret) -+ goto out_disable_clks; -+ - /* Must be first so as to configure endianness including that - * of the standard AHCI register space. - */ -@@ -472,7 +482,7 @@ static int brcm_ahci_probe(struct platform_device *pdev) - priv->port_mask = brcm_ahci_get_portmask(hpriv, priv); - if (!priv->port_mask) { - ret = -ENODEV; -- goto out_disable_clks; -+ goto out_disable_regulators; - } - - /* Must be done before ahci_platform_enable_phys() */ -@@ -497,6 +507,8 @@ out_disable_platform_phys: - ahci_platform_disable_phys(hpriv); - out_disable_phys: - brcm_sata_phys_disable(priv); -+out_disable_regulators: -+ ahci_platform_disable_regulators(hpriv); - out_disable_clks: - ahci_platform_disable_clks(hpriv); - out_reset: -diff --git a/drivers/auxdisplay/ht16k33.c b/drivers/auxdisplay/ht16k33.c -index a2fcde582e2a1..33b887b389061 100644 ---- a/drivers/auxdisplay/ht16k33.c -+++ b/drivers/auxdisplay/ht16k33.c -@@ -117,8 +117,7 @@ static void ht16k33_fb_queue(struct ht16k33_priv *priv) - { - struct ht16k33_fbdev *fbdev = &priv->fbdev; - -- schedule_delayed_work(&fbdev->work, -- msecs_to_jiffies(HZ / fbdev->refresh_rate)); -+ schedule_delayed_work(&fbdev->work, HZ / fbdev->refresh_rate); - } - - /* -diff --git a/drivers/base/regmap/regmap-sdw.c b/drivers/base/regmap/regmap-sdw.c -index 50a66382d87d0..e75168b941d0c 100644 ---- a/drivers/base/regmap/regmap-sdw.c -+++ b/drivers/base/regmap/regmap-sdw.c -@@ -12,7 +12,7 @@ static int regmap_sdw_write(void *context, unsigned int reg, unsigned int val) - struct device *dev = context; - struct sdw_slave *slave = dev_to_sdw_dev(dev); - -- return sdw_write(slave, reg, val); -+ return sdw_write_no_pm(slave, reg, val); - } - - static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val) -@@ -21,7 +21,7 @@ static int regmap_sdw_read(void *context, unsigned int reg, unsigned int *val) - struct sdw_slave *slave = dev_to_sdw_dev(dev); - int read; - -- read = sdw_read(slave, reg); -+ read = sdw_read_no_pm(slave, reg); - if (read < 0) - return read; - -diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c -index 77cc138d138cd..7d5236eafe845 100644 ---- a/drivers/base/swnode.c -+++ b/drivers/base/swnode.c -@@ -534,14 +534,18 @@ software_node_get_next_child(const struct fwnode_handle *fwnode, - struct swnode *c = to_swnode(child); - - if (!p || list_empty(&p->children) || -- (c && list_is_last(&c->entry, &p->children))) -+ (c && list_is_last(&c->entry, &p->children))) { -+ fwnode_handle_put(child); - return NULL; -+ } - - if (c) - c = list_next_entry(c, entry); - else - c = list_first_entry(&p->children, struct swnode, entry); -- return &c->fwnode; -+ -+ fwnode_handle_put(child); -+ return fwnode_handle_get(&c->fwnode); - } - - static struct fwnode_handle * -diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c -index ac97a1e2e5ddc..40ea1a425c431 100644 ---- a/drivers/block/floppy.c -+++ b/drivers/block/floppy.c -@@ -4063,21 +4063,22 @@ static int floppy_open(struct block_device *bdev, fmode_t mode) - if (UFDCS->rawcmd == 1) - UFDCS->rawcmd = 2; - -- if (!(mode & FMODE_NDELAY)) { -- if (mode & (FMODE_READ|FMODE_WRITE)) { -- UDRS->last_checked = 0; -- clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); -- check_disk_change(bdev); -- if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) -- goto out; -- if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) -- goto out; -- } -- res = -EROFS; -- if ((mode & FMODE_WRITE) && -- !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) -+ if (mode & (FMODE_READ|FMODE_WRITE)) { -+ UDRS->last_checked = 0; -+ clear_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags); -+ check_disk_change(bdev); -+ if (test_bit(FD_DISK_CHANGED_BIT, &UDRS->flags)) -+ goto out; -+ if (test_bit(FD_OPEN_SHOULD_FAIL_BIT, &UDRS->flags)) - goto out; - } -+ -+ res = -EROFS; -+ -+ if ((mode & FMODE_WRITE) && -+ !test_bit(FD_DISK_WRITABLE_BIT, &UDRS->flags)) -+ goto out; -+ - mutex_unlock(&open_lock); - mutex_unlock(&floppy_mutex); - return 0; -diff --git a/drivers/bluetooth/btqcomsmd.c b/drivers/bluetooth/btqcomsmd.c -index 98d53764871f5..2acb719e596f5 100644 ---- a/drivers/bluetooth/btqcomsmd.c -+++ b/drivers/bluetooth/btqcomsmd.c -@@ -142,12 +142,16 @@ static int btqcomsmd_probe(struct platform_device *pdev) - - btq->cmd_channel = qcom_wcnss_open_channel(wcnss, "APPS_RIVA_BT_CMD", - btqcomsmd_cmd_callback, btq); -- if (IS_ERR(btq->cmd_channel)) -- return PTR_ERR(btq->cmd_channel); -+ if (IS_ERR(btq->cmd_channel)) { -+ ret = PTR_ERR(btq->cmd_channel); -+ goto destroy_acl_channel; -+ } - - hdev = hci_alloc_dev(); -- if (!hdev) -- return -ENOMEM; -+ if (!hdev) { -+ ret = -ENOMEM; -+ goto destroy_cmd_channel; -+ } - - hci_set_drvdata(hdev, btq); - btq->hdev = hdev; -@@ -161,14 +165,21 @@ static int btqcomsmd_probe(struct platform_device *pdev) - hdev->set_bdaddr = qca_set_bdaddr_rome; - - ret = hci_register_dev(hdev); -- if (ret < 0) { -- hci_free_dev(hdev); -- return ret; -- } -+ if (ret < 0) -+ goto hci_free_dev; - - platform_set_drvdata(pdev, btq); - - return 0; -+ -+hci_free_dev: -+ hci_free_dev(hdev); -+destroy_cmd_channel: -+ rpmsg_destroy_ept(btq->cmd_channel); -+destroy_acl_channel: -+ rpmsg_destroy_ept(btq->acl_channel); -+ -+ return ret; - } - - static int btqcomsmd_remove(struct platform_device *pdev) -diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c -index b92bd97b1c399..b467fd05c5e82 100644 ---- a/drivers/bluetooth/btusb.c -+++ b/drivers/bluetooth/btusb.c -@@ -2568,7 +2568,7 @@ static void btusb_mtk_wmt_recv(struct urb *urb) - skb = bt_skb_alloc(HCI_WMT_MAX_EVENT_SIZE, GFP_ATOMIC); - if (!skb) { - hdev->stat.err_rx++; -- goto err_out; -+ return; - } - - hci_skb_pkt_type(skb) = HCI_EVENT_PKT; -@@ -2586,13 +2586,18 @@ static void btusb_mtk_wmt_recv(struct urb *urb) - */ - if (test_bit(BTUSB_TX_WAIT_VND_EVT, &data->flags)) { - data->evt_skb = skb_clone(skb, GFP_ATOMIC); -- if (!data->evt_skb) -- goto err_out; -+ if (!data->evt_skb) { -+ kfree_skb(skb); -+ return; -+ } - } - - err = hci_recv_frame(hdev, skb); -- if (err < 0) -- goto err_free_skb; -+ if (err < 0) { -+ kfree_skb(data->evt_skb); -+ data->evt_skb = NULL; -+ return; -+ } - - if (test_and_clear_bit(BTUSB_TX_WAIT_VND_EVT, - &data->flags)) { -@@ -2601,11 +2606,6 @@ static void btusb_mtk_wmt_recv(struct urb *urb) - wake_up_bit(&data->flags, - BTUSB_TX_WAIT_VND_EVT); - } --err_out: -- return; --err_free_skb: -- kfree_skb(data->evt_skb); -- data->evt_skb = NULL; - return; - } else if (urb->status == -ENOENT) { - /* Avoid suspend failed when usb_kill_urb */ -diff --git a/drivers/bluetooth/hci_ldisc.c b/drivers/bluetooth/hci_ldisc.c -index f83d67eafc9f0..8be4d807d1370 100644 ---- a/drivers/bluetooth/hci_ldisc.c -+++ b/drivers/bluetooth/hci_ldisc.c -@@ -127,10 +127,9 @@ int hci_uart_tx_wakeup(struct hci_uart *hu) - if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) - goto no_schedule; - -- if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) { -- set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); -+ set_bit(HCI_UART_TX_WAKEUP, &hu->tx_state); -+ if (test_and_set_bit(HCI_UART_SENDING, &hu->tx_state)) - goto no_schedule; -- } - - BT_DBG(""); - -@@ -174,10 +173,10 @@ restart: - kfree_skb(skb); - } - -+ clear_bit(HCI_UART_SENDING, &hu->tx_state); - if (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)) - goto restart; - -- clear_bit(HCI_UART_SENDING, &hu->tx_state); - wake_up_bit(&hu->tx_state, HCI_UART_SENDING); - } - -diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c -index 5b9aa73ff2b7f..1b4ad231e6ed3 100644 ---- a/drivers/bluetooth/hci_serdev.c -+++ b/drivers/bluetooth/hci_serdev.c -@@ -85,9 +85,9 @@ static void hci_uart_write_work(struct work_struct *work) - hci_uart_tx_complete(hu, hci_skb_pkt_type(skb)); - kfree_skb(skb); - } -- } while (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)); - -- clear_bit(HCI_UART_SENDING, &hu->tx_state); -+ clear_bit(HCI_UART_SENDING, &hu->tx_state); -+ } while (test_bit(HCI_UART_TX_WAKEUP, &hu->tx_state)); - } - - /* ------- Interface to HCI layer ------ */ -diff --git a/drivers/char/hw_random/timeriomem-rng.c b/drivers/char/hw_random/timeriomem-rng.c -index e262445fed5f5..f35f0f31f52ad 100644 ---- a/drivers/char/hw_random/timeriomem-rng.c -+++ b/drivers/char/hw_random/timeriomem-rng.c -@@ -69,7 +69,7 @@ static int timeriomem_rng_read(struct hwrng *hwrng, void *data, - */ - if (retval > 0) - usleep_range(period_us, -- period_us + min(1, period_us / 100)); -+ period_us + max(1, period_us / 100)); - - *(u32 *)data = readl(priv->io_base); - retval += sizeof(u32); -diff --git a/drivers/char/random.c b/drivers/char/random.c -index 2c29f83ae3d5a..ffd61aadb7614 100644 ---- a/drivers/char/random.c -+++ b/drivers/char/random.c -@@ -2149,7 +2149,7 @@ static long random_ioctl(struct file *f, unsigned int cmd, unsigned long arg) - return -EPERM; - if (crng_init < 2) - return -ENODATA; -- crng_reseed(&primary_crng, NULL); -+ crng_reseed(&primary_crng, &input_pool); - crng_global_init_time = jiffies - 1; - return 0; - default: -diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c -index 63f6bed78d893..46d1fac247db7 100644 ---- a/drivers/char/tpm/tpm_tis_core.c -+++ b/drivers/char/tpm/tpm_tis_core.c -@@ -125,7 +125,8 @@ static bool check_locality(struct tpm_chip *chip, int l) - if (rc < 0) - return false; - -- if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) == -+ if ((access & (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID -+ | TPM_ACCESS_REQUEST_USE)) == - (TPM_ACCESS_ACTIVE_LOCALITY | TPM_ACCESS_VALID)) { - priv->locality = l; - return true; -@@ -134,58 +135,13 @@ static bool check_locality(struct tpm_chip *chip, int l) - return false; - } - --static bool locality_inactive(struct tpm_chip *chip, int l) --{ -- struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); -- int rc; -- u8 access; -- -- rc = tpm_tis_read8(priv, TPM_ACCESS(l), &access); -- if (rc < 0) -- return false; -- -- if ((access & (TPM_ACCESS_VALID | TPM_ACCESS_ACTIVE_LOCALITY)) -- == TPM_ACCESS_VALID) -- return true; -- -- return false; --} -- - static int release_locality(struct tpm_chip *chip, int l) - { - struct tpm_tis_data *priv = dev_get_drvdata(&chip->dev); -- unsigned long stop, timeout; -- long rc; - - tpm_tis_write8(priv, TPM_ACCESS(l), TPM_ACCESS_ACTIVE_LOCALITY); - -- stop = jiffies + chip->timeout_a; -- -- if (chip->flags & TPM_CHIP_FLAG_IRQ) { --again: -- timeout = stop - jiffies; -- if ((long)timeout <= 0) -- return -1; -- -- rc = wait_event_interruptible_timeout(priv->int_queue, -- (locality_inactive(chip, l)), -- timeout); -- -- if (rc > 0) -- return 0; -- -- if (rc == -ERESTARTSYS && freezing(current)) { -- clear_thread_flag(TIF_SIGPENDING); -- goto again; -- } -- } else { -- do { -- if (locality_inactive(chip, l)) -- return 0; -- tpm_msleep(TPM_TIMEOUT); -- } while (time_before(jiffies, stop)); -- } -- return -1; -+ return 0; - } - - static int request_locality(struct tpm_chip *chip, int l) -diff --git a/drivers/clk/clk-ast2600.c b/drivers/clk/clk-ast2600.c -index 7015974f24b43..84ca38450d021 100644 ---- a/drivers/clk/clk-ast2600.c -+++ b/drivers/clk/clk-ast2600.c -@@ -17,7 +17,8 @@ - - #define ASPEED_G6_NUM_CLKS 67 - --#define ASPEED_G6_SILICON_REV 0x004 -+#define ASPEED_G6_SILICON_REV 0x014 -+#define CHIP_REVISION_ID GENMASK(23, 16) - - #define ASPEED_G6_RESET_CTRL 0x040 - #define ASPEED_G6_RESET_CTRL2 0x050 -@@ -189,18 +190,34 @@ static struct clk_hw *ast2600_calc_pll(const char *name, u32 val) - static struct clk_hw *ast2600_calc_apll(const char *name, u32 val) - { - unsigned int mult, div; -+ u32 chip_id = readl(scu_g6_base + ASPEED_G6_SILICON_REV); - -- if (val & BIT(20)) { -- /* Pass through mode */ -- mult = div = 1; -+ if (((chip_id & CHIP_REVISION_ID) >> 16) >= 2) { -+ if (val & BIT(24)) { -+ /* Pass through mode */ -+ mult = div = 1; -+ } else { -+ /* F = 25Mhz * [(m + 1) / (n + 1)] / (p + 1) */ -+ u32 m = val & 0x1fff; -+ u32 n = (val >> 13) & 0x3f; -+ u32 p = (val >> 19) & 0xf; -+ -+ mult = (m + 1); -+ div = (n + 1) * (p + 1); -+ } - } else { -- /* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -- u32 m = (val >> 5) & 0x3f; -- u32 od = (val >> 4) & 0x1; -- u32 n = val & 0xf; -+ if (val & BIT(20)) { -+ /* Pass through mode */ -+ mult = div = 1; -+ } else { -+ /* F = 25Mhz * (2-od) * [(m + 2) / (n + 1)] */ -+ u32 m = (val >> 5) & 0x3f; -+ u32 od = (val >> 4) & 0x1; -+ u32 n = val & 0xf; - -- mult = (2 - od) * (m + 2); -- div = n + 1; -+ mult = (2 - od) * (m + 2); -+ div = n + 1; -+ } - } - return clk_hw_register_fixed_factor(NULL, name, "clkin", 0, - mult, div); -diff --git a/drivers/clk/meson/clk-pll.c b/drivers/clk/meson/clk-pll.c -index 3a5853ca98c6c..e8df254f8085b 100644 ---- a/drivers/clk/meson/clk-pll.c -+++ b/drivers/clk/meson/clk-pll.c -@@ -363,13 +363,14 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, - { - struct clk_regmap *clk = to_clk_regmap(hw); - struct meson_clk_pll_data *pll = meson_clk_pll_data(clk); -- unsigned int enabled, m, n, frac = 0, ret; -+ unsigned int enabled, m, n, frac = 0; - unsigned long old_rate; -+ int ret; - - if (parent_rate == 0 || rate == 0) - return -EINVAL; - -- old_rate = rate; -+ old_rate = clk_hw_get_rate(hw); - - ret = meson_clk_get_pll_settings(rate, parent_rate, &m, &n, pll); - if (ret) -@@ -391,7 +392,8 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, - if (!enabled) - return 0; - -- if (meson_clk_pll_enable(hw)) { -+ ret = meson_clk_pll_enable(hw); -+ if (ret) { - pr_warn("%s: pll did not lock, trying to restore old rate %lu\n", - __func__, old_rate); - /* -@@ -403,7 +405,7 @@ static int meson_clk_pll_set_rate(struct clk_hw *hw, unsigned long rate, - meson_clk_pll_set_rate(hw, old_rate, parent_rate); - } - -- return 0; -+ return ret; - } - - /* -diff --git a/drivers/clk/qcom/gcc-msm8998.c b/drivers/clk/qcom/gcc-msm8998.c -index 091acd59c1d64..752f267b2881a 100644 ---- a/drivers/clk/qcom/gcc-msm8998.c -+++ b/drivers/clk/qcom/gcc-msm8998.c -@@ -135,7 +135,7 @@ static struct pll_vco fabia_vco[] = { - - static struct clk_alpha_pll gpll0 = { - .offset = 0x0, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .vco_table = fabia_vco, - .num_vco = ARRAY_SIZE(fabia_vco), - .clkr = { -@@ -145,58 +145,58 @@ static struct clk_alpha_pll gpll0 = { - .name = "gpll0", - .parent_names = (const char *[]){ "xo" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_ops, -+ .ops = &clk_alpha_pll_fixed_fabia_ops, - } - }, - }; - - static struct clk_alpha_pll_postdiv gpll0_out_even = { - .offset = 0x0, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll0_out_even", - .parent_names = (const char *[]){ "gpll0" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll0_out_main = { - .offset = 0x0, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll0_out_main", - .parent_names = (const char *[]){ "gpll0" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll0_out_odd = { - .offset = 0x0, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll0_out_odd", - .parent_names = (const char *[]){ "gpll0" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll0_out_test = { - .offset = 0x0, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll0_out_test", - .parent_names = (const char *[]){ "gpll0" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll gpll1 = { - .offset = 0x1000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .vco_table = fabia_vco, - .num_vco = ARRAY_SIZE(fabia_vco), - .clkr = { -@@ -206,58 +206,58 @@ static struct clk_alpha_pll gpll1 = { - .name = "gpll1", - .parent_names = (const char *[]){ "xo" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_ops, -+ .ops = &clk_alpha_pll_fixed_fabia_ops, - } - }, - }; - - static struct clk_alpha_pll_postdiv gpll1_out_even = { - .offset = 0x1000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll1_out_even", - .parent_names = (const char *[]){ "gpll1" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll1_out_main = { - .offset = 0x1000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll1_out_main", - .parent_names = (const char *[]){ "gpll1" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll1_out_odd = { - .offset = 0x1000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll1_out_odd", - .parent_names = (const char *[]){ "gpll1" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll1_out_test = { - .offset = 0x1000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll1_out_test", - .parent_names = (const char *[]){ "gpll1" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll gpll2 = { - .offset = 0x2000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .vco_table = fabia_vco, - .num_vco = ARRAY_SIZE(fabia_vco), - .clkr = { -@@ -267,58 +267,58 @@ static struct clk_alpha_pll gpll2 = { - .name = "gpll2", - .parent_names = (const char *[]){ "xo" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_ops, -+ .ops = &clk_alpha_pll_fixed_fabia_ops, - } - }, - }; - - static struct clk_alpha_pll_postdiv gpll2_out_even = { - .offset = 0x2000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll2_out_even", - .parent_names = (const char *[]){ "gpll2" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll2_out_main = { - .offset = 0x2000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll2_out_main", - .parent_names = (const char *[]){ "gpll2" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll2_out_odd = { - .offset = 0x2000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll2_out_odd", - .parent_names = (const char *[]){ "gpll2" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll2_out_test = { - .offset = 0x2000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll2_out_test", - .parent_names = (const char *[]){ "gpll2" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll gpll3 = { - .offset = 0x3000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .vco_table = fabia_vco, - .num_vco = ARRAY_SIZE(fabia_vco), - .clkr = { -@@ -328,58 +328,58 @@ static struct clk_alpha_pll gpll3 = { - .name = "gpll3", - .parent_names = (const char *[]){ "xo" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_ops, -+ .ops = &clk_alpha_pll_fixed_fabia_ops, - } - }, - }; - - static struct clk_alpha_pll_postdiv gpll3_out_even = { - .offset = 0x3000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll3_out_even", - .parent_names = (const char *[]){ "gpll3" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll3_out_main = { - .offset = 0x3000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll3_out_main", - .parent_names = (const char *[]){ "gpll3" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll3_out_odd = { - .offset = 0x3000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll3_out_odd", - .parent_names = (const char *[]){ "gpll3" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll3_out_test = { - .offset = 0x3000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll3_out_test", - .parent_names = (const char *[]){ "gpll3" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll gpll4 = { - .offset = 0x77000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .vco_table = fabia_vco, - .num_vco = ARRAY_SIZE(fabia_vco), - .clkr = { -@@ -389,52 +389,52 @@ static struct clk_alpha_pll gpll4 = { - .name = "gpll4", - .parent_names = (const char *[]){ "xo" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_ops, -+ .ops = &clk_alpha_pll_fixed_fabia_ops, - } - }, - }; - - static struct clk_alpha_pll_postdiv gpll4_out_even = { - .offset = 0x77000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll4_out_even", - .parent_names = (const char *[]){ "gpll4" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll4_out_main = { - .offset = 0x77000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll4_out_main", - .parent_names = (const char *[]){ "gpll4" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll4_out_odd = { - .offset = 0x77000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll4_out_odd", - .parent_names = (const char *[]){ "gpll4" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - - static struct clk_alpha_pll_postdiv gpll4_out_test = { - .offset = 0x77000, -- .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_DEFAULT], -+ .regs = clk_alpha_pll_regs[CLK_ALPHA_PLL_TYPE_FABIA], - .clkr.hw.init = &(struct clk_init_data){ - .name = "gpll4_out_test", - .parent_names = (const char *[]){ "gpll4" }, - .num_parents = 1, -- .ops = &clk_alpha_pll_postdiv_ops, -+ .ops = &clk_alpha_pll_postdiv_fabia_ops, - }, - }; - -diff --git a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c -index d89353a3cdec7..2f00f1b7b9c00 100644 ---- a/drivers/clk/sunxi-ng/ccu-sun50i-h6.c -+++ b/drivers/clk/sunxi-ng/ccu-sun50i-h6.c -@@ -228,7 +228,7 @@ static const char * const psi_ahb1_ahb2_parents[] = { "osc24M", "osc32k", - static SUNXI_CCU_MP_WITH_MUX(psi_ahb1_ahb2_clk, "psi-ahb1-ahb2", - psi_ahb1_ahb2_parents, - 0x510, -- 0, 5, /* M */ -+ 0, 2, /* M */ - 8, 2, /* P */ - 24, 2, /* mux */ - 0); -@@ -237,19 +237,19 @@ static const char * const ahb3_apb1_apb2_parents[] = { "osc24M", "osc32k", - "psi-ahb1-ahb2", - "pll-periph0" }; - static SUNXI_CCU_MP_WITH_MUX(ahb3_clk, "ahb3", ahb3_apb1_apb2_parents, 0x51c, -- 0, 5, /* M */ -+ 0, 2, /* M */ - 8, 2, /* P */ - 24, 2, /* mux */ - 0); - - static SUNXI_CCU_MP_WITH_MUX(apb1_clk, "apb1", ahb3_apb1_apb2_parents, 0x520, -- 0, 5, /* M */ -+ 0, 2, /* M */ - 8, 2, /* P */ - 24, 2, /* mux */ - 0); - - static SUNXI_CCU_MP_WITH_MUX(apb2_clk, "apb2", ahb3_apb1_apb2_parents, 0x524, -- 0, 5, /* M */ -+ 0, 2, /* M */ - 8, 2, /* P */ - 24, 2, /* mux */ - 0); -@@ -673,7 +673,7 @@ static struct ccu_mux hdmi_cec_clk = { - - .common = { - .reg = 0xb10, -- .features = CCU_FEATURE_VARIABLE_PREDIV, -+ .features = CCU_FEATURE_FIXED_PREDIV, - .hw.init = CLK_HW_INIT_PARENTS("hdmi-cec", - hdmi_cec_parents, - &ccu_mux_ops, -diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig -index f35a53ce8988a..3bb5625504e2f 100644 ---- a/drivers/clocksource/Kconfig -+++ b/drivers/clocksource/Kconfig -@@ -79,6 +79,7 @@ config IXP4XX_TIMER - bool "Intel XScale IXP4xx timer driver" if COMPILE_TEST - depends on HAS_IOMEM - select CLKSRC_MMIO -+ select TIMER_OF if OF - help - Enables support for the Intel XScale IXP4xx SoC timer. - -diff --git a/drivers/clocksource/mxs_timer.c b/drivers/clocksource/mxs_timer.c -index f6ddae30933f7..dae8c0c2e606f 100644 ---- a/drivers/clocksource/mxs_timer.c -+++ b/drivers/clocksource/mxs_timer.c -@@ -138,10 +138,7 @@ static void mxs_irq_clear(char *state) - - /* Clear pending interrupt */ - timrot_irq_acknowledge(); -- --#ifdef DEBUG -- pr_info("%s: changing mode to %s\n", __func__, state) --#endif /* DEBUG */ -+ pr_debug("%s: changing mode to %s\n", __func__, state); - } - - static int mxs_shutdown(struct clock_event_device *evt) -diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c -index 77b0e5d0fb134..a3c82f530d608 100644 ---- a/drivers/cpufreq/brcmstb-avs-cpufreq.c -+++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c -@@ -566,6 +566,16 @@ unmap_base: - return ret; - } - -+static void brcm_avs_prepare_uninit(struct platform_device *pdev) -+{ -+ struct private_data *priv; -+ -+ priv = platform_get_drvdata(pdev); -+ -+ iounmap(priv->avs_intr_base); -+ iounmap(priv->base); -+} -+ - static int brcm_avs_cpufreq_init(struct cpufreq_policy *policy) - { - struct cpufreq_frequency_table *freq_table; -@@ -701,21 +711,21 @@ static int brcm_avs_cpufreq_probe(struct platform_device *pdev) - - brcm_avs_driver.driver_data = pdev; - -- return cpufreq_register_driver(&brcm_avs_driver); -+ ret = cpufreq_register_driver(&brcm_avs_driver); -+ if (ret) -+ brcm_avs_prepare_uninit(pdev); -+ -+ return ret; - } - - static int brcm_avs_cpufreq_remove(struct platform_device *pdev) - { -- struct private_data *priv; - int ret; - - ret = cpufreq_unregister_driver(&brcm_avs_driver); -- if (ret) -- return ret; -+ WARN_ON(ret); - -- priv = platform_get_drvdata(pdev); -- iounmap(priv->base); -- iounmap(priv->avs_intr_base); -+ brcm_avs_prepare_uninit(pdev); - - return 0; - } -diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c -index b9ca89dc75c7d..88fe803a044d5 100644 ---- a/drivers/cpufreq/intel_pstate.c -+++ b/drivers/cpufreq/intel_pstate.c -@@ -1566,11 +1566,9 @@ static void intel_pstate_max_within_limits(struct cpudata *cpu) - static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) - { - cpu->pstate.min_pstate = pstate_funcs.get_min(); -- cpu->pstate.max_pstate = pstate_funcs.get_max(); - cpu->pstate.max_pstate_physical = pstate_funcs.get_max_physical(); - cpu->pstate.turbo_pstate = pstate_funcs.get_turbo(); - cpu->pstate.scaling = pstate_funcs.get_scaling(); -- cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; - - if (hwp_active && !hwp_mode_bdw) { - unsigned int phy_max, current_max; -@@ -1578,9 +1576,12 @@ static void intel_pstate_get_cpu_pstates(struct cpudata *cpu) - intel_pstate_get_hwp_max(cpu->cpu, &phy_max, ¤t_max); - cpu->pstate.turbo_freq = phy_max * cpu->pstate.scaling; - cpu->pstate.turbo_pstate = phy_max; -+ cpu->pstate.max_pstate = HWP_GUARANTEED_PERF(READ_ONCE(cpu->hwp_cap_cached)); - } else { - cpu->pstate.turbo_freq = cpu->pstate.turbo_pstate * cpu->pstate.scaling; -+ cpu->pstate.max_pstate = pstate_funcs.get_max(); - } -+ cpu->pstate.max_freq = cpu->pstate.max_pstate * cpu->pstate.scaling; - - if (pstate_funcs.get_aperf_mperf_shift) - cpu->aperf_mperf_shift = pstate_funcs.get_aperf_mperf_shift(); -diff --git a/drivers/crypto/bcm/cipher.c b/drivers/crypto/bcm/cipher.c -index ec4b5033013eb..98b8483577ce2 100644 ---- a/drivers/crypto/bcm/cipher.c -+++ b/drivers/crypto/bcm/cipher.c -@@ -41,7 +41,7 @@ - - /* ================= Device Structure ================== */ - --struct device_private iproc_priv; -+struct bcm_device_private iproc_priv; - - /* ==================== Parameters ===================== */ - -diff --git a/drivers/crypto/bcm/cipher.h b/drivers/crypto/bcm/cipher.h -index 766452b24d0ab..01feed268a0d4 100644 ---- a/drivers/crypto/bcm/cipher.h -+++ b/drivers/crypto/bcm/cipher.h -@@ -418,7 +418,7 @@ struct spu_hw { - u32 num_chan; - }; - --struct device_private { -+struct bcm_device_private { - struct platform_device *pdev; - - struct spu_hw spu; -@@ -465,6 +465,6 @@ struct device_private { - struct mbox_chan **mbox; - }; - --extern struct device_private iproc_priv; -+extern struct bcm_device_private iproc_priv; - - #endif -diff --git a/drivers/crypto/bcm/util.c b/drivers/crypto/bcm/util.c -index cd7504101acde..7227dbf8f46c7 100644 ---- a/drivers/crypto/bcm/util.c -+++ b/drivers/crypto/bcm/util.c -@@ -348,7 +348,7 @@ char *spu_alg_name(enum spu_cipher_alg alg, enum spu_cipher_mode mode) - static ssize_t spu_debugfs_read(struct file *filp, char __user *ubuf, - size_t count, loff_t *offp) - { -- struct device_private *ipriv; -+ struct bcm_device_private *ipriv; - char *buf; - ssize_t ret, out_offset, out_count; - int i; -diff --git a/drivers/crypto/chelsio/chtls/chtls_cm.h b/drivers/crypto/chelsio/chtls/chtls_cm.h -index 3fac0c74a41fa..df4451b306495 100644 ---- a/drivers/crypto/chelsio/chtls/chtls_cm.h -+++ b/drivers/crypto/chelsio/chtls/chtls_cm.h -@@ -50,9 +50,6 @@ - #define MIN_RCV_WND (24 * 1024U) - #define LOOPBACK(x) (((x) & htonl(0xff000000)) == htonl(0x7f000000)) - --/* ulp_mem_io + ulptx_idata + payload + padding */ --#define MAX_IMM_ULPTX_WR_LEN (32 + 8 + 256 + 8) -- - /* for TX: a skb must have a headroom of at least TX_HEADER_LEN bytes */ - #define TX_HEADER_LEN \ - (sizeof(struct fw_ofld_tx_data_wr) + sizeof(struct sge_opaque_hdr)) -diff --git a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -index 7e5e092a23b3c..dce3a6f96c97e 100644 ---- a/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -+++ b/drivers/crypto/sunxi-ss/sun4i-ss-cipher.c -@@ -30,6 +30,8 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) - unsigned int ileft = areq->cryptlen; - unsigned int oleft = areq->cryptlen; - unsigned int todo; -+ unsigned long pi = 0, po = 0; /* progress for in and out */ -+ bool miter_err; - struct sg_mapping_iter mi, mo; - unsigned int oi, oo; /* offset for in and out */ - unsigned long flags; -@@ -44,50 +46,62 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) - - spin_lock_irqsave(&ss->slock, flags); - -- for (i = 0; i < op->keylen; i += 4) -- writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); -+ for (i = 0; i < op->keylen / 4; i++) -+ writesl(ss->base + SS_KEY0 + i * 4, &op->key[i], 1); - - if (areq->iv) { - for (i = 0; i < 4 && i < ivsize / 4; i++) { - v = *(u32 *)(areq->iv + i * 4); -- writel(v, ss->base + SS_IV0 + i * 4); -+ writesl(ss->base + SS_IV0 + i * 4, &v, 1); - } - } - writel(mode, ss->base + SS_CTL); - -- sg_miter_start(&mi, areq->src, sg_nents(areq->src), -- SG_MITER_FROM_SG | SG_MITER_ATOMIC); -- sg_miter_start(&mo, areq->dst, sg_nents(areq->dst), -- SG_MITER_TO_SG | SG_MITER_ATOMIC); -- sg_miter_next(&mi); -- sg_miter_next(&mo); -- if (!mi.addr || !mo.addr) { -- dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -- err = -EINVAL; -- goto release_ss; -- } - - ileft = areq->cryptlen / 4; - oleft = areq->cryptlen / 4; - oi = 0; - oo = 0; - do { -- todo = min(rx_cnt, ileft); -- todo = min_t(size_t, todo, (mi.length - oi) / 4); -- if (todo) { -- ileft -= todo; -- writesl(ss->base + SS_RXFIFO, mi.addr + oi, todo); -- oi += todo * 4; -- } -- if (oi == mi.length) { -- sg_miter_next(&mi); -- oi = 0; -+ if (ileft) { -+ sg_miter_start(&mi, areq->src, sg_nents(areq->src), -+ SG_MITER_FROM_SG | SG_MITER_ATOMIC); -+ if (pi) -+ sg_miter_skip(&mi, pi); -+ miter_err = sg_miter_next(&mi); -+ if (!miter_err || !mi.addr) { -+ dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -+ err = -EINVAL; -+ goto release_ss; -+ } -+ todo = min(rx_cnt, ileft); -+ todo = min_t(size_t, todo, (mi.length - oi) / 4); -+ if (todo) { -+ ileft -= todo; -+ writesl(ss->base + SS_RXFIFO, mi.addr + oi, todo); -+ oi += todo * 4; -+ } -+ if (oi == mi.length) { -+ pi += mi.length; -+ oi = 0; -+ } -+ sg_miter_stop(&mi); - } - - spaces = readl(ss->base + SS_FCSR); - rx_cnt = SS_RXFIFO_SPACES(spaces); - tx_cnt = SS_TXFIFO_SPACES(spaces); - -+ sg_miter_start(&mo, areq->dst, sg_nents(areq->dst), -+ SG_MITER_TO_SG | SG_MITER_ATOMIC); -+ if (po) -+ sg_miter_skip(&mo, po); -+ miter_err = sg_miter_next(&mo); -+ if (!miter_err || !mo.addr) { -+ dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -+ err = -EINVAL; -+ goto release_ss; -+ } - todo = min(tx_cnt, oleft); - todo = min_t(size_t, todo, (mo.length - oo) / 4); - if (todo) { -@@ -96,9 +110,10 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) - oo += todo * 4; - } - if (oo == mo.length) { -- sg_miter_next(&mo); - oo = 0; -+ po += mo.length; - } -+ sg_miter_stop(&mo); - } while (oleft); - - if (areq->iv) { -@@ -109,8 +124,6 @@ static int noinline_for_stack sun4i_ss_opti_poll(struct skcipher_request *areq) - } - - release_ss: -- sg_miter_stop(&mi); -- sg_miter_stop(&mo); - writel(0, ss->base + SS_CTL); - spin_unlock_irqrestore(&ss->slock, flags); - return err; -@@ -164,12 +177,14 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - unsigned int oleft = areq->cryptlen; - unsigned int todo; - struct sg_mapping_iter mi, mo; -+ unsigned long pi = 0, po = 0; /* progress for in and out */ -+ bool miter_err; - unsigned int oi, oo; /* offset for in and out */ - unsigned int ob = 0; /* offset in buf */ - unsigned int obo = 0; /* offset in bufo*/ - unsigned int obl = 0; /* length of data in bufo */ - unsigned long flags; -- bool need_fallback; -+ bool need_fallback = false; - - if (!areq->cryptlen) - return 0; -@@ -188,12 +203,12 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - * we can use the SS optimized function - */ - while (in_sg && no_chunk == 1) { -- if (in_sg->length % 4) -+ if ((in_sg->length | in_sg->offset) & 3u) - no_chunk = 0; - in_sg = sg_next(in_sg); - } - while (out_sg && no_chunk == 1) { -- if (out_sg->length % 4) -+ if ((out_sg->length | out_sg->offset) & 3u) - no_chunk = 0; - out_sg = sg_next(out_sg); - } -@@ -206,28 +221,17 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - - spin_lock_irqsave(&ss->slock, flags); - -- for (i = 0; i < op->keylen; i += 4) -- writel(*(op->key + i / 4), ss->base + SS_KEY0 + i); -+ for (i = 0; i < op->keylen / 4; i++) -+ writesl(ss->base + SS_KEY0 + i * 4, &op->key[i], 1); - - if (areq->iv) { - for (i = 0; i < 4 && i < ivsize / 4; i++) { - v = *(u32 *)(areq->iv + i * 4); -- writel(v, ss->base + SS_IV0 + i * 4); -+ writesl(ss->base + SS_IV0 + i * 4, &v, 1); - } - } - writel(mode, ss->base + SS_CTL); - -- sg_miter_start(&mi, areq->src, sg_nents(areq->src), -- SG_MITER_FROM_SG | SG_MITER_ATOMIC); -- sg_miter_start(&mo, areq->dst, sg_nents(areq->dst), -- SG_MITER_TO_SG | SG_MITER_ATOMIC); -- sg_miter_next(&mi); -- sg_miter_next(&mo); -- if (!mi.addr || !mo.addr) { -- dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -- err = -EINVAL; -- goto release_ss; -- } - ileft = areq->cryptlen; - oleft = areq->cryptlen; - oi = 0; -@@ -235,8 +239,16 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - - while (oleft) { - if (ileft) { -- char buf[4 * SS_RX_MAX];/* buffer for linearize SG src */ -- -+ sg_miter_start(&mi, areq->src, sg_nents(areq->src), -+ SG_MITER_FROM_SG | SG_MITER_ATOMIC); -+ if (pi) -+ sg_miter_skip(&mi, pi); -+ miter_err = sg_miter_next(&mi); -+ if (!miter_err || !mi.addr) { -+ dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -+ err = -EINVAL; -+ goto release_ss; -+ } - /* - * todo is the number of consecutive 4byte word that we - * can read from current SG -@@ -258,52 +270,57 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - */ - todo = min(rx_cnt * 4 - ob, ileft); - todo = min_t(size_t, todo, mi.length - oi); -- memcpy(buf + ob, mi.addr + oi, todo); -+ memcpy(ss->buf + ob, mi.addr + oi, todo); - ileft -= todo; - oi += todo; - ob += todo; - if (!(ob % 4)) { -- writesl(ss->base + SS_RXFIFO, buf, -+ writesl(ss->base + SS_RXFIFO, ss->buf, - ob / 4); - ob = 0; - } - } - if (oi == mi.length) { -- sg_miter_next(&mi); -+ pi += mi.length; - oi = 0; - } -+ sg_miter_stop(&mi); - } - - spaces = readl(ss->base + SS_FCSR); - rx_cnt = SS_RXFIFO_SPACES(spaces); - tx_cnt = SS_TXFIFO_SPACES(spaces); -- dev_dbg(ss->dev, -- "%x %u/%zu %u/%u cnt=%u %u/%zu %u/%u cnt=%u %u\n", -- mode, -- oi, mi.length, ileft, areq->cryptlen, rx_cnt, -- oo, mo.length, oleft, areq->cryptlen, tx_cnt, ob); - - if (!tx_cnt) - continue; -+ sg_miter_start(&mo, areq->dst, sg_nents(areq->dst), -+ SG_MITER_TO_SG | SG_MITER_ATOMIC); -+ if (po) -+ sg_miter_skip(&mo, po); -+ miter_err = sg_miter_next(&mo); -+ if (!miter_err || !mo.addr) { -+ dev_err_ratelimited(ss->dev, "ERROR: sg_miter return null\n"); -+ err = -EINVAL; -+ goto release_ss; -+ } - /* todo in 4bytes word */ - todo = min(tx_cnt, oleft / 4); - todo = min_t(size_t, todo, (mo.length - oo) / 4); -+ - if (todo) { - readsl(ss->base + SS_TXFIFO, mo.addr + oo, todo); - oleft -= todo * 4; - oo += todo * 4; - if (oo == mo.length) { -- sg_miter_next(&mo); -+ po += mo.length; - oo = 0; - } - } else { -- char bufo[4 * SS_TX_MAX]; /* buffer for linearize SG dst */ -- - /* - * read obl bytes in bufo, we read at maximum for - * emptying the device - */ -- readsl(ss->base + SS_TXFIFO, bufo, tx_cnt); -+ readsl(ss->base + SS_TXFIFO, ss->bufo, tx_cnt); - obl = tx_cnt * 4; - obo = 0; - do { -@@ -315,17 +332,19 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - */ - todo = min_t(size_t, - mo.length - oo, obl - obo); -- memcpy(mo.addr + oo, bufo + obo, todo); -+ memcpy(mo.addr + oo, ss->bufo + obo, todo); - oleft -= todo; - obo += todo; - oo += todo; - if (oo == mo.length) { -+ po += mo.length; - sg_miter_next(&mo); - oo = 0; - } - } while (obo < obl); - /* bufo must be fully used here */ - } -+ sg_miter_stop(&mo); - } - if (areq->iv) { - for (i = 0; i < 4 && i < ivsize / 4; i++) { -@@ -335,8 +354,6 @@ static int sun4i_ss_cipher_poll(struct skcipher_request *areq) - } - - release_ss: -- sg_miter_stop(&mi); -- sg_miter_stop(&mo); - writel(0, ss->base + SS_CTL); - spin_unlock_irqrestore(&ss->slock, flags); - -diff --git a/drivers/crypto/sunxi-ss/sun4i-ss.h b/drivers/crypto/sunxi-ss/sun4i-ss.h -index 35a27a7145f84..9a2adc130d9aa 100644 ---- a/drivers/crypto/sunxi-ss/sun4i-ss.h -+++ b/drivers/crypto/sunxi-ss/sun4i-ss.h -@@ -138,6 +138,8 @@ struct sun4i_ss_ctx { - struct reset_control *reset; - struct device *dev; - struct resource *res; -+ char buf[4 * SS_RX_MAX];/* buffer for linearize SG src */ -+ char bufo[4 * SS_TX_MAX]; /* buffer for linearize SG dst */ - spinlock_t slock; /* control the use of the device */ - #ifdef CONFIG_CRYPTO_DEV_SUN4I_SS_PRNG - u32 seed[SS_SEED_LEN / BITS_PER_LONG]; -diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c -index b7c66fc0ae0c2..8ef6e93e43f3c 100644 ---- a/drivers/crypto/talitos.c -+++ b/drivers/crypto/talitos.c -@@ -1097,11 +1097,12 @@ static void ipsec_esp_decrypt_hwauth_done(struct device *dev, - */ - static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count, - unsigned int offset, int datalen, int elen, -- struct talitos_ptr *link_tbl_ptr) -+ struct talitos_ptr *link_tbl_ptr, int align) - { - int n_sg = elen ? sg_count + 1 : sg_count; - int count = 0; - int cryptlen = datalen + elen; -+ int padding = ALIGN(cryptlen, align) - cryptlen; - - while (cryptlen && sg && n_sg--) { - unsigned int len = sg_dma_len(sg); -@@ -1125,7 +1126,7 @@ static int sg_to_link_tbl_offset(struct scatterlist *sg, int sg_count, - offset += datalen; - } - to_talitos_ptr(link_tbl_ptr + count, -- sg_dma_address(sg) + offset, len, 0); -+ sg_dma_address(sg) + offset, sg_next(sg) ? len : len + padding, 0); - to_talitos_ptr_ext_set(link_tbl_ptr + count, 0, 0); - count++; - cryptlen -= len; -@@ -1148,10 +1149,11 @@ static int talitos_sg_map_ext(struct device *dev, struct scatterlist *src, - unsigned int len, struct talitos_edesc *edesc, - struct talitos_ptr *ptr, int sg_count, - unsigned int offset, int tbl_off, int elen, -- bool force) -+ bool force, int align) - { - struct talitos_private *priv = dev_get_drvdata(dev); - bool is_sec1 = has_ftr_sec1(priv); -+ int aligned_len = ALIGN(len, align); - - if (!src) { - to_talitos_ptr(ptr, 0, 0, is_sec1); -@@ -1159,22 +1161,22 @@ static int talitos_sg_map_ext(struct device *dev, struct scatterlist *src, - } - to_talitos_ptr_ext_set(ptr, elen, is_sec1); - if (sg_count == 1 && !force) { -- to_talitos_ptr(ptr, sg_dma_address(src) + offset, len, is_sec1); -+ to_talitos_ptr(ptr, sg_dma_address(src) + offset, aligned_len, is_sec1); - return sg_count; - } - if (is_sec1) { -- to_talitos_ptr(ptr, edesc->dma_link_tbl + offset, len, is_sec1); -+ to_talitos_ptr(ptr, edesc->dma_link_tbl + offset, aligned_len, is_sec1); - return sg_count; - } - sg_count = sg_to_link_tbl_offset(src, sg_count, offset, len, elen, -- &edesc->link_tbl[tbl_off]); -+ &edesc->link_tbl[tbl_off], align); - if (sg_count == 1 && !force) { - /* Only one segment now, so no link tbl needed*/ - copy_talitos_ptr(ptr, &edesc->link_tbl[tbl_off], is_sec1); - return sg_count; - } - to_talitos_ptr(ptr, edesc->dma_link_tbl + -- tbl_off * sizeof(struct talitos_ptr), len, is_sec1); -+ tbl_off * sizeof(struct talitos_ptr), aligned_len, is_sec1); - to_talitos_ptr_ext_or(ptr, DESC_PTR_LNKTBL_JUMP, is_sec1); - - return sg_count; -@@ -1186,7 +1188,7 @@ static int talitos_sg_map(struct device *dev, struct scatterlist *src, - unsigned int offset, int tbl_off) - { - return talitos_sg_map_ext(dev, src, len, edesc, ptr, sg_count, offset, -- tbl_off, 0, false); -+ tbl_off, 0, false, 1); - } - - /* -@@ -1255,7 +1257,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - - ret = talitos_sg_map_ext(dev, areq->src, cryptlen, edesc, &desc->ptr[4], - sg_count, areq->assoclen, tbl_off, elen, -- false); -+ false, 1); - - if (ret > 1) { - tbl_off += ret; -@@ -1275,7 +1277,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq, - elen = 0; - ret = talitos_sg_map_ext(dev, areq->dst, cryptlen, edesc, &desc->ptr[5], - sg_count, areq->assoclen, tbl_off, elen, -- is_ipsec_esp && !encrypt); -+ is_ipsec_esp && !encrypt, 1); - tbl_off += ret; - - if (!encrypt && is_ipsec_esp) { -@@ -1583,6 +1585,8 @@ static int common_nonsnoop(struct talitos_edesc *edesc, - bool sync_needed = false; - struct talitos_private *priv = dev_get_drvdata(dev); - bool is_sec1 = has_ftr_sec1(priv); -+ bool is_ctr = (desc->hdr & DESC_HDR_SEL0_MASK) == DESC_HDR_SEL0_AESU && -+ (desc->hdr & DESC_HDR_MODE0_AESU_MASK) == DESC_HDR_MODE0_AESU_CTR; - - /* first DWORD empty */ - -@@ -1603,8 +1607,8 @@ static int common_nonsnoop(struct talitos_edesc *edesc, - /* - * cipher in - */ -- sg_count = talitos_sg_map(dev, areq->src, cryptlen, edesc, -- &desc->ptr[3], sg_count, 0, 0); -+ sg_count = talitos_sg_map_ext(dev, areq->src, cryptlen, edesc, &desc->ptr[3], -+ sg_count, 0, 0, 0, false, is_ctr ? 16 : 1); - if (sg_count > 1) - sync_needed = true; - -diff --git a/drivers/crypto/talitos.h b/drivers/crypto/talitos.h -index 1469b956948ab..32825119e8805 100644 ---- a/drivers/crypto/talitos.h -+++ b/drivers/crypto/talitos.h -@@ -344,6 +344,7 @@ static inline bool has_ftr_sec1(struct talitos_private *priv) - - /* primary execution unit mode (MODE0) and derivatives */ - #define DESC_HDR_MODE0_ENCRYPT cpu_to_be32(0x00100000) -+#define DESC_HDR_MODE0_AESU_MASK cpu_to_be32(0x00600000) - #define DESC_HDR_MODE0_AESU_CBC cpu_to_be32(0x00200000) - #define DESC_HDR_MODE0_AESU_CTR cpu_to_be32(0x00600000) - #define DESC_HDR_MODE0_DEU_CBC cpu_to_be32(0x00400000) -diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c -index ad72b3f42ffa0..eae385a312b88 100644 ---- a/drivers/dma/fsldma.c -+++ b/drivers/dma/fsldma.c -@@ -1214,6 +1214,7 @@ static int fsldma_of_probe(struct platform_device *op) - { - struct fsldma_device *fdev; - struct device_node *child; -+ unsigned int i; - int err; - - fdev = kzalloc(sizeof(*fdev), GFP_KERNEL); -@@ -1292,6 +1293,10 @@ static int fsldma_of_probe(struct platform_device *op) - return 0; - - out_free_fdev: -+ for (i = 0; i < FSL_DMA_MAX_CHANS_PER_DEVICE; i++) { -+ if (fdev->chan[i]) -+ fsl_dma_chan_remove(fdev->chan[i]); -+ } - irq_dispose_mapping(fdev->irq); - iounmap(fdev->regs); - out_free: -@@ -1314,6 +1319,7 @@ static int fsldma_of_remove(struct platform_device *op) - if (fdev->chan[i]) - fsl_dma_chan_remove(fdev->chan[i]); - } -+ irq_dispose_mapping(fdev->irq); - - iounmap(fdev->regs); - kfree(fdev); -diff --git a/drivers/dma/hsu/pci.c b/drivers/dma/hsu/pci.c -index 07cc7320a614f..9045a6f7f5893 100644 ---- a/drivers/dma/hsu/pci.c -+++ b/drivers/dma/hsu/pci.c -@@ -26,22 +26,12 @@ - static irqreturn_t hsu_pci_irq(int irq, void *dev) - { - struct hsu_dma_chip *chip = dev; -- struct pci_dev *pdev = to_pci_dev(chip->dev); - u32 dmaisr; - u32 status; - unsigned short i; - int ret = 0; - int err; - -- /* -- * On Intel Tangier B0 and Anniedale the interrupt line, disregarding -- * to have different numbers, is shared between HSU DMA and UART IPs. -- * Thus on such SoCs we are expecting that IRQ handler is called in -- * UART driver only. -- */ -- if (pdev->device == PCI_DEVICE_ID_INTEL_MRFLD_HSU_DMA) -- return IRQ_HANDLED; -- - dmaisr = readl(chip->regs + HSU_PCI_DMAISR); - for (i = 0; i < chip->hsu->nr_channels; i++) { - if (dmaisr & 0x1) { -@@ -105,6 +95,17 @@ static int hsu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) - if (ret) - goto err_register_irq; - -+ /* -+ * On Intel Tangier B0 and Anniedale the interrupt line, disregarding -+ * to have different numbers, is shared between HSU DMA and UART IPs. -+ * Thus on such SoCs we are expecting that IRQ handler is called in -+ * UART driver only. Instead of handling the spurious interrupt -+ * from HSU DMA here and waste CPU time and delay HSU UART interrupt -+ * handling, disable the interrupt entirely. -+ */ -+ if (pdev->device == PCI_DEVICE_ID_INTEL_MRFLD_HSU_DMA) -+ disable_irq_nosync(chip->irq); -+ - pci_set_drvdata(pdev, chip); - - return 0; -diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c -index af20e9a790a2a..bb9c361e224bc 100644 ---- a/drivers/dma/owl-dma.c -+++ b/drivers/dma/owl-dma.c -@@ -1201,6 +1201,7 @@ static int owl_dma_remove(struct platform_device *pdev) - owl_dma_free(od); - - clk_disable_unprepare(od->clk); -+ dma_pool_destroy(od->lli_pool); - - return 0; - } -diff --git a/drivers/gpio/gpio-pcf857x.c b/drivers/gpio/gpio-pcf857x.c -index 14fb8f6a1ad29..abcc8c0136c4e 100644 ---- a/drivers/gpio/gpio-pcf857x.c -+++ b/drivers/gpio/gpio-pcf857x.c -@@ -332,7 +332,7 @@ static int pcf857x_probe(struct i2c_client *client, - * reset state. Otherwise it flags pins to be driven low. - */ - gpio->out = ~n_latch; -- gpio->status = gpio->out; -+ gpio->status = gpio->read(gpio->client); - - status = devm_gpiochip_add_data(&client->dev, &gpio->chip, gpio); - if (status < 0) -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c -index 3f744e72912f1..bcb7ab5c602d1 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_pm.c -@@ -870,7 +870,7 @@ static ssize_t amdgpu_get_pp_dpm_sclk(struct device *dev, - static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask) - { - int ret; -- long level; -+ unsigned long level; - char *sub_str = NULL; - char *tmp; - char buf_cpy[AMDGPU_MASK_BUF_MAX + 1]; -@@ -886,8 +886,8 @@ static ssize_t amdgpu_read_mask(const char *buf, size_t count, uint32_t *mask) - while (tmp[0]) { - sub_str = strsep(&tmp, delimiter); - if (strlen(sub_str)) { -- ret = kstrtol(sub_str, 0, &level); -- if (ret) -+ ret = kstrtoul(sub_str, 0, &level); -+ if (ret || level > 31) - return -EINVAL; - *mask |= 1 << level; - } else -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h -index 91899d28fa722..e8132210c244c 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h -@@ -21,7 +21,7 @@ - * - */ - --#if !defined(_AMDGPU_TRACE_H) || defined(TRACE_HEADER_MULTI_READ) -+#if !defined(_AMDGPU_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ) - #define _AMDGPU_TRACE_H_ - - #include -diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c b/drivers/gpu/drm/amd/amdgpu/soc15.c -index 317aa257c06bb..41631271d64ca 100644 ---- a/drivers/gpu/drm/amd/amdgpu/soc15.c -+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c -@@ -276,6 +276,8 @@ static u32 soc15_get_xclk(struct amdgpu_device *adev) - { - u32 reference_clock = adev->clock.spll.reference_freq; - -+ if (adev->asic_type == CHIP_RENOIR) -+ return 10000; - if (adev->asic_type == CHIP_RAVEN) - return reference_clock / 4; - -diff --git a/drivers/gpu/drm/amd/display/dc/bios/command_table.c b/drivers/gpu/drm/amd/display/dc/bios/command_table.c -index 5815983caaf80..0d2e13627c647 100644 ---- a/drivers/gpu/drm/amd/display/dc/bios/command_table.c -+++ b/drivers/gpu/drm/amd/display/dc/bios/command_table.c -@@ -245,6 +245,23 @@ static enum bp_result encoder_control_digx_v3( - cntl->enable_dp_audio); - params.ucLaneNum = (uint8_t)(cntl->lanes_number); - -+ switch (cntl->color_depth) { -+ case COLOR_DEPTH_888: -+ params.ucBitPerColor = PANEL_8BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_101010: -+ params.ucBitPerColor = PANEL_10BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_121212: -+ params.ucBitPerColor = PANEL_12BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_161616: -+ params.ucBitPerColor = PANEL_16BIT_PER_COLOR; -+ break; -+ default: -+ break; -+ } -+ - if (EXEC_BIOS_CMD_TABLE(DIGxEncoderControl, params)) - result = BP_RESULT_OK; - -@@ -274,6 +291,23 @@ static enum bp_result encoder_control_digx_v4( - cntl->enable_dp_audio)); - params.ucLaneNum = (uint8_t)(cntl->lanes_number); - -+ switch (cntl->color_depth) { -+ case COLOR_DEPTH_888: -+ params.ucBitPerColor = PANEL_8BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_101010: -+ params.ucBitPerColor = PANEL_10BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_121212: -+ params.ucBitPerColor = PANEL_12BIT_PER_COLOR; -+ break; -+ case COLOR_DEPTH_161616: -+ params.ucBitPerColor = PANEL_16BIT_PER_COLOR; -+ break; -+ default: -+ break; -+ } -+ - if (EXEC_BIOS_CMD_TABLE(DIGxEncoderControl, params)) - result = BP_RESULT_OK; - -@@ -1057,6 +1091,19 @@ static enum bp_result set_pixel_clock_v5( - * driver choose program it itself, i.e. here we program it - * to 888 by default. - */ -+ if (bp_params->signal_type == SIGNAL_TYPE_HDMI_TYPE_A) -+ switch (bp_params->color_depth) { -+ case TRANSMITTER_COLOR_DEPTH_30: -+ /* yes this is correct, the atom define is wrong */ -+ clk.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_32BPP; -+ break; -+ case TRANSMITTER_COLOR_DEPTH_36: -+ /* yes this is correct, the atom define is wrong */ -+ clk.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V5_MISC_HDMI_30BPP; -+ break; -+ default: -+ break; -+ } - - if (EXEC_BIOS_CMD_TABLE(SetPixelClock, clk)) - result = BP_RESULT_OK; -@@ -1135,6 +1182,20 @@ static enum bp_result set_pixel_clock_v6( - * driver choose program it itself, i.e. here we pass required - * target rate that includes deep color. - */ -+ if (bp_params->signal_type == SIGNAL_TYPE_HDMI_TYPE_A) -+ switch (bp_params->color_depth) { -+ case TRANSMITTER_COLOR_DEPTH_30: -+ clk.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_30BPP_V6; -+ break; -+ case TRANSMITTER_COLOR_DEPTH_36: -+ clk.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_36BPP_V6; -+ break; -+ case TRANSMITTER_COLOR_DEPTH_48: -+ clk.sPCLKInput.ucMiscInfo |= PIXEL_CLOCK_V6_MISC_HDMI_48BPP; -+ break; -+ default: -+ break; -+ } - - if (EXEC_BIOS_CMD_TABLE(SetPixelClock, clk)) - result = BP_RESULT_OK; -diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c -index f787a6b947812..eca67d5d5b10d 100644 ---- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c -+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c -@@ -871,6 +871,20 @@ static bool dce110_program_pix_clk( - bp_pc_params.flags.SET_EXTERNAL_REF_DIV_SRC = - pll_settings->use_external_clk; - -+ switch (pix_clk_params->color_depth) { -+ case COLOR_DEPTH_101010: -+ bp_pc_params.color_depth = TRANSMITTER_COLOR_DEPTH_30; -+ break; -+ case COLOR_DEPTH_121212: -+ bp_pc_params.color_depth = TRANSMITTER_COLOR_DEPTH_36; -+ break; -+ case COLOR_DEPTH_161616: -+ bp_pc_params.color_depth = TRANSMITTER_COLOR_DEPTH_48; -+ break; -+ default: -+ break; -+ } -+ - if (clk_src->bios->funcs->set_pixel_clock( - clk_src->bios, &bp_pc_params) != BP_RESULT_OK) - return false; -diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c -index 6ed922a3c1cd5..c25840a774f94 100644 ---- a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c -+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c -@@ -563,6 +563,7 @@ static void dce110_stream_encoder_hdmi_set_stream_attribute( - cntl.enable_dp_audio = enable_audio; - cntl.pixel_clock = actual_pix_clk_khz; - cntl.lanes_number = LANE_COUNT_FOUR; -+ cntl.color_depth = crtc_timing->display_color_depth; - - if (enc110->base.bp->funcs->encoder_control( - enc110->base.bp, &cntl) != BP_RESULT_OK) -diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c -index ab63d0d0304cb..6fd57cfb112f5 100644 ---- a/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c -+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_transform.c -@@ -429,12 +429,12 @@ static void set_clamp( - clamp_max = 0x3FC0; - break; - case COLOR_DEPTH_101010: -- /* 10bit MSB aligned on 14 bit bus '11 1111 1111 1100' */ -- clamp_max = 0x3FFC; -+ /* 10bit MSB aligned on 14 bit bus '11 1111 1111 0000' */ -+ clamp_max = 0x3FF0; - break; - case COLOR_DEPTH_121212: -- /* 12bit MSB aligned on 14 bit bus '11 1111 1111 1111' */ -- clamp_max = 0x3FFF; -+ /* 12bit MSB aligned on 14 bit bus '11 1111 1111 1100' */ -+ clamp_max = 0x3FFC; - break; - default: - clamp_max = 0x3FC0; -diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c -index cbe7818529bbf..623455cd75203 100644 ---- a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c -+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c -@@ -168,6 +168,11 @@ static const struct irq_source_info_funcs vblank_irq_info_funcs = { - .ack = NULL - }; - -+static const struct irq_source_info_funcs vupdate_no_lock_irq_info_funcs = { -+ .set = NULL, -+ .ack = NULL -+}; -+ - #undef BASE_INNER - #define BASE_INNER(seg) DMU_BASE__INST0_SEG ## seg - -@@ -230,6 +235,17 @@ static const struct irq_source_info_funcs vblank_irq_info_funcs = { - .funcs = &vblank_irq_info_funcs\ - } - -+/* vupdate_no_lock_int_entry maps to DC_IRQ_SOURCE_VUPDATEx, to match semantic -+ * of DCE's DC_IRQ_SOURCE_VUPDATEx. -+ */ -+#define vupdate_no_lock_int_entry(reg_num)\ -+ [DC_IRQ_SOURCE_VUPDATE1 + reg_num] = {\ -+ IRQ_REG_ENTRY(OTG, reg_num,\ -+ OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_INT_EN,\ -+ OTG_GLOBAL_SYNC_STATUS, VUPDATE_NO_LOCK_EVENT_CLEAR),\ -+ .funcs = &vupdate_no_lock_irq_info_funcs\ -+ } -+ - #define vblank_int_entry(reg_num)\ - [DC_IRQ_SOURCE_VBLANK1 + reg_num] = {\ - IRQ_REG_ENTRY(OTG, reg_num,\ -@@ -338,6 +354,12 @@ irq_source_info_dcn21[DAL_IRQ_SOURCES_NUMBER] = { - vupdate_int_entry(3), - vupdate_int_entry(4), - vupdate_int_entry(5), -+ vupdate_no_lock_int_entry(0), -+ vupdate_no_lock_int_entry(1), -+ vupdate_no_lock_int_entry(2), -+ vupdate_no_lock_int_entry(3), -+ vupdate_no_lock_int_entry(4), -+ vupdate_no_lock_int_entry(5), - vblank_int_entry(0), - vblank_int_entry(1), - vblank_int_entry(2), -diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c -index 6b8502bcf0fd3..02ffde5fd7226 100644 ---- a/drivers/gpu/drm/drm_fb_helper.c -+++ b/drivers/gpu/drm/drm_fb_helper.c -@@ -965,11 +965,15 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info) - drm_modeset_lock_all(fb_helper->dev); - drm_client_for_each_modeset(modeset, &fb_helper->client) { - crtc = modeset->crtc; -- if (!crtc->funcs->gamma_set || !crtc->gamma_size) -- return -EINVAL; -+ if (!crtc->funcs->gamma_set || !crtc->gamma_size) { -+ ret = -EINVAL; -+ goto out; -+ } - -- if (cmap->start + cmap->len > crtc->gamma_size) -- return -EINVAL; -+ if (cmap->start + cmap->len > crtc->gamma_size) { -+ ret = -EINVAL; -+ goto out; -+ } - - r = crtc->gamma_store; - g = r + crtc->gamma_size; -@@ -982,8 +986,9 @@ static int setcmap_legacy(struct fb_cmap *cmap, struct fb_info *info) - ret = crtc->funcs->gamma_set(crtc, r, g, b, - crtc->gamma_size, NULL); - if (ret) -- return ret; -+ goto out; - } -+out: - drm_modeset_unlock_all(fb_helper->dev); - - return ret; -diff --git a/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c b/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c -index e281070611480..fc9a34ed58bd1 100644 ---- a/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c -+++ b/drivers/gpu/drm/gma500/oaktrail_hdmi_i2c.c -@@ -279,11 +279,8 @@ int oaktrail_hdmi_i2c_init(struct pci_dev *dev) - hdmi_dev = pci_get_drvdata(dev); - - i2c_dev = kzalloc(sizeof(struct hdmi_i2c_dev), GFP_KERNEL); -- if (i2c_dev == NULL) { -- DRM_ERROR("Can't allocate interface\n"); -- ret = -ENOMEM; -- goto exit; -- } -+ if (!i2c_dev) -+ return -ENOMEM; - - i2c_dev->adap = &oaktrail_hdmi_i2c_adapter; - i2c_dev->status = I2C_STAT_INIT; -@@ -300,16 +297,23 @@ int oaktrail_hdmi_i2c_init(struct pci_dev *dev) - oaktrail_hdmi_i2c_adapter.name, hdmi_dev); - if (ret) { - DRM_ERROR("Failed to request IRQ for I2C controller\n"); -- goto err; -+ goto free_dev; - } - - /* Adapter registration */ - ret = i2c_add_numbered_adapter(&oaktrail_hdmi_i2c_adapter); -- return ret; -+ if (ret) { -+ DRM_ERROR("Failed to add I2C adapter\n"); -+ goto free_irq; -+ } - --err: -+ return 0; -+ -+free_irq: -+ free_irq(dev->irq, hdmi_dev); -+free_dev: - kfree(i2c_dev); --exit: -+ - return ret; - } - -diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c -index 7005f8f69c683..d414525eccf6d 100644 ---- a/drivers/gpu/drm/gma500/psb_drv.c -+++ b/drivers/gpu/drm/gma500/psb_drv.c -@@ -313,6 +313,8 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags) - if (ret) - goto out_err; - -+ ret = -ENOMEM; -+ - dev_priv->mmu = psb_mmu_driver_init(dev, 1, 0, 0); - if (!dev_priv->mmu) - goto out_err; -diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c -index b030f7ae33029..4cf95e8031e38 100644 ---- a/drivers/gpu/drm/i915/display/intel_hdmi.c -+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c -@@ -2129,7 +2129,11 @@ hdmi_port_clock_valid(struct intel_hdmi *hdmi, - if (clock > hdmi_port_clock_limit(hdmi, respect_downstream_limits, force_dvi)) - return MODE_CLOCK_HIGH; - -- /* BXT DPLL can't generate 223-240 MHz */ -+ /* GLK DPLL can't generate 446-480 MHz */ -+ if (IS_GEMINILAKE(dev_priv) && clock > 446666 && clock < 480000) -+ return MODE_CLOCK_RANGE; -+ -+ /* BXT/GLK DPLL can't generate 223-240 MHz */ - if (IS_GEN9_LP(dev_priv) && clock > 223333 && clock < 240000) - return MODE_CLOCK_RANGE; - -diff --git a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c -index 03c6d6157e4d0..395146884a222 100644 ---- a/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c -+++ b/drivers/gpu/drm/msm/disp/mdp5/mdp5_crtc.c -@@ -1099,7 +1099,7 @@ static void mdp5_crtc_pp_done_irq(struct mdp_irq *irq, uint32_t irqstatus) - struct mdp5_crtc *mdp5_crtc = container_of(irq, struct mdp5_crtc, - pp_done); - -- complete(&mdp5_crtc->pp_completion); -+ complete_all(&mdp5_crtc->pp_completion); - } - - static void mdp5_crtc_wait_for_pp_done(struct drm_crtc *crtc) -diff --git a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c -index 1afb7c579dbbb..eca86bf448f74 100644 ---- a/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c -+++ b/drivers/gpu/drm/msm/dsi/phy/dsi_phy_20nm.c -@@ -139,7 +139,7 @@ const struct msm_dsi_phy_cfg dsi_phy_20nm_cfgs = { - .disable = dsi_20nm_phy_disable, - .init = msm_dsi_phy_init_common, - }, -- .io_start = { 0xfd998300, 0xfd9a0300 }, -+ .io_start = { 0xfd998500, 0xfd9a0500 }, - .num_dsi_phy = 2, - }; - -diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h -index f5f59261ea819..d1beaad0c82b6 100644 ---- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h -+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios/conn.h -@@ -14,6 +14,7 @@ enum dcb_connector_type { - DCB_CONNECTOR_LVDS_SPWG = 0x41, - DCB_CONNECTOR_DP = 0x46, - DCB_CONNECTOR_eDP = 0x47, -+ DCB_CONNECTOR_mDP = 0x48, - DCB_CONNECTOR_HDMI_0 = 0x60, - DCB_CONNECTOR_HDMI_1 = 0x61, - DCB_CONNECTOR_HDMI_C = 0x63, -diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c -index 282fd90b65e13..9ce7b0d4b8764 100644 ---- a/drivers/gpu/drm/nouveau/nouveau_chan.c -+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c -@@ -497,6 +497,7 @@ nouveau_channel_new(struct nouveau_drm *drm, struct nvif_device *device, - if (ret) { - NV_PRINTK(err, cli, "channel failed to initialise, %d\n", ret); - nouveau_channel_del(pchan); -+ goto done; - } - - ret = nouveau_svmm_join((*pchan)->vmm->svmm, (*pchan)->inst); -diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c -index 0994aee7671ad..496e7dcd6b7dc 100644 ---- a/drivers/gpu/drm/nouveau/nouveau_connector.c -+++ b/drivers/gpu/drm/nouveau/nouveau_connector.c -@@ -1240,6 +1240,7 @@ drm_conntype_from_dcb(enum dcb_connector_type dcb) - case DCB_CONNECTOR_DMS59_DP0: - case DCB_CONNECTOR_DMS59_DP1: - case DCB_CONNECTOR_DP : -+ case DCB_CONNECTOR_mDP : - case DCB_CONNECTOR_USB_C : return DRM_MODE_CONNECTOR_DisplayPort; - case DCB_CONNECTOR_eDP : return DRM_MODE_CONNECTOR_eDP; - case DCB_CONNECTOR_HDMI_0 : -diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c -index 134e9106ebac1..37679507f9432 100644 ---- a/drivers/gpu/drm/scheduler/sched_main.c -+++ b/drivers/gpu/drm/scheduler/sched_main.c -@@ -851,6 +851,9 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched) - if (sched->thread) - kthread_stop(sched->thread); - -+ /* Confirm no work left behind accessing device structures */ -+ cancel_delayed_work_sync(&sched->work_tdr); -+ - sched->ready = false; - } - EXPORT_SYMBOL(drm_sched_fini); -diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.c b/drivers/gpu/drm/sun4i/sun4i_tcon.c -index 6bf1425e8b0ca..eb3b2350687fb 100644 ---- a/drivers/gpu/drm/sun4i/sun4i_tcon.c -+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.c -@@ -545,30 +545,13 @@ static void sun4i_tcon0_mode_set_rgb(struct sun4i_tcon *tcon, - if (info->bus_flags & DRM_BUS_FLAG_DE_LOW) - val |= SUN4I_TCON0_IO_POL_DE_NEGATIVE; - -- /* -- * On A20 and similar SoCs, the only way to achieve Positive Edge -- * (Rising Edge), is setting dclk clock phase to 2/3(240°). -- * By default TCON works in Negative Edge(Falling Edge), -- * this is why phase is set to 0 in that case. -- * Unfortunately there's no way to logically invert dclk through -- * IO_POL register. -- * The only acceptable way to work, triple checked with scope, -- * is using clock phase set to 0° for Negative Edge and set to 240° -- * for Positive Edge. -- * On A33 and similar SoCs there would be a 90° phase option, -- * but it divides also dclk by 2. -- * Following code is a way to avoid quirks all around TCON -- * and DOTCLOCK drivers. -- */ -- if (info->bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_POSEDGE) -- clk_set_phase(tcon->dclk, 240); -- - if (info->bus_flags & DRM_BUS_FLAG_PIXDATA_DRIVE_NEGEDGE) -- clk_set_phase(tcon->dclk, 0); -+ val |= SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE; - - regmap_update_bits(tcon->regs, SUN4I_TCON0_IO_POL_REG, - SUN4I_TCON0_IO_POL_HSYNC_POSITIVE | - SUN4I_TCON0_IO_POL_VSYNC_POSITIVE | -+ SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE | - SUN4I_TCON0_IO_POL_DE_NEGATIVE, - val); - -diff --git a/drivers/gpu/drm/sun4i/sun4i_tcon.h b/drivers/gpu/drm/sun4i/sun4i_tcon.h -index 5bdbaf0847824..ce500c8dd4c72 100644 ---- a/drivers/gpu/drm/sun4i/sun4i_tcon.h -+++ b/drivers/gpu/drm/sun4i/sun4i_tcon.h -@@ -113,6 +113,7 @@ - #define SUN4I_TCON0_IO_POL_REG 0x88 - #define SUN4I_TCON0_IO_POL_DCLK_PHASE(phase) ((phase & 3) << 28) - #define SUN4I_TCON0_IO_POL_DE_NEGATIVE BIT(27) -+#define SUN4I_TCON0_IO_POL_DCLK_DRIVE_NEGEDGE BIT(26) - #define SUN4I_TCON0_IO_POL_HSYNC_POSITIVE BIT(25) - #define SUN4I_TCON0_IO_POL_VSYNC_POSITIVE BIT(24) - -diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c -index 263eca119ff0f..8d202011b2db5 100644 ---- a/drivers/hid/hid-core.c -+++ b/drivers/hid/hid-core.c -@@ -1300,6 +1300,9 @@ EXPORT_SYMBOL_GPL(hid_open_report); - - static s32 snto32(__u32 value, unsigned n) - { -+ if (!value || !n) -+ return 0; -+ - switch (n) { - case 8: return ((__s8)value); - case 16: return ((__s16)value); -diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c -index e5550a5bf49d0..86001cfbdb6f1 100644 ---- a/drivers/hid/hid-logitech-dj.c -+++ b/drivers/hid/hid-logitech-dj.c -@@ -980,6 +980,7 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev, - case 0x07: - device_type = "eQUAD step 4 Gaming"; - logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); -+ workitem.reports_supported |= STD_KEYBOARD; - break; - case 0x08: - device_type = "eQUAD step 4 for gamepads"; -diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c -index b74acbd5997b5..f1928c1ac139c 100644 ---- a/drivers/hid/wacom_wac.c -+++ b/drivers/hid/wacom_wac.c -@@ -2600,7 +2600,12 @@ static void wacom_wac_finger_event(struct hid_device *hdev, - wacom_wac->is_invalid_bt_frame = !value; - return; - case HID_DG_CONTACTMAX: -- features->touch_max = value; -+ if (!features->touch_max) { -+ features->touch_max = value; -+ } else { -+ hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max " -+ "%d -> %d\n", __func__, features->touch_max, value); -+ } - return; - } - -diff --git a/drivers/hsi/controllers/omap_ssi_core.c b/drivers/hsi/controllers/omap_ssi_core.c -index 2be9c01e175ca..f36036be7f032 100644 ---- a/drivers/hsi/controllers/omap_ssi_core.c -+++ b/drivers/hsi/controllers/omap_ssi_core.c -@@ -424,7 +424,7 @@ static int ssi_hw_init(struct hsi_controller *ssi) - struct omap_ssi_controller *omap_ssi = hsi_controller_drvdata(ssi); - int err; - -- err = pm_runtime_get_sync(ssi->device.parent); -+ err = pm_runtime_resume_and_get(ssi->device.parent); - if (err < 0) { - dev_err(&ssi->device, "runtime PM failed %d\n", err); - return err; -diff --git a/drivers/hv/channel_mgmt.c b/drivers/hv/channel_mgmt.c -index 452307c79e4b9..0b55bc146b292 100644 ---- a/drivers/hv/channel_mgmt.c -+++ b/drivers/hv/channel_mgmt.c -@@ -1101,8 +1101,7 @@ static void vmbus_onoffer_rescind(struct vmbus_channel_message_header *hdr) - vmbus_device_unregister(channel->device_obj); - put_device(dev); - } -- } -- if (channel->primary_channel != NULL) { -+ } else if (channel->primary_channel != NULL) { - /* - * Sub-channel is being rescinded. Following is the channel - * close sequence when initiated from the driveri (refer to -diff --git a/drivers/i2c/busses/i2c-bcm-iproc.c b/drivers/i2c/busses/i2c-bcm-iproc.c -index dd9661c11782a..70cd9fc7fb869 100644 ---- a/drivers/i2c/busses/i2c-bcm-iproc.c -+++ b/drivers/i2c/busses/i2c-bcm-iproc.c -@@ -157,6 +157,11 @@ - - #define IE_S_ALL_INTERRUPT_SHIFT 21 - #define IE_S_ALL_INTERRUPT_MASK 0x3f -+/* -+ * It takes ~18us to reading 10bytes of data, hence to keep tasklet -+ * running for less time, max slave read per tasklet is set to 10 bytes. -+ */ -+#define MAX_SLAVE_RX_PER_INT 10 - - enum i2c_slave_read_status { - I2C_SLAVE_RX_FIFO_EMPTY = 0, -@@ -203,8 +208,18 @@ struct bcm_iproc_i2c_dev { - /* bytes that have been read */ - unsigned int rx_bytes; - unsigned int thld_bytes; -+ -+ bool slave_rx_only; -+ bool rx_start_rcvd; -+ bool slave_read_complete; -+ u32 tx_underrun; -+ u32 slave_int_mask; -+ struct tasklet_struct slave_rx_tasklet; - }; - -+/* tasklet to process slave rx data */ -+static void slave_rx_tasklet_fn(unsigned long); -+ - /* - * Can be expanded in the future if more interrupt status bits are utilized - */ -@@ -213,7 +228,8 @@ struct bcm_iproc_i2c_dev { - - #define ISR_MASK_SLAVE (BIT(IS_S_START_BUSY_SHIFT)\ - | BIT(IS_S_RX_EVENT_SHIFT) | BIT(IS_S_RD_EVENT_SHIFT)\ -- | BIT(IS_S_TX_UNDERRUN_SHIFT)) -+ | BIT(IS_S_TX_UNDERRUN_SHIFT) | BIT(IS_S_RX_FIFO_FULL_SHIFT)\ -+ | BIT(IS_S_RX_THLD_SHIFT)) - - static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave); - static int bcm_iproc_i2c_unreg_slave(struct i2c_client *slave); -@@ -257,6 +273,7 @@ static void bcm_iproc_i2c_slave_init( - { - u32 val; - -+ iproc_i2c->tx_underrun = 0; - if (need_reset) { - /* put controller in reset */ - val = iproc_i2c_rd_reg(iproc_i2c, CFG_OFFSET); -@@ -293,8 +310,11 @@ static void bcm_iproc_i2c_slave_init( - - /* Enable interrupt register to indicate a valid byte in receive fifo */ - val = BIT(IE_S_RX_EVENT_SHIFT); -+ /* Enable interrupt register to indicate a Master read transaction */ -+ val |= BIT(IE_S_RD_EVENT_SHIFT); - /* Enable interrupt register for the Slave BUSY command */ - val |= BIT(IE_S_START_BUSY_SHIFT); -+ iproc_i2c->slave_int_mask = val; - iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); - } - -@@ -319,76 +339,176 @@ static void bcm_iproc_i2c_check_slave_status( - } - } - --static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, -- u32 status) -+static void bcm_iproc_i2c_slave_read(struct bcm_iproc_i2c_dev *iproc_i2c) - { -+ u8 rx_data, rx_status; -+ u32 rx_bytes = 0; - u32 val; -- u8 value, rx_status; - -- /* Slave RX byte receive */ -- if (status & BIT(IS_S_RX_EVENT_SHIFT)) { -+ while (rx_bytes < MAX_SLAVE_RX_PER_INT) { - val = iproc_i2c_rd_reg(iproc_i2c, S_RX_OFFSET); - rx_status = (val >> S_RX_STATUS_SHIFT) & S_RX_STATUS_MASK; -+ rx_data = ((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); -+ - if (rx_status == I2C_SLAVE_RX_START) { -- /* Start of SMBUS for Master write */ -+ /* Start of SMBUS Master write */ - i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_WRITE_REQUESTED, &value); -- -- val = iproc_i2c_rd_reg(iproc_i2c, S_RX_OFFSET); -- value = (u8)((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); -+ I2C_SLAVE_WRITE_REQUESTED, &rx_data); -+ iproc_i2c->rx_start_rcvd = true; -+ iproc_i2c->slave_read_complete = false; -+ } else if (rx_status == I2C_SLAVE_RX_DATA && -+ iproc_i2c->rx_start_rcvd) { -+ /* Middle of SMBUS Master write */ - i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_WRITE_RECEIVED, &value); -- } else if (status & BIT(IS_S_RD_EVENT_SHIFT)) { -- /* Start of SMBUS for Master Read */ -- i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_READ_REQUESTED, &value); -- iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, value); -+ I2C_SLAVE_WRITE_RECEIVED, &rx_data); -+ } else if (rx_status == I2C_SLAVE_RX_END && -+ iproc_i2c->rx_start_rcvd) { -+ /* End of SMBUS Master write */ -+ if (iproc_i2c->slave_rx_only) -+ i2c_slave_event(iproc_i2c->slave, -+ I2C_SLAVE_WRITE_RECEIVED, -+ &rx_data); -+ -+ i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, -+ &rx_data); -+ } else if (rx_status == I2C_SLAVE_RX_FIFO_EMPTY) { -+ iproc_i2c->rx_start_rcvd = false; -+ iproc_i2c->slave_read_complete = true; -+ break; -+ } - -- val = BIT(S_CMD_START_BUSY_SHIFT); -- iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); -+ rx_bytes++; -+ } -+} - -- /* -- * Enable interrupt for TX FIFO becomes empty and -- * less than PKT_LENGTH bytes were output on the SMBUS -- */ -- val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); -- val |= BIT(IE_S_TX_UNDERRUN_SHIFT); -- iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); -- } else { -- /* Master write other than start */ -- value = (u8)((val >> S_RX_DATA_SHIFT) & S_RX_DATA_MASK); -+static void slave_rx_tasklet_fn(unsigned long data) -+{ -+ struct bcm_iproc_i2c_dev *iproc_i2c = (struct bcm_iproc_i2c_dev *)data; -+ u32 int_clr; -+ -+ bcm_iproc_i2c_slave_read(iproc_i2c); -+ -+ /* clear pending IS_S_RX_EVENT_SHIFT interrupt */ -+ int_clr = BIT(IS_S_RX_EVENT_SHIFT); -+ -+ if (!iproc_i2c->slave_rx_only && iproc_i2c->slave_read_complete) { -+ /* -+ * In case of single byte master-read request, -+ * IS_S_TX_UNDERRUN_SHIFT event is generated before -+ * IS_S_START_BUSY_SHIFT event. Hence start slave data send -+ * from first IS_S_TX_UNDERRUN_SHIFT event. -+ * -+ * This means don't send any data from slave when -+ * IS_S_RD_EVENT_SHIFT event is generated else it will increment -+ * eeprom or other backend slave driver read pointer twice. -+ */ -+ iproc_i2c->tx_underrun = 0; -+ iproc_i2c->slave_int_mask |= BIT(IE_S_TX_UNDERRUN_SHIFT); -+ -+ /* clear IS_S_RD_EVENT_SHIFT interrupt */ -+ int_clr |= BIT(IS_S_RD_EVENT_SHIFT); -+ } -+ -+ /* clear slave interrupt */ -+ iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, int_clr); -+ /* enable slave interrupts */ -+ iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, iproc_i2c->slave_int_mask); -+} -+ -+static bool bcm_iproc_i2c_slave_isr(struct bcm_iproc_i2c_dev *iproc_i2c, -+ u32 status) -+{ -+ u32 val; -+ u8 value; -+ -+ /* -+ * Slave events in case of master-write, master-write-read and, -+ * master-read -+ * -+ * Master-write : only IS_S_RX_EVENT_SHIFT event -+ * Master-write-read: both IS_S_RX_EVENT_SHIFT and IS_S_RD_EVENT_SHIFT -+ * events -+ * Master-read : both IS_S_RX_EVENT_SHIFT and IS_S_RD_EVENT_SHIFT -+ * events or only IS_S_RD_EVENT_SHIFT -+ */ -+ if (status & BIT(IS_S_RX_EVENT_SHIFT) || -+ status & BIT(IS_S_RD_EVENT_SHIFT)) { -+ /* disable slave interrupts */ -+ val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); -+ val &= ~iproc_i2c->slave_int_mask; -+ iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); -+ -+ if (status & BIT(IS_S_RD_EVENT_SHIFT)) -+ /* Master-write-read request */ -+ iproc_i2c->slave_rx_only = false; -+ else -+ /* Master-write request only */ -+ iproc_i2c->slave_rx_only = true; -+ -+ /* schedule tasklet to read data later */ -+ tasklet_schedule(&iproc_i2c->slave_rx_tasklet); -+ -+ /* clear only IS_S_RX_EVENT_SHIFT interrupt */ -+ iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, -+ BIT(IS_S_RX_EVENT_SHIFT)); -+ } -+ -+ if (status & BIT(IS_S_TX_UNDERRUN_SHIFT)) { -+ iproc_i2c->tx_underrun++; -+ if (iproc_i2c->tx_underrun == 1) -+ /* Start of SMBUS for Master Read */ - i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_WRITE_RECEIVED, &value); -- if (rx_status == I2C_SLAVE_RX_END) -- i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_STOP, &value); -- } -- } else if (status & BIT(IS_S_TX_UNDERRUN_SHIFT)) { -- /* Master read other than start */ -- i2c_slave_event(iproc_i2c->slave, -- I2C_SLAVE_READ_PROCESSED, &value); -+ I2C_SLAVE_READ_REQUESTED, -+ &value); -+ else -+ /* Master read other than start */ -+ i2c_slave_event(iproc_i2c->slave, -+ I2C_SLAVE_READ_PROCESSED, -+ &value); - - iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, value); -+ /* start transfer */ - val = BIT(S_CMD_START_BUSY_SHIFT); - iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); -+ -+ /* clear interrupt */ -+ iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, -+ BIT(IS_S_TX_UNDERRUN_SHIFT)); - } - -- /* Stop */ -+ /* Stop received from master in case of master read transaction */ - if (status & BIT(IS_S_START_BUSY_SHIFT)) { -- i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, &value); - /* - * Enable interrupt for TX FIFO becomes empty and - * less than PKT_LENGTH bytes were output on the SMBUS - */ -- val = iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET); -- val &= ~BIT(IE_S_TX_UNDERRUN_SHIFT); -- iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, val); -+ iproc_i2c->slave_int_mask &= ~BIT(IE_S_TX_UNDERRUN_SHIFT); -+ iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, -+ iproc_i2c->slave_int_mask); -+ -+ /* End of SMBUS for Master Read */ -+ val = BIT(S_TX_WR_STATUS_SHIFT); -+ iproc_i2c_wr_reg(iproc_i2c, S_TX_OFFSET, val); -+ -+ val = BIT(S_CMD_START_BUSY_SHIFT); -+ iproc_i2c_wr_reg(iproc_i2c, S_CMD_OFFSET, val); -+ -+ /* flush TX FIFOs */ -+ val = iproc_i2c_rd_reg(iproc_i2c, S_FIFO_CTRL_OFFSET); -+ val |= (BIT(S_FIFO_TX_FLUSH_SHIFT)); -+ iproc_i2c_wr_reg(iproc_i2c, S_FIFO_CTRL_OFFSET, val); -+ -+ i2c_slave_event(iproc_i2c->slave, I2C_SLAVE_STOP, &value); -+ -+ /* clear interrupt */ -+ iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, -+ BIT(IS_S_START_BUSY_SHIFT)); - } - -- /* clear interrupt status */ -- iproc_i2c_wr_reg(iproc_i2c, IS_OFFSET, status); -+ /* check slave transmit status only if slave is transmitting */ -+ if (!iproc_i2c->slave_rx_only) -+ bcm_iproc_i2c_check_slave_status(iproc_i2c); - -- bcm_iproc_i2c_check_slave_status(iproc_i2c); - return true; - } - -@@ -503,12 +623,17 @@ static void bcm_iproc_i2c_process_m_event(struct bcm_iproc_i2c_dev *iproc_i2c, - static irqreturn_t bcm_iproc_i2c_isr(int irq, void *data) - { - struct bcm_iproc_i2c_dev *iproc_i2c = data; -- u32 status = iproc_i2c_rd_reg(iproc_i2c, IS_OFFSET); -+ u32 slave_status; -+ u32 status; - bool ret; -- u32 sl_status = status & ISR_MASK_SLAVE; - -- if (sl_status) { -- ret = bcm_iproc_i2c_slave_isr(iproc_i2c, sl_status); -+ status = iproc_i2c_rd_reg(iproc_i2c, IS_OFFSET); -+ /* process only slave interrupt which are enabled */ -+ slave_status = status & iproc_i2c_rd_reg(iproc_i2c, IE_OFFSET) & -+ ISR_MASK_SLAVE; -+ -+ if (slave_status) { -+ ret = bcm_iproc_i2c_slave_isr(iproc_i2c, slave_status); - if (ret) - return IRQ_HANDLED; - else -@@ -1025,6 +1150,10 @@ static int bcm_iproc_i2c_reg_slave(struct i2c_client *slave) - return -EAFNOSUPPORT; - - iproc_i2c->slave = slave; -+ -+ tasklet_init(&iproc_i2c->slave_rx_tasklet, slave_rx_tasklet_fn, -+ (unsigned long)iproc_i2c); -+ - bcm_iproc_i2c_slave_init(iproc_i2c, false); - return 0; - } -@@ -1045,6 +1174,8 @@ static int bcm_iproc_i2c_unreg_slave(struct i2c_client *slave) - IE_S_ALL_INTERRUPT_SHIFT); - iproc_i2c_wr_reg(iproc_i2c, IE_OFFSET, tmp); - -+ tasklet_kill(&iproc_i2c->slave_rx_tasklet); -+ - /* Erase the slave address programmed */ - tmp = iproc_i2c_rd_reg(iproc_i2c, S_CFG_SMBUS_ADDR_OFFSET); - tmp &= ~BIT(S_CFG_EN_NIC_SMB_ADDR3_SHIFT); -diff --git a/drivers/i2c/busses/i2c-brcmstb.c b/drivers/i2c/busses/i2c-brcmstb.c -index 506991596b68d..5e89cd6b690ce 100644 ---- a/drivers/i2c/busses/i2c-brcmstb.c -+++ b/drivers/i2c/busses/i2c-brcmstb.c -@@ -316,7 +316,7 @@ static int brcmstb_send_i2c_cmd(struct brcmstb_i2c_dev *dev, - goto cmd_out; - } - -- if ((CMD_RD || CMD_WR) && -+ if ((cmd == CMD_RD || cmd == CMD_WR) && - bsc_readl(dev, iic_enable) & BSC_IIC_EN_NOACK_MASK) { - rc = -EREMOTEIO; - dev_dbg(dev->device, "controller received NOACK intr for %s\n", -diff --git a/drivers/i2c/busses/i2c-qcom-geni.c b/drivers/i2c/busses/i2c-qcom-geni.c -index 17abf60c94aeb..b56a427fb928f 100644 ---- a/drivers/i2c/busses/i2c-qcom-geni.c -+++ b/drivers/i2c/busses/i2c-qcom-geni.c -@@ -87,6 +87,9 @@ struct geni_i2c_dev { - u32 clk_freq_out; - const struct geni_i2c_clk_fld *clk_fld; - int suspended; -+ void *dma_buf; -+ size_t xfer_len; -+ dma_addr_t dma_addr; - }; - - struct geni_i2c_err_log { -@@ -350,14 +353,39 @@ static void geni_i2c_tx_fsm_rst(struct geni_i2c_dev *gi2c) - dev_err(gi2c->se.dev, "Timeout resetting TX_FSM\n"); - } - -+static void geni_i2c_rx_msg_cleanup(struct geni_i2c_dev *gi2c, -+ struct i2c_msg *cur) -+{ -+ gi2c->cur_rd = 0; -+ if (gi2c->dma_buf) { -+ if (gi2c->err) -+ geni_i2c_rx_fsm_rst(gi2c); -+ geni_se_rx_dma_unprep(&gi2c->se, gi2c->dma_addr, gi2c->xfer_len); -+ i2c_put_dma_safe_msg_buf(gi2c->dma_buf, cur, !gi2c->err); -+ } -+} -+ -+static void geni_i2c_tx_msg_cleanup(struct geni_i2c_dev *gi2c, -+ struct i2c_msg *cur) -+{ -+ gi2c->cur_wr = 0; -+ if (gi2c->dma_buf) { -+ if (gi2c->err) -+ geni_i2c_tx_fsm_rst(gi2c); -+ geni_se_tx_dma_unprep(&gi2c->se, gi2c->dma_addr, gi2c->xfer_len); -+ i2c_put_dma_safe_msg_buf(gi2c->dma_buf, cur, !gi2c->err); -+ } -+} -+ - static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, - u32 m_param) - { -- dma_addr_t rx_dma; -+ dma_addr_t rx_dma = 0; - unsigned long time_left; - void *dma_buf = NULL; - struct geni_se *se = &gi2c->se; - size_t len = msg->len; -+ struct i2c_msg *cur; - - if (!of_machine_is_compatible("lenovo,yoga-c630")) - dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); -@@ -374,19 +402,18 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, - geni_se_select_mode(se, GENI_SE_FIFO); - i2c_put_dma_safe_msg_buf(dma_buf, msg, false); - dma_buf = NULL; -+ } else { -+ gi2c->xfer_len = len; -+ gi2c->dma_addr = rx_dma; -+ gi2c->dma_buf = dma_buf; - } - -+ cur = gi2c->cur; - time_left = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT); - if (!time_left) - geni_i2c_abort_xfer(gi2c); - -- gi2c->cur_rd = 0; -- if (dma_buf) { -- if (gi2c->err) -- geni_i2c_rx_fsm_rst(gi2c); -- geni_se_rx_dma_unprep(se, rx_dma, len); -- i2c_put_dma_safe_msg_buf(dma_buf, msg, !gi2c->err); -- } -+ geni_i2c_rx_msg_cleanup(gi2c, cur); - - return gi2c->err; - } -@@ -394,11 +421,12 @@ static int geni_i2c_rx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, - static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, - u32 m_param) - { -- dma_addr_t tx_dma; -+ dma_addr_t tx_dma = 0; - unsigned long time_left; - void *dma_buf = NULL; - struct geni_se *se = &gi2c->se; - size_t len = msg->len; -+ struct i2c_msg *cur; - - if (!of_machine_is_compatible("lenovo,yoga-c630")) - dma_buf = i2c_get_dma_safe_msg_buf(msg, 32); -@@ -415,22 +443,21 @@ static int geni_i2c_tx_one_msg(struct geni_i2c_dev *gi2c, struct i2c_msg *msg, - geni_se_select_mode(se, GENI_SE_FIFO); - i2c_put_dma_safe_msg_buf(dma_buf, msg, false); - dma_buf = NULL; -+ } else { -+ gi2c->xfer_len = len; -+ gi2c->dma_addr = tx_dma; -+ gi2c->dma_buf = dma_buf; - } - - if (!dma_buf) /* Get FIFO IRQ */ - writel_relaxed(1, se->base + SE_GENI_TX_WATERMARK_REG); - -+ cur = gi2c->cur; - time_left = wait_for_completion_timeout(&gi2c->done, XFER_TIMEOUT); - if (!time_left) - geni_i2c_abort_xfer(gi2c); - -- gi2c->cur_wr = 0; -- if (dma_buf) { -- if (gi2c->err) -- geni_i2c_tx_fsm_rst(gi2c); -- geni_se_tx_dma_unprep(se, tx_dma, len); -- i2c_put_dma_safe_msg_buf(dma_buf, msg, !gi2c->err); -- } -+ geni_i2c_tx_msg_cleanup(gi2c, cur); - - return gi2c->err; - } -diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c -index fd7c84721b0de..c933c1c7ddd8e 100644 ---- a/drivers/infiniband/core/cm.c -+++ b/drivers/infiniband/core/cm.c -@@ -4336,7 +4336,7 @@ static void cm_add_one(struct ib_device *ib_device) - unsigned long flags; - int ret; - int count = 0; -- u8 i; -+ unsigned int i; - - cm_dev = kzalloc(struct_size(cm_dev, port, ib_device->phys_port_cnt), - GFP_KERNEL); -@@ -4348,7 +4348,7 @@ static void cm_add_one(struct ib_device *ib_device) - cm_dev->going_down = 0; - - set_bit(IB_MGMT_METHOD_SEND, reg_req.method_mask); -- for (i = 1; i <= ib_device->phys_port_cnt; i++) { -+ rdma_for_each_port (ib_device, i) { - if (!rdma_cap_ib_cm(ib_device, i)) - continue; - -@@ -4427,7 +4427,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data) - .clr_port_cap_mask = IB_PORT_CM_SUP - }; - unsigned long flags; -- int i; -+ unsigned int i; - - if (!cm_dev) - return; -@@ -4440,7 +4440,7 @@ static void cm_remove_one(struct ib_device *ib_device, void *client_data) - cm_dev->going_down = 1; - spin_unlock_irq(&cm.lock); - -- for (i = 1; i <= ib_device->phys_port_cnt; i++) { -+ rdma_for_each_port (ib_device, i) { - if (!rdma_cap_ib_cm(ib_device, i)) - continue; - -diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c -index da229eab59032..ad3a092b8b5c3 100644 ---- a/drivers/infiniband/core/user_mad.c -+++ b/drivers/infiniband/core/user_mad.c -@@ -379,6 +379,11 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf, - - mutex_lock(&file->mutex); - -+ if (file->agents_dead) { -+ mutex_unlock(&file->mutex); -+ return -EIO; -+ } -+ - while (list_empty(&file->recv_list)) { - mutex_unlock(&file->mutex); - -@@ -392,6 +397,11 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf, - mutex_lock(&file->mutex); - } - -+ if (file->agents_dead) { -+ mutex_unlock(&file->mutex); -+ return -EIO; -+ } -+ - packet = list_entry(file->recv_list.next, struct ib_umad_packet, list); - list_del(&packet->list); - -@@ -524,7 +534,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf, - - agent = __get_agent(file, packet->mad.hdr.id); - if (!agent) { -- ret = -EINVAL; -+ ret = -EIO; - goto err_up; - } - -@@ -653,10 +663,14 @@ static __poll_t ib_umad_poll(struct file *filp, struct poll_table_struct *wait) - /* we will always be able to post a MAD send */ - __poll_t mask = EPOLLOUT | EPOLLWRNORM; - -+ mutex_lock(&file->mutex); - poll_wait(filp, &file->recv_wait, wait); - - if (!list_empty(&file->recv_list)) - mask |= EPOLLIN | EPOLLRDNORM; -+ if (file->agents_dead) -+ mask = EPOLLERR; -+ mutex_unlock(&file->mutex); - - return mask; - } -@@ -1336,6 +1350,7 @@ static void ib_umad_kill_port(struct ib_umad_port *port) - list_for_each_entry(file, &port->file_list, port_list) { - mutex_lock(&file->mutex); - file->agents_dead = 1; -+ wake_up_interruptible(&file->recv_wait); - mutex_unlock(&file->mutex); - - for (id = 0; id < IB_UMAD_MAX_AGENTS; ++id) -diff --git a/drivers/infiniband/hw/hns/hns_roce_device.h b/drivers/infiniband/hw/hns/hns_roce_device.h -index e36d315690819..3e68ba9dab45d 100644 ---- a/drivers/infiniband/hw/hns/hns_roce_device.h -+++ b/drivers/infiniband/hw/hns/hns_roce_device.h -@@ -657,7 +657,7 @@ struct hns_roce_qp { - u8 rdb_en; - u8 sdb_en; - u32 doorbell_qpn; -- u32 sq_signal_bits; -+ enum ib_sig_type sq_signal_bits; - struct hns_roce_wq sq; - - struct ib_umem *umem; -diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c -index e8933daab4995..d01e3222c00cf 100644 ---- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c -+++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c -@@ -1009,7 +1009,7 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, - u32 timeout = 0; - int handle = 0; - u16 desc_ret; -- int ret = 0; -+ int ret; - int ntc; - - spin_lock_bh(&csq->lock); -@@ -1054,15 +1054,14 @@ static int __hns_roce_cmq_send(struct hns_roce_dev *hr_dev, - if (hns_roce_cmq_csq_done(hr_dev)) { - complete = true; - handle = 0; -+ ret = 0; - while (handle < num) { - /* get the result of hardware write back */ - desc_to_use = &csq->desc[ntc]; - desc[handle] = *desc_to_use; - dev_dbg(hr_dev->dev, "Get cmq desc:\n"); - desc_ret = le16_to_cpu(desc[handle].retval); -- if (desc_ret == CMD_EXEC_SUCCESS) -- ret = 0; -- else -+ if (unlikely(desc_ret != CMD_EXEC_SUCCESS)) - ret = -EIO; - priv->cmq.last_status = desc_ret; - ntc++; -diff --git a/drivers/infiniband/hw/hns/hns_roce_main.c b/drivers/infiniband/hw/hns/hns_roce_main.c -index b5d196c119eec..f23a341400c06 100644 ---- a/drivers/infiniband/hw/hns/hns_roce_main.c -+++ b/drivers/infiniband/hw/hns/hns_roce_main.c -@@ -848,8 +848,7 @@ static int hns_roce_setup_hca(struct hns_roce_dev *hr_dev) - return 0; - - err_qp_table_free: -- if (hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_SRQ) -- hns_roce_cleanup_qp_table(hr_dev); -+ hns_roce_cleanup_qp_table(hr_dev); - - err_cq_table_free: - hns_roce_cleanup_cq_table(hr_dev); -diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c -index fd75a9043bf15..4d6f25fdcc0ef 100644 ---- a/drivers/infiniband/hw/mlx5/devx.c -+++ b/drivers/infiniband/hw/mlx5/devx.c -@@ -1118,7 +1118,9 @@ static void devx_obj_build_destroy_cmd(void *in, void *out, void *din, - MLX5_SET(general_obj_in_cmd_hdr, din, opcode, MLX5_CMD_OP_DESTROY_RQT); - break; - case MLX5_CMD_OP_CREATE_TIR: -- MLX5_SET(general_obj_in_cmd_hdr, din, opcode, MLX5_CMD_OP_DESTROY_TIR); -+ *obj_id = MLX5_GET(create_tir_out, out, tirn); -+ MLX5_SET(destroy_tir_in, din, opcode, MLX5_CMD_OP_DESTROY_TIR); -+ MLX5_SET(destroy_tir_in, din, tirn, *obj_id); - break; - case MLX5_CMD_OP_CREATE_TIS: - MLX5_SET(general_obj_in_cmd_hdr, din, opcode, MLX5_CMD_OP_DESTROY_TIS); -diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c -index c9e583c05ef27..e2656b68ec222 100644 ---- a/drivers/infiniband/hw/mlx5/main.c -+++ b/drivers/infiniband/hw/mlx5/main.c -@@ -6213,8 +6213,7 @@ static int mlx5_ib_stage_init_init(struct mlx5_ib_dev *dev) - - err_mp: - mlx5_ib_cleanup_multiport_master(dev); -- -- return -ENOMEM; -+ return err; - } - - static int mlx5_ib_stage_flow_db_init(struct mlx5_ib_dev *dev) -diff --git a/drivers/infiniband/sw/rxe/rxe_net.c b/drivers/infiniband/sw/rxe/rxe_net.c -index 312c2fc961c00..d411356828911 100644 ---- a/drivers/infiniband/sw/rxe/rxe_net.c -+++ b/drivers/infiniband/sw/rxe/rxe_net.c -@@ -453,6 +453,11 @@ int rxe_send(struct rxe_pkt_info *pkt, struct sk_buff *skb) - - void rxe_loopback(struct sk_buff *skb) - { -+ if (skb->protocol == htons(ETH_P_IP)) -+ skb_pull(skb, sizeof(struct iphdr)); -+ else -+ skb_pull(skb, sizeof(struct ipv6hdr)); -+ - rxe_rcv(skb); - } - -diff --git a/drivers/infiniband/sw/rxe/rxe_recv.c b/drivers/infiniband/sw/rxe/rxe_recv.c -index 9bfb98056fc2a..369ba76f1605e 100644 ---- a/drivers/infiniband/sw/rxe/rxe_recv.c -+++ b/drivers/infiniband/sw/rxe/rxe_recv.c -@@ -36,21 +36,26 @@ - #include "rxe.h" - #include "rxe_loc.h" - -+/* check that QP matches packet opcode type and is in a valid state */ - static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, - struct rxe_qp *qp) - { -+ unsigned int pkt_type; -+ - if (unlikely(!qp->valid)) - goto err1; - -+ pkt_type = pkt->opcode & 0xe0; -+ - switch (qp_type(qp)) { - case IB_QPT_RC: -- if (unlikely((pkt->opcode & IB_OPCODE_RC) != 0)) { -+ if (unlikely(pkt_type != IB_OPCODE_RC)) { - pr_warn_ratelimited("bad qp type\n"); - goto err1; - } - break; - case IB_QPT_UC: -- if (unlikely(!(pkt->opcode & IB_OPCODE_UC))) { -+ if (unlikely(pkt_type != IB_OPCODE_UC)) { - pr_warn_ratelimited("bad qp type\n"); - goto err1; - } -@@ -58,7 +63,7 @@ static int check_type_state(struct rxe_dev *rxe, struct rxe_pkt_info *pkt, - case IB_QPT_UD: - case IB_QPT_SMI: - case IB_QPT_GSI: -- if (unlikely(!(pkt->opcode & IB_OPCODE_UD))) { -+ if (unlikely(pkt_type != IB_OPCODE_UD)) { - pr_warn_ratelimited("bad qp type\n"); - goto err1; - } -@@ -300,7 +305,6 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) - - list_for_each_entry(mce, &mcg->qp_list, qp_list) { - qp = mce->qp; -- pkt = SKB_TO_PKT(skb); - - /* validate qp for incoming packet */ - err = check_type_state(rxe, pkt, qp); -@@ -312,12 +316,18 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) - continue; - - /* for all but the last qp create a new clone of the -- * skb and pass to the qp. -+ * skb and pass to the qp. If an error occurs in the -+ * checks for the last qp in the list we need to -+ * free the skb since it hasn't been passed on to -+ * rxe_rcv_pkt() which would free it later. - */ -- if (mce->qp_list.next != &mcg->qp_list) -+ if (mce->qp_list.next != &mcg->qp_list) { - per_qp_skb = skb_clone(skb, GFP_ATOMIC); -- else -+ } else { - per_qp_skb = skb; -+ /* show we have consumed the skb */ -+ skb = NULL; -+ } - - if (unlikely(!per_qp_skb)) - continue; -@@ -332,9 +342,8 @@ static void rxe_rcv_mcast_pkt(struct rxe_dev *rxe, struct sk_buff *skb) - - rxe_drop_ref(mcg); /* drop ref from rxe_pool_get_key. */ - -- return; -- - err1: -+ /* free skb if not consumed */ - kfree_skb(skb); - } - -diff --git a/drivers/infiniband/sw/siw/siw.h b/drivers/infiniband/sw/siw/siw.h -index dba4535494abd..4d8bc995b4503 100644 ---- a/drivers/infiniband/sw/siw/siw.h -+++ b/drivers/infiniband/sw/siw/siw.h -@@ -667,7 +667,7 @@ static inline struct siw_sqe *orq_get_free(struct siw_qp *qp) - { - struct siw_sqe *orq_e = orq_get_tail(qp); - -- if (orq_e && READ_ONCE(orq_e->flags) == 0) -+ if (READ_ONCE(orq_e->flags) == 0) - return orq_e; - - return NULL; -diff --git a/drivers/infiniband/sw/siw/siw_main.c b/drivers/infiniband/sw/siw/siw_main.c -index fb66d67572787..dbbf8c6c16d38 100644 ---- a/drivers/infiniband/sw/siw/siw_main.c -+++ b/drivers/infiniband/sw/siw/siw_main.c -@@ -134,7 +134,7 @@ static struct { - - static int siw_init_cpulist(void) - { -- int i, num_nodes = num_possible_nodes(); -+ int i, num_nodes = nr_node_ids; - - memset(siw_tx_thread, 0, sizeof(siw_tx_thread)); - -diff --git a/drivers/infiniband/sw/siw/siw_qp.c b/drivers/infiniband/sw/siw/siw_qp.c -index b4317480cee74..5927ac5923dd8 100644 ---- a/drivers/infiniband/sw/siw/siw_qp.c -+++ b/drivers/infiniband/sw/siw/siw_qp.c -@@ -199,26 +199,26 @@ void siw_qp_llp_write_space(struct sock *sk) - - static int siw_qp_readq_init(struct siw_qp *qp, int irq_size, int orq_size) - { -- irq_size = roundup_pow_of_two(irq_size); -- orq_size = roundup_pow_of_two(orq_size); -- -- qp->attrs.irq_size = irq_size; -- qp->attrs.orq_size = orq_size; -- -- qp->irq = vzalloc(irq_size * sizeof(struct siw_sqe)); -- if (!qp->irq) { -- siw_dbg_qp(qp, "irq malloc for %d failed\n", irq_size); -- qp->attrs.irq_size = 0; -- return -ENOMEM; -+ if (irq_size) { -+ irq_size = roundup_pow_of_two(irq_size); -+ qp->irq = vzalloc(irq_size * sizeof(struct siw_sqe)); -+ if (!qp->irq) { -+ qp->attrs.irq_size = 0; -+ return -ENOMEM; -+ } - } -- qp->orq = vzalloc(orq_size * sizeof(struct siw_sqe)); -- if (!qp->orq) { -- siw_dbg_qp(qp, "orq malloc for %d failed\n", orq_size); -- qp->attrs.orq_size = 0; -- qp->attrs.irq_size = 0; -- vfree(qp->irq); -- return -ENOMEM; -+ if (orq_size) { -+ orq_size = roundup_pow_of_two(orq_size); -+ qp->orq = vzalloc(orq_size * sizeof(struct siw_sqe)); -+ if (!qp->orq) { -+ qp->attrs.orq_size = 0; -+ qp->attrs.irq_size = 0; -+ vfree(qp->irq); -+ return -ENOMEM; -+ } - } -+ qp->attrs.irq_size = irq_size; -+ qp->attrs.orq_size = orq_size; - siw_dbg_qp(qp, "ORD %d, IRD %d\n", orq_size, irq_size); - return 0; - } -@@ -288,13 +288,14 @@ int siw_qp_mpa_rts(struct siw_qp *qp, enum mpa_v2_ctrl ctrl) - if (ctrl & MPA_V2_RDMA_WRITE_RTR) - wqe->sqe.opcode = SIW_OP_WRITE; - else if (ctrl & MPA_V2_RDMA_READ_RTR) { -- struct siw_sqe *rreq; -+ struct siw_sqe *rreq = NULL; - - wqe->sqe.opcode = SIW_OP_READ; - - spin_lock(&qp->orq_lock); - -- rreq = orq_get_free(qp); -+ if (qp->attrs.orq_size) -+ rreq = orq_get_free(qp); - if (rreq) { - siw_read_to_orq(rreq, &wqe->sqe); - qp->orq_put++; -@@ -877,135 +878,88 @@ void siw_read_to_orq(struct siw_sqe *rreq, struct siw_sqe *sqe) - rreq->num_sge = 1; - } - --/* -- * Must be called with SQ locked. -- * To avoid complete SQ starvation by constant inbound READ requests, -- * the active IRQ will not be served after qp->irq_burst, if the -- * SQ has pending work. -- */ --int siw_activate_tx(struct siw_qp *qp) -+static int siw_activate_tx_from_sq(struct siw_qp *qp) - { -- struct siw_sqe *irqe, *sqe; -+ struct siw_sqe *sqe; - struct siw_wqe *wqe = tx_wqe(qp); - int rv = 1; - -- irqe = &qp->irq[qp->irq_get % qp->attrs.irq_size]; -- -- if (irqe->flags & SIW_WQE_VALID) { -- sqe = sq_get_next(qp); -- -- /* -- * Avoid local WQE processing starvation in case -- * of constant inbound READ request stream -- */ -- if (sqe && ++qp->irq_burst >= SIW_IRQ_MAXBURST_SQ_ACTIVE) { -- qp->irq_burst = 0; -- goto skip_irq; -- } -- memset(wqe->mem, 0, sizeof(*wqe->mem) * SIW_MAX_SGE); -- wqe->wr_status = SIW_WR_QUEUED; -- -- /* start READ RESPONSE */ -- wqe->sqe.opcode = SIW_OP_READ_RESPONSE; -- wqe->sqe.flags = 0; -- if (irqe->num_sge) { -- wqe->sqe.num_sge = 1; -- wqe->sqe.sge[0].length = irqe->sge[0].length; -- wqe->sqe.sge[0].laddr = irqe->sge[0].laddr; -- wqe->sqe.sge[0].lkey = irqe->sge[0].lkey; -- } else { -- wqe->sqe.num_sge = 0; -- } -- -- /* Retain original RREQ's message sequence number for -- * potential error reporting cases. -- */ -- wqe->sqe.sge[1].length = irqe->sge[1].length; -- -- wqe->sqe.rkey = irqe->rkey; -- wqe->sqe.raddr = irqe->raddr; -+ sqe = sq_get_next(qp); -+ if (!sqe) -+ return 0; - -- wqe->processed = 0; -- qp->irq_get++; -+ memset(wqe->mem, 0, sizeof(*wqe->mem) * SIW_MAX_SGE); -+ wqe->wr_status = SIW_WR_QUEUED; - -- /* mark current IRQ entry free */ -- smp_store_mb(irqe->flags, 0); -+ /* First copy SQE to kernel private memory */ -+ memcpy(&wqe->sqe, sqe, sizeof(*sqe)); - -+ if (wqe->sqe.opcode >= SIW_NUM_OPCODES) { -+ rv = -EINVAL; - goto out; - } -- sqe = sq_get_next(qp); -- if (sqe) { --skip_irq: -- memset(wqe->mem, 0, sizeof(*wqe->mem) * SIW_MAX_SGE); -- wqe->wr_status = SIW_WR_QUEUED; -- -- /* First copy SQE to kernel private memory */ -- memcpy(&wqe->sqe, sqe, sizeof(*sqe)); -- -- if (wqe->sqe.opcode >= SIW_NUM_OPCODES) { -+ if (wqe->sqe.flags & SIW_WQE_INLINE) { -+ if (wqe->sqe.opcode != SIW_OP_SEND && -+ wqe->sqe.opcode != SIW_OP_WRITE) { - rv = -EINVAL; - goto out; - } -- if (wqe->sqe.flags & SIW_WQE_INLINE) { -- if (wqe->sqe.opcode != SIW_OP_SEND && -- wqe->sqe.opcode != SIW_OP_WRITE) { -- rv = -EINVAL; -- goto out; -- } -- if (wqe->sqe.sge[0].length > SIW_MAX_INLINE) { -- rv = -EINVAL; -- goto out; -- } -- wqe->sqe.sge[0].laddr = (uintptr_t)&wqe->sqe.sge[1]; -- wqe->sqe.sge[0].lkey = 0; -- wqe->sqe.num_sge = 1; -+ if (wqe->sqe.sge[0].length > SIW_MAX_INLINE) { -+ rv = -EINVAL; -+ goto out; - } -- if (wqe->sqe.flags & SIW_WQE_READ_FENCE) { -- /* A READ cannot be fenced */ -- if (unlikely(wqe->sqe.opcode == SIW_OP_READ || -- wqe->sqe.opcode == -- SIW_OP_READ_LOCAL_INV)) { -- siw_dbg_qp(qp, "cannot fence read\n"); -- rv = -EINVAL; -- goto out; -- } -- spin_lock(&qp->orq_lock); -+ wqe->sqe.sge[0].laddr = (uintptr_t)&wqe->sqe.sge[1]; -+ wqe->sqe.sge[0].lkey = 0; -+ wqe->sqe.num_sge = 1; -+ } -+ if (wqe->sqe.flags & SIW_WQE_READ_FENCE) { -+ /* A READ cannot be fenced */ -+ if (unlikely(wqe->sqe.opcode == SIW_OP_READ || -+ wqe->sqe.opcode == -+ SIW_OP_READ_LOCAL_INV)) { -+ siw_dbg_qp(qp, "cannot fence read\n"); -+ rv = -EINVAL; -+ goto out; -+ } -+ spin_lock(&qp->orq_lock); - -- if (!siw_orq_empty(qp)) { -- qp->tx_ctx.orq_fence = 1; -- rv = 0; -- } -- spin_unlock(&qp->orq_lock); -+ if (qp->attrs.orq_size && !siw_orq_empty(qp)) { -+ qp->tx_ctx.orq_fence = 1; -+ rv = 0; -+ } -+ spin_unlock(&qp->orq_lock); - -- } else if (wqe->sqe.opcode == SIW_OP_READ || -- wqe->sqe.opcode == SIW_OP_READ_LOCAL_INV) { -- struct siw_sqe *rreq; -+ } else if (wqe->sqe.opcode == SIW_OP_READ || -+ wqe->sqe.opcode == SIW_OP_READ_LOCAL_INV) { -+ struct siw_sqe *rreq; - -- wqe->sqe.num_sge = 1; -+ if (unlikely(!qp->attrs.orq_size)) { -+ /* We negotiated not to send READ req's */ -+ rv = -EINVAL; -+ goto out; -+ } -+ wqe->sqe.num_sge = 1; - -- spin_lock(&qp->orq_lock); -+ spin_lock(&qp->orq_lock); - -- rreq = orq_get_free(qp); -- if (rreq) { -- /* -- * Make an immediate copy in ORQ to be ready -- * to process loopback READ reply -- */ -- siw_read_to_orq(rreq, &wqe->sqe); -- qp->orq_put++; -- } else { -- qp->tx_ctx.orq_fence = 1; -- rv = 0; -- } -- spin_unlock(&qp->orq_lock); -+ rreq = orq_get_free(qp); -+ if (rreq) { -+ /* -+ * Make an immediate copy in ORQ to be ready -+ * to process loopback READ reply -+ */ -+ siw_read_to_orq(rreq, &wqe->sqe); -+ qp->orq_put++; -+ } else { -+ qp->tx_ctx.orq_fence = 1; -+ rv = 0; - } -- -- /* Clear SQE, can be re-used by application */ -- smp_store_mb(sqe->flags, 0); -- qp->sq_get++; -- } else { -- rv = 0; -+ spin_unlock(&qp->orq_lock); - } -+ -+ /* Clear SQE, can be re-used by application */ -+ smp_store_mb(sqe->flags, 0); -+ qp->sq_get++; - out: - if (unlikely(rv < 0)) { - siw_dbg_qp(qp, "error %d\n", rv); -@@ -1014,6 +968,65 @@ out: - return rv; - } - -+/* -+ * Must be called with SQ locked. -+ * To avoid complete SQ starvation by constant inbound READ requests, -+ * the active IRQ will not be served after qp->irq_burst, if the -+ * SQ has pending work. -+ */ -+int siw_activate_tx(struct siw_qp *qp) -+{ -+ struct siw_sqe *irqe; -+ struct siw_wqe *wqe = tx_wqe(qp); -+ -+ if (!qp->attrs.irq_size) -+ return siw_activate_tx_from_sq(qp); -+ -+ irqe = &qp->irq[qp->irq_get % qp->attrs.irq_size]; -+ -+ if (!(irqe->flags & SIW_WQE_VALID)) -+ return siw_activate_tx_from_sq(qp); -+ -+ /* -+ * Avoid local WQE processing starvation in case -+ * of constant inbound READ request stream -+ */ -+ if (sq_get_next(qp) && ++qp->irq_burst >= SIW_IRQ_MAXBURST_SQ_ACTIVE) { -+ qp->irq_burst = 0; -+ return siw_activate_tx_from_sq(qp); -+ } -+ memset(wqe->mem, 0, sizeof(*wqe->mem) * SIW_MAX_SGE); -+ wqe->wr_status = SIW_WR_QUEUED; -+ -+ /* start READ RESPONSE */ -+ wqe->sqe.opcode = SIW_OP_READ_RESPONSE; -+ wqe->sqe.flags = 0; -+ if (irqe->num_sge) { -+ wqe->sqe.num_sge = 1; -+ wqe->sqe.sge[0].length = irqe->sge[0].length; -+ wqe->sqe.sge[0].laddr = irqe->sge[0].laddr; -+ wqe->sqe.sge[0].lkey = irqe->sge[0].lkey; -+ } else { -+ wqe->sqe.num_sge = 0; -+ } -+ -+ /* Retain original RREQ's message sequence number for -+ * potential error reporting cases. -+ */ -+ wqe->sqe.sge[1].length = irqe->sge[1].length; -+ -+ wqe->sqe.rkey = irqe->rkey; -+ wqe->sqe.raddr = irqe->raddr; -+ -+ wqe->processed = 0; -+ qp->irq_get++; -+ -+ /* mark current IRQ entry free */ -+ smp_store_mb(irqe->flags, 0); -+ -+ return 1; -+} -+ - /* - * Check if current CQ state qualifies for calling CQ completion - * handler. Must be called with CQ lock held. -diff --git a/drivers/infiniband/sw/siw/siw_qp_rx.c b/drivers/infiniband/sw/siw/siw_qp_rx.c -index 0520e70084f97..c7c38f7fd29d6 100644 ---- a/drivers/infiniband/sw/siw/siw_qp_rx.c -+++ b/drivers/infiniband/sw/siw/siw_qp_rx.c -@@ -680,6 +680,10 @@ static int siw_init_rresp(struct siw_qp *qp, struct siw_rx_stream *srx) - } - spin_lock_irqsave(&qp->sq_lock, flags); - -+ if (unlikely(!qp->attrs.irq_size)) { -+ run_sq = 0; -+ goto error_irq; -+ } - if (tx_work->wr_status == SIW_WR_IDLE) { - /* - * immediately schedule READ response w/o -@@ -712,8 +716,9 @@ static int siw_init_rresp(struct siw_qp *qp, struct siw_rx_stream *srx) - /* RRESP now valid as current TX wqe or placed into IRQ */ - smp_store_mb(resp->flags, SIW_WQE_VALID); - } else { -- pr_warn("siw: [QP %u]: irq %d exceeded %d\n", qp_id(qp), -- qp->irq_put % qp->attrs.irq_size, qp->attrs.irq_size); -+error_irq: -+ pr_warn("siw: [QP %u]: IRQ exceeded or null, size %d\n", -+ qp_id(qp), qp->attrs.irq_size); - - siw_init_terminate(qp, TERM_ERROR_LAYER_RDMAP, - RDMAP_ETYPE_REMOTE_OPERATION, -@@ -740,6 +745,9 @@ static int siw_orqe_start_rx(struct siw_qp *qp) - struct siw_sqe *orqe; - struct siw_wqe *wqe = NULL; - -+ if (unlikely(!qp->attrs.orq_size)) -+ return -EPROTO; -+ - /* make sure ORQ indices are current */ - smp_mb(); - -@@ -796,8 +804,8 @@ int siw_proc_rresp(struct siw_qp *qp) - */ - rv = siw_orqe_start_rx(qp); - if (rv) { -- pr_warn("siw: [QP %u]: ORQ empty at idx %d\n", -- qp_id(qp), qp->orq_get % qp->attrs.orq_size); -+ pr_warn("siw: [QP %u]: ORQ empty, size %d\n", -+ qp_id(qp), qp->attrs.orq_size); - goto error_term; - } - rv = siw_rresp_check_ntoh(srx, frx); -@@ -1290,11 +1298,13 @@ static int siw_rdmap_complete(struct siw_qp *qp, int error) - wc_status); - siw_wqe_put_mem(wqe, SIW_OP_READ); - -- if (!error) -+ if (!error) { - rv = siw_check_tx_fence(qp); -- else -- /* Disable current ORQ eleement */ -- WRITE_ONCE(orq_get_current(qp)->flags, 0); -+ } else { -+ /* Disable current ORQ element */ -+ if (qp->attrs.orq_size) -+ WRITE_ONCE(orq_get_current(qp)->flags, 0); -+ } - break; - - case RDMAP_RDMA_READ_REQ: -diff --git a/drivers/infiniband/sw/siw/siw_qp_tx.c b/drivers/infiniband/sw/siw/siw_qp_tx.c -index e7cd04eda04ac..424918eb1cd4a 100644 ---- a/drivers/infiniband/sw/siw/siw_qp_tx.c -+++ b/drivers/infiniband/sw/siw/siw_qp_tx.c -@@ -1107,8 +1107,8 @@ next_wqe: - /* - * RREQ may have already been completed by inbound RRESP! - */ -- if (tx_type == SIW_OP_READ || -- tx_type == SIW_OP_READ_LOCAL_INV) { -+ if ((tx_type == SIW_OP_READ || -+ tx_type == SIW_OP_READ_LOCAL_INV) && qp->attrs.orq_size) { - /* Cleanup pending entry in ORQ */ - qp->orq_put--; - qp->orq[qp->orq_put % qp->attrs.orq_size].flags = 0; -diff --git a/drivers/infiniband/sw/siw/siw_verbs.c b/drivers/infiniband/sw/siw/siw_verbs.c -index 1b1a40db529c6..2c3704f0f10fa 100644 ---- a/drivers/infiniband/sw/siw/siw_verbs.c -+++ b/drivers/infiniband/sw/siw/siw_verbs.c -@@ -387,13 +387,23 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, - if (rv) - goto err_out; - -+ num_sqe = attrs->cap.max_send_wr; -+ num_rqe = attrs->cap.max_recv_wr; -+ - /* All queue indices are derived from modulo operations - * on a free running 'get' (consumer) and 'put' (producer) - * unsigned counter. Having queue sizes at power of two - * avoids handling counter wrap around. - */ -- num_sqe = roundup_pow_of_two(attrs->cap.max_send_wr); -- num_rqe = roundup_pow_of_two(attrs->cap.max_recv_wr); -+ if (num_sqe) -+ num_sqe = roundup_pow_of_two(num_sqe); -+ else { -+ /* Zero sized SQ is not supported */ -+ rv = -EINVAL; -+ goto err_out; -+ } -+ if (num_rqe) -+ num_rqe = roundup_pow_of_two(num_rqe); - - if (qp->kernel_verbs) - qp->sendq = vzalloc(num_sqe * sizeof(struct siw_sqe)); -@@ -401,7 +411,6 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, - qp->sendq = vmalloc_user(num_sqe * sizeof(struct siw_sqe)); - - if (qp->sendq == NULL) { -- siw_dbg(base_dev, "SQ size %d alloc failed\n", num_sqe); - rv = -ENOMEM; - goto err_out_xa; - } -@@ -434,7 +443,6 @@ struct ib_qp *siw_create_qp(struct ib_pd *pd, - vmalloc_user(num_rqe * sizeof(struct siw_rqe)); - - if (qp->recvq == NULL) { -- siw_dbg(base_dev, "RQ size %d alloc failed\n", num_rqe); - rv = -ENOMEM; - goto err_out_xa; - } -@@ -982,9 +990,9 @@ int siw_post_receive(struct ib_qp *base_qp, const struct ib_recv_wr *wr, - unsigned long flags; - int rv = 0; - -- if (qp->srq) { -+ if (qp->srq || qp->attrs.rq_size == 0) { - *bad_wr = wr; -- return -EOPNOTSUPP; /* what else from errno.h? */ -+ return -EINVAL; - } - if (!qp->kernel_verbs) { - siw_dbg_qp(qp, "no kernel post_recv for user mapped sq\n"); -diff --git a/drivers/input/joydev.c b/drivers/input/joydev.c -index a2b5fbba2d3b3..430dc69750048 100644 ---- a/drivers/input/joydev.c -+++ b/drivers/input/joydev.c -@@ -456,7 +456,7 @@ static int joydev_handle_JSIOCSAXMAP(struct joydev *joydev, - if (IS_ERR(abspam)) - return PTR_ERR(abspam); - -- for (i = 0; i < joydev->nabs; i++) { -+ for (i = 0; i < len && i < joydev->nabs; i++) { - if (abspam[i] > ABS_MAX) { - retval = -EINVAL; - goto out; -@@ -480,6 +480,9 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev, - int i; - int retval = 0; - -+ if (len % sizeof(*keypam)) -+ return -EINVAL; -+ - len = min(len, sizeof(joydev->keypam)); - - /* Validate the map. */ -@@ -487,7 +490,7 @@ static int joydev_handle_JSIOCSBTNMAP(struct joydev *joydev, - if (IS_ERR(keypam)) - return PTR_ERR(keypam); - -- for (i = 0; i < joydev->nkey; i++) { -+ for (i = 0; i < (len / 2) && i < joydev->nkey; i++) { - if (keypam[i] > KEY_MAX || keypam[i] < BTN_MISC) { - retval = -EINVAL; - goto out; -diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c -index 3d004ca76b6ed..e5f1e3cf9179f 100644 ---- a/drivers/input/joystick/xpad.c -+++ b/drivers/input/joystick/xpad.c -@@ -305,6 +305,7 @@ static const struct xpad_device { - { 0x1bad, 0xfd00, "Razer Onza TE", 0, XTYPE_XBOX360 }, - { 0x1bad, 0xfd01, "Razer Onza", 0, XTYPE_XBOX360 }, - { 0x20d6, 0x2001, "BDA Xbox Series X Wired Controller", 0, XTYPE_XBOXONE }, -+ { 0x20d6, 0x2009, "PowerA Enhanced Wired Controller for Xbox Series X|S", 0, XTYPE_XBOXONE }, - { 0x20d6, 0x281f, "PowerA Wired Controller For Xbox 360", 0, XTYPE_XBOX360 }, - { 0x2e24, 0x0652, "Hyperkin Duke X-Box One pad", 0, XTYPE_XBOXONE }, - { 0x24c6, 0x5000, "Razer Atrox Arcade Stick", MAP_TRIGGERS_TO_BUTTONS, XTYPE_XBOX360 }, -diff --git a/drivers/input/serio/i8042-x86ia64io.h b/drivers/input/serio/i8042-x86ia64io.h -index b7dbcbac3a1a5..e7346c5f4738a 100644 ---- a/drivers/input/serio/i8042-x86ia64io.h -+++ b/drivers/input/serio/i8042-x86ia64io.h -@@ -588,6 +588,10 @@ static const struct dmi_system_id i8042_dmi_noselftest_table[] = { - DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), - DMI_MATCH(DMI_CHASSIS_TYPE, "10"), /* Notebook */ - }, -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), -+ DMI_MATCH(DMI_CHASSIS_TYPE, "31"), /* Convertible Notebook */ -+ }, - }, - { } - }; -diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c -index d6772a2c2d096..e396857cb4c1b 100644 ---- a/drivers/input/touchscreen/elo.c -+++ b/drivers/input/touchscreen/elo.c -@@ -341,8 +341,10 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) - switch (elo->id) { - - case 0: /* 10-byte protocol */ -- if (elo_setup_10(elo)) -+ if (elo_setup_10(elo)) { -+ err = -EIO; - goto fail3; -+ } - - break; - -diff --git a/drivers/input/touchscreen/raydium_i2c_ts.c b/drivers/input/touchscreen/raydium_i2c_ts.c -index fe245439adee0..2c67f8eacc7c5 100644 ---- a/drivers/input/touchscreen/raydium_i2c_ts.c -+++ b/drivers/input/touchscreen/raydium_i2c_ts.c -@@ -410,6 +410,7 @@ static int raydium_i2c_write_object(struct i2c_client *client, - enum raydium_bl_ack state) - { - int error; -+ static const u8 cmd[] = { 0xFF, 0x39 }; - - error = raydium_i2c_send(client, RM_CMD_BOOT_WRT, data, len); - if (error) { -@@ -418,7 +419,7 @@ static int raydium_i2c_write_object(struct i2c_client *client, - return error; - } - -- error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, NULL, 0); -+ error = raydium_i2c_send(client, RM_CMD_BOOT_ACK, cmd, sizeof(cmd)); - if (error) { - dev_err(&client->dev, "Ack obj command failed: %d\n", error); - return error; -diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c -index 2e2ea5719c90e..902522df03592 100644 ---- a/drivers/input/touchscreen/sur40.c -+++ b/drivers/input/touchscreen/sur40.c -@@ -774,6 +774,7 @@ static int sur40_probe(struct usb_interface *interface, - dev_err(&interface->dev, - "Unable to register video controls."); - v4l2_ctrl_handler_free(&sur40->hdl); -+ error = sur40->hdl.error; - goto err_unreg_v4l2; - } - -diff --git a/drivers/md/bcache/bcache.h b/drivers/md/bcache/bcache.h -index 859567ad3db4e..36de6f7ddf221 100644 ---- a/drivers/md/bcache/bcache.h -+++ b/drivers/md/bcache/bcache.h -@@ -986,6 +986,7 @@ void bch_write_bdev_super(struct cached_dev *dc, struct closure *parent); - - extern struct workqueue_struct *bcache_wq; - extern struct workqueue_struct *bch_journal_wq; -+extern struct workqueue_struct *bch_flush_wq; - extern struct mutex bch_register_lock; - extern struct list_head bch_cache_sets; - -@@ -1027,5 +1028,7 @@ void bch_debug_exit(void); - void bch_debug_init(void); - void bch_request_exit(void); - int bch_request_init(void); -+void bch_btree_exit(void); -+int bch_btree_init(void); - - #endif /* _BCACHE_H */ -diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c -index 8d06105fc9ff5..5a33910aea788 100644 ---- a/drivers/md/bcache/btree.c -+++ b/drivers/md/bcache/btree.c -@@ -99,6 +99,8 @@ - #define PTR_HASH(c, k) \ - (((k)->ptr[0] >> c->bucket_bits) | PTR_GEN(k, 0)) - -+static struct workqueue_struct *btree_io_wq; -+ - #define insert_lock(s, b) ((b)->level <= (s)->lock) - - /* -@@ -366,7 +368,7 @@ static void __btree_node_write_done(struct closure *cl) - btree_complete_write(b, w); - - if (btree_node_dirty(b)) -- schedule_delayed_work(&b->work, 30 * HZ); -+ queue_delayed_work(btree_io_wq, &b->work, 30 * HZ); - - closure_return_with_destructor(cl, btree_node_write_unlock); - } -@@ -539,7 +541,7 @@ static void bch_btree_leaf_dirty(struct btree *b, atomic_t *journal_ref) - BUG_ON(!i->keys); - - if (!btree_node_dirty(b)) -- schedule_delayed_work(&b->work, 30 * HZ); -+ queue_delayed_work(btree_io_wq, &b->work, 30 * HZ); - - set_btree_node_dirty(b); - -@@ -2659,3 +2661,18 @@ void bch_keybuf_init(struct keybuf *buf) - spin_lock_init(&buf->lock); - array_allocator_init(&buf->freelist); - } -+ -+void bch_btree_exit(void) -+{ -+ if (btree_io_wq) -+ destroy_workqueue(btree_io_wq); -+} -+ -+int __init bch_btree_init(void) -+{ -+ btree_io_wq = alloc_workqueue("bch_btree_io", WQ_MEM_RECLAIM, 0); -+ if (!btree_io_wq) -+ return -ENOMEM; -+ -+ return 0; -+} -diff --git a/drivers/md/bcache/journal.c b/drivers/md/bcache/journal.c -index 8250d2d1d780c..b4fd923e0d401 100644 ---- a/drivers/md/bcache/journal.c -+++ b/drivers/md/bcache/journal.c -@@ -958,8 +958,8 @@ atomic_t *bch_journal(struct cache_set *c, - journal_try_write(c); - } else if (!w->dirty) { - w->dirty = true; -- schedule_delayed_work(&c->journal.work, -- msecs_to_jiffies(c->journal_delay_ms)); -+ queue_delayed_work(bch_flush_wq, &c->journal.work, -+ msecs_to_jiffies(c->journal_delay_ms)); - spin_unlock(&c->journal.lock); - } else { - spin_unlock(&c->journal.lock); -diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c -index 63f5ce18311bb..b0d569032dd4e 100644 ---- a/drivers/md/bcache/super.c -+++ b/drivers/md/bcache/super.c -@@ -48,6 +48,7 @@ static int bcache_major; - static DEFINE_IDA(bcache_device_idx); - static wait_queue_head_t unregister_wait; - struct workqueue_struct *bcache_wq; -+struct workqueue_struct *bch_flush_wq; - struct workqueue_struct *bch_journal_wq; - - -@@ -2652,6 +2653,9 @@ static void bcache_exit(void) - destroy_workqueue(bcache_wq); - if (bch_journal_wq) - destroy_workqueue(bch_journal_wq); -+ if (bch_flush_wq) -+ destroy_workqueue(bch_flush_wq); -+ bch_btree_exit(); - - if (bcache_major) - unregister_blkdev(bcache_major, "bcache"); -@@ -2707,10 +2711,26 @@ static int __init bcache_init(void) - return bcache_major; - } - -+ if (bch_btree_init()) -+ goto err; -+ - bcache_wq = alloc_workqueue("bcache", WQ_MEM_RECLAIM, 0); - if (!bcache_wq) - goto err; - -+ /* -+ * Let's not make this `WQ_MEM_RECLAIM` for the following reasons: -+ * -+ * 1. It used `system_wq` before which also does no memory reclaim. -+ * 2. With `WQ_MEM_RECLAIM` desktop stalls, increased boot times, and -+ * reduced throughput can be observed. -+ * -+ * We still want to user our own queue to not congest the `system_wq`. -+ */ -+ bch_flush_wq = alloc_workqueue("bch_flush", 0, 0); -+ if (!bch_flush_wq) -+ goto err; -+ - bch_journal_wq = alloc_workqueue("bch_journal", WQ_MEM_RECLAIM, 0); - if (!bch_journal_wq) - goto err; -diff --git a/drivers/md/dm-core.h b/drivers/md/dm-core.h -index c4ef1fceead6e..3fea121fcbcf9 100644 ---- a/drivers/md/dm-core.h -+++ b/drivers/md/dm-core.h -@@ -106,6 +106,10 @@ struct mapped_device { - - struct block_device *bdev; - -+ int swap_bios; -+ struct semaphore swap_bios_semaphore; -+ struct mutex swap_bios_lock; -+ - struct dm_stats stats; - - /* for blk-mq request-based DM support */ -diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c -index 1af82fbbac0c4..d85648b9c247a 100644 ---- a/drivers/md/dm-crypt.c -+++ b/drivers/md/dm-crypt.c -@@ -2737,6 +2737,7 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) - wake_up_process(cc->write_thread); - - ti->num_flush_bios = 1; -+ ti->limit_swap_bios = true; - - return 0; - -diff --git a/drivers/md/dm-era-target.c b/drivers/md/dm-era-target.c -index bdb84b8e71621..6b0b3a13ab4a2 100644 ---- a/drivers/md/dm-era-target.c -+++ b/drivers/md/dm-era-target.c -@@ -47,6 +47,7 @@ struct writeset { - static void writeset_free(struct writeset *ws) - { - vfree(ws->bits); -+ ws->bits = NULL; - } - - static int setup_on_disk_bitset(struct dm_disk_bitset *info, -@@ -71,8 +72,6 @@ static size_t bitset_size(unsigned nr_bits) - */ - static int writeset_alloc(struct writeset *ws, dm_block_t nr_blocks) - { -- ws->md.nr_bits = nr_blocks; -- ws->md.root = INVALID_WRITESET_ROOT; - ws->bits = vzalloc(bitset_size(nr_blocks)); - if (!ws->bits) { - DMERR("%s: couldn't allocate in memory bitset", __func__); -@@ -85,12 +84,14 @@ static int writeset_alloc(struct writeset *ws, dm_block_t nr_blocks) - /* - * Wipes the in-core bitset, and creates a new on disk bitset. - */ --static int writeset_init(struct dm_disk_bitset *info, struct writeset *ws) -+static int writeset_init(struct dm_disk_bitset *info, struct writeset *ws, -+ dm_block_t nr_blocks) - { - int r; - -- memset(ws->bits, 0, bitset_size(ws->md.nr_bits)); -+ memset(ws->bits, 0, bitset_size(nr_blocks)); - -+ ws->md.nr_bits = nr_blocks; - r = setup_on_disk_bitset(info, ws->md.nr_bits, &ws->md.root); - if (r) { - DMERR("%s: setup_on_disk_bitset failed", __func__); -@@ -134,7 +135,7 @@ static int writeset_test_and_set(struct dm_disk_bitset *info, - { - int r; - -- if (!test_and_set_bit(block, ws->bits)) { -+ if (!test_bit(block, ws->bits)) { - r = dm_bitset_set_bit(info, ws->md.root, block, &ws->md.root); - if (r) { - /* FIXME: fail mode */ -@@ -388,7 +389,7 @@ static void ws_dec(void *context, const void *value) - - static int ws_eq(void *context, const void *value1, const void *value2) - { -- return !memcmp(value1, value2, sizeof(struct writeset_metadata)); -+ return !memcmp(value1, value2, sizeof(struct writeset_disk)); - } - - /*----------------------------------------------------------------*/ -@@ -564,6 +565,15 @@ static int open_metadata(struct era_metadata *md) - } - - disk = dm_block_data(sblock); -+ -+ /* Verify the data block size hasn't changed */ -+ if (le32_to_cpu(disk->data_block_size) != md->block_size) { -+ DMERR("changing the data block size (from %u to %llu) is not supported", -+ le32_to_cpu(disk->data_block_size), md->block_size); -+ r = -EINVAL; -+ goto bad; -+ } -+ - r = dm_tm_open_with_sm(md->bm, SUPERBLOCK_LOCATION, - disk->metadata_space_map_root, - sizeof(disk->metadata_space_map_root), -@@ -575,10 +585,10 @@ static int open_metadata(struct era_metadata *md) - - setup_infos(md); - -- md->block_size = le32_to_cpu(disk->data_block_size); - md->nr_blocks = le32_to_cpu(disk->nr_blocks); - md->current_era = le32_to_cpu(disk->current_era); - -+ ws_unpack(&disk->current_writeset, &md->current_writeset->md); - md->writeset_tree_root = le64_to_cpu(disk->writeset_tree_root); - md->era_array_root = le64_to_cpu(disk->era_array_root); - md->metadata_snap = le64_to_cpu(disk->metadata_snap); -@@ -746,6 +756,12 @@ static int metadata_digest_lookup_writeset(struct era_metadata *md, - ws_unpack(&disk, &d->writeset); - d->value = cpu_to_le32(key); - -+ /* -+ * We initialise another bitset info to avoid any caching side effects -+ * with the previous one. -+ */ -+ dm_disk_bitset_init(md->tm, &d->info); -+ - d->nr_bits = min(d->writeset.nr_bits, md->nr_blocks); - d->current_bit = 0; - d->step = metadata_digest_transcribe_writeset; -@@ -759,12 +775,6 @@ static int metadata_digest_start(struct era_metadata *md, struct digest *d) - return 0; - - memset(d, 0, sizeof(*d)); -- -- /* -- * We initialise another bitset info to avoid any caching side -- * effects with the previous one. -- */ -- dm_disk_bitset_init(md->tm, &d->info); - d->step = metadata_digest_lookup_writeset; - - return 0; -@@ -802,6 +812,8 @@ static struct era_metadata *metadata_open(struct block_device *bdev, - - static void metadata_close(struct era_metadata *md) - { -+ writeset_free(&md->writesets[0]); -+ writeset_free(&md->writesets[1]); - destroy_persistent_data_objects(md); - kfree(md); - } -@@ -839,6 +851,7 @@ static int metadata_resize(struct era_metadata *md, void *arg) - r = writeset_alloc(&md->writesets[1], *new_size); - if (r) { - DMERR("%s: writeset_alloc failed for writeset 1", __func__); -+ writeset_free(&md->writesets[0]); - return r; - } - -@@ -849,6 +862,8 @@ static int metadata_resize(struct era_metadata *md, void *arg) - &value, &md->era_array_root); - if (r) { - DMERR("%s: dm_array_resize failed", __func__); -+ writeset_free(&md->writesets[0]); -+ writeset_free(&md->writesets[1]); - return r; - } - -@@ -870,7 +885,6 @@ static int metadata_era_archive(struct era_metadata *md) - } - - ws_pack(&md->current_writeset->md, &value); -- md->current_writeset->md.root = INVALID_WRITESET_ROOT; - - keys[0] = md->current_era; - __dm_bless_for_disk(&value); -@@ -882,6 +896,7 @@ static int metadata_era_archive(struct era_metadata *md) - return r; - } - -+ md->current_writeset->md.root = INVALID_WRITESET_ROOT; - md->archived_writesets = true; - - return 0; -@@ -898,7 +913,7 @@ static int metadata_new_era(struct era_metadata *md) - int r; - struct writeset *new_writeset = next_writeset(md); - -- r = writeset_init(&md->bitset_info, new_writeset); -+ r = writeset_init(&md->bitset_info, new_writeset, md->nr_blocks); - if (r) { - DMERR("%s: writeset_init failed", __func__); - return r; -@@ -951,7 +966,7 @@ static int metadata_commit(struct era_metadata *md) - int r; - struct dm_block *sblock; - -- if (md->current_writeset->md.root != SUPERBLOCK_LOCATION) { -+ if (md->current_writeset->md.root != INVALID_WRITESET_ROOT) { - r = dm_bitset_flush(&md->bitset_info, md->current_writeset->md.root, - &md->current_writeset->md.root); - if (r) { -@@ -1226,8 +1241,10 @@ static void process_deferred_bios(struct era *era) - int r; - struct bio_list deferred_bios, marked_bios; - struct bio *bio; -+ struct blk_plug plug; - bool commit_needed = false; - bool failed = false; -+ struct writeset *ws = era->md->current_writeset; - - bio_list_init(&deferred_bios); - bio_list_init(&marked_bios); -@@ -1237,9 +1254,11 @@ static void process_deferred_bios(struct era *era) - bio_list_init(&era->deferred_bios); - spin_unlock(&era->deferred_lock); - -+ if (bio_list_empty(&deferred_bios)) -+ return; -+ - while ((bio = bio_list_pop(&deferred_bios))) { -- r = writeset_test_and_set(&era->md->bitset_info, -- era->md->current_writeset, -+ r = writeset_test_and_set(&era->md->bitset_info, ws, - get_block(era, bio)); - if (r < 0) { - /* -@@ -1247,7 +1266,6 @@ static void process_deferred_bios(struct era *era) - * FIXME: finish. - */ - failed = true; -- - } else if (r == 0) - commit_needed = true; - -@@ -1263,9 +1281,19 @@ static void process_deferred_bios(struct era *era) - if (failed) - while ((bio = bio_list_pop(&marked_bios))) - bio_io_error(bio); -- else -- while ((bio = bio_list_pop(&marked_bios))) -+ else { -+ blk_start_plug(&plug); -+ while ((bio = bio_list_pop(&marked_bios))) { -+ /* -+ * Only update the in-core writeset if the on-disk one -+ * was updated too. -+ */ -+ if (commit_needed) -+ set_bit(get_block(era, bio), ws->bits); - generic_make_request(bio); -+ } -+ blk_finish_plug(&plug); -+ } - } - - static void process_rpc_calls(struct era *era) -@@ -1486,15 +1514,6 @@ static int era_ctr(struct dm_target *ti, unsigned argc, char **argv) - } - era->md = md; - -- era->nr_blocks = calc_nr_blocks(era); -- -- r = metadata_resize(era->md, &era->nr_blocks); -- if (r) { -- ti->error = "couldn't resize metadata"; -- era_destroy(era); -- return -ENOMEM; -- } -- - era->wq = alloc_ordered_workqueue("dm-" DM_MSG_PREFIX, WQ_MEM_RECLAIM); - if (!era->wq) { - ti->error = "could not create workqueue for metadata object"; -@@ -1571,16 +1590,24 @@ static int era_preresume(struct dm_target *ti) - dm_block_t new_size = calc_nr_blocks(era); - - if (era->nr_blocks != new_size) { -- r = in_worker1(era, metadata_resize, &new_size); -- if (r) -+ r = metadata_resize(era->md, &new_size); -+ if (r) { -+ DMERR("%s: metadata_resize failed", __func__); -+ return r; -+ } -+ -+ r = metadata_commit(era->md); -+ if (r) { -+ DMERR("%s: metadata_commit failed", __func__); - return r; -+ } - - era->nr_blocks = new_size; - } - - start_worker(era); - -- r = in_worker0(era, metadata_new_era); -+ r = in_worker0(era, metadata_era_rollover); - if (r) { - DMERR("%s: metadata_era_rollover failed", __func__); - return r; -diff --git a/drivers/md/dm-writecache.c b/drivers/md/dm-writecache.c -index 08ae59a6e8734..4c2971835d330 100644 ---- a/drivers/md/dm-writecache.c -+++ b/drivers/md/dm-writecache.c -@@ -142,6 +142,7 @@ struct dm_writecache { - size_t metadata_sectors; - size_t n_blocks; - uint64_t seq_count; -+ sector_t data_device_sectors; - void *block_start; - struct wc_entry *entries; - unsigned block_size; -@@ -918,6 +919,8 @@ static void writecache_resume(struct dm_target *ti) - - wc_lock(wc); - -+ wc->data_device_sectors = i_size_read(wc->dev->bdev->bd_inode) >> SECTOR_SHIFT; -+ - if (WC_MODE_PMEM(wc)) { - persistent_memory_invalidate_cache(wc->memory_map, wc->memory_map_size); - } else { -@@ -1488,6 +1491,10 @@ static bool wc_add_block(struct writeback_struct *wb, struct wc_entry *e, gfp_t - void *address = memory_data(wc, e); - - persistent_memory_flush_cache(address, block_size); -+ -+ if (unlikely(bio_end_sector(&wb->bio) >= wc->data_device_sectors)) -+ return true; -+ - return bio_add_page(&wb->bio, persistent_memory_page(address), - block_size, persistent_memory_page_offset(address)) != 0; - } -@@ -1559,6 +1566,9 @@ static void __writecache_writeback_pmem(struct dm_writecache *wc, struct writeba - if (writecache_has_error(wc)) { - bio->bi_status = BLK_STS_IOERR; - bio_endio(bio); -+ } else if (unlikely(!bio_sectors(bio))) { -+ bio->bi_status = BLK_STS_OK; -+ bio_endio(bio); - } else { - submit_bio(bio); - } -@@ -1602,6 +1612,14 @@ static void __writecache_writeback_ssd(struct dm_writecache *wc, struct writebac - e = f; - } - -+ if (unlikely(to.sector + to.count > wc->data_device_sectors)) { -+ if (to.sector >= wc->data_device_sectors) { -+ writecache_copy_endio(0, 0, c); -+ continue; -+ } -+ from.count = to.count = wc->data_device_sectors - to.sector; -+ } -+ - dm_kcopyd_copy(wc->dm_kcopyd, &from, 1, &to, 0, writecache_copy_endio, c); - - __writeback_throttle(wc, wbl); -diff --git a/drivers/md/dm.c b/drivers/md/dm.c -index c6ce42daff27b..de32f8553735f 100644 ---- a/drivers/md/dm.c -+++ b/drivers/md/dm.c -@@ -146,6 +146,16 @@ EXPORT_SYMBOL_GPL(dm_bio_get_target_bio_nr); - #define DM_NUMA_NODE NUMA_NO_NODE - static int dm_numa_node = DM_NUMA_NODE; - -+#define DEFAULT_SWAP_BIOS (8 * 1048576 / PAGE_SIZE) -+static int swap_bios = DEFAULT_SWAP_BIOS; -+static int get_swap_bios(void) -+{ -+ int latch = READ_ONCE(swap_bios); -+ if (unlikely(latch <= 0)) -+ latch = DEFAULT_SWAP_BIOS; -+ return latch; -+} -+ - /* - * For mempools pre-allocation at the table loading time. - */ -@@ -972,6 +982,11 @@ void disable_write_zeroes(struct mapped_device *md) - limits->max_write_zeroes_sectors = 0; - } - -+static bool swap_bios_limit(struct dm_target *ti, struct bio *bio) -+{ -+ return unlikely((bio->bi_opf & REQ_SWAP) != 0) && unlikely(ti->limit_swap_bios); -+} -+ - static void clone_endio(struct bio *bio) - { - blk_status_t error = bio->bi_status; -@@ -1009,6 +1024,11 @@ static void clone_endio(struct bio *bio) - } - } - -+ if (unlikely(swap_bios_limit(tio->ti, bio))) { -+ struct mapped_device *md = io->md; -+ up(&md->swap_bios_semaphore); -+ } -+ - free_tio(tio); - dec_pending(io, error); - } -@@ -1263,6 +1283,22 @@ void dm_remap_zone_report(struct dm_target *ti, sector_t start, - } - EXPORT_SYMBOL_GPL(dm_remap_zone_report); - -+static noinline void __set_swap_bios_limit(struct mapped_device *md, int latch) -+{ -+ mutex_lock(&md->swap_bios_lock); -+ while (latch < md->swap_bios) { -+ cond_resched(); -+ down(&md->swap_bios_semaphore); -+ md->swap_bios--; -+ } -+ while (latch > md->swap_bios) { -+ cond_resched(); -+ up(&md->swap_bios_semaphore); -+ md->swap_bios++; -+ } -+ mutex_unlock(&md->swap_bios_lock); -+} -+ - static blk_qc_t __map_bio(struct dm_target_io *tio) - { - int r; -@@ -1283,6 +1319,14 @@ static blk_qc_t __map_bio(struct dm_target_io *tio) - atomic_inc(&io->io_count); - sector = clone->bi_iter.bi_sector; - -+ if (unlikely(swap_bios_limit(ti, clone))) { -+ struct mapped_device *md = io->md; -+ int latch = get_swap_bios(); -+ if (unlikely(latch != md->swap_bios)) -+ __set_swap_bios_limit(md, latch); -+ down(&md->swap_bios_semaphore); -+ } -+ - r = ti->type->map(ti, clone); - switch (r) { - case DM_MAPIO_SUBMITTED: -@@ -1297,10 +1341,18 @@ static blk_qc_t __map_bio(struct dm_target_io *tio) - ret = generic_make_request(clone); - break; - case DM_MAPIO_KILL: -+ if (unlikely(swap_bios_limit(ti, clone))) { -+ struct mapped_device *md = io->md; -+ up(&md->swap_bios_semaphore); -+ } - free_tio(tio); - dec_pending(io, BLK_STS_IOERR); - break; - case DM_MAPIO_REQUEUE: -+ if (unlikely(swap_bios_limit(ti, clone))) { -+ struct mapped_device *md = io->md; -+ up(&md->swap_bios_semaphore); -+ } - free_tio(tio); - dec_pending(io, BLK_STS_DM_REQUEUE); - break; -@@ -1894,6 +1946,7 @@ static void cleanup_mapped_device(struct mapped_device *md) - mutex_destroy(&md->suspend_lock); - mutex_destroy(&md->type_lock); - mutex_destroy(&md->table_devices_lock); -+ mutex_destroy(&md->swap_bios_lock); - - dm_mq_cleanup_mapped_device(md); - } -@@ -1963,6 +2016,10 @@ static struct mapped_device *alloc_dev(int minor) - init_waitqueue_head(&md->eventq); - init_completion(&md->kobj_holder.completion); - -+ md->swap_bios = get_swap_bios(); -+ sema_init(&md->swap_bios_semaphore, md->swap_bios); -+ mutex_init(&md->swap_bios_lock); -+ - md->disk->major = _major; - md->disk->first_minor = minor; - md->disk->fops = &dm_blk_dops; -@@ -3245,6 +3302,9 @@ MODULE_PARM_DESC(reserved_bio_based_ios, "Reserved IOs in bio-based mempools"); - module_param(dm_numa_node, int, S_IRUGO | S_IWUSR); - MODULE_PARM_DESC(dm_numa_node, "NUMA node for DM device memory allocations"); - -+module_param(swap_bios, int, S_IRUGO | S_IWUSR); -+MODULE_PARM_DESC(swap_bios, "Maximum allowed inflight swap IOs"); -+ - MODULE_DESCRIPTION(DM_NAME " driver"); - MODULE_AUTHOR("Joe Thornber "); - MODULE_LICENSE("GPL"); -diff --git a/drivers/media/i2c/ov5670.c b/drivers/media/i2c/ov5670.c -index 041fcbb4eebdf..79e608dba4b6d 100644 ---- a/drivers/media/i2c/ov5670.c -+++ b/drivers/media/i2c/ov5670.c -@@ -2081,7 +2081,8 @@ static int ov5670_init_controls(struct ov5670 *ov5670) - - /* By default, V4L2_CID_PIXEL_RATE is read only */ - ov5670->pixel_rate = v4l2_ctrl_new_std(ctrl_hdlr, &ov5670_ctrl_ops, -- V4L2_CID_PIXEL_RATE, 0, -+ V4L2_CID_PIXEL_RATE, -+ link_freq_configs[0].pixel_rate, - link_freq_configs[0].pixel_rate, - 1, - link_freq_configs[0].pixel_rate); -diff --git a/drivers/media/pci/cx25821/cx25821-core.c b/drivers/media/pci/cx25821/cx25821-core.c -index 41be22ce66f3e..44839a6461e88 100644 ---- a/drivers/media/pci/cx25821/cx25821-core.c -+++ b/drivers/media/pci/cx25821/cx25821-core.c -@@ -976,8 +976,10 @@ int cx25821_riscmem_alloc(struct pci_dev *pci, - __le32 *cpu; - dma_addr_t dma = 0; - -- if (NULL != risc->cpu && risc->size < size) -+ if (risc->cpu && risc->size < size) { - pci_free_consistent(pci, risc->size, risc->cpu, risc->dma); -+ risc->cpu = NULL; -+ } - if (NULL == risc->cpu) { - cpu = pci_zalloc_consistent(pci, size, &dma); - if (NULL == cpu) -diff --git a/drivers/media/pci/intel/ipu3/ipu3-cio2.c b/drivers/media/pci/intel/ipu3/ipu3-cio2.c -index 253f05aef3b1f..7808ec1052bf6 100644 ---- a/drivers/media/pci/intel/ipu3/ipu3-cio2.c -+++ b/drivers/media/pci/intel/ipu3/ipu3-cio2.c -@@ -1288,7 +1288,7 @@ static int cio2_subdev_set_fmt(struct v4l2_subdev *sd, - fmt->format.code = formats[0].mbus_code; - - for (i = 0; i < ARRAY_SIZE(formats); i++) { -- if (formats[i].mbus_code == fmt->format.code) { -+ if (formats[i].mbus_code == mbus_code) { - fmt->format.code = mbus_code; - break; - } -diff --git a/drivers/media/pci/saa7134/saa7134-empress.c b/drivers/media/pci/saa7134/saa7134-empress.c -index cb65d345fd3e9..e2666d1c68964 100644 ---- a/drivers/media/pci/saa7134/saa7134-empress.c -+++ b/drivers/media/pci/saa7134/saa7134-empress.c -@@ -282,8 +282,11 @@ static int empress_init(struct saa7134_dev *dev) - q->lock = &dev->lock; - q->dev = &dev->pci->dev; - err = vb2_queue_init(q); -- if (err) -+ if (err) { -+ video_device_release(dev->empress_dev); -+ dev->empress_dev = NULL; - return err; -+ } - dev->empress_dev->queue = q; - dev->empress_dev->device_caps = V4L2_CAP_READWRITE | V4L2_CAP_STREAMING | - V4L2_CAP_VIDEO_CAPTURE; -diff --git a/drivers/media/pci/smipcie/smipcie-ir.c b/drivers/media/pci/smipcie/smipcie-ir.c -index 9445d792bfc98..731aa702e2b79 100644 ---- a/drivers/media/pci/smipcie/smipcie-ir.c -+++ b/drivers/media/pci/smipcie/smipcie-ir.c -@@ -60,39 +60,45 @@ static void smi_ir_decode(struct smi_rc *ir) - { - struct smi_dev *dev = ir->dev; - struct rc_dev *rc_dev = ir->rc_dev; -- u32 dwIRControl, dwIRData; -- u8 index, ucIRCount, readLoop; -+ u32 control, data; -+ u8 index, ir_count, read_loop; - -- dwIRControl = smi_read(IR_Init_Reg); -+ control = smi_read(IR_Init_Reg); - -- if (dwIRControl & rbIRVld) { -- ucIRCount = (u8) smi_read(IR_Data_Cnt); -+ dev_dbg(&rc_dev->dev, "ircontrol: 0x%08x\n", control); - -- readLoop = ucIRCount/4; -- if (ucIRCount % 4) -- readLoop += 1; -- for (index = 0; index < readLoop; index++) { -- dwIRData = smi_read(IR_DATA_BUFFER_BASE + (index * 4)); -+ if (control & rbIRVld) { -+ ir_count = (u8)smi_read(IR_Data_Cnt); - -- ir->irData[index*4 + 0] = (u8)(dwIRData); -- ir->irData[index*4 + 1] = (u8)(dwIRData >> 8); -- ir->irData[index*4 + 2] = (u8)(dwIRData >> 16); -- ir->irData[index*4 + 3] = (u8)(dwIRData >> 24); -+ dev_dbg(&rc_dev->dev, "ircount %d\n", ir_count); -+ -+ read_loop = ir_count / 4; -+ if (ir_count % 4) -+ read_loop += 1; -+ for (index = 0; index < read_loop; index++) { -+ data = smi_read(IR_DATA_BUFFER_BASE + (index * 4)); -+ dev_dbg(&rc_dev->dev, "IRData 0x%08x\n", data); -+ -+ ir->irData[index * 4 + 0] = (u8)(data); -+ ir->irData[index * 4 + 1] = (u8)(data >> 8); -+ ir->irData[index * 4 + 2] = (u8)(data >> 16); -+ ir->irData[index * 4 + 3] = (u8)(data >> 24); - } -- smi_raw_process(rc_dev, ir->irData, ucIRCount); -- smi_set(IR_Init_Reg, rbIRVld); -+ smi_raw_process(rc_dev, ir->irData, ir_count); - } - -- if (dwIRControl & rbIRhighidle) { -+ if (control & rbIRhighidle) { - struct ir_raw_event rawir = {}; - -+ dev_dbg(&rc_dev->dev, "high idle\n"); -+ - rawir.pulse = 0; - rawir.duration = US_TO_NS(SMI_SAMPLE_PERIOD * - SMI_SAMPLE_IDLEMIN); - ir_raw_event_store_with_filter(rc_dev, &rawir); -- smi_set(IR_Init_Reg, rbIRhighidle); - } - -+ smi_set(IR_Init_Reg, rbIRVld); - ir_raw_event_handle(rc_dev); - } - -@@ -151,7 +157,7 @@ int smi_ir_init(struct smi_dev *dev) - rc_dev->dev.parent = &dev->pci_dev->dev; - - rc_dev->map_name = dev->info->rc_map; -- rc_dev->timeout = MS_TO_NS(100); -+ rc_dev->timeout = US_TO_NS(SMI_SAMPLE_PERIOD * SMI_SAMPLE_IDLEMIN); - rc_dev->rx_resolution = US_TO_NS(SMI_SAMPLE_PERIOD); - - ir->rc_dev = rc_dev; -@@ -174,7 +180,7 @@ void smi_ir_exit(struct smi_dev *dev) - struct smi_rc *ir = &dev->ir; - struct rc_dev *rc_dev = ir->rc_dev; - -- smi_ir_stop(ir); - rc_unregister_device(rc_dev); -+ smi_ir_stop(ir); - ir->rc_dev = NULL; - } -diff --git a/drivers/media/platform/aspeed-video.c b/drivers/media/platform/aspeed-video.c -index 4eaaf39b9223c..e0299a7899231 100644 ---- a/drivers/media/platform/aspeed-video.c -+++ b/drivers/media/platform/aspeed-video.c -@@ -1529,12 +1529,12 @@ static int aspeed_video_setup_video(struct aspeed_video *video) - V4L2_JPEG_CHROMA_SUBSAMPLING_420, mask, - V4L2_JPEG_CHROMA_SUBSAMPLING_444); - -- if (video->ctrl_handler.error) { -+ rc = video->ctrl_handler.error; -+ if (rc) { - v4l2_ctrl_handler_free(&video->ctrl_handler); - v4l2_device_unregister(v4l2_dev); - -- dev_err(video->dev, "Failed to init controls: %d\n", -- video->ctrl_handler.error); -+ dev_err(video->dev, "Failed to init controls: %d\n", rc); - return rc; - } - -diff --git a/drivers/media/platform/pxa_camera.c b/drivers/media/platform/pxa_camera.c -index 8d47ea0c33f84..6e04e3ec61bac 100644 ---- a/drivers/media/platform/pxa_camera.c -+++ b/drivers/media/platform/pxa_camera.c -@@ -1447,6 +1447,9 @@ static int pxac_vb2_prepare(struct vb2_buffer *vb) - struct pxa_camera_dev *pcdev = vb2_get_drv_priv(vb->vb2_queue); - struct pxa_buffer *buf = vb2_to_pxa_buffer(vb); - int ret = 0; -+#ifdef DEBUG -+ int i; -+#endif - - switch (pcdev->channels) { - case 1: -diff --git a/drivers/media/platform/qcom/camss/camss-video.c b/drivers/media/platform/qcom/camss/camss-video.c -index 1d50dfbbb762e..4c2675b437181 100644 ---- a/drivers/media/platform/qcom/camss/camss-video.c -+++ b/drivers/media/platform/qcom/camss/camss-video.c -@@ -901,6 +901,7 @@ int msm_video_register(struct camss_video *video, struct v4l2_device *v4l2_dev, - video->nformats = ARRAY_SIZE(formats_rdi_8x96); - } - } else { -+ ret = -EINVAL; - goto error_video_register; - } - -diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c -index dc62533cf32ce..aa66e4f5f3f34 100644 ---- a/drivers/media/platform/vsp1/vsp1_drv.c -+++ b/drivers/media/platform/vsp1/vsp1_drv.c -@@ -882,8 +882,10 @@ static int vsp1_probe(struct platform_device *pdev) - } - - done: -- if (ret) -+ if (ret) { - pm_runtime_disable(&pdev->dev); -+ rcar_fcp_put(vsp1->fcp); -+ } - - return ret; - } -diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c -index f9616158bcf44..867f5fb6fbe11 100644 ---- a/drivers/media/rc/mceusb.c -+++ b/drivers/media/rc/mceusb.c -@@ -1169,7 +1169,7 @@ static void mceusb_handle_command(struct mceusb_dev *ir, u8 *buf_in) - switch (subcmd) { - /* the one and only 5-byte return value command */ - case MCE_RSP_GETPORTSTATUS: -- if (buf_in[5] == 0) -+ if (buf_in[5] == 0 && *hi < 8) - ir->txports_cabled |= 1 << *hi; - break; - -diff --git a/drivers/media/tuners/qm1d1c0042.c b/drivers/media/tuners/qm1d1c0042.c -index 83ca5dc047ea2..baa9950783b66 100644 ---- a/drivers/media/tuners/qm1d1c0042.c -+++ b/drivers/media/tuners/qm1d1c0042.c -@@ -343,8 +343,10 @@ static int qm1d1c0042_init(struct dvb_frontend *fe) - if (val == reg_initval[reg_index][0x00]) - break; - } -- if (reg_index >= QM1D1C0042_NUM_REG_ROWS) -+ if (reg_index >= QM1D1C0042_NUM_REG_ROWS) { -+ ret = -EINVAL; - goto failed; -+ } - memcpy(state->regs, reg_initval[reg_index], QM1D1C0042_NUM_REGS); - usleep_range(2000, 3000); - -diff --git a/drivers/media/usb/dvb-usb-v2/lmedm04.c b/drivers/media/usb/dvb-usb-v2/lmedm04.c -index 62d3566bf7eeb..5ac1a6af87826 100644 ---- a/drivers/media/usb/dvb-usb-v2/lmedm04.c -+++ b/drivers/media/usb/dvb-usb-v2/lmedm04.c -@@ -391,7 +391,7 @@ static int lme2510_int_read(struct dvb_usb_adapter *adap) - ep = usb_pipe_endpoint(d->udev, lme_int->lme_urb->pipe); - - if (usb_endpoint_type(&ep->desc) == USB_ENDPOINT_XFER_BULK) -- lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa), -+ lme_int->lme_urb->pipe = usb_rcvbulkpipe(d->udev, 0xa); - - usb_submit_urb(lme_int->lme_urb, GFP_ATOMIC); - info("INT Interrupt Service Started"); -diff --git a/drivers/media/usb/em28xx/em28xx-core.c b/drivers/media/usb/em28xx/em28xx-core.c -index e6088b5d1b805..3daa64bb1e1d9 100644 ---- a/drivers/media/usb/em28xx/em28xx-core.c -+++ b/drivers/media/usb/em28xx/em28xx-core.c -@@ -956,14 +956,10 @@ int em28xx_alloc_urbs(struct em28xx *dev, enum em28xx_mode mode, int xfer_bulk, - - usb_bufs->buf[i] = kzalloc(sb_size, GFP_KERNEL); - if (!usb_bufs->buf[i]) { -- em28xx_uninit_usb_xfer(dev, mode); -- - for (i--; i >= 0; i--) - kfree(usb_bufs->buf[i]); - -- kfree(usb_bufs->buf); -- usb_bufs->buf = NULL; -- -+ em28xx_uninit_usb_xfer(dev, mode); - return -ENOMEM; - } - -diff --git a/drivers/media/usb/tm6000/tm6000-dvb.c b/drivers/media/usb/tm6000/tm6000-dvb.c -index 19c90fa9e443d..293a460f4616c 100644 ---- a/drivers/media/usb/tm6000/tm6000-dvb.c -+++ b/drivers/media/usb/tm6000/tm6000-dvb.c -@@ -141,6 +141,10 @@ static int tm6000_start_stream(struct tm6000_core *dev) - if (ret < 0) { - printk(KERN_ERR "tm6000: error %i in %s during pipe reset\n", - ret, __func__); -+ -+ kfree(dvb->bulk_urb->transfer_buffer); -+ usb_free_urb(dvb->bulk_urb); -+ dvb->bulk_urb = NULL; - return ret; - } else - printk(KERN_ERR "tm6000: pipe reset\n"); -diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c -index 5e6f3153b5ff8..7d60dd3b0bd85 100644 ---- a/drivers/media/usb/uvc/uvc_v4l2.c -+++ b/drivers/media/usb/uvc/uvc_v4l2.c -@@ -248,7 +248,9 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, - goto done; - - /* After the probe, update fmt with the values returned from -- * negotiation with the device. -+ * negotiation with the device. Some devices return invalid bFormatIndex -+ * and bFrameIndex values, in which case we can only assume they have -+ * accepted the requested format as-is. - */ - for (i = 0; i < stream->nformats; ++i) { - if (probe->bFormatIndex == stream->format[i].index) { -@@ -257,11 +259,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, - } - } - -- if (i == stream->nformats) { -- uvc_trace(UVC_TRACE_FORMAT, "Unknown bFormatIndex %u\n", -+ if (i == stream->nformats) -+ uvc_trace(UVC_TRACE_FORMAT, -+ "Unknown bFormatIndex %u, using default\n", - probe->bFormatIndex); -- return -EINVAL; -- } - - for (i = 0; i < format->nframes; ++i) { - if (probe->bFrameIndex == format->frame[i].bFrameIndex) { -@@ -270,11 +271,10 @@ static int uvc_v4l2_try_format(struct uvc_streaming *stream, - } - } - -- if (i == format->nframes) { -- uvc_trace(UVC_TRACE_FORMAT, "Unknown bFrameIndex %u\n", -+ if (i == format->nframes) -+ uvc_trace(UVC_TRACE_FORMAT, -+ "Unknown bFrameIndex %u, using default\n", - probe->bFrameIndex); -- return -EINVAL; -- } - - fmt->fmt.pix.width = frame->wWidth; - fmt->fmt.pix.height = frame->wHeight; -diff --git a/drivers/memory/mtk-smi.c b/drivers/memory/mtk-smi.c -index a113e811faabe..da1ce7fd4cf5c 100644 ---- a/drivers/memory/mtk-smi.c -+++ b/drivers/memory/mtk-smi.c -@@ -127,7 +127,7 @@ static void mtk_smi_clk_disable(const struct mtk_smi *smi) - - int mtk_smi_larb_get(struct device *larbdev) - { -- int ret = pm_runtime_get_sync(larbdev); -+ int ret = pm_runtime_resume_and_get(larbdev); - - return (ret < 0) ? ret : 0; - } -@@ -336,7 +336,7 @@ static int __maybe_unused mtk_smi_larb_resume(struct device *dev) - int ret; - - /* Power on smi-common. */ -- ret = pm_runtime_get_sync(larb->smi_common_dev); -+ ret = pm_runtime_resume_and_get(larb->smi_common_dev); - if (ret < 0) { - dev_err(dev, "Failed to pm get for smi-common(%d).\n", ret); - return ret; -diff --git a/drivers/memory/ti-aemif.c b/drivers/memory/ti-aemif.c -index db526dbf71eed..94219d2a2773d 100644 ---- a/drivers/memory/ti-aemif.c -+++ b/drivers/memory/ti-aemif.c -@@ -378,8 +378,10 @@ static int aemif_probe(struct platform_device *pdev) - */ - for_each_available_child_of_node(np, child_np) { - ret = of_aemif_parse_abus_config(pdev, child_np); -- if (ret < 0) -+ if (ret < 0) { -+ of_node_put(child_np); - goto error; -+ } - } - } else if (pdata && pdata->num_abus_data > 0) { - for (i = 0; i < pdata->num_abus_data; i++, aemif->num_cs++) { -@@ -405,8 +407,10 @@ static int aemif_probe(struct platform_device *pdev) - for_each_available_child_of_node(np, child_np) { - ret = of_platform_populate(child_np, NULL, - dev_lookup, dev); -- if (ret < 0) -+ if (ret < 0) { -+ of_node_put(child_np); - goto error; -+ } - } - } else if (pdata) { - for (i = 0; i < pdata->num_sub_devices; i++) { -diff --git a/drivers/mfd/bd9571mwv.c b/drivers/mfd/bd9571mwv.c -index fab3cdc27ed64..19d57a45134c6 100644 ---- a/drivers/mfd/bd9571mwv.c -+++ b/drivers/mfd/bd9571mwv.c -@@ -185,9 +185,9 @@ static int bd9571mwv_probe(struct i2c_client *client, - return ret; - } - -- ret = mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO, bd9571mwv_cells, -- ARRAY_SIZE(bd9571mwv_cells), NULL, 0, -- regmap_irq_get_domain(bd->irq_data)); -+ ret = devm_mfd_add_devices(bd->dev, PLATFORM_DEVID_AUTO, -+ bd9571mwv_cells, ARRAY_SIZE(bd9571mwv_cells), -+ NULL, 0, regmap_irq_get_domain(bd->irq_data)); - if (ret) { - regmap_del_irq_chip(bd->irq, bd->irq_data); - return ret; -diff --git a/drivers/mfd/wm831x-auxadc.c b/drivers/mfd/wm831x-auxadc.c -index 8a7cc0f86958b..65b98f3fbd929 100644 ---- a/drivers/mfd/wm831x-auxadc.c -+++ b/drivers/mfd/wm831x-auxadc.c -@@ -93,11 +93,10 @@ static int wm831x_auxadc_read_irq(struct wm831x *wm831x, - wait_for_completion_timeout(&req->done, msecs_to_jiffies(500)); - - mutex_lock(&wm831x->auxadc_lock); -- -- list_del(&req->list); - ret = req->val; - - out: -+ list_del(&req->list); - mutex_unlock(&wm831x->auxadc_lock); - - kfree(req); -diff --git a/drivers/misc/cardreader/rts5227.c b/drivers/misc/cardreader/rts5227.c -index 3a9467aaa4356..c3e3907a0c2f1 100644 ---- a/drivers/misc/cardreader/rts5227.c -+++ b/drivers/misc/cardreader/rts5227.c -@@ -338,6 +338,11 @@ static int rts522a_extra_init_hw(struct rtsx_pcr *pcr) - { - rts5227_extra_init_hw(pcr); - -+ /* Power down OCP for power consumption */ -+ if (!pcr->card_exist) -+ rtsx_pci_write_register(pcr, FPDCTL, OC_POWER_DOWN, -+ OC_POWER_DOWN); -+ - rtsx_pci_write_register(pcr, FUNC_FORCE_CTL, FUNC_FORCE_UPME_XMT_DBG, - FUNC_FORCE_UPME_XMT_DBG); - rtsx_pci_write_register(pcr, PCLK_CTL, 0x04, 0x04); -diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c -index 94cfb675fe4ed..414dcbd3c3c25 100644 ---- a/drivers/misc/eeprom/eeprom_93xx46.c -+++ b/drivers/misc/eeprom/eeprom_93xx46.c -@@ -511,3 +511,4 @@ MODULE_LICENSE("GPL"); - MODULE_DESCRIPTION("Driver for 93xx46 EEPROMs"); - MODULE_AUTHOR("Anatolij Gustschin "); - MODULE_ALIAS("spi:93xx46"); -+MODULE_ALIAS("spi:eeprom-93xx46"); -diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c -index a44094cdbc36c..d20b2b99c6f24 100644 ---- a/drivers/misc/mei/hbm.c -+++ b/drivers/misc/mei/hbm.c -@@ -1300,7 +1300,7 @@ int mei_hbm_dispatch(struct mei_device *dev, struct mei_msg_hdr *hdr) - return -EPROTO; - } - -- dev->dev_state = MEI_DEV_POWER_DOWN; -+ mei_set_devstate(dev, MEI_DEV_POWER_DOWN); - dev_info(dev->dev, "hbm: stop response: resetting.\n"); - /* force the reset */ - return -EPROTO; -diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c -index c49065887e8f5..c2338750313c4 100644 ---- a/drivers/misc/vmw_vmci/vmci_queue_pair.c -+++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c -@@ -537,6 +537,9 @@ static struct vmci_queue *qp_host_alloc_queue(u64 size) - - queue_page_size = num_pages * sizeof(*queue->kernel_if->u.h.page); - -+ if (queue_size + queue_page_size > KMALLOC_MAX_SIZE) -+ return NULL; -+ - queue = kzalloc(queue_size + queue_page_size, GFP_KERNEL); - if (queue) { - queue->q_header = NULL; -@@ -630,7 +633,7 @@ static void qp_release_pages(struct page **pages, - - for (i = 0; i < num_pages; i++) { - if (dirty) -- set_page_dirty(pages[i]); -+ set_page_dirty_lock(pages[i]); - - put_page(pages[i]); - pages[i] = NULL; -diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c -index cb89f0578d425..f54d0427e9c00 100644 ---- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c -+++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c -@@ -186,8 +186,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, - mmc_get_dma_dir(data))) - goto force_pio; - -- /* This DMAC cannot handle if buffer is not 8-bytes alignment */ -- if (!IS_ALIGNED(sg_dma_address(sg), 8)) -+ /* This DMAC cannot handle if buffer is not 128-bytes alignment */ -+ if (!IS_ALIGNED(sg_dma_address(sg), 128)) - goto force_pio_with_unmap; - - if (data->flags & MMC_DATA_READ) { -diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c -index b03d652226225..771676209005b 100644 ---- a/drivers/mmc/host/sdhci-esdhc-imx.c -+++ b/drivers/mmc/host/sdhci-esdhc-imx.c -@@ -1589,9 +1589,10 @@ static int sdhci_esdhc_imx_remove(struct platform_device *pdev) - struct sdhci_host *host = platform_get_drvdata(pdev); - struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); - struct pltfm_imx_data *imx_data = sdhci_pltfm_priv(pltfm_host); -- int dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); -+ int dead; - - pm_runtime_get_sync(&pdev->dev); -+ dead = (readl(host->ioaddr + SDHCI_INT_STATUS) == 0xffffffff); - pm_runtime_disable(&pdev->dev); - pm_runtime_put_noidle(&pdev->dev); - -diff --git a/drivers/mmc/host/sdhci-sprd.c b/drivers/mmc/host/sdhci-sprd.c -index d07b9793380f0..10705e5fa90ee 100644 ---- a/drivers/mmc/host/sdhci-sprd.c -+++ b/drivers/mmc/host/sdhci-sprd.c -@@ -665,14 +665,14 @@ static int sdhci_sprd_remove(struct platform_device *pdev) - { - struct sdhci_host *host = platform_get_drvdata(pdev); - struct sdhci_sprd_host *sprd_host = TO_SPRD_HOST(host); -- struct mmc_host *mmc = host->mmc; - -- mmc_remove_host(mmc); -+ sdhci_remove_host(host, 0); -+ - clk_disable_unprepare(sprd_host->clk_sdio); - clk_disable_unprepare(sprd_host->clk_enable); - clk_disable_unprepare(sprd_host->clk_2x_enable); - -- mmc_free_host(mmc); -+ sdhci_pltfm_free(pdev); - - return 0; - } -diff --git a/drivers/mmc/host/usdhi6rol0.c b/drivers/mmc/host/usdhi6rol0.c -index b11ac2314328d..6eba2441c7efd 100644 ---- a/drivers/mmc/host/usdhi6rol0.c -+++ b/drivers/mmc/host/usdhi6rol0.c -@@ -1860,10 +1860,12 @@ static int usdhi6_probe(struct platform_device *pdev) - - ret = mmc_add_host(mmc); - if (ret < 0) -- goto e_clk_off; -+ goto e_release_dma; - - return 0; - -+e_release_dma: -+ usdhi6_dma_release(host); - e_clk_off: - clk_disable_unprepare(host->clk); - e_free_mmc: -diff --git a/drivers/mtd/parsers/afs.c b/drivers/mtd/parsers/afs.c -index 752b6cf005f71..8fd61767af831 100644 ---- a/drivers/mtd/parsers/afs.c -+++ b/drivers/mtd/parsers/afs.c -@@ -370,10 +370,8 @@ static int parse_afs_partitions(struct mtd_info *mtd, - return i; - - out_free_parts: -- while (i >= 0) { -+ while (--i >= 0) - kfree(parts[i].name); -- i--; -- } - kfree(parts); - *pparts = NULL; - return ret; -diff --git a/drivers/mtd/parsers/parser_imagetag.c b/drivers/mtd/parsers/parser_imagetag.c -index d69607b482272..fab0949aabba1 100644 ---- a/drivers/mtd/parsers/parser_imagetag.c -+++ b/drivers/mtd/parsers/parser_imagetag.c -@@ -83,6 +83,7 @@ static int bcm963xx_parse_imagetag_partitions(struct mtd_info *master, - pr_err("invalid rootfs address: %*ph\n", - (int)sizeof(buf->flash_image_start), - buf->flash_image_start); -+ ret = -EINVAL; - goto out; - } - -@@ -92,6 +93,7 @@ static int bcm963xx_parse_imagetag_partitions(struct mtd_info *master, - pr_err("invalid kernel address: %*ph\n", - (int)sizeof(buf->kernel_address), - buf->kernel_address); -+ ret = -EINVAL; - goto out; - } - -@@ -100,6 +102,7 @@ static int bcm963xx_parse_imagetag_partitions(struct mtd_info *master, - pr_err("invalid kernel length: %*ph\n", - (int)sizeof(buf->kernel_length), - buf->kernel_length); -+ ret = -EINVAL; - goto out; - } - -@@ -108,6 +111,7 @@ static int bcm963xx_parse_imagetag_partitions(struct mtd_info *master, - pr_err("invalid total length: %*ph\n", - (int)sizeof(buf->total_length), - buf->total_length); -+ ret = -EINVAL; - goto out; - } - -diff --git a/drivers/mtd/spi-nor/cadence-quadspi.c b/drivers/mtd/spi-nor/cadence-quadspi.c -index 7bef63947b29f..97a5e1eaeefdf 100644 ---- a/drivers/mtd/spi-nor/cadence-quadspi.c -+++ b/drivers/mtd/spi-nor/cadence-quadspi.c -@@ -475,7 +475,7 @@ static int cqspi_read_setup(struct spi_nor *nor) - /* Setup dummy clock cycles */ - dummy_clk = nor->read_dummy; - if (dummy_clk > CQSPI_DUMMY_CLKS_MAX) -- dummy_clk = CQSPI_DUMMY_CLKS_MAX; -+ return -EOPNOTSUPP; - - if (dummy_clk / 8) { - reg |= (1 << CQSPI_REG_RD_INSTR_MODE_EN_LSB); -diff --git a/drivers/mtd/spi-nor/hisi-sfc.c b/drivers/mtd/spi-nor/hisi-sfc.c -index 6dac9dd8bf42d..8fcc48056a8bc 100644 ---- a/drivers/mtd/spi-nor/hisi-sfc.c -+++ b/drivers/mtd/spi-nor/hisi-sfc.c -@@ -396,8 +396,10 @@ static int hisi_spi_nor_register_all(struct hifmc_host *host) - - for_each_available_child_of_node(dev->of_node, np) { - ret = hisi_spi_nor_register(np, host); -- if (ret) -+ if (ret) { -+ of_node_put(np); - goto fail; -+ } - - if (host->num_chip == HIFMC_MAX_CHIP_NUM) { - dev_warn(dev, "Flash device number exceeds the maximum chipselect number\n"); -diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c -index 40586ad17f522..dd6963e4af2c7 100644 ---- a/drivers/mtd/spi-nor/spi-nor.c -+++ b/drivers/mtd/spi-nor/spi-nor.c -@@ -1011,14 +1011,15 @@ spi_nor_find_best_erase_type(const struct spi_nor_erase_map *map, - - erase = &map->erase_type[i]; - -+ /* Alignment is not mandatory for overlaid regions */ -+ if (region->offset & SNOR_OVERLAID_REGION && -+ region->size <= len) -+ return erase; -+ - /* Don't erase more than what the user has asked for. */ - if (erase->size > len) - continue; - -- /* Alignment is not mandatory for overlaid regions */ -- if (region->offset & SNOR_OVERLAID_REGION) -- return erase; -- - spi_nor_div_by_erase_size(erase, addr, &rem); - if (rem) - continue; -@@ -1152,6 +1153,7 @@ static int spi_nor_init_erase_cmd_list(struct spi_nor *nor, - goto destroy_erase_cmd_list; - - if (prev_erase != erase || -+ erase->size != cmd->size || - region->offset & SNOR_OVERLAID_REGION) { - cmd = spi_nor_init_erase_cmd(region, erase); - if (IS_ERR(cmd)) { -@@ -3700,7 +3702,7 @@ spi_nor_region_check_overlay(struct spi_nor_erase_region *region, - int i; - - for (i = 0; i < SNOR_ERASE_TYPE_MAX; i++) { -- if (!(erase_type & BIT(i))) -+ if (!(erase[i].size && erase_type & BIT(erase[i].idx))) - continue; - if (region->size & erase[i].size_mask) { - spi_nor_region_mark_overlay(region); -@@ -3770,6 +3772,7 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, - offset = (region[i].offset & ~SNOR_ERASE_FLAGS_MASK) + - region[i].size; - } -+ spi_nor_region_mark_end(®ion[i - 1]); - - save_uniform_erase_type = map->uniform_erase_type; - map->uniform_erase_type = spi_nor_sort_erase_mask(map, -@@ -3793,8 +3796,6 @@ spi_nor_init_non_uniform_erase_map(struct spi_nor *nor, - if (!(regions_erase_type & BIT(erase[i].idx))) - spi_nor_set_erase_type(&erase[i], 0, 0xFF); - -- spi_nor_region_mark_end(®ion[i - 1]); -- - return 0; - } - -diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-common.h b/drivers/net/ethernet/amd/xgbe/xgbe-common.h -index b40d4377cc71d..b2cd3bdba9f89 100644 ---- a/drivers/net/ethernet/amd/xgbe/xgbe-common.h -+++ b/drivers/net/ethernet/amd/xgbe/xgbe-common.h -@@ -1279,10 +1279,18 @@ - #define MDIO_PMA_10GBR_FECCTRL 0x00ab - #endif - -+#ifndef MDIO_PMA_RX_CTRL1 -+#define MDIO_PMA_RX_CTRL1 0x8051 -+#endif -+ - #ifndef MDIO_PCS_DIG_CTRL - #define MDIO_PCS_DIG_CTRL 0x8000 - #endif - -+#ifndef MDIO_PCS_DIGITAL_STAT -+#define MDIO_PCS_DIGITAL_STAT 0x8010 -+#endif -+ - #ifndef MDIO_AN_XNP - #define MDIO_AN_XNP 0x0016 - #endif -@@ -1358,6 +1366,8 @@ - #define XGBE_KR_TRAINING_ENABLE BIT(1) - - #define XGBE_PCS_CL37_BP BIT(12) -+#define XGBE_PCS_PSEQ_STATE_MASK 0x1c -+#define XGBE_PCS_PSEQ_STATE_POWER_GOOD 0x10 - - #define XGBE_AN_CL37_INT_CMPLT BIT(0) - #define XGBE_AN_CL37_INT_MASK 0x01 -@@ -1375,6 +1385,10 @@ - #define XGBE_PMA_CDR_TRACK_EN_OFF 0x00 - #define XGBE_PMA_CDR_TRACK_EN_ON 0x01 - -+#define XGBE_PMA_RX_RST_0_MASK BIT(4) -+#define XGBE_PMA_RX_RST_0_RESET_ON 0x10 -+#define XGBE_PMA_RX_RST_0_RESET_OFF 0x00 -+ - /* Bit setting and getting macros - * The get macro will extract the current bit field value from within - * the variable -diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c -index 3bd20f7651207..da8c2c4aca7ef 100644 ---- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c -+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c -@@ -1443,6 +1443,7 @@ static void xgbe_stop(struct xgbe_prv_data *pdata) - return; - - netif_tx_stop_all_queues(netdev); -+ netif_carrier_off(pdata->netdev); - - xgbe_stop_timers(pdata); - flush_workqueue(pdata->dev_workqueue); -diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c -index 8a3a60bb26888..156a0bc8ab01d 100644 ---- a/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c -+++ b/drivers/net/ethernet/amd/xgbe/xgbe-mdio.c -@@ -1345,7 +1345,7 @@ static void xgbe_phy_status(struct xgbe_prv_data *pdata) - &an_restart); - if (an_restart) { - xgbe_phy_config_aneg(pdata); -- return; -+ goto adjust_link; - } - - if (pdata->phy.link) { -@@ -1396,7 +1396,6 @@ static void xgbe_phy_stop(struct xgbe_prv_data *pdata) - pdata->phy_if.phy_impl.stop(pdata); - - pdata->phy.link = 0; -- netif_carrier_off(pdata->netdev); - - xgbe_phy_adjust_link(pdata); - } -diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c -index 128cd648ba99c..d6f6afb67bcc6 100644 ---- a/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c -+++ b/drivers/net/ethernet/amd/xgbe/xgbe-phy-v2.c -@@ -921,6 +921,9 @@ static bool xgbe_phy_belfuse_phy_quirks(struct xgbe_prv_data *pdata) - if ((phy_id & 0xfffffff0) != 0x03625d10) - return false; - -+ /* Reset PHY - wait for self-clearing reset bit to clear */ -+ genphy_soft_reset(phy_data->phydev); -+ - /* Disable RGMII mode */ - phy_write(phy_data->phydev, 0x18, 0x7007); - reg = phy_read(phy_data->phydev, 0x18); -@@ -1948,6 +1951,27 @@ static void xgbe_phy_set_redrv_mode(struct xgbe_prv_data *pdata) - xgbe_phy_put_comm_ownership(pdata); - } - -+static void xgbe_phy_rx_reset(struct xgbe_prv_data *pdata) -+{ -+ int reg; -+ -+ reg = XMDIO_READ_BITS(pdata, MDIO_MMD_PCS, MDIO_PCS_DIGITAL_STAT, -+ XGBE_PCS_PSEQ_STATE_MASK); -+ if (reg == XGBE_PCS_PSEQ_STATE_POWER_GOOD) { -+ /* Mailbox command timed out, reset of RX block is required. -+ * This can be done by asseting the reset bit and wait for -+ * its compeletion. -+ */ -+ XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, -+ XGBE_PMA_RX_RST_0_MASK, XGBE_PMA_RX_RST_0_RESET_ON); -+ ndelay(20); -+ XMDIO_WRITE_BITS(pdata, MDIO_MMD_PMAPMD, MDIO_PMA_RX_CTRL1, -+ XGBE_PMA_RX_RST_0_MASK, XGBE_PMA_RX_RST_0_RESET_OFF); -+ usleep_range(40, 50); -+ netif_err(pdata, link, pdata->netdev, "firmware mailbox reset performed\n"); -+ } -+} -+ - static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, - unsigned int cmd, unsigned int sub_cmd) - { -@@ -1955,9 +1979,11 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, - unsigned int wait; - - /* Log if a previous command did not complete */ -- if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) -+ if (XP_IOREAD_BITS(pdata, XP_DRIVER_INT_RO, STATUS)) { - netif_dbg(pdata, link, pdata->netdev, - "firmware mailbox not ready for command\n"); -+ xgbe_phy_rx_reset(pdata); -+ } - - /* Construct the command */ - XP_SET_BITS(s0, XP_DRIVER_SCRATCH_0, COMMAND, cmd); -@@ -1979,6 +2005,9 @@ static void xgbe_phy_perform_ratechange(struct xgbe_prv_data *pdata, - - netif_dbg(pdata, link, pdata->netdev, - "firmware mailbox command did not complete\n"); -+ -+ /* Reset on error */ -+ xgbe_phy_rx_reset(pdata); - } - - static void xgbe_phy_rrc(struct xgbe_prv_data *pdata) -@@ -2575,6 +2604,14 @@ static int xgbe_phy_link_status(struct xgbe_prv_data *pdata, int *an_restart) - if (reg & MDIO_STAT1_LSTATUS) - return 1; - -+ if (pdata->phy.autoneg == AUTONEG_ENABLE && -+ phy_data->port_mode == XGBE_PORT_MODE_BACKPLANE) { -+ if (!test_bit(XGBE_LINK_INIT, &pdata->dev_state)) { -+ netif_carrier_off(pdata->netdev); -+ *an_restart = 1; -+ } -+ } -+ - /* No link, attempt a receiver reset cycle */ - if (phy_data->rrc_count++ > XGBE_RRC_FREQUENCY) { - phy_data->rrc_count = 0; -diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -index 7c8187d386756..4ae49d92c1eed 100644 ---- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c -+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -@@ -8347,9 +8347,10 @@ void bnxt_tx_disable(struct bnxt *bp) - txr->dev_state = BNXT_DEV_STATE_CLOSING; - } - } -+ /* Drop carrier first to prevent TX timeout */ -+ netif_carrier_off(bp->dev); - /* Stop all TX queues */ - netif_tx_disable(bp->dev); -- netif_carrier_off(bp->dev); - } - - void bnxt_tx_enable(struct bnxt *bp) -diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h -index cee582e361341..6b71ec33bf14d 100644 ---- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h -+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.h -@@ -44,6 +44,9 @@ - - #define MAX_ULD_QSETS 16 - -+/* ulp_mem_io + ulptx_idata + payload + padding */ -+#define MAX_IMM_ULPTX_WR_LEN (32 + 8 + 256 + 8) -+ - /* CPL message priority levels */ - enum { - CPL_PRIORITY_DATA = 0, /* data messages */ -diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c -index 049f1bbe27ab3..57bf10b4d80c8 100644 ---- a/drivers/net/ethernet/chelsio/cxgb4/sge.c -+++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c -@@ -2158,17 +2158,22 @@ int t4_mgmt_tx(struct adapter *adap, struct sk_buff *skb) - * @skb: the packet - * - * Returns true if a packet can be sent as an offload WR with immediate -- * data. We currently use the same limit as for Ethernet packets. -+ * data. -+ * FW_OFLD_TX_DATA_WR limits the payload to 255 bytes due to 8-bit field. -+ * However, FW_ULPTX_WR commands have a 256 byte immediate only -+ * payload limit. - */ - static inline int is_ofld_imm(const struct sk_buff *skb) - { - struct work_request_hdr *req = (struct work_request_hdr *)skb->data; - unsigned long opcode = FW_WR_OP_G(ntohl(req->wr_hi)); - -- if (opcode == FW_CRYPTO_LOOKASIDE_WR) -+ if (unlikely(opcode == FW_ULPTX_WR)) -+ return skb->len <= MAX_IMM_ULPTX_WR_LEN; -+ else if (opcode == FW_CRYPTO_LOOKASIDE_WR) - return skb->len <= SGE_MAX_WR_LEN; - else -- return skb->len <= MAX_IMM_TX_PKT_LEN; -+ return skb->len <= MAX_IMM_OFLD_TX_DATA_WR_LEN; - } - - /** -diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c -index 0f35eec967ae8..309cdc5ebc1ff 100644 ---- a/drivers/net/ethernet/ibm/ibmvnic.c -+++ b/drivers/net/ethernet/ibm/ibmvnic.c -@@ -202,8 +202,13 @@ static void free_long_term_buff(struct ibmvnic_adapter *adapter, - if (!ltb->buff) - return; - -+ /* VIOS automatically unmaps the long term buffer at remote -+ * end for the following resets: -+ * FAILOVER, MOBILITY, TIMEOUT. -+ */ - if (adapter->reset_reason != VNIC_RESET_FAILOVER && -- adapter->reset_reason != VNIC_RESET_MOBILITY) -+ adapter->reset_reason != VNIC_RESET_MOBILITY && -+ adapter->reset_reason != VNIC_RESET_TIMEOUT) - send_request_unmap(adapter, ltb->map_id); - dma_free_coherent(dev, ltb->size, ltb->buff, ltb->addr); - } -@@ -1254,10 +1259,8 @@ static int __ibmvnic_close(struct net_device *netdev) - - adapter->state = VNIC_CLOSING; - rc = set_link_state(adapter, IBMVNIC_LOGICAL_LNK_DN); -- if (rc) -- return rc; - adapter->state = VNIC_CLOSED; -- return 0; -+ return rc; - } - - static int ibmvnic_close(struct net_device *netdev) -@@ -1520,6 +1523,9 @@ static netdev_tx_t ibmvnic_xmit(struct sk_buff *skb, struct net_device *netdev) - skb_copy_from_linear_data(skb, dst, skb->len); - } - -+ /* post changes to long_term_buff *dst before VIOS accessing it */ -+ dma_wmb(); -+ - tx_pool->consumer_index = - (tx_pool->consumer_index + 1) % tx_pool->num_buffers; - -@@ -2342,6 +2348,8 @@ restart_poll: - offset = be16_to_cpu(next->rx_comp.off_frame_data); - flags = next->rx_comp.flags; - skb = rx_buff->skb; -+ /* load long_term_buff before copying to skb */ -+ dma_rmb(); - skb_copy_to_linear_data(skb, rx_buff->data + offset, - length); - -diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -index b577e6adf3bff..82c62e4678705 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c -@@ -4874,7 +4874,7 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags) - enum i40e_admin_queue_err adq_err; - struct i40e_vsi *vsi = np->vsi; - struct i40e_pf *pf = vsi->back; -- bool is_reset_needed; -+ u32 reset_needed = 0; - i40e_status status; - u32 i, j; - -@@ -4919,9 +4919,11 @@ static int i40e_set_priv_flags(struct net_device *dev, u32 flags) - flags_complete: - changed_flags = orig_flags ^ new_flags; - -- is_reset_needed = !!(changed_flags & (I40E_FLAG_VEB_STATS_ENABLED | -- I40E_FLAG_LEGACY_RX | I40E_FLAG_SOURCE_PRUNING_DISABLED | -- I40E_FLAG_DISABLE_FW_LLDP)); -+ if (changed_flags & I40E_FLAG_DISABLE_FW_LLDP) -+ reset_needed = I40E_PF_RESET_AND_REBUILD_FLAG; -+ if (changed_flags & (I40E_FLAG_VEB_STATS_ENABLED | -+ I40E_FLAG_LEGACY_RX | I40E_FLAG_SOURCE_PRUNING_DISABLED)) -+ reset_needed = BIT(__I40E_PF_RESET_REQUESTED); - - /* Before we finalize any flag changes, we need to perform some - * checks to ensure that the changes are supported and safe. -@@ -5038,7 +5040,7 @@ flags_complete: - case I40E_AQ_RC_EEXIST: - dev_warn(&pf->pdev->dev, - "FW LLDP agent is already running\n"); -- is_reset_needed = false; -+ reset_needed = 0; - break; - case I40E_AQ_RC_EPERM: - dev_warn(&pf->pdev->dev, -@@ -5067,8 +5069,8 @@ flags_complete: - /* Issue reset to cause things to take effect, as additional bits - * are added we will need to create a mask of bits requiring reset - */ -- if (is_reset_needed) -- i40e_do_reset(pf, BIT(__I40E_PF_RESET_REQUESTED), true); -+ if (reset_needed) -+ i40e_do_reset(pf, reset_needed, true); - - return 0; - } -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index c19b45a90fcd2..0604b5aaad86f 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c -@@ -2603,7 +2603,7 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf) - return; - if (!test_and_clear_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state)) - return; -- if (test_and_set_bit(__I40E_VF_DISABLE, pf->state)) { -+ if (test_bit(__I40E_VF_DISABLE, pf->state)) { - set_bit(__I40E_MACVLAN_SYNC_PENDING, pf->state); - return; - } -@@ -2621,7 +2621,6 @@ static void i40e_sync_filters_subtask(struct i40e_pf *pf) - } - } - } -- clear_bit(__I40E_VF_DISABLE, pf->state); - } - - /** -@@ -7612,6 +7611,8 @@ int i40e_add_del_cloud_filter(struct i40e_vsi *vsi, - if (filter->flags >= ARRAY_SIZE(flag_table)) - return I40E_ERR_CONFIG; - -+ memset(&cld_filter, 0, sizeof(cld_filter)); -+ - /* copy element needed to add cloud filter from filter */ - i40e_set_cld_element(filter, &cld_filter); - -@@ -7675,10 +7676,13 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi, - return -EOPNOTSUPP; - - /* adding filter using src_port/src_ip is not supported at this stage */ -- if (filter->src_port || filter->src_ipv4 || -+ if (filter->src_port || -+ (filter->src_ipv4 && filter->n_proto != ETH_P_IPV6) || - !ipv6_addr_any(&filter->ip.v6.src_ip6)) - return -EOPNOTSUPP; - -+ memset(&cld_filter, 0, sizeof(cld_filter)); -+ - /* copy element needed to add cloud filter from filter */ - i40e_set_cld_element(filter, &cld_filter.element); - -@@ -7702,7 +7706,7 @@ int i40e_add_del_cloud_filter_big_buf(struct i40e_vsi *vsi, - cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_MAC_VLAN_PORT); - } - -- } else if (filter->dst_ipv4 || -+ } else if ((filter->dst_ipv4 && filter->n_proto != ETH_P_IPV6) || - !ipv6_addr_any(&filter->ip.v6.dst_ip6)) { - cld_filter.element.flags = - cpu_to_le16(I40E_AQC_ADD_CLOUD_FILTER_IP_PORT); -@@ -8481,11 +8485,6 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired) - dev_dbg(&pf->pdev->dev, "PFR requested\n"); - i40e_handle_reset_warning(pf, lock_acquired); - -- dev_info(&pf->pdev->dev, -- pf->flags & I40E_FLAG_DISABLE_FW_LLDP ? -- "FW LLDP is disabled\n" : -- "FW LLDP is enabled\n"); -- - } else if (reset_flags & I40E_PF_RESET_AND_REBUILD_FLAG) { - /* Request a PF Reset - * -@@ -8493,6 +8492,10 @@ void i40e_do_reset(struct i40e_pf *pf, u32 reset_flags, bool lock_acquired) - */ - i40e_prep_for_reset(pf, lock_acquired); - i40e_reset_and_rebuild(pf, true, lock_acquired); -+ dev_info(&pf->pdev->dev, -+ pf->flags & I40E_FLAG_DISABLE_FW_LLDP ? -+ "FW LLDP is disabled\n" : -+ "FW LLDP is enabled\n"); - - } else if (reset_flags & BIT_ULL(__I40E_REINIT_REQUESTED)) { - int v; -@@ -9955,7 +9958,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) - int old_recovery_mode_bit = test_bit(__I40E_RECOVERY_MODE, pf->state); - struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi]; - struct i40e_hw *hw = &pf->hw; -- u8 set_fc_aq_fail = 0; - i40e_status ret; - u32 val; - int v; -@@ -10081,13 +10083,6 @@ static void i40e_rebuild(struct i40e_pf *pf, bool reinit, bool lock_acquired) - i40e_stat_str(&pf->hw, ret), - i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); - -- /* make sure our flow control settings are restored */ -- ret = i40e_set_fc(&pf->hw, &set_fc_aq_fail, true); -- if (ret) -- dev_dbg(&pf->pdev->dev, "setting flow control: ret = %s last_status = %s\n", -- i40e_stat_str(&pf->hw, ret), -- i40e_aq_str(&pf->hw, pf->hw.aq.asq_last_status)); -- - /* Rebuild the VSIs and VEBs that existed before reset. - * They are still in our local switch element arrays, so only - * need to rebuild the switch model in the HW. -@@ -11770,6 +11765,8 @@ i40e_status i40e_set_partition_bw_setting(struct i40e_pf *pf) - struct i40e_aqc_configure_partition_bw_data bw_data; - i40e_status status; - -+ memset(&bw_data, 0, sizeof(bw_data)); -+ - /* Set the valid bit for this PF */ - bw_data.pf_valid_bits = cpu_to_le16(BIT(pf->hw.pf_id)); - bw_data.max_bw[pf->hw.pf_id] = pf->max_bw & I40E_ALT_BW_VALUE_MASK; -@@ -14768,7 +14765,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - int err; - u32 val; - u32 i; -- u8 set_fc_aq_fail; - - err = pci_enable_device_mem(pdev); - if (err) -@@ -15090,24 +15086,6 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - } - INIT_LIST_HEAD(&pf->vsi[pf->lan_vsi]->ch_list); - -- /* Make sure flow control is set according to current settings */ -- err = i40e_set_fc(hw, &set_fc_aq_fail, true); -- if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_GET) -- dev_dbg(&pf->pdev->dev, -- "Set fc with err %s aq_err %s on get_phy_cap\n", -- i40e_stat_str(hw, err), -- i40e_aq_str(hw, hw->aq.asq_last_status)); -- if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_SET) -- dev_dbg(&pf->pdev->dev, -- "Set fc with err %s aq_err %s on set_phy_config\n", -- i40e_stat_str(hw, err), -- i40e_aq_str(hw, hw->aq.asq_last_status)); -- if (set_fc_aq_fail & I40E_SET_FC_AQ_FAIL_UPDATE) -- dev_dbg(&pf->pdev->dev, -- "Set fc with err %s aq_err %s on get_link_info\n", -- i40e_stat_str(hw, err), -- i40e_aq_str(hw, hw->aq.asq_last_status)); -- - /* if FDIR VSI was set up, start it now */ - for (i = 0; i < pf->num_alloc_vsi; i++) { - if (pf->vsi[i] && pf->vsi[i]->type == I40E_VSI_FDIR) { -diff --git a/drivers/net/ethernet/intel/i40e/i40e_txrx.c b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -index f47841f3a69d5..218aada8949d9 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_txrx.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_txrx.c -@@ -3093,13 +3093,16 @@ static int i40e_tx_enable_csum(struct sk_buff *skb, u32 *tx_flags, - - l4_proto = ip.v4->protocol; - } else if (*tx_flags & I40E_TX_FLAGS_IPV6) { -+ int ret; -+ - tunnel |= I40E_TX_CTX_EXT_IP_IPV6; - - exthdr = ip.hdr + sizeof(*ip.v6); - l4_proto = ip.v6->nexthdr; -- if (l4.hdr != exthdr) -- ipv6_skip_exthdr(skb, exthdr - skb->data, -- &l4_proto, &frag_off); -+ ret = ipv6_skip_exthdr(skb, exthdr - skb->data, -+ &l4_proto, &frag_off); -+ if (ret < 0) -+ return -1; - } - - /* define outer transport */ -diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c -index 94e3f8b869be4..7b0543056b101 100644 ---- a/drivers/net/ethernet/marvell/mvneta.c -+++ b/drivers/net/ethernet/marvell/mvneta.c -@@ -3027,7 +3027,9 @@ static int mvneta_txq_sw_init(struct mvneta_port *pp, - } - - /* Setup XPS mapping */ -- if (txq_number > 1) -+ if (pp->neta_armada3700) -+ cpu = 0; -+ else if (txq_number > 1) - cpu = txq->id % num_present_cpus(); - else - cpu = pp->rxq_def % num_present_cpus(); -@@ -3764,6 +3766,11 @@ static int mvneta_cpu_online(unsigned int cpu, struct hlist_node *node) - node_online); - struct mvneta_pcpu_port *port = per_cpu_ptr(pp->ports, cpu); - -+ /* Armada 3700's per-cpu interrupt for mvneta is broken, all interrupts -+ * are routed to CPU 0, so we don't need all the cpu-hotplug support -+ */ -+ if (pp->neta_armada3700) -+ return 0; - - spin_lock(&pp->lock); - /* -diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c -index 1187ef1375e29..cb341372d5a35 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c -+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c -@@ -4986,6 +4986,7 @@ static int mlx4_do_mirror_rule(struct mlx4_dev *dev, struct res_fs_rule *fs_rule - - if (!fs_rule->mirr_mbox) { - mlx4_err(dev, "rule mirroring mailbox is null\n"); -+ mlx4_free_cmd_mailbox(dev, mailbox); - return -EINVAL; - } - memcpy(mailbox->buf, fs_rule->mirr_mbox, fs_rule->mirr_mbox_size); -diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c -index 1e8244ec5b332..131be1fa770cb 100644 ---- a/drivers/net/ethernet/realtek/r8169_main.c -+++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -4077,7 +4077,7 @@ static void r8168dp_hw_jumbo_disable(struct rtl8169_private *tp) - - static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) - { -- RTL_W8(tp, MaxTxPacketSize, 0x3f); -+ RTL_W8(tp, MaxTxPacketSize, 0x24); - RTL_W8(tp, Config3, RTL_R8(tp, Config3) | Jumbo_En0); - RTL_W8(tp, Config4, RTL_R8(tp, Config4) | 0x01); - rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_512B); -@@ -4085,7 +4085,7 @@ static void r8168e_hw_jumbo_enable(struct rtl8169_private *tp) - - static void r8168e_hw_jumbo_disable(struct rtl8169_private *tp) - { -- RTL_W8(tp, MaxTxPacketSize, 0x0c); -+ RTL_W8(tp, MaxTxPacketSize, 0x3f); - RTL_W8(tp, Config3, RTL_R8(tp, Config3) & ~Jumbo_En0); - RTL_W8(tp, Config4, RTL_R8(tp, Config4) & ~0x01); - rtl_tx_performance_tweak(tp, PCI_EXP_DEVCTL_READRQ_4096B); -diff --git a/drivers/net/ethernet/sun/sunvnet_common.c b/drivers/net/ethernet/sun/sunvnet_common.c -index 8b94d9ad9e2ba..f87e135a8aef9 100644 ---- a/drivers/net/ethernet/sun/sunvnet_common.c -+++ b/drivers/net/ethernet/sun/sunvnet_common.c -@@ -1353,27 +1353,12 @@ sunvnet_start_xmit_common(struct sk_buff *skb, struct net_device *dev, - if (vio_version_after_eq(&port->vio, 1, 3)) - localmtu -= VLAN_HLEN; - -- if (skb->protocol == htons(ETH_P_IP)) { -- struct flowi4 fl4; -- struct rtable *rt = NULL; -- -- memset(&fl4, 0, sizeof(fl4)); -- fl4.flowi4_oif = dev->ifindex; -- fl4.flowi4_tos = RT_TOS(ip_hdr(skb)->tos); -- fl4.daddr = ip_hdr(skb)->daddr; -- fl4.saddr = ip_hdr(skb)->saddr; -- -- rt = ip_route_output_key(dev_net(dev), &fl4); -- if (!IS_ERR(rt)) { -- skb_dst_set(skb, &rt->dst); -- icmp_send(skb, ICMP_DEST_UNREACH, -- ICMP_FRAG_NEEDED, -- htonl(localmtu)); -- } -- } -+ if (skb->protocol == htons(ETH_P_IP)) -+ icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, -+ htonl(localmtu)); - #if IS_ENABLED(CONFIG_IPV6) - else if (skb->protocol == htons(ETH_P_IPV6)) -- icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, localmtu); -+ icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, localmtu); - #endif - goto out_dropped; - } -diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -index bb6e52f3bdf9b..f98318d93ce72 100644 ---- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c -@@ -1689,6 +1689,18 @@ static int axienet_probe(struct platform_device *pdev) - lp->options = XAE_OPTION_DEFAULTS; - lp->rx_bd_num = RX_BD_NUM_DEFAULT; - lp->tx_bd_num = TX_BD_NUM_DEFAULT; -+ -+ lp->clk = devm_clk_get_optional(&pdev->dev, NULL); -+ if (IS_ERR(lp->clk)) { -+ ret = PTR_ERR(lp->clk); -+ goto free_netdev; -+ } -+ ret = clk_prepare_enable(lp->clk); -+ if (ret) { -+ dev_err(&pdev->dev, "Unable to enable clock: %d\n", ret); -+ goto free_netdev; -+ } -+ - /* Map device registers */ - ethres = platform_get_resource(pdev, IORESOURCE_MEM, 0); - lp->regs = devm_ioremap_resource(&pdev->dev, ethres); -@@ -1836,20 +1848,6 @@ static int axienet_probe(struct platform_device *pdev) - - lp->phy_node = of_parse_phandle(pdev->dev.of_node, "phy-handle", 0); - if (lp->phy_node) { -- lp->clk = devm_clk_get(&pdev->dev, NULL); -- if (IS_ERR(lp->clk)) { -- dev_warn(&pdev->dev, "Failed to get clock: %ld\n", -- PTR_ERR(lp->clk)); -- lp->clk = NULL; -- } else { -- ret = clk_prepare_enable(lp->clk); -- if (ret) { -- dev_err(&pdev->dev, "Unable to enable clock: %d\n", -- ret); -- goto free_netdev; -- } -- } -- - ret = axienet_mdio_setup(lp); - if (ret) - dev_warn(&pdev->dev, -diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c -index 4e19c3149848b..d0653babab923 100644 ---- a/drivers/net/gtp.c -+++ b/drivers/net/gtp.c -@@ -545,9 +545,8 @@ static int gtp_build_skb_ip4(struct sk_buff *skb, struct net_device *dev, - if (!skb_is_gso(skb) && (iph->frag_off & htons(IP_DF)) && - mtu < ntohs(iph->tot_len)) { - netdev_dbg(dev, "packet too big, fragmentation needed\n"); -- memset(IPCB(skb), 0, sizeof(*IPCB(skb))); -- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, -- htonl(mtu)); -+ icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, -+ htonl(mtu)); - goto err_rt; - } - -diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c -index 5502e145aa17b..8443df79fabc7 100644 ---- a/drivers/net/vxlan.c -+++ b/drivers/net/vxlan.c -@@ -4424,7 +4424,6 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) - struct vxlan_net *vn = net_generic(net, vxlan_net_id); - struct vxlan_dev *vxlan, *next; - struct net_device *dev, *aux; -- unsigned int h; - - for_each_netdev_safe(net, dev, aux) - if (dev->rtnl_link_ops == &vxlan_link_ops) -@@ -4438,14 +4437,13 @@ static void vxlan_destroy_tunnels(struct net *net, struct list_head *head) - unregister_netdevice_queue(vxlan->dev, head); - } - -- for (h = 0; h < PORT_HASH_SIZE; ++h) -- WARN_ON_ONCE(!hlist_empty(&vn->sock_list[h])); - } - - static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) - { - struct net *net; - LIST_HEAD(list); -+ unsigned int h; - - rtnl_lock(); - list_for_each_entry(net, net_list, exit_list) -@@ -4453,6 +4451,13 @@ static void __net_exit vxlan_exit_batch_net(struct list_head *net_list) - - unregister_netdevice_many(&list); - rtnl_unlock(); -+ -+ list_for_each_entry(net, net_list, exit_list) { -+ struct vxlan_net *vn = net_generic(net, vxlan_net_id); -+ -+ for (h = 0; h < PORT_HASH_SIZE; ++h) -+ WARN_ON_ONCE(!hlist_empty(&vn->sock_list[h])); -+ } - } - - static struct pernet_operations vxlan_net_ops = { -diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c -index 63607c3b8e818..d4589b2ab3b6d 100644 ---- a/drivers/net/wireless/ath/ath10k/snoc.c -+++ b/drivers/net/wireless/ath/ath10k/snoc.c -@@ -1039,12 +1039,13 @@ static int ath10k_snoc_hif_power_up(struct ath10k *ar, - ret = ath10k_snoc_init_pipes(ar); - if (ret) { - ath10k_err(ar, "failed to initialize CE: %d\n", ret); -- goto err_wlan_enable; -+ goto err_free_rri; - } - - return 0; - --err_wlan_enable: -+err_free_rri: -+ ath10k_ce_free_rri(ar); - ath10k_snoc_wlan_disable(ar); - - return ret; -diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c -index 26ea51a721564..859a865c59950 100644 ---- a/drivers/net/wireless/ath/ath9k/debug.c -+++ b/drivers/net/wireless/ath/ath9k/debug.c -@@ -1223,8 +1223,11 @@ static ssize_t write_file_nf_override(struct file *file, - - ah->nf_override = val; - -- if (ah->curchan) -+ if (ah->curchan) { -+ ath9k_ps_wakeup(sc); - ath9k_hw_loadnf(ah, ah->curchan); -+ ath9k_ps_restore(sc); -+ } - - return count; - } -diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c -index d3c001fa8eb46..32ce1b42ce08b 100644 ---- a/drivers/net/wireless/broadcom/b43/phy_n.c -+++ b/drivers/net/wireless/broadcom/b43/phy_n.c -@@ -5308,7 +5308,7 @@ static void b43_nphy_restore_cal(struct b43_wldev *dev) - - for (i = 0; i < 4; i++) { - if (dev->phy.rev >= 3) -- table[i] = coef[i]; -+ coef[i] = table[i]; - else - coef[i] = 0; - } -diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c -index e889488b84a03..8090895873011 100644 ---- a/drivers/net/xen-netback/interface.c -+++ b/drivers/net/xen-netback/interface.c -@@ -162,13 +162,15 @@ irqreturn_t xenvif_interrupt(int irq, void *dev_id) - { - struct xenvif_queue *queue = dev_id; - int old; -+ bool has_rx, has_tx; - - old = atomic_fetch_or(NETBK_COMMON_EOI, &queue->eoi_pending); - WARN(old, "Interrupt while EOI pending\n"); - -- /* Use bitwise or as we need to call both functions. */ -- if ((!xenvif_handle_tx_interrupt(queue) | -- !xenvif_handle_rx_interrupt(queue))) { -+ has_tx = xenvif_handle_tx_interrupt(queue); -+ has_rx = xenvif_handle_rx_interrupt(queue); -+ -+ if (!has_rx && !has_tx) { - atomic_andnot(NETBK_COMMON_EOI, &queue->eoi_pending); - xen_irq_lateeoi(irq, XEN_EOI_FLAG_SPURIOUS); - } -diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c -index 84f4078216a36..3ba68baeed1db 100644 ---- a/drivers/nvmem/core.c -+++ b/drivers/nvmem/core.c -@@ -314,7 +314,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) - - for_each_child_of_node(parent, child) { - addr = of_get_property(child, "reg", &len); -- if (!addr || (len < 2 * sizeof(u32))) { -+ if (!addr) -+ continue; -+ if (len < 2 * sizeof(u32)) { - dev_err(dev, "nvmem: invalid reg on %pOF\n", child); - return -EINVAL; - } -@@ -345,6 +347,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem) - cell->name, nvmem->stride); - /* Cells already added will be freed later. */ - kfree_const(cell->name); -+ of_node_put(cell->np); - kfree(cell); - return -EINVAL; - } -diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c -index 223d617ecfe17..fc24102e25ce7 100644 ---- a/drivers/of/fdt.c -+++ b/drivers/of/fdt.c -@@ -1153,8 +1153,16 @@ int __init __weak early_init_dt_mark_hotplug_memory_arch(u64 base, u64 size) - int __init __weak early_init_dt_reserve_memory_arch(phys_addr_t base, - phys_addr_t size, bool nomap) - { -- if (nomap) -- return memblock_remove(base, size); -+ if (nomap) { -+ /* -+ * If the memory is already reserved (by another region), we -+ * should not allow it to be marked nomap. -+ */ -+ if (memblock_is_region_reserved(base, size)) -+ return -EBUSY; -+ -+ return memblock_mark_nomap(base, size); -+ } - return memblock_reserve(base, size); - } - -diff --git a/drivers/pci/controller/dwc/pcie-qcom.c b/drivers/pci/controller/dwc/pcie-qcom.c -index 14196c0287a24..a8eab4e67af10 100644 ---- a/drivers/pci/controller/dwc/pcie-qcom.c -+++ b/drivers/pci/controller/dwc/pcie-qcom.c -@@ -402,7 +402,9 @@ static int qcom_pcie_init_2_1_0(struct qcom_pcie *pcie) - - /* enable external reference clock */ - val = readl(pcie->parf + PCIE20_PARF_PHY_REFCLK); -- val &= ~PHY_REFCLK_USE_PAD; -+ /* USE_PAD is required only for ipq806x */ -+ if (!of_device_is_compatible(node, "qcom,pcie-apq8064")) -+ val &= ~PHY_REFCLK_USE_PAD; - val |= PHY_REFCLK_SSP_EN; - writel(val, pcie->parf + PCIE20_PARF_PHY_REFCLK); - -diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c -index d21fa04fa44d2..da5023e27951a 100644 ---- a/drivers/pci/setup-res.c -+++ b/drivers/pci/setup-res.c -@@ -409,10 +409,16 @@ EXPORT_SYMBOL(pci_release_resource); - int pci_resize_resource(struct pci_dev *dev, int resno, int size) - { - struct resource *res = dev->resource + resno; -+ struct pci_host_bridge *host; - int old, ret; - u32 sizes; - u16 cmd; - -+ /* Check if we must preserve the firmware's resource assignment */ -+ host = pci_find_host_bridge(dev->bus); -+ if (host->preserve_config) -+ return -ENOTSUPP; -+ - /* Make sure the resource isn't assigned before resizing it. */ - if (!(res->flags & IORESOURCE_UNSET)) - return -EBUSY; -diff --git a/drivers/pci/syscall.c b/drivers/pci/syscall.c -index 31e39558d49d8..8b003c890b87b 100644 ---- a/drivers/pci/syscall.c -+++ b/drivers/pci/syscall.c -@@ -20,7 +20,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, - u16 word; - u32 dword; - long err; -- long cfg_ret; -+ int cfg_ret; - - if (!capable(CAP_SYS_ADMIN)) - return -EPERM; -@@ -46,7 +46,7 @@ SYSCALL_DEFINE5(pciconfig_read, unsigned long, bus, unsigned long, dfn, - } - - err = -EIO; -- if (cfg_ret != PCIBIOS_SUCCESSFUL) -+ if (cfg_ret) - goto error; - - switch (len) { -@@ -105,7 +105,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn, - if (err) - break; - err = pci_user_write_config_byte(dev, off, byte); -- if (err != PCIBIOS_SUCCESSFUL) -+ if (err) - err = -EIO; - break; - -@@ -114,7 +114,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn, - if (err) - break; - err = pci_user_write_config_word(dev, off, word); -- if (err != PCIBIOS_SUCCESSFUL) -+ if (err) - err = -EIO; - break; - -@@ -123,7 +123,7 @@ SYSCALL_DEFINE5(pciconfig_write, unsigned long, bus, unsigned long, dfn, - if (err) - break; - err = pci_user_write_config_dword(dev, off, dword); -- if (err != PCIBIOS_SUCCESSFUL) -+ if (err) - err = -EIO; - break; - -diff --git a/drivers/phy/rockchip/phy-rockchip-emmc.c b/drivers/phy/rockchip/phy-rockchip-emmc.c -index 2dc19ddd120f5..a005fc58bbf02 100644 ---- a/drivers/phy/rockchip/phy-rockchip-emmc.c -+++ b/drivers/phy/rockchip/phy-rockchip-emmc.c -@@ -240,15 +240,17 @@ static int rockchip_emmc_phy_init(struct phy *phy) - * - SDHCI driver to get the PHY - * - SDHCI driver to init the PHY - * -- * The clock is optional, so upon any error we just set to NULL. -+ * The clock is optional, using clk_get_optional() to get the clock -+ * and do error processing if the return value != NULL - * - * NOTE: we don't do anything special for EPROBE_DEFER here. Given the - * above expected use case, EPROBE_DEFER isn't sensible to expect, so - * it's just like any other error. - */ -- rk_phy->emmcclk = clk_get(&phy->dev, "emmcclk"); -+ rk_phy->emmcclk = clk_get_optional(&phy->dev, "emmcclk"); - if (IS_ERR(rk_phy->emmcclk)) { -- dev_dbg(&phy->dev, "Error getting emmcclk: %d\n", ret); -+ ret = PTR_ERR(rk_phy->emmcclk); -+ dev_err(&phy->dev, "Error getting emmcclk: %d\n", ret); - rk_phy->emmcclk = NULL; - } - -diff --git a/drivers/power/reset/at91-sama5d2_shdwc.c b/drivers/power/reset/at91-sama5d2_shdwc.c -index e341cc5c0ea6f..c84df27cd5482 100644 ---- a/drivers/power/reset/at91-sama5d2_shdwc.c -+++ b/drivers/power/reset/at91-sama5d2_shdwc.c -@@ -37,7 +37,7 @@ - - #define AT91_SHDW_MR 0x04 /* Shut Down Mode Register */ - #define AT91_SHDW_WKUPDBC_SHIFT 24 --#define AT91_SHDW_WKUPDBC_MASK GENMASK(31, 16) -+#define AT91_SHDW_WKUPDBC_MASK GENMASK(26, 24) - #define AT91_SHDW_WKUPDBC(x) (((x) << AT91_SHDW_WKUPDBC_SHIFT) \ - & AT91_SHDW_WKUPDBC_MASK) - -diff --git a/drivers/pwm/pwm-rockchip.c b/drivers/pwm/pwm-rockchip.c -index 73352e6fbccbf..6ad6aad215cf1 100644 ---- a/drivers/pwm/pwm-rockchip.c -+++ b/drivers/pwm/pwm-rockchip.c -@@ -361,7 +361,6 @@ static int rockchip_pwm_probe(struct platform_device *pdev) - - ret = pwmchip_add(&pc->chip); - if (ret < 0) { -- clk_unprepare(pc->clk); - dev_err(&pdev->dev, "pwmchip_add() failed: %d\n", ret); - goto err_pclk; - } -diff --git a/drivers/regulator/axp20x-regulator.c b/drivers/regulator/axp20x-regulator.c -index aefc351bfed59..86a3c2dd05848 100644 ---- a/drivers/regulator/axp20x-regulator.c -+++ b/drivers/regulator/axp20x-regulator.c -@@ -1072,7 +1072,7 @@ static int axp20x_set_dcdc_freq(struct platform_device *pdev, u32 dcdcfreq) - static int axp20x_regulator_parse_dt(struct platform_device *pdev) - { - struct device_node *np, *regulators; -- int ret; -+ int ret = 0; - u32 dcdcfreq = 0; - - np = of_node_get(pdev->dev.parent->of_node); -@@ -1087,13 +1087,12 @@ static int axp20x_regulator_parse_dt(struct platform_device *pdev) - ret = axp20x_set_dcdc_freq(pdev, dcdcfreq); - if (ret < 0) { - dev_err(&pdev->dev, "Error setting dcdc frequency: %d\n", ret); -- return ret; - } -- - of_node_put(regulators); - } - -- return 0; -+ of_node_put(np); -+ return ret; - } - - static int axp20x_set_dcdc_workmode(struct regulator_dev *rdev, int id, u32 workmode) -diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c -index 5b9d570df85cc..a31b6ae92a84e 100644 ---- a/drivers/regulator/core.c -+++ b/drivers/regulator/core.c -@@ -1576,7 +1576,7 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, - const char *supply_name) - { - struct regulator *regulator; -- int err; -+ int err = 0; - - if (dev) { - char buf[REG_STR_SIZE]; -@@ -1622,8 +1622,8 @@ static struct regulator *create_regulator(struct regulator_dev *rdev, - } - } - -- regulator->debugfs = debugfs_create_dir(supply_name, -- rdev->debugfs); -+ if (err != -EEXIST) -+ regulator->debugfs = debugfs_create_dir(supply_name, rdev->debugfs); - if (!regulator->debugfs) { - rdev_dbg(rdev, "Failed to create debugfs directory\n"); - } else { -diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c -index a47f87b8373df..68d22acdb037a 100644 ---- a/drivers/regulator/qcom-rpmh-regulator.c -+++ b/drivers/regulator/qcom-rpmh-regulator.c -@@ -874,7 +874,7 @@ static const struct rpmh_vreg_init_data pm8009_vreg_data[] = { - RPMH_VREG("ldo4", "ldo%s4", &pmic5_nldo, "vdd-l4"), - RPMH_VREG("ldo5", "ldo%s5", &pmic5_pldo, "vdd-l5-l6"), - RPMH_VREG("ldo6", "ldo%s6", &pmic5_pldo, "vdd-l5-l6"), -- RPMH_VREG("ldo7", "ldo%s6", &pmic5_pldo_lv, "vdd-l7"), -+ RPMH_VREG("ldo7", "ldo%s7", &pmic5_pldo_lv, "vdd-l7"), - {}, - }; - -diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c -index 6ca27e9d5ef7d..5276f8442f3c6 100644 ---- a/drivers/regulator/s5m8767.c -+++ b/drivers/regulator/s5m8767.c -@@ -544,14 +544,18 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, - rdata = devm_kcalloc(&pdev->dev, - pdata->num_regulators, sizeof(*rdata), - GFP_KERNEL); -- if (!rdata) -+ if (!rdata) { -+ of_node_put(regulators_np); - return -ENOMEM; -+ } - - rmode = devm_kcalloc(&pdev->dev, - pdata->num_regulators, sizeof(*rmode), - GFP_KERNEL); -- if (!rmode) -+ if (!rmode) { -+ of_node_put(regulators_np); - return -ENOMEM; -+ } - - pdata->regulators = rdata; - pdata->opmode = rmode; -@@ -574,10 +578,13 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, - 0, - GPIOD_OUT_HIGH | GPIOD_FLAGS_BIT_NONEXCLUSIVE, - "s5m8767"); -- if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT) -+ if (PTR_ERR(rdata->ext_control_gpiod) == -ENOENT) { - rdata->ext_control_gpiod = NULL; -- else if (IS_ERR(rdata->ext_control_gpiod)) -+ } else if (IS_ERR(rdata->ext_control_gpiod)) { -+ of_node_put(reg_np); -+ of_node_put(regulators_np); - return PTR_ERR(rdata->ext_control_gpiod); -+ } - - rdata->id = i; - rdata->initdata = of_get_regulator_init_data( -diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig -index c5b9804140860..9ae7ce3f50696 100644 ---- a/drivers/rtc/Kconfig -+++ b/drivers/rtc/Kconfig -@@ -683,6 +683,7 @@ config RTC_DRV_S5M - tristate "Samsung S2M/S5M series" - depends on MFD_SEC_CORE || COMPILE_TEST - select REGMAP_IRQ -+ select REGMAP_I2C - help - If you say yes here you will get support for the - RTC of Samsung S2MPS14 and S5M PMIC series. -diff --git a/drivers/s390/virtio/virtio_ccw.c b/drivers/s390/virtio/virtio_ccw.c -index 957889a42d2ea..f6f03a349c3f0 100644 ---- a/drivers/s390/virtio/virtio_ccw.c -+++ b/drivers/s390/virtio/virtio_ccw.c -@@ -117,7 +117,7 @@ struct virtio_rev_info { - }; - - /* the highest virtio-ccw revision we support */ --#define VIRTIO_CCW_REV_MAX 1 -+#define VIRTIO_CCW_REV_MAX 2 - - struct virtio_ccw_vq_info { - struct virtqueue *vq; -@@ -952,7 +952,7 @@ static u8 virtio_ccw_get_status(struct virtio_device *vdev) - u8 old_status = vcdev->dma_area->status; - struct ccw1 *ccw; - -- if (vcdev->revision < 1) -+ if (vcdev->revision < 2) - return vcdev->dma_area->status; - - ccw = ccw_device_dma_zalloc(vcdev->cdev, sizeof(*ccw)); -diff --git a/drivers/scsi/bnx2fc/Kconfig b/drivers/scsi/bnx2fc/Kconfig -index e0ccb48ec9617..40e9c9dc04bd8 100644 ---- a/drivers/scsi/bnx2fc/Kconfig -+++ b/drivers/scsi/bnx2fc/Kconfig -@@ -5,6 +5,7 @@ config SCSI_BNX2X_FCOE - depends on (IPV6 || IPV6=n) - depends on LIBFC - depends on LIBFCOE -+ depends on MMU - select NETDEVICES - select ETHERNET - select NET_VENDOR_BROADCOM -diff --git a/drivers/soc/aspeed/aspeed-lpc-snoop.c b/drivers/soc/aspeed/aspeed-lpc-snoop.c -index f3d8d53ab84de..dbe5325a324d5 100644 ---- a/drivers/soc/aspeed/aspeed-lpc-snoop.c -+++ b/drivers/soc/aspeed/aspeed-lpc-snoop.c -@@ -11,6 +11,7 @@ - */ - - #include -+#include - #include - #include - #include -@@ -67,6 +68,7 @@ struct aspeed_lpc_snoop_channel { - struct aspeed_lpc_snoop { - struct regmap *regmap; - int irq; -+ struct clk *clk; - struct aspeed_lpc_snoop_channel chan[NUM_SNOOP_CHANNELS]; - }; - -@@ -282,22 +284,42 @@ static int aspeed_lpc_snoop_probe(struct platform_device *pdev) - return -ENODEV; - } - -+ lpc_snoop->clk = devm_clk_get(dev, NULL); -+ if (IS_ERR(lpc_snoop->clk)) { -+ rc = PTR_ERR(lpc_snoop->clk); -+ if (rc != -EPROBE_DEFER) -+ dev_err(dev, "couldn't get clock\n"); -+ return rc; -+ } -+ rc = clk_prepare_enable(lpc_snoop->clk); -+ if (rc) { -+ dev_err(dev, "couldn't enable clock\n"); -+ return rc; -+ } -+ - rc = aspeed_lpc_snoop_config_irq(lpc_snoop, pdev); - if (rc) -- return rc; -+ goto err; - - rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 0, port); - if (rc) -- return rc; -+ goto err; - - /* Configuration of 2nd snoop channel port is optional */ - if (of_property_read_u32_index(dev->of_node, "snoop-ports", - 1, &port) == 0) { - rc = aspeed_lpc_enable_snoop(lpc_snoop, dev, 1, port); -- if (rc) -+ if (rc) { - aspeed_lpc_disable_snoop(lpc_snoop, 0); -+ goto err; -+ } - } - -+ return 0; -+ -+err: -+ clk_disable_unprepare(lpc_snoop->clk); -+ - return rc; - } - -@@ -309,6 +331,8 @@ static int aspeed_lpc_snoop_remove(struct platform_device *pdev) - aspeed_lpc_disable_snoop(lpc_snoop, 0); - aspeed_lpc_disable_snoop(lpc_snoop, 1); - -+ clk_disable_unprepare(lpc_snoop->clk); -+ - return 0; - } - -diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c -index e3d06330d1258..f7d0f63921dc2 100644 ---- a/drivers/soundwire/cadence_master.c -+++ b/drivers/soundwire/cadence_master.c -@@ -368,10 +368,10 @@ cdns_fill_msg_resp(struct sdw_cdns *cdns, - if (!(cdns->response_buf[i] & CDNS_MCP_RESP_ACK)) { - no_ack = 1; - dev_dbg_ratelimited(cdns->dev, "Msg Ack not received\n"); -- if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { -- nack = 1; -- dev_err_ratelimited(cdns->dev, "Msg NACK received\n"); -- } -+ } -+ if (cdns->response_buf[i] & CDNS_MCP_RESP_NACK) { -+ nack = 1; -+ dev_err_ratelimited(cdns->dev, "Msg NACK received\n"); - } - } - -diff --git a/drivers/spi/spi-atmel.c b/drivers/spi/spi-atmel.c -index abbc1582f457e..d9711ea5b01d3 100644 ---- a/drivers/spi/spi-atmel.c -+++ b/drivers/spi/spi-atmel.c -@@ -1569,7 +1569,7 @@ static int atmel_spi_probe(struct platform_device *pdev) - if (ret == 0) { - as->use_dma = true; - } else if (ret == -EPROBE_DEFER) { -- return ret; -+ goto out_unmap_regs; - } - } else if (as->caps.has_pdc_support) { - as->use_pdc = true; -diff --git a/drivers/spi/spi-pxa2xx-pci.c b/drivers/spi/spi-pxa2xx-pci.c -index f236e3034cf85..aafac128bb5f1 100644 ---- a/drivers/spi/spi-pxa2xx-pci.c -+++ b/drivers/spi/spi-pxa2xx-pci.c -@@ -21,7 +21,8 @@ enum { - PORT_BSW1, - PORT_BSW2, - PORT_CE4100, -- PORT_LPT, -+ PORT_LPT0, -+ PORT_LPT1, - }; - - struct pxa_spi_info { -@@ -57,8 +58,10 @@ static struct dw_dma_slave bsw1_rx_param = { .src_id = 7 }; - static struct dw_dma_slave bsw2_tx_param = { .dst_id = 8 }; - static struct dw_dma_slave bsw2_rx_param = { .src_id = 9 }; - --static struct dw_dma_slave lpt_tx_param = { .dst_id = 0 }; --static struct dw_dma_slave lpt_rx_param = { .src_id = 1 }; -+static struct dw_dma_slave lpt1_tx_param = { .dst_id = 0 }; -+static struct dw_dma_slave lpt1_rx_param = { .src_id = 1 }; -+static struct dw_dma_slave lpt0_tx_param = { .dst_id = 2 }; -+static struct dw_dma_slave lpt0_rx_param = { .src_id = 3 }; - - static bool lpss_dma_filter(struct dma_chan *chan, void *param) - { -@@ -185,12 +188,19 @@ static struct pxa_spi_info spi_info_configs[] = { - .num_chipselect = 1, - .max_clk_rate = 50000000, - }, -- [PORT_LPT] = { -+ [PORT_LPT0] = { - .type = LPSS_LPT_SSP, - .port_id = 0, - .setup = lpss_spi_setup, -- .tx_param = &lpt_tx_param, -- .rx_param = &lpt_rx_param, -+ .tx_param = &lpt0_tx_param, -+ .rx_param = &lpt0_rx_param, -+ }, -+ [PORT_LPT1] = { -+ .type = LPSS_LPT_SSP, -+ .port_id = 1, -+ .setup = lpss_spi_setup, -+ .tx_param = &lpt1_tx_param, -+ .rx_param = &lpt1_rx_param, - }, - }; - -@@ -285,8 +295,9 @@ static const struct pci_device_id pxa2xx_spi_pci_devices[] = { - { PCI_VDEVICE(INTEL, 0x2290), PORT_BSW1 }, - { PCI_VDEVICE(INTEL, 0x22ac), PORT_BSW2 }, - { PCI_VDEVICE(INTEL, 0x2e6a), PORT_CE4100 }, -- { PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT }, -- { }, -+ { PCI_VDEVICE(INTEL, 0x9ce5), PORT_LPT0 }, -+ { PCI_VDEVICE(INTEL, 0x9ce6), PORT_LPT1 }, -+ { } - }; - MODULE_DEVICE_TABLE(pci, pxa2xx_spi_pci_devices); - -diff --git a/drivers/spi/spi-s3c24xx-fiq.S b/drivers/spi/spi-s3c24xx-fiq.S -index e95d6282109e7..68ea12bead227 100644 ---- a/drivers/spi/spi-s3c24xx-fiq.S -+++ b/drivers/spi/spi-s3c24xx-fiq.S -@@ -33,7 +33,6 @@ - @ and an offset to the irq acknowledgment word - - ENTRY(s3c24xx_spi_fiq_rx) --s3c24xx_spi_fix_rx: - .word fiq_rx_end - fiq_rx_start - .word fiq_rx_irq_ack - fiq_rx_start - fiq_rx_start: -@@ -47,7 +46,7 @@ fiq_rx_start: - strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] - - subs fiq_rcount, fiq_rcount, #1 -- subnes pc, lr, #4 @@ return, still have work to do -+ subsne pc, lr, #4 @@ return, still have work to do - - @@ set IRQ controller so that next op will trigger IRQ - mov fiq_rtmp, #0 -@@ -59,7 +58,6 @@ fiq_rx_irq_ack: - fiq_rx_end: - - ENTRY(s3c24xx_spi_fiq_txrx) --s3c24xx_spi_fiq_txrx: - .word fiq_txrx_end - fiq_txrx_start - .word fiq_txrx_irq_ack - fiq_txrx_start - fiq_txrx_start: -@@ -74,7 +72,7 @@ fiq_txrx_start: - strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] - - subs fiq_rcount, fiq_rcount, #1 -- subnes pc, lr, #4 @@ return, still have work to do -+ subsne pc, lr, #4 @@ return, still have work to do - - mov fiq_rtmp, #0 - str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] -@@ -86,7 +84,6 @@ fiq_txrx_irq_ack: - fiq_txrx_end: - - ENTRY(s3c24xx_spi_fiq_tx) --s3c24xx_spi_fix_tx: - .word fiq_tx_end - fiq_tx_start - .word fiq_tx_irq_ack - fiq_tx_start - fiq_tx_start: -@@ -99,7 +96,7 @@ fiq_tx_start: - strb fiq_rtmp, [ fiq_rspi, # S3C2410_SPTDAT ] - - subs fiq_rcount, fiq_rcount, #1 -- subnes pc, lr, #4 @@ return, still have work to do -+ subsne pc, lr, #4 @@ return, still have work to do - - mov fiq_rtmp, #0 - str fiq_rtmp, [ fiq_rirq, # S3C2410_INTMOD - S3C24XX_VA_IRQ ] -diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c -index 77ddf23b65d65..8622cf9d3f640 100644 ---- a/drivers/spi/spi-stm32.c -+++ b/drivers/spi/spi-stm32.c -@@ -1668,6 +1668,10 @@ static int stm32_spi_transfer_one(struct spi_master *master, - struct stm32_spi *spi = spi_master_get_devdata(master); - int ret; - -+ /* Don't do anything on 0 bytes transfers */ -+ if (transfer->len == 0) -+ return 0; -+ - spi->tx_buf = transfer->tx_buf; - spi->rx_buf = transfer->rx_buf; - spi->tx_len = spi->tx_buf ? transfer->len : 0; -diff --git a/drivers/spi/spi-synquacer.c b/drivers/spi/spi-synquacer.c -index 5ab5119e2f1b0..785e7c4451233 100644 ---- a/drivers/spi/spi-synquacer.c -+++ b/drivers/spi/spi-synquacer.c -@@ -490,6 +490,10 @@ static void synquacer_spi_set_cs(struct spi_device *spi, bool enable) - val &= ~(SYNQUACER_HSSPI_DMPSEL_CS_MASK << - SYNQUACER_HSSPI_DMPSEL_CS_SHIFT); - val |= spi->chip_select << SYNQUACER_HSSPI_DMPSEL_CS_SHIFT; -+ -+ if (!enable) -+ val |= SYNQUACER_HSSPI_DMSTOP_STOP; -+ - writel(val, sspi->regs + SYNQUACER_HSSPI_REG_DMSTART); - } - -diff --git a/drivers/spmi/spmi-pmic-arb.c b/drivers/spmi/spmi-pmic-arb.c -index de844b4121107..bbbd311eda030 100644 ---- a/drivers/spmi/spmi-pmic-arb.c -+++ b/drivers/spmi/spmi-pmic-arb.c -@@ -1,6 +1,6 @@ - // SPDX-License-Identifier: GPL-2.0-only - /* -- * Copyright (c) 2012-2015, 2017, The Linux Foundation. All rights reserved. -+ * Copyright (c) 2012-2015, 2017, 2021, The Linux Foundation. All rights reserved. - */ - #include - #include -@@ -505,8 +505,7 @@ static void cleanup_irq(struct spmi_pmic_arb *pmic_arb, u16 apid, int id) - static void periph_interrupt(struct spmi_pmic_arb *pmic_arb, u16 apid) - { - unsigned int irq; -- u32 status; -- int id; -+ u32 status, id; - u8 sid = (pmic_arb->apid_data[apid].ppid >> 8) & 0xF; - u8 per = pmic_arb->apid_data[apid].ppid & 0xFF; - -diff --git a/drivers/staging/gdm724x/gdm_usb.c b/drivers/staging/gdm724x/gdm_usb.c -index dc4da66c3695b..54bdb64f52e88 100644 ---- a/drivers/staging/gdm724x/gdm_usb.c -+++ b/drivers/staging/gdm724x/gdm_usb.c -@@ -56,20 +56,24 @@ static int gdm_usb_recv(void *priv_dev, - - static int request_mac_address(struct lte_udev *udev) - { -- u8 buf[16] = {0,}; -- struct hci_packet *hci = (struct hci_packet *)buf; -+ struct hci_packet *hci; - struct usb_device *usbdev = udev->usbdev; - int actual; - int ret = -1; - -+ hci = kmalloc(struct_size(hci, data, 1), GFP_KERNEL); -+ if (!hci) -+ return -ENOMEM; -+ - hci->cmd_evt = gdm_cpu_to_dev16(udev->gdm_ed, LTE_GET_INFORMATION); - hci->len = gdm_cpu_to_dev16(udev->gdm_ed, 1); - hci->data[0] = MAC_ADDRESS; - -- ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 2), buf, 5, -+ ret = usb_bulk_msg(usbdev, usb_sndbulkpipe(usbdev, 2), hci, 5, - &actual, 1000); - - udev->request_mac_addr = 1; -+ kfree(hci); - - return ret; - } -diff --git a/drivers/staging/media/imx/imx-media-csc-scaler.c b/drivers/staging/media/imx/imx-media-csc-scaler.c -index 2b635ebf62d6a..a15d970adb983 100644 ---- a/drivers/staging/media/imx/imx-media-csc-scaler.c -+++ b/drivers/staging/media/imx/imx-media-csc-scaler.c -@@ -866,11 +866,7 @@ void imx_media_csc_scaler_device_unregister(struct imx_media_video_dev *vdev) - struct ipu_csc_scaler_priv *priv = vdev_to_priv(vdev); - struct video_device *vfd = priv->vdev.vfd; - -- mutex_lock(&priv->mutex); -- - video_unregister_device(vfd); -- -- mutex_unlock(&priv->mutex); - } - - struct imx_media_video_dev * -diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c -index 2c3c2adca6832..e16408af92d9c 100644 ---- a/drivers/staging/media/imx/imx-media-dev.c -+++ b/drivers/staging/media/imx/imx-media-dev.c -@@ -53,6 +53,7 @@ static int imx6_media_probe_complete(struct v4l2_async_notifier *notifier) - imxmd->m2m_vdev = imx_media_csc_scaler_device_init(imxmd); - if (IS_ERR(imxmd->m2m_vdev)) { - ret = PTR_ERR(imxmd->m2m_vdev); -+ imxmd->m2m_vdev = NULL; - goto unlock; - } - -@@ -107,10 +108,14 @@ static int imx_media_remove(struct platform_device *pdev) - - v4l2_info(&imxmd->v4l2_dev, "Removing imx-media\n"); - -+ if (imxmd->m2m_vdev) { -+ imx_media_csc_scaler_device_unregister(imxmd->m2m_vdev); -+ imxmd->m2m_vdev = NULL; -+ } -+ - v4l2_async_notifier_unregister(&imxmd->notifier); - imx_media_unregister_ipu_internal_subdevs(imxmd); - v4l2_async_notifier_cleanup(&imxmd->notifier); -- imx_media_csc_scaler_device_unregister(imxmd->m2m_vdev); - media_device_unregister(&imxmd->md); - v4l2_device_unregister(&imxmd->v4l2_dev); - media_device_cleanup(&imxmd->md); -diff --git a/drivers/staging/mt7621-dma/Makefile b/drivers/staging/mt7621-dma/Makefile -index 66da1bf10c32e..23256d1286f3e 100644 ---- a/drivers/staging/mt7621-dma/Makefile -+++ b/drivers/staging/mt7621-dma/Makefile -@@ -1,4 +1,4 @@ - # SPDX-License-Identifier: GPL-2.0 --obj-$(CONFIG_MTK_HSDMA) += mtk-hsdma.o -+obj-$(CONFIG_MTK_HSDMA) += hsdma-mt7621.o - - ccflags-y += -I$(srctree)/drivers/dma -diff --git a/drivers/staging/mt7621-dma/hsdma-mt7621.c b/drivers/staging/mt7621-dma/hsdma-mt7621.c -new file mode 100644 -index 0000000000000..803b66d8ee6b5 ---- /dev/null -+++ b/drivers/staging/mt7621-dma/hsdma-mt7621.c -@@ -0,0 +1,762 @@ -+// SPDX-License-Identifier: GPL-2.0+ -+/* -+ * Copyright (C) 2015, Michael Lee -+ * MTK HSDMA support -+ */ -+ -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+#include -+ -+#include "virt-dma.h" -+ -+#define HSDMA_BASE_OFFSET 0x800 -+ -+#define HSDMA_REG_TX_BASE 0x00 -+#define HSDMA_REG_TX_CNT 0x04 -+#define HSDMA_REG_TX_CTX 0x08 -+#define HSDMA_REG_TX_DTX 0x0c -+#define HSDMA_REG_RX_BASE 0x100 -+#define HSDMA_REG_RX_CNT 0x104 -+#define HSDMA_REG_RX_CRX 0x108 -+#define HSDMA_REG_RX_DRX 0x10c -+#define HSDMA_REG_INFO 0x200 -+#define HSDMA_REG_GLO_CFG 0x204 -+#define HSDMA_REG_RST_CFG 0x208 -+#define HSDMA_REG_DELAY_INT 0x20c -+#define HSDMA_REG_FREEQ_THRES 0x210 -+#define HSDMA_REG_INT_STATUS 0x220 -+#define HSDMA_REG_INT_MASK 0x228 -+#define HSDMA_REG_SCH_Q01 0x280 -+#define HSDMA_REG_SCH_Q23 0x284 -+ -+#define HSDMA_DESCS_MAX 0xfff -+#define HSDMA_DESCS_NUM 8 -+#define HSDMA_DESCS_MASK (HSDMA_DESCS_NUM - 1) -+#define HSDMA_NEXT_DESC(x) (((x) + 1) & HSDMA_DESCS_MASK) -+ -+/* HSDMA_REG_INFO */ -+#define HSDMA_INFO_INDEX_MASK 0xf -+#define HSDMA_INFO_INDEX_SHIFT 24 -+#define HSDMA_INFO_BASE_MASK 0xff -+#define HSDMA_INFO_BASE_SHIFT 16 -+#define HSDMA_INFO_RX_MASK 0xff -+#define HSDMA_INFO_RX_SHIFT 8 -+#define HSDMA_INFO_TX_MASK 0xff -+#define HSDMA_INFO_TX_SHIFT 0 -+ -+/* HSDMA_REG_GLO_CFG */ -+#define HSDMA_GLO_TX_2B_OFFSET BIT(31) -+#define HSDMA_GLO_CLK_GATE BIT(30) -+#define HSDMA_GLO_BYTE_SWAP BIT(29) -+#define HSDMA_GLO_MULTI_DMA BIT(10) -+#define HSDMA_GLO_TWO_BUF BIT(9) -+#define HSDMA_GLO_32B_DESC BIT(8) -+#define HSDMA_GLO_BIG_ENDIAN BIT(7) -+#define HSDMA_GLO_TX_DONE BIT(6) -+#define HSDMA_GLO_BT_MASK 0x3 -+#define HSDMA_GLO_BT_SHIFT 4 -+#define HSDMA_GLO_RX_BUSY BIT(3) -+#define HSDMA_GLO_RX_DMA BIT(2) -+#define HSDMA_GLO_TX_BUSY BIT(1) -+#define HSDMA_GLO_TX_DMA BIT(0) -+ -+#define HSDMA_BT_SIZE_16BYTES (0 << HSDMA_GLO_BT_SHIFT) -+#define HSDMA_BT_SIZE_32BYTES (1 << HSDMA_GLO_BT_SHIFT) -+#define HSDMA_BT_SIZE_64BYTES (2 << HSDMA_GLO_BT_SHIFT) -+#define HSDMA_BT_SIZE_128BYTES (3 << HSDMA_GLO_BT_SHIFT) -+ -+#define HSDMA_GLO_DEFAULT (HSDMA_GLO_MULTI_DMA | \ -+ HSDMA_GLO_RX_DMA | HSDMA_GLO_TX_DMA | HSDMA_BT_SIZE_32BYTES) -+ -+/* HSDMA_REG_RST_CFG */ -+#define HSDMA_RST_RX_SHIFT 16 -+#define HSDMA_RST_TX_SHIFT 0 -+ -+/* HSDMA_REG_DELAY_INT */ -+#define HSDMA_DELAY_INT_EN BIT(15) -+#define HSDMA_DELAY_PEND_OFFSET 8 -+#define HSDMA_DELAY_TIME_OFFSET 0 -+#define HSDMA_DELAY_TX_OFFSET 16 -+#define HSDMA_DELAY_RX_OFFSET 0 -+ -+#define HSDMA_DELAY_INIT(x) (HSDMA_DELAY_INT_EN | \ -+ ((x) << HSDMA_DELAY_PEND_OFFSET)) -+#define HSDMA_DELAY(x) ((HSDMA_DELAY_INIT(x) << \ -+ HSDMA_DELAY_TX_OFFSET) | HSDMA_DELAY_INIT(x)) -+ -+/* HSDMA_REG_INT_STATUS */ -+#define HSDMA_INT_DELAY_RX_COH BIT(31) -+#define HSDMA_INT_DELAY_RX_INT BIT(30) -+#define HSDMA_INT_DELAY_TX_COH BIT(29) -+#define HSDMA_INT_DELAY_TX_INT BIT(28) -+#define HSDMA_INT_RX_MASK 0x3 -+#define HSDMA_INT_RX_SHIFT 16 -+#define HSDMA_INT_RX_Q0 BIT(16) -+#define HSDMA_INT_TX_MASK 0xf -+#define HSDMA_INT_TX_SHIFT 0 -+#define HSDMA_INT_TX_Q0 BIT(0) -+ -+/* tx/rx dma desc flags */ -+#define HSDMA_PLEN_MASK 0x3fff -+#define HSDMA_DESC_DONE BIT(31) -+#define HSDMA_DESC_LS0 BIT(30) -+#define HSDMA_DESC_PLEN0(_x) (((_x) & HSDMA_PLEN_MASK) << 16) -+#define HSDMA_DESC_TAG BIT(15) -+#define HSDMA_DESC_LS1 BIT(14) -+#define HSDMA_DESC_PLEN1(_x) ((_x) & HSDMA_PLEN_MASK) -+ -+/* align 4 bytes */ -+#define HSDMA_ALIGN_SIZE 3 -+/* align size 128bytes */ -+#define HSDMA_MAX_PLEN 0x3f80 -+ -+struct hsdma_desc { -+ u32 addr0; -+ u32 flags; -+ u32 addr1; -+ u32 unused; -+}; -+ -+struct mtk_hsdma_sg { -+ dma_addr_t src_addr; -+ dma_addr_t dst_addr; -+ u32 len; -+}; -+ -+struct mtk_hsdma_desc { -+ struct virt_dma_desc vdesc; -+ unsigned int num_sgs; -+ struct mtk_hsdma_sg sg[1]; -+}; -+ -+struct mtk_hsdma_chan { -+ struct virt_dma_chan vchan; -+ unsigned int id; -+ dma_addr_t desc_addr; -+ int tx_idx; -+ int rx_idx; -+ struct hsdma_desc *tx_ring; -+ struct hsdma_desc *rx_ring; -+ struct mtk_hsdma_desc *desc; -+ unsigned int next_sg; -+}; -+ -+struct mtk_hsdam_engine { -+ struct dma_device ddev; -+ struct device_dma_parameters dma_parms; -+ void __iomem *base; -+ struct tasklet_struct task; -+ volatile unsigned long chan_issued; -+ -+ struct mtk_hsdma_chan chan[1]; -+}; -+ -+static inline struct mtk_hsdam_engine *mtk_hsdma_chan_get_dev( -+ struct mtk_hsdma_chan *chan) -+{ -+ return container_of(chan->vchan.chan.device, struct mtk_hsdam_engine, -+ ddev); -+} -+ -+static inline struct mtk_hsdma_chan *to_mtk_hsdma_chan(struct dma_chan *c) -+{ -+ return container_of(c, struct mtk_hsdma_chan, vchan.chan); -+} -+ -+static inline struct mtk_hsdma_desc *to_mtk_hsdma_desc( -+ struct virt_dma_desc *vdesc) -+{ -+ return container_of(vdesc, struct mtk_hsdma_desc, vdesc); -+} -+ -+static inline u32 mtk_hsdma_read(struct mtk_hsdam_engine *hsdma, u32 reg) -+{ -+ return readl(hsdma->base + reg); -+} -+ -+static inline void mtk_hsdma_write(struct mtk_hsdam_engine *hsdma, -+ unsigned int reg, u32 val) -+{ -+ writel(val, hsdma->base + reg); -+} -+ -+static void mtk_hsdma_reset_chan(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ chan->tx_idx = 0; -+ chan->rx_idx = HSDMA_DESCS_NUM - 1; -+ -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_CTX, chan->tx_idx); -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_CRX, chan->rx_idx); -+ -+ mtk_hsdma_write(hsdma, HSDMA_REG_RST_CFG, -+ 0x1 << (chan->id + HSDMA_RST_TX_SHIFT)); -+ mtk_hsdma_write(hsdma, HSDMA_REG_RST_CFG, -+ 0x1 << (chan->id + HSDMA_RST_RX_SHIFT)); -+} -+ -+static void hsdma_dump_reg(struct mtk_hsdam_engine *hsdma) -+{ -+ dev_dbg(hsdma->ddev.dev, "tbase %08x, tcnt %08x, " \ -+ "tctx %08x, tdtx: %08x, rbase %08x, " \ -+ "rcnt %08x, rctx %08x, rdtx %08x\n", -+ mtk_hsdma_read(hsdma, HSDMA_REG_TX_BASE), -+ mtk_hsdma_read(hsdma, HSDMA_REG_TX_CNT), -+ mtk_hsdma_read(hsdma, HSDMA_REG_TX_CTX), -+ mtk_hsdma_read(hsdma, HSDMA_REG_TX_DTX), -+ mtk_hsdma_read(hsdma, HSDMA_REG_RX_BASE), -+ mtk_hsdma_read(hsdma, HSDMA_REG_RX_CNT), -+ mtk_hsdma_read(hsdma, HSDMA_REG_RX_CRX), -+ mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX)); -+ -+ dev_dbg(hsdma->ddev.dev, "info %08x, glo %08x, delay %08x, " \ -+ "intr_stat %08x, intr_mask %08x\n", -+ mtk_hsdma_read(hsdma, HSDMA_REG_INFO), -+ mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG), -+ mtk_hsdma_read(hsdma, HSDMA_REG_DELAY_INT), -+ mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS), -+ mtk_hsdma_read(hsdma, HSDMA_REG_INT_MASK)); -+} -+ -+static void hsdma_dump_desc(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ struct hsdma_desc *tx_desc; -+ struct hsdma_desc *rx_desc; -+ int i; -+ -+ dev_dbg(hsdma->ddev.dev, "tx idx: %d, rx idx: %d\n", -+ chan->tx_idx, chan->rx_idx); -+ -+ for (i = 0; i < HSDMA_DESCS_NUM; i++) { -+ tx_desc = &chan->tx_ring[i]; -+ rx_desc = &chan->rx_ring[i]; -+ -+ dev_dbg(hsdma->ddev.dev, "%d tx addr0: %08x, flags %08x, " \ -+ "tx addr1: %08x, rx addr0 %08x, flags %08x\n", -+ i, tx_desc->addr0, tx_desc->flags, \ -+ tx_desc->addr1, rx_desc->addr0, rx_desc->flags); -+ } -+} -+ -+static void mtk_hsdma_reset(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ int i; -+ -+ /* disable dma */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, 0); -+ -+ /* disable intr */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, 0); -+ -+ /* init desc value */ -+ for (i = 0; i < HSDMA_DESCS_NUM; i++) { -+ chan->tx_ring[i].addr0 = 0; -+ chan->tx_ring[i].flags = HSDMA_DESC_LS0 | HSDMA_DESC_DONE; -+ } -+ for (i = 0; i < HSDMA_DESCS_NUM; i++) { -+ chan->rx_ring[i].addr0 = 0; -+ chan->rx_ring[i].flags = 0; -+ } -+ -+ /* reset */ -+ mtk_hsdma_reset_chan(hsdma, chan); -+ -+ /* enable intr */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, HSDMA_INT_RX_Q0); -+ -+ /* enable dma */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, HSDMA_GLO_DEFAULT); -+} -+ -+static int mtk_hsdma_terminate_all(struct dma_chan *c) -+{ -+ struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -+ struct mtk_hsdam_engine *hsdma = mtk_hsdma_chan_get_dev(chan); -+ unsigned long timeout; -+ LIST_HEAD(head); -+ -+ spin_lock_bh(&chan->vchan.lock); -+ chan->desc = NULL; -+ clear_bit(chan->id, &hsdma->chan_issued); -+ vchan_get_all_descriptors(&chan->vchan, &head); -+ spin_unlock_bh(&chan->vchan.lock); -+ -+ vchan_dma_desc_free_list(&chan->vchan, &head); -+ -+ /* wait dma transfer complete */ -+ timeout = jiffies + msecs_to_jiffies(2000); -+ while (mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG) & -+ (HSDMA_GLO_RX_BUSY | HSDMA_GLO_TX_BUSY)) { -+ if (time_after_eq(jiffies, timeout)) { -+ hsdma_dump_desc(hsdma, chan); -+ mtk_hsdma_reset(hsdma, chan); -+ dev_err(hsdma->ddev.dev, "timeout, reset it\n"); -+ break; -+ } -+ cpu_relax(); -+ } -+ -+ return 0; -+} -+ -+static int mtk_hsdma_start_transfer(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ dma_addr_t src, dst; -+ size_t len, tlen; -+ struct hsdma_desc *tx_desc, *rx_desc; -+ struct mtk_hsdma_sg *sg; -+ unsigned int i; -+ int rx_idx; -+ -+ sg = &chan->desc->sg[0]; -+ len = sg->len; -+ chan->desc->num_sgs = DIV_ROUND_UP(len, HSDMA_MAX_PLEN); -+ -+ /* tx desc */ -+ src = sg->src_addr; -+ for (i = 0; i < chan->desc->num_sgs; i++) { -+ tx_desc = &chan->tx_ring[chan->tx_idx]; -+ -+ if (len > HSDMA_MAX_PLEN) -+ tlen = HSDMA_MAX_PLEN; -+ else -+ tlen = len; -+ -+ if (i & 0x1) { -+ tx_desc->addr1 = src; -+ tx_desc->flags |= HSDMA_DESC_PLEN1(tlen); -+ } else { -+ tx_desc->addr0 = src; -+ tx_desc->flags = HSDMA_DESC_PLEN0(tlen); -+ -+ /* update index */ -+ chan->tx_idx = HSDMA_NEXT_DESC(chan->tx_idx); -+ } -+ -+ src += tlen; -+ len -= tlen; -+ } -+ if (i & 0x1) -+ tx_desc->flags |= HSDMA_DESC_LS0; -+ else -+ tx_desc->flags |= HSDMA_DESC_LS1; -+ -+ /* rx desc */ -+ rx_idx = HSDMA_NEXT_DESC(chan->rx_idx); -+ len = sg->len; -+ dst = sg->dst_addr; -+ for (i = 0; i < chan->desc->num_sgs; i++) { -+ rx_desc = &chan->rx_ring[rx_idx]; -+ if (len > HSDMA_MAX_PLEN) -+ tlen = HSDMA_MAX_PLEN; -+ else -+ tlen = len; -+ -+ rx_desc->addr0 = dst; -+ rx_desc->flags = HSDMA_DESC_PLEN0(tlen); -+ -+ dst += tlen; -+ len -= tlen; -+ -+ /* update index */ -+ rx_idx = HSDMA_NEXT_DESC(rx_idx); -+ } -+ -+ /* make sure desc and index all up to date */ -+ wmb(); -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_CTX, chan->tx_idx); -+ -+ return 0; -+} -+ -+static int gdma_next_desc(struct mtk_hsdma_chan *chan) -+{ -+ struct virt_dma_desc *vdesc; -+ -+ vdesc = vchan_next_desc(&chan->vchan); -+ if (!vdesc) { -+ chan->desc = NULL; -+ return 0; -+ } -+ chan->desc = to_mtk_hsdma_desc(vdesc); -+ chan->next_sg = 0; -+ -+ return 1; -+} -+ -+static void mtk_hsdma_chan_done(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ struct mtk_hsdma_desc *desc; -+ int chan_issued; -+ -+ chan_issued = 0; -+ spin_lock_bh(&chan->vchan.lock); -+ desc = chan->desc; -+ if (likely(desc)) { -+ if (chan->next_sg == desc->num_sgs) { -+ list_del(&desc->vdesc.node); -+ vchan_cookie_complete(&desc->vdesc); -+ chan_issued = gdma_next_desc(chan); -+ } -+ } else { -+ dev_dbg(hsdma->ddev.dev, "no desc to complete\n"); -+ } -+ -+ if (chan_issued) -+ set_bit(chan->id, &hsdma->chan_issued); -+ spin_unlock_bh(&chan->vchan.lock); -+} -+ -+static irqreturn_t mtk_hsdma_irq(int irq, void *devid) -+{ -+ struct mtk_hsdam_engine *hsdma = devid; -+ u32 status; -+ -+ status = mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS); -+ if (unlikely(!status)) -+ return IRQ_NONE; -+ -+ if (likely(status & HSDMA_INT_RX_Q0)) -+ tasklet_schedule(&hsdma->task); -+ else -+ dev_dbg(hsdma->ddev.dev, "unhandle irq status %08x\n", status); -+ /* clean intr bits */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_INT_STATUS, status); -+ -+ return IRQ_HANDLED; -+} -+ -+static void mtk_hsdma_issue_pending(struct dma_chan *c) -+{ -+ struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -+ struct mtk_hsdam_engine *hsdma = mtk_hsdma_chan_get_dev(chan); -+ -+ spin_lock_bh(&chan->vchan.lock); -+ if (vchan_issue_pending(&chan->vchan) && !chan->desc) { -+ if (gdma_next_desc(chan)) { -+ set_bit(chan->id, &hsdma->chan_issued); -+ tasklet_schedule(&hsdma->task); -+ } else { -+ dev_dbg(hsdma->ddev.dev, "no desc to issue\n"); -+ } -+ } -+ spin_unlock_bh(&chan->vchan.lock); -+} -+ -+static struct dma_async_tx_descriptor *mtk_hsdma_prep_dma_memcpy( -+ struct dma_chan *c, dma_addr_t dest, dma_addr_t src, -+ size_t len, unsigned long flags) -+{ -+ struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -+ struct mtk_hsdma_desc *desc; -+ -+ if (len <= 0) -+ return NULL; -+ -+ desc = kzalloc(sizeof(*desc), GFP_ATOMIC); -+ if (!desc) { -+ dev_err(c->device->dev, "alloc memcpy decs error\n"); -+ return NULL; -+ } -+ -+ desc->sg[0].src_addr = src; -+ desc->sg[0].dst_addr = dest; -+ desc->sg[0].len = len; -+ -+ return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); -+} -+ -+static enum dma_status mtk_hsdma_tx_status(struct dma_chan *c, -+ dma_cookie_t cookie, -+ struct dma_tx_state *state) -+{ -+ return dma_cookie_status(c, cookie, state); -+} -+ -+static void mtk_hsdma_free_chan_resources(struct dma_chan *c) -+{ -+ vchan_free_chan_resources(to_virt_chan(c)); -+} -+ -+static void mtk_hsdma_desc_free(struct virt_dma_desc *vdesc) -+{ -+ kfree(container_of(vdesc, struct mtk_hsdma_desc, vdesc)); -+} -+ -+static void mtk_hsdma_tx(struct mtk_hsdam_engine *hsdma) -+{ -+ struct mtk_hsdma_chan *chan; -+ -+ if (test_and_clear_bit(0, &hsdma->chan_issued)) { -+ chan = &hsdma->chan[0]; -+ if (chan->desc) -+ mtk_hsdma_start_transfer(hsdma, chan); -+ else -+ dev_dbg(hsdma->ddev.dev, "chan 0 no desc to issue\n"); -+ } -+} -+ -+static void mtk_hsdma_rx(struct mtk_hsdam_engine *hsdma) -+{ -+ struct mtk_hsdma_chan *chan; -+ int next_idx, drx_idx, cnt; -+ -+ chan = &hsdma->chan[0]; -+ next_idx = HSDMA_NEXT_DESC(chan->rx_idx); -+ drx_idx = mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX); -+ -+ cnt = (drx_idx - next_idx) & HSDMA_DESCS_MASK; -+ if (!cnt) -+ return; -+ -+ chan->next_sg += cnt; -+ chan->rx_idx = (chan->rx_idx + cnt) & HSDMA_DESCS_MASK; -+ -+ /* update rx crx */ -+ wmb(); -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_CRX, chan->rx_idx); -+ -+ mtk_hsdma_chan_done(hsdma, chan); -+} -+ -+static void mtk_hsdma_tasklet(unsigned long arg) -+{ -+ struct mtk_hsdam_engine *hsdma = (struct mtk_hsdam_engine *)arg; -+ -+ mtk_hsdma_rx(hsdma); -+ mtk_hsdma_tx(hsdma); -+} -+ -+static int mtk_hsdam_alloc_desc(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ int i; -+ -+ chan->tx_ring = dma_alloc_coherent(hsdma->ddev.dev, -+ 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), -+ &chan->desc_addr, GFP_ATOMIC | __GFP_ZERO); -+ if (!chan->tx_ring) -+ goto no_mem; -+ -+ chan->rx_ring = &chan->tx_ring[HSDMA_DESCS_NUM]; -+ -+ /* init tx ring value */ -+ for (i = 0; i < HSDMA_DESCS_NUM; i++) -+ chan->tx_ring[i].flags = HSDMA_DESC_LS0 | HSDMA_DESC_DONE; -+ -+ return 0; -+no_mem: -+ return -ENOMEM; -+} -+ -+static void mtk_hsdam_free_desc(struct mtk_hsdam_engine *hsdma, -+ struct mtk_hsdma_chan *chan) -+{ -+ if (chan->tx_ring) { -+ dma_free_coherent(hsdma->ddev.dev, -+ 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), -+ chan->tx_ring, chan->desc_addr); -+ chan->tx_ring = NULL; -+ chan->rx_ring = NULL; -+ } -+} -+ -+static int mtk_hsdma_init(struct mtk_hsdam_engine *hsdma) -+{ -+ struct mtk_hsdma_chan *chan; -+ int ret; -+ u32 reg; -+ -+ /* init desc */ -+ chan = &hsdma->chan[0]; -+ ret = mtk_hsdam_alloc_desc(hsdma, chan); -+ if (ret) -+ return ret; -+ -+ /* tx */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_BASE, chan->desc_addr); -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_CNT, HSDMA_DESCS_NUM); -+ /* rx */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_BASE, chan->desc_addr + -+ (sizeof(struct hsdma_desc) * HSDMA_DESCS_NUM)); -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_CNT, HSDMA_DESCS_NUM); -+ /* reset */ -+ mtk_hsdma_reset_chan(hsdma, chan); -+ -+ /* enable rx intr */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, HSDMA_INT_RX_Q0); -+ -+ /* enable dma */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, HSDMA_GLO_DEFAULT); -+ -+ /* hardware info */ -+ reg = mtk_hsdma_read(hsdma, HSDMA_REG_INFO); -+ dev_info(hsdma->ddev.dev, "rx: %d, tx: %d\n", -+ (reg >> HSDMA_INFO_RX_SHIFT) & HSDMA_INFO_RX_MASK, -+ (reg >> HSDMA_INFO_TX_SHIFT) & HSDMA_INFO_TX_MASK); -+ -+ hsdma_dump_reg(hsdma); -+ -+ return ret; -+} -+ -+static void mtk_hsdma_uninit(struct mtk_hsdam_engine *hsdma) -+{ -+ struct mtk_hsdma_chan *chan; -+ -+ /* disable dma */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, 0); -+ -+ /* disable intr */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, 0); -+ -+ /* free desc */ -+ chan = &hsdma->chan[0]; -+ mtk_hsdam_free_desc(hsdma, chan); -+ -+ /* tx */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_BASE, 0); -+ mtk_hsdma_write(hsdma, HSDMA_REG_TX_CNT, 0); -+ /* rx */ -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_BASE, 0); -+ mtk_hsdma_write(hsdma, HSDMA_REG_RX_CNT, 0); -+ /* reset */ -+ mtk_hsdma_reset_chan(hsdma, chan); -+} -+ -+static const struct of_device_id mtk_hsdma_of_match[] = { -+ { .compatible = "mediatek,mt7621-hsdma" }, -+ { }, -+}; -+ -+static int mtk_hsdma_probe(struct platform_device *pdev) -+{ -+ const struct of_device_id *match; -+ struct mtk_hsdma_chan *chan; -+ struct mtk_hsdam_engine *hsdma; -+ struct dma_device *dd; -+ struct resource *res; -+ int ret; -+ int irq; -+ void __iomem *base; -+ -+ ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); -+ if (ret) -+ return ret; -+ -+ match = of_match_device(mtk_hsdma_of_match, &pdev->dev); -+ if (!match) -+ return -EINVAL; -+ -+ hsdma = devm_kzalloc(&pdev->dev, sizeof(*hsdma), GFP_KERNEL); -+ if (!hsdma) -+ return -EINVAL; -+ -+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -+ base = devm_ioremap_resource(&pdev->dev, res); -+ if (IS_ERR(base)) -+ return PTR_ERR(base); -+ hsdma->base = base + HSDMA_BASE_OFFSET; -+ tasklet_init(&hsdma->task, mtk_hsdma_tasklet, (unsigned long)hsdma); -+ -+ irq = platform_get_irq(pdev, 0); -+ if (irq < 0) -+ return -EINVAL; -+ ret = devm_request_irq(&pdev->dev, irq, mtk_hsdma_irq, -+ 0, dev_name(&pdev->dev), hsdma); -+ if (ret) { -+ dev_err(&pdev->dev, "failed to request irq\n"); -+ return ret; -+ } -+ -+ device_reset(&pdev->dev); -+ -+ dd = &hsdma->ddev; -+ dma_cap_set(DMA_MEMCPY, dd->cap_mask); -+ dd->copy_align = HSDMA_ALIGN_SIZE; -+ dd->device_free_chan_resources = mtk_hsdma_free_chan_resources; -+ dd->device_prep_dma_memcpy = mtk_hsdma_prep_dma_memcpy; -+ dd->device_terminate_all = mtk_hsdma_terminate_all; -+ dd->device_tx_status = mtk_hsdma_tx_status; -+ dd->device_issue_pending = mtk_hsdma_issue_pending; -+ dd->dev = &pdev->dev; -+ dd->dev->dma_parms = &hsdma->dma_parms; -+ dma_set_max_seg_size(dd->dev, HSDMA_MAX_PLEN); -+ INIT_LIST_HEAD(&dd->channels); -+ -+ chan = &hsdma->chan[0]; -+ chan->id = 0; -+ chan->vchan.desc_free = mtk_hsdma_desc_free; -+ vchan_init(&chan->vchan, dd); -+ -+ /* init hardware */ -+ ret = mtk_hsdma_init(hsdma); -+ if (ret) { -+ dev_err(&pdev->dev, "failed to alloc ring descs\n"); -+ return ret; -+ } -+ -+ ret = dma_async_device_register(dd); -+ if (ret) { -+ dev_err(&pdev->dev, "failed to register dma device\n"); -+ goto err_uninit_hsdma; -+ } -+ -+ ret = of_dma_controller_register(pdev->dev.of_node, -+ of_dma_xlate_by_chan_id, hsdma); -+ if (ret) { -+ dev_err(&pdev->dev, "failed to register of dma controller\n"); -+ goto err_unregister; -+ } -+ -+ platform_set_drvdata(pdev, hsdma); -+ -+ return 0; -+ -+err_unregister: -+ dma_async_device_unregister(dd); -+err_uninit_hsdma: -+ mtk_hsdma_uninit(hsdma); -+ return ret; -+} -+ -+static int mtk_hsdma_remove(struct platform_device *pdev) -+{ -+ struct mtk_hsdam_engine *hsdma = platform_get_drvdata(pdev); -+ -+ mtk_hsdma_uninit(hsdma); -+ -+ of_dma_controller_free(pdev->dev.of_node); -+ dma_async_device_unregister(&hsdma->ddev); -+ -+ return 0; -+} -+ -+static struct platform_driver mtk_hsdma_driver = { -+ .probe = mtk_hsdma_probe, -+ .remove = mtk_hsdma_remove, -+ .driver = { -+ .name = KBUILD_MODNAME, -+ .of_match_table = mtk_hsdma_of_match, -+ }, -+}; -+module_platform_driver(mtk_hsdma_driver); -+ -+MODULE_AUTHOR("Michael Lee "); -+MODULE_DESCRIPTION("MTK HSDMA driver"); -+MODULE_LICENSE("GPL v2"); -diff --git a/drivers/staging/mt7621-dma/mtk-hsdma.c b/drivers/staging/mt7621-dma/mtk-hsdma.c -deleted file mode 100644 -index bf2772af1045f..0000000000000 ---- a/drivers/staging/mt7621-dma/mtk-hsdma.c -+++ /dev/null -@@ -1,762 +0,0 @@ --// SPDX-License-Identifier: GPL-2.0+ --/* -- * Copyright (C) 2015, Michael Lee -- * MTK HSDMA support -- */ -- --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include --#include -- --#include "virt-dma.h" -- --#define HSDMA_BASE_OFFSET 0x800 -- --#define HSDMA_REG_TX_BASE 0x00 --#define HSDMA_REG_TX_CNT 0x04 --#define HSDMA_REG_TX_CTX 0x08 --#define HSDMA_REG_TX_DTX 0x0c --#define HSDMA_REG_RX_BASE 0x100 --#define HSDMA_REG_RX_CNT 0x104 --#define HSDMA_REG_RX_CRX 0x108 --#define HSDMA_REG_RX_DRX 0x10c --#define HSDMA_REG_INFO 0x200 --#define HSDMA_REG_GLO_CFG 0x204 --#define HSDMA_REG_RST_CFG 0x208 --#define HSDMA_REG_DELAY_INT 0x20c --#define HSDMA_REG_FREEQ_THRES 0x210 --#define HSDMA_REG_INT_STATUS 0x220 --#define HSDMA_REG_INT_MASK 0x228 --#define HSDMA_REG_SCH_Q01 0x280 --#define HSDMA_REG_SCH_Q23 0x284 -- --#define HSDMA_DESCS_MAX 0xfff --#define HSDMA_DESCS_NUM 8 --#define HSDMA_DESCS_MASK (HSDMA_DESCS_NUM - 1) --#define HSDMA_NEXT_DESC(x) (((x) + 1) & HSDMA_DESCS_MASK) -- --/* HSDMA_REG_INFO */ --#define HSDMA_INFO_INDEX_MASK 0xf --#define HSDMA_INFO_INDEX_SHIFT 24 --#define HSDMA_INFO_BASE_MASK 0xff --#define HSDMA_INFO_BASE_SHIFT 16 --#define HSDMA_INFO_RX_MASK 0xff --#define HSDMA_INFO_RX_SHIFT 8 --#define HSDMA_INFO_TX_MASK 0xff --#define HSDMA_INFO_TX_SHIFT 0 -- --/* HSDMA_REG_GLO_CFG */ --#define HSDMA_GLO_TX_2B_OFFSET BIT(31) --#define HSDMA_GLO_CLK_GATE BIT(30) --#define HSDMA_GLO_BYTE_SWAP BIT(29) --#define HSDMA_GLO_MULTI_DMA BIT(10) --#define HSDMA_GLO_TWO_BUF BIT(9) --#define HSDMA_GLO_32B_DESC BIT(8) --#define HSDMA_GLO_BIG_ENDIAN BIT(7) --#define HSDMA_GLO_TX_DONE BIT(6) --#define HSDMA_GLO_BT_MASK 0x3 --#define HSDMA_GLO_BT_SHIFT 4 --#define HSDMA_GLO_RX_BUSY BIT(3) --#define HSDMA_GLO_RX_DMA BIT(2) --#define HSDMA_GLO_TX_BUSY BIT(1) --#define HSDMA_GLO_TX_DMA BIT(0) -- --#define HSDMA_BT_SIZE_16BYTES (0 << HSDMA_GLO_BT_SHIFT) --#define HSDMA_BT_SIZE_32BYTES (1 << HSDMA_GLO_BT_SHIFT) --#define HSDMA_BT_SIZE_64BYTES (2 << HSDMA_GLO_BT_SHIFT) --#define HSDMA_BT_SIZE_128BYTES (3 << HSDMA_GLO_BT_SHIFT) -- --#define HSDMA_GLO_DEFAULT (HSDMA_GLO_MULTI_DMA | \ -- HSDMA_GLO_RX_DMA | HSDMA_GLO_TX_DMA | HSDMA_BT_SIZE_32BYTES) -- --/* HSDMA_REG_RST_CFG */ --#define HSDMA_RST_RX_SHIFT 16 --#define HSDMA_RST_TX_SHIFT 0 -- --/* HSDMA_REG_DELAY_INT */ --#define HSDMA_DELAY_INT_EN BIT(15) --#define HSDMA_DELAY_PEND_OFFSET 8 --#define HSDMA_DELAY_TIME_OFFSET 0 --#define HSDMA_DELAY_TX_OFFSET 16 --#define HSDMA_DELAY_RX_OFFSET 0 -- --#define HSDMA_DELAY_INIT(x) (HSDMA_DELAY_INT_EN | \ -- ((x) << HSDMA_DELAY_PEND_OFFSET)) --#define HSDMA_DELAY(x) ((HSDMA_DELAY_INIT(x) << \ -- HSDMA_DELAY_TX_OFFSET) | HSDMA_DELAY_INIT(x)) -- --/* HSDMA_REG_INT_STATUS */ --#define HSDMA_INT_DELAY_RX_COH BIT(31) --#define HSDMA_INT_DELAY_RX_INT BIT(30) --#define HSDMA_INT_DELAY_TX_COH BIT(29) --#define HSDMA_INT_DELAY_TX_INT BIT(28) --#define HSDMA_INT_RX_MASK 0x3 --#define HSDMA_INT_RX_SHIFT 16 --#define HSDMA_INT_RX_Q0 BIT(16) --#define HSDMA_INT_TX_MASK 0xf --#define HSDMA_INT_TX_SHIFT 0 --#define HSDMA_INT_TX_Q0 BIT(0) -- --/* tx/rx dma desc flags */ --#define HSDMA_PLEN_MASK 0x3fff --#define HSDMA_DESC_DONE BIT(31) --#define HSDMA_DESC_LS0 BIT(30) --#define HSDMA_DESC_PLEN0(_x) (((_x) & HSDMA_PLEN_MASK) << 16) --#define HSDMA_DESC_TAG BIT(15) --#define HSDMA_DESC_LS1 BIT(14) --#define HSDMA_DESC_PLEN1(_x) ((_x) & HSDMA_PLEN_MASK) -- --/* align 4 bytes */ --#define HSDMA_ALIGN_SIZE 3 --/* align size 128bytes */ --#define HSDMA_MAX_PLEN 0x3f80 -- --struct hsdma_desc { -- u32 addr0; -- u32 flags; -- u32 addr1; -- u32 unused; --}; -- --struct mtk_hsdma_sg { -- dma_addr_t src_addr; -- dma_addr_t dst_addr; -- u32 len; --}; -- --struct mtk_hsdma_desc { -- struct virt_dma_desc vdesc; -- unsigned int num_sgs; -- struct mtk_hsdma_sg sg[1]; --}; -- --struct mtk_hsdma_chan { -- struct virt_dma_chan vchan; -- unsigned int id; -- dma_addr_t desc_addr; -- int tx_idx; -- int rx_idx; -- struct hsdma_desc *tx_ring; -- struct hsdma_desc *rx_ring; -- struct mtk_hsdma_desc *desc; -- unsigned int next_sg; --}; -- --struct mtk_hsdam_engine { -- struct dma_device ddev; -- struct device_dma_parameters dma_parms; -- void __iomem *base; -- struct tasklet_struct task; -- volatile unsigned long chan_issued; -- -- struct mtk_hsdma_chan chan[1]; --}; -- --static inline struct mtk_hsdam_engine *mtk_hsdma_chan_get_dev( -- struct mtk_hsdma_chan *chan) --{ -- return container_of(chan->vchan.chan.device, struct mtk_hsdam_engine, -- ddev); --} -- --static inline struct mtk_hsdma_chan *to_mtk_hsdma_chan(struct dma_chan *c) --{ -- return container_of(c, struct mtk_hsdma_chan, vchan.chan); --} -- --static inline struct mtk_hsdma_desc *to_mtk_hsdma_desc( -- struct virt_dma_desc *vdesc) --{ -- return container_of(vdesc, struct mtk_hsdma_desc, vdesc); --} -- --static inline u32 mtk_hsdma_read(struct mtk_hsdam_engine *hsdma, u32 reg) --{ -- return readl(hsdma->base + reg); --} -- --static inline void mtk_hsdma_write(struct mtk_hsdam_engine *hsdma, -- unsigned int reg, u32 val) --{ -- writel(val, hsdma->base + reg); --} -- --static void mtk_hsdma_reset_chan(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- chan->tx_idx = 0; -- chan->rx_idx = HSDMA_DESCS_NUM - 1; -- -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_CTX, chan->tx_idx); -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_CRX, chan->rx_idx); -- -- mtk_hsdma_write(hsdma, HSDMA_REG_RST_CFG, -- 0x1 << (chan->id + HSDMA_RST_TX_SHIFT)); -- mtk_hsdma_write(hsdma, HSDMA_REG_RST_CFG, -- 0x1 << (chan->id + HSDMA_RST_RX_SHIFT)); --} -- --static void hsdma_dump_reg(struct mtk_hsdam_engine *hsdma) --{ -- dev_dbg(hsdma->ddev.dev, "tbase %08x, tcnt %08x, " \ -- "tctx %08x, tdtx: %08x, rbase %08x, " \ -- "rcnt %08x, rctx %08x, rdtx %08x\n", -- mtk_hsdma_read(hsdma, HSDMA_REG_TX_BASE), -- mtk_hsdma_read(hsdma, HSDMA_REG_TX_CNT), -- mtk_hsdma_read(hsdma, HSDMA_REG_TX_CTX), -- mtk_hsdma_read(hsdma, HSDMA_REG_TX_DTX), -- mtk_hsdma_read(hsdma, HSDMA_REG_RX_BASE), -- mtk_hsdma_read(hsdma, HSDMA_REG_RX_CNT), -- mtk_hsdma_read(hsdma, HSDMA_REG_RX_CRX), -- mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX)); -- -- dev_dbg(hsdma->ddev.dev, "info %08x, glo %08x, delay %08x, " \ -- "intr_stat %08x, intr_mask %08x\n", -- mtk_hsdma_read(hsdma, HSDMA_REG_INFO), -- mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG), -- mtk_hsdma_read(hsdma, HSDMA_REG_DELAY_INT), -- mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS), -- mtk_hsdma_read(hsdma, HSDMA_REG_INT_MASK)); --} -- --static void hsdma_dump_desc(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- struct hsdma_desc *tx_desc; -- struct hsdma_desc *rx_desc; -- int i; -- -- dev_dbg(hsdma->ddev.dev, "tx idx: %d, rx idx: %d\n", -- chan->tx_idx, chan->rx_idx); -- -- for (i = 0; i < HSDMA_DESCS_NUM; i++) { -- tx_desc = &chan->tx_ring[i]; -- rx_desc = &chan->rx_ring[i]; -- -- dev_dbg(hsdma->ddev.dev, "%d tx addr0: %08x, flags %08x, " \ -- "tx addr1: %08x, rx addr0 %08x, flags %08x\n", -- i, tx_desc->addr0, tx_desc->flags, \ -- tx_desc->addr1, rx_desc->addr0, rx_desc->flags); -- } --} -- --static void mtk_hsdma_reset(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- int i; -- -- /* disable dma */ -- mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, 0); -- -- /* disable intr */ -- mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, 0); -- -- /* init desc value */ -- for (i = 0; i < HSDMA_DESCS_NUM; i++) { -- chan->tx_ring[i].addr0 = 0; -- chan->tx_ring[i].flags = HSDMA_DESC_LS0 | HSDMA_DESC_DONE; -- } -- for (i = 0; i < HSDMA_DESCS_NUM; i++) { -- chan->rx_ring[i].addr0 = 0; -- chan->rx_ring[i].flags = 0; -- } -- -- /* reset */ -- mtk_hsdma_reset_chan(hsdma, chan); -- -- /* enable intr */ -- mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, HSDMA_INT_RX_Q0); -- -- /* enable dma */ -- mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, HSDMA_GLO_DEFAULT); --} -- --static int mtk_hsdma_terminate_all(struct dma_chan *c) --{ -- struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -- struct mtk_hsdam_engine *hsdma = mtk_hsdma_chan_get_dev(chan); -- unsigned long timeout; -- LIST_HEAD(head); -- -- spin_lock_bh(&chan->vchan.lock); -- chan->desc = NULL; -- clear_bit(chan->id, &hsdma->chan_issued); -- vchan_get_all_descriptors(&chan->vchan, &head); -- spin_unlock_bh(&chan->vchan.lock); -- -- vchan_dma_desc_free_list(&chan->vchan, &head); -- -- /* wait dma transfer complete */ -- timeout = jiffies + msecs_to_jiffies(2000); -- while (mtk_hsdma_read(hsdma, HSDMA_REG_GLO_CFG) & -- (HSDMA_GLO_RX_BUSY | HSDMA_GLO_TX_BUSY)) { -- if (time_after_eq(jiffies, timeout)) { -- hsdma_dump_desc(hsdma, chan); -- mtk_hsdma_reset(hsdma, chan); -- dev_err(hsdma->ddev.dev, "timeout, reset it\n"); -- break; -- } -- cpu_relax(); -- } -- -- return 0; --} -- --static int mtk_hsdma_start_transfer(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- dma_addr_t src, dst; -- size_t len, tlen; -- struct hsdma_desc *tx_desc, *rx_desc; -- struct mtk_hsdma_sg *sg; -- unsigned int i; -- int rx_idx; -- -- sg = &chan->desc->sg[0]; -- len = sg->len; -- chan->desc->num_sgs = DIV_ROUND_UP(len, HSDMA_MAX_PLEN); -- -- /* tx desc */ -- src = sg->src_addr; -- for (i = 0; i < chan->desc->num_sgs; i++) { -- tx_desc = &chan->tx_ring[chan->tx_idx]; -- -- if (len > HSDMA_MAX_PLEN) -- tlen = HSDMA_MAX_PLEN; -- else -- tlen = len; -- -- if (i & 0x1) { -- tx_desc->addr1 = src; -- tx_desc->flags |= HSDMA_DESC_PLEN1(tlen); -- } else { -- tx_desc->addr0 = src; -- tx_desc->flags = HSDMA_DESC_PLEN0(tlen); -- -- /* update index */ -- chan->tx_idx = HSDMA_NEXT_DESC(chan->tx_idx); -- } -- -- src += tlen; -- len -= tlen; -- } -- if (i & 0x1) -- tx_desc->flags |= HSDMA_DESC_LS0; -- else -- tx_desc->flags |= HSDMA_DESC_LS1; -- -- /* rx desc */ -- rx_idx = HSDMA_NEXT_DESC(chan->rx_idx); -- len = sg->len; -- dst = sg->dst_addr; -- for (i = 0; i < chan->desc->num_sgs; i++) { -- rx_desc = &chan->rx_ring[rx_idx]; -- if (len > HSDMA_MAX_PLEN) -- tlen = HSDMA_MAX_PLEN; -- else -- tlen = len; -- -- rx_desc->addr0 = dst; -- rx_desc->flags = HSDMA_DESC_PLEN0(tlen); -- -- dst += tlen; -- len -= tlen; -- -- /* update index */ -- rx_idx = HSDMA_NEXT_DESC(rx_idx); -- } -- -- /* make sure desc and index all up to date */ -- wmb(); -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_CTX, chan->tx_idx); -- -- return 0; --} -- --static int gdma_next_desc(struct mtk_hsdma_chan *chan) --{ -- struct virt_dma_desc *vdesc; -- -- vdesc = vchan_next_desc(&chan->vchan); -- if (!vdesc) { -- chan->desc = NULL; -- return 0; -- } -- chan->desc = to_mtk_hsdma_desc(vdesc); -- chan->next_sg = 0; -- -- return 1; --} -- --static void mtk_hsdma_chan_done(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- struct mtk_hsdma_desc *desc; -- int chan_issued; -- -- chan_issued = 0; -- spin_lock_bh(&chan->vchan.lock); -- desc = chan->desc; -- if (likely(desc)) { -- if (chan->next_sg == desc->num_sgs) { -- list_del(&desc->vdesc.node); -- vchan_cookie_complete(&desc->vdesc); -- chan_issued = gdma_next_desc(chan); -- } -- } else { -- dev_dbg(hsdma->ddev.dev, "no desc to complete\n"); -- } -- -- if (chan_issued) -- set_bit(chan->id, &hsdma->chan_issued); -- spin_unlock_bh(&chan->vchan.lock); --} -- --static irqreturn_t mtk_hsdma_irq(int irq, void *devid) --{ -- struct mtk_hsdam_engine *hsdma = devid; -- u32 status; -- -- status = mtk_hsdma_read(hsdma, HSDMA_REG_INT_STATUS); -- if (unlikely(!status)) -- return IRQ_NONE; -- -- if (likely(status & HSDMA_INT_RX_Q0)) -- tasklet_schedule(&hsdma->task); -- else -- dev_dbg(hsdma->ddev.dev, "unhandle irq status %08x\n", status); -- /* clean intr bits */ -- mtk_hsdma_write(hsdma, HSDMA_REG_INT_STATUS, status); -- -- return IRQ_HANDLED; --} -- --static void mtk_hsdma_issue_pending(struct dma_chan *c) --{ -- struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -- struct mtk_hsdam_engine *hsdma = mtk_hsdma_chan_get_dev(chan); -- -- spin_lock_bh(&chan->vchan.lock); -- if (vchan_issue_pending(&chan->vchan) && !chan->desc) { -- if (gdma_next_desc(chan)) { -- set_bit(chan->id, &hsdma->chan_issued); -- tasklet_schedule(&hsdma->task); -- } else { -- dev_dbg(hsdma->ddev.dev, "no desc to issue\n"); -- } -- } -- spin_unlock_bh(&chan->vchan.lock); --} -- --static struct dma_async_tx_descriptor *mtk_hsdma_prep_dma_memcpy( -- struct dma_chan *c, dma_addr_t dest, dma_addr_t src, -- size_t len, unsigned long flags) --{ -- struct mtk_hsdma_chan *chan = to_mtk_hsdma_chan(c); -- struct mtk_hsdma_desc *desc; -- -- if (len <= 0) -- return NULL; -- -- desc = kzalloc(sizeof(*desc), GFP_ATOMIC); -- if (!desc) { -- dev_err(c->device->dev, "alloc memcpy decs error\n"); -- return NULL; -- } -- -- desc->sg[0].src_addr = src; -- desc->sg[0].dst_addr = dest; -- desc->sg[0].len = len; -- -- return vchan_tx_prep(&chan->vchan, &desc->vdesc, flags); --} -- --static enum dma_status mtk_hsdma_tx_status(struct dma_chan *c, -- dma_cookie_t cookie, -- struct dma_tx_state *state) --{ -- return dma_cookie_status(c, cookie, state); --} -- --static void mtk_hsdma_free_chan_resources(struct dma_chan *c) --{ -- vchan_free_chan_resources(to_virt_chan(c)); --} -- --static void mtk_hsdma_desc_free(struct virt_dma_desc *vdesc) --{ -- kfree(container_of(vdesc, struct mtk_hsdma_desc, vdesc)); --} -- --static void mtk_hsdma_tx(struct mtk_hsdam_engine *hsdma) --{ -- struct mtk_hsdma_chan *chan; -- -- if (test_and_clear_bit(0, &hsdma->chan_issued)) { -- chan = &hsdma->chan[0]; -- if (chan->desc) -- mtk_hsdma_start_transfer(hsdma, chan); -- else -- dev_dbg(hsdma->ddev.dev, "chan 0 no desc to issue\n"); -- } --} -- --static void mtk_hsdma_rx(struct mtk_hsdam_engine *hsdma) --{ -- struct mtk_hsdma_chan *chan; -- int next_idx, drx_idx, cnt; -- -- chan = &hsdma->chan[0]; -- next_idx = HSDMA_NEXT_DESC(chan->rx_idx); -- drx_idx = mtk_hsdma_read(hsdma, HSDMA_REG_RX_DRX); -- -- cnt = (drx_idx - next_idx) & HSDMA_DESCS_MASK; -- if (!cnt) -- return; -- -- chan->next_sg += cnt; -- chan->rx_idx = (chan->rx_idx + cnt) & HSDMA_DESCS_MASK; -- -- /* update rx crx */ -- wmb(); -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_CRX, chan->rx_idx); -- -- mtk_hsdma_chan_done(hsdma, chan); --} -- --static void mtk_hsdma_tasklet(unsigned long arg) --{ -- struct mtk_hsdam_engine *hsdma = (struct mtk_hsdam_engine *)arg; -- -- mtk_hsdma_rx(hsdma); -- mtk_hsdma_tx(hsdma); --} -- --static int mtk_hsdam_alloc_desc(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- int i; -- -- chan->tx_ring = dma_alloc_coherent(hsdma->ddev.dev, -- 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), -- &chan->desc_addr, GFP_ATOMIC | __GFP_ZERO); -- if (!chan->tx_ring) -- goto no_mem; -- -- chan->rx_ring = &chan->tx_ring[HSDMA_DESCS_NUM]; -- -- /* init tx ring value */ -- for (i = 0; i < HSDMA_DESCS_NUM; i++) -- chan->tx_ring[i].flags = HSDMA_DESC_LS0 | HSDMA_DESC_DONE; -- -- return 0; --no_mem: -- return -ENOMEM; --} -- --static void mtk_hsdam_free_desc(struct mtk_hsdam_engine *hsdma, -- struct mtk_hsdma_chan *chan) --{ -- if (chan->tx_ring) { -- dma_free_coherent(hsdma->ddev.dev, -- 2 * HSDMA_DESCS_NUM * sizeof(*chan->tx_ring), -- chan->tx_ring, chan->desc_addr); -- chan->tx_ring = NULL; -- chan->rx_ring = NULL; -- } --} -- --static int mtk_hsdma_init(struct mtk_hsdam_engine *hsdma) --{ -- struct mtk_hsdma_chan *chan; -- int ret; -- u32 reg; -- -- /* init desc */ -- chan = &hsdma->chan[0]; -- ret = mtk_hsdam_alloc_desc(hsdma, chan); -- if (ret) -- return ret; -- -- /* tx */ -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_BASE, chan->desc_addr); -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_CNT, HSDMA_DESCS_NUM); -- /* rx */ -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_BASE, chan->desc_addr + -- (sizeof(struct hsdma_desc) * HSDMA_DESCS_NUM)); -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_CNT, HSDMA_DESCS_NUM); -- /* reset */ -- mtk_hsdma_reset_chan(hsdma, chan); -- -- /* enable rx intr */ -- mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, HSDMA_INT_RX_Q0); -- -- /* enable dma */ -- mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, HSDMA_GLO_DEFAULT); -- -- /* hardware info */ -- reg = mtk_hsdma_read(hsdma, HSDMA_REG_INFO); -- dev_info(hsdma->ddev.dev, "rx: %d, tx: %d\n", -- (reg >> HSDMA_INFO_RX_SHIFT) & HSDMA_INFO_RX_MASK, -- (reg >> HSDMA_INFO_TX_SHIFT) & HSDMA_INFO_TX_MASK); -- -- hsdma_dump_reg(hsdma); -- -- return ret; --} -- --static void mtk_hsdma_uninit(struct mtk_hsdam_engine *hsdma) --{ -- struct mtk_hsdma_chan *chan; -- -- /* disable dma */ -- mtk_hsdma_write(hsdma, HSDMA_REG_GLO_CFG, 0); -- -- /* disable intr */ -- mtk_hsdma_write(hsdma, HSDMA_REG_INT_MASK, 0); -- -- /* free desc */ -- chan = &hsdma->chan[0]; -- mtk_hsdam_free_desc(hsdma, chan); -- -- /* tx */ -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_BASE, 0); -- mtk_hsdma_write(hsdma, HSDMA_REG_TX_CNT, 0); -- /* rx */ -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_BASE, 0); -- mtk_hsdma_write(hsdma, HSDMA_REG_RX_CNT, 0); -- /* reset */ -- mtk_hsdma_reset_chan(hsdma, chan); --} -- --static const struct of_device_id mtk_hsdma_of_match[] = { -- { .compatible = "mediatek,mt7621-hsdma" }, -- { }, --}; -- --static int mtk_hsdma_probe(struct platform_device *pdev) --{ -- const struct of_device_id *match; -- struct mtk_hsdma_chan *chan; -- struct mtk_hsdam_engine *hsdma; -- struct dma_device *dd; -- struct resource *res; -- int ret; -- int irq; -- void __iomem *base; -- -- ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); -- if (ret) -- return ret; -- -- match = of_match_device(mtk_hsdma_of_match, &pdev->dev); -- if (!match) -- return -EINVAL; -- -- hsdma = devm_kzalloc(&pdev->dev, sizeof(*hsdma), GFP_KERNEL); -- if (!hsdma) -- return -EINVAL; -- -- res = platform_get_resource(pdev, IORESOURCE_MEM, 0); -- base = devm_ioremap_resource(&pdev->dev, res); -- if (IS_ERR(base)) -- return PTR_ERR(base); -- hsdma->base = base + HSDMA_BASE_OFFSET; -- tasklet_init(&hsdma->task, mtk_hsdma_tasklet, (unsigned long)hsdma); -- -- irq = platform_get_irq(pdev, 0); -- if (irq < 0) -- return -EINVAL; -- ret = devm_request_irq(&pdev->dev, irq, mtk_hsdma_irq, -- 0, dev_name(&pdev->dev), hsdma); -- if (ret) { -- dev_err(&pdev->dev, "failed to request irq\n"); -- return ret; -- } -- -- device_reset(&pdev->dev); -- -- dd = &hsdma->ddev; -- dma_cap_set(DMA_MEMCPY, dd->cap_mask); -- dd->copy_align = HSDMA_ALIGN_SIZE; -- dd->device_free_chan_resources = mtk_hsdma_free_chan_resources; -- dd->device_prep_dma_memcpy = mtk_hsdma_prep_dma_memcpy; -- dd->device_terminate_all = mtk_hsdma_terminate_all; -- dd->device_tx_status = mtk_hsdma_tx_status; -- dd->device_issue_pending = mtk_hsdma_issue_pending; -- dd->dev = &pdev->dev; -- dd->dev->dma_parms = &hsdma->dma_parms; -- dma_set_max_seg_size(dd->dev, HSDMA_MAX_PLEN); -- INIT_LIST_HEAD(&dd->channels); -- -- chan = &hsdma->chan[0]; -- chan->id = 0; -- chan->vchan.desc_free = mtk_hsdma_desc_free; -- vchan_init(&chan->vchan, dd); -- -- /* init hardware */ -- ret = mtk_hsdma_init(hsdma); -- if (ret) { -- dev_err(&pdev->dev, "failed to alloc ring descs\n"); -- return ret; -- } -- -- ret = dma_async_device_register(dd); -- if (ret) { -- dev_err(&pdev->dev, "failed to register dma device\n"); -- goto err_uninit_hsdma; -- } -- -- ret = of_dma_controller_register(pdev->dev.of_node, -- of_dma_xlate_by_chan_id, hsdma); -- if (ret) { -- dev_err(&pdev->dev, "failed to register of dma controller\n"); -- goto err_unregister; -- } -- -- platform_set_drvdata(pdev, hsdma); -- -- return 0; -- --err_unregister: -- dma_async_device_unregister(dd); --err_uninit_hsdma: -- mtk_hsdma_uninit(hsdma); -- return ret; --} -- --static int mtk_hsdma_remove(struct platform_device *pdev) --{ -- struct mtk_hsdam_engine *hsdma = platform_get_drvdata(pdev); -- -- mtk_hsdma_uninit(hsdma); -- -- of_dma_controller_free(pdev->dev.of_node); -- dma_async_device_unregister(&hsdma->ddev); -- -- return 0; --} -- --static struct platform_driver mtk_hsdma_driver = { -- .probe = mtk_hsdma_probe, -- .remove = mtk_hsdma_remove, -- .driver = { -- .name = "hsdma-mt7621", -- .of_match_table = mtk_hsdma_of_match, -- }, --}; --module_platform_driver(mtk_hsdma_driver); -- --MODULE_AUTHOR("Michael Lee "); --MODULE_DESCRIPTION("MTK HSDMA driver"); --MODULE_LICENSE("GPL v2"); -diff --git a/drivers/staging/rtl8188eu/os_dep/usb_intf.c b/drivers/staging/rtl8188eu/os_dep/usb_intf.c -index f7f09c0d273f5..5b103e829ee7f 100644 ---- a/drivers/staging/rtl8188eu/os_dep/usb_intf.c -+++ b/drivers/staging/rtl8188eu/os_dep/usb_intf.c -@@ -41,6 +41,7 @@ static const struct usb_device_id rtw_usb_id_tbl[] = { - {USB_DEVICE(0x2357, 0x0111)}, /* TP-Link TL-WN727N v5.21 */ - {USB_DEVICE(0x2C4E, 0x0102)}, /* MERCUSYS MW150US v2 */ - {USB_DEVICE(0x0df6, 0x0076)}, /* Sitecom N150 v2 */ -+ {USB_DEVICE(0x7392, 0xb811)}, /* Edimax EW-7811UN V2 */ - {USB_DEVICE(USB_VENDER_ID_REALTEK, 0xffef)}, /* Rosewill RNX-N150NUB */ - {} /* Terminating entry */ - }; -diff --git a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c -index 578b9f734231e..65592bf84f380 100644 ---- a/drivers/staging/rtl8723bs/os_dep/wifi_regd.c -+++ b/drivers/staging/rtl8723bs/os_dep/wifi_regd.c -@@ -34,7 +34,7 @@ - NL80211_RRF_PASSIVE_SCAN) - - static const struct ieee80211_regdomain rtw_regdom_rd = { -- .n_reg_rules = 3, -+ .n_reg_rules = 2, - .alpha2 = "99", - .reg_rules = { - RTW_2GHZ_CH01_11, -diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c -index fcdc4211e3c27..45a1bfa2f7351 100644 ---- a/drivers/target/iscsi/cxgbit/cxgbit_target.c -+++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c -@@ -86,8 +86,7 @@ static int cxgbit_is_ofld_imm(const struct sk_buff *skb) - if (likely(cxgbit_skcb_flags(skb) & SKCBF_TX_ISO)) - length += sizeof(struct cpl_tx_data_iso); - --#define MAX_IMM_TX_PKT_LEN 256 -- return length <= MAX_IMM_TX_PKT_LEN; -+ return length <= MAX_IMM_OFLD_TX_DATA_WR_LEN; - } - - /* -diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c -index 81afe553aa666..a91f2aa24118a 100644 ---- a/drivers/usb/dwc2/hcd.c -+++ b/drivers/usb/dwc2/hcd.c -@@ -1313,19 +1313,20 @@ static void dwc2_hc_start_transfer(struct dwc2_hsotg *hsotg, - if (num_packets > max_hc_pkt_count) { - num_packets = max_hc_pkt_count; - chan->xfer_len = num_packets * chan->max_packet; -+ } else if (chan->ep_is_in) { -+ /* -+ * Always program an integral # of max packets -+ * for IN transfers. -+ * Note: This assumes that the input buffer is -+ * aligned and sized accordingly. -+ */ -+ chan->xfer_len = num_packets * chan->max_packet; - } - } else { - /* Need 1 packet for transfer length of 0 */ - num_packets = 1; - } - -- if (chan->ep_is_in) -- /* -- * Always program an integral # of max packets for IN -- * transfers -- */ -- chan->xfer_len = num_packets * chan->max_packet; -- - if (chan->ep_type == USB_ENDPOINT_XFER_INT || - chan->ep_type == USB_ENDPOINT_XFER_ISOC) - /* -diff --git a/drivers/usb/dwc2/hcd_intr.c b/drivers/usb/dwc2/hcd_intr.c -index a052d39b4375e..d5f4ec1b73b15 100644 ---- a/drivers/usb/dwc2/hcd_intr.c -+++ b/drivers/usb/dwc2/hcd_intr.c -@@ -500,7 +500,7 @@ static int dwc2_update_urb_state(struct dwc2_hsotg *hsotg, - &short_read); - - if (urb->actual_length + xfer_length > urb->length) { -- dev_warn(hsotg->dev, "%s(): trimming xfer length\n", __func__); -+ dev_dbg(hsotg->dev, "%s(): trimming xfer length\n", __func__); - xfer_length = urb->length - urb->actual_length; - } - -@@ -1977,6 +1977,18 @@ error: - qtd->error_count++; - dwc2_update_urb_state_abn(hsotg, chan, chnum, qtd->urb, - qtd, DWC2_HC_XFER_XACT_ERR); -+ /* -+ * We can get here after a completed transaction -+ * (urb->actual_length >= urb->length) which was not reported -+ * as completed. If that is the case, and we do not abort -+ * the transfer, a transfer of size 0 will be enqueued -+ * subsequently. If urb->actual_length is not DMA-aligned, -+ * the buffer will then point to an unaligned address, and -+ * the resulting behavior is undefined. Bail out in that -+ * situation. -+ */ -+ if (qtd->urb->actual_length >= qtd->urb->length) -+ qtd->error_count = 3; - dwc2_hcd_save_data_toggle(hsotg, chan, chnum, qtd); - dwc2_halt_channel(hsotg, chan, qtd, DWC2_HC_XFER_XACT_ERR); - } -diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c -index 9269cda4c1831..904b0043011cf 100644 ---- a/drivers/usb/dwc3/gadget.c -+++ b/drivers/usb/dwc3/gadget.c -@@ -593,8 +593,23 @@ static int dwc3_gadget_set_ep_config(struct dwc3_ep *dep, unsigned int action) - params.param0 |= DWC3_DEPCFG_FIFO_NUMBER(dep->number >> 1); - - if (desc->bInterval) { -- params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(desc->bInterval - 1); -- dep->interval = 1 << (desc->bInterval - 1); -+ u8 bInterval_m1; -+ -+ /* -+ * Valid range for DEPCFG.bInterval_m1 is from 0 to 13, and it -+ * must be set to 0 when the controller operates in full-speed. -+ */ -+ bInterval_m1 = min_t(u8, desc->bInterval - 1, 13); -+ if (dwc->gadget.speed == USB_SPEED_FULL) -+ bInterval_m1 = 0; -+ -+ if (usb_endpoint_type(desc) == USB_ENDPOINT_XFER_INT && -+ dwc->gadget.speed == USB_SPEED_FULL) -+ dep->interval = desc->bInterval; -+ else -+ dep->interval = 1 << (desc->bInterval - 1); -+ -+ params.param1 |= DWC3_DEPCFG_BINTERVAL_M1(bInterval_m1); - } - - return dwc3_send_gadget_ep_cmd(dep, DWC3_DEPCMD_SETEPCONFIG, ¶ms); -diff --git a/drivers/usb/gadget/function/u_audio.c b/drivers/usb/gadget/function/u_audio.c -index 56906d15fb551..223029fa84459 100644 ---- a/drivers/usb/gadget/function/u_audio.c -+++ b/drivers/usb/gadget/function/u_audio.c -@@ -89,7 +89,12 @@ static void u_audio_iso_complete(struct usb_ep *ep, struct usb_request *req) - struct snd_uac_chip *uac = prm->uac; - - /* i/f shutting down */ -- if (!prm->ep_enabled || req->status == -ESHUTDOWN) -+ if (!prm->ep_enabled) { -+ usb_ep_free_request(ep, req); -+ return; -+ } -+ -+ if (req->status == -ESHUTDOWN) - return; - - /* -@@ -351,8 +356,14 @@ static inline void free_ep(struct uac_rtd_params *prm, struct usb_ep *ep) - - for (i = 0; i < params->req_number; i++) { - if (prm->ureq[i].req) { -- usb_ep_dequeue(ep, prm->ureq[i].req); -- usb_ep_free_request(ep, prm->ureq[i].req); -+ if (usb_ep_dequeue(ep, prm->ureq[i].req)) -+ usb_ep_free_request(ep, prm->ureq[i].req); -+ /* -+ * If usb_ep_dequeue() cannot successfully dequeue the -+ * request, the request will be freed by the completion -+ * callback. -+ */ -+ - prm->ureq[i].req = NULL; - } - } -diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c -index 0fbf9adef34be..9fcff4e94484e 100644 ---- a/drivers/usb/musb/musb_core.c -+++ b/drivers/usb/musb/musb_core.c -@@ -2102,32 +2102,35 @@ int musb_queue_resume_work(struct musb *musb, - { - struct musb_pending_work *w; - unsigned long flags; -+ bool is_suspended; - int error; - - if (WARN_ON(!callback)) - return -EINVAL; - -- if (pm_runtime_active(musb->controller)) -- return callback(musb, data); -+ spin_lock_irqsave(&musb->list_lock, flags); -+ is_suspended = musb->is_runtime_suspended; -+ -+ if (is_suspended) { -+ w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC); -+ if (!w) { -+ error = -ENOMEM; -+ goto out_unlock; -+ } - -- w = devm_kzalloc(musb->controller, sizeof(*w), GFP_ATOMIC); -- if (!w) -- return -ENOMEM; -+ w->callback = callback; -+ w->data = data; - -- w->callback = callback; -- w->data = data; -- spin_lock_irqsave(&musb->list_lock, flags); -- if (musb->is_runtime_suspended) { - list_add_tail(&w->node, &musb->pending_list); - error = 0; -- } else { -- dev_err(musb->controller, "could not add resume work %p\n", -- callback); -- devm_kfree(musb->controller, w); -- error = -EINPROGRESS; - } -+ -+out_unlock: - spin_unlock_irqrestore(&musb->list_lock, flags); - -+ if (!is_suspended) -+ error = callback(musb, data); -+ - return error; - } - EXPORT_SYMBOL_GPL(musb_queue_resume_work); -diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c -index 01a98d071c7c7..c00e4177651a8 100644 ---- a/drivers/usb/serial/ftdi_sio.c -+++ b/drivers/usb/serial/ftdi_sio.c -@@ -1386,8 +1386,9 @@ static int change_speed(struct tty_struct *tty, struct usb_serial_port *port) - index_value = get_ftdi_divisor(tty, port); - value = (u16)index_value; - index = (u16)(index_value >> 16); -- if ((priv->chip_type == FT2232C) || (priv->chip_type == FT2232H) || -- (priv->chip_type == FT4232H) || (priv->chip_type == FT232H)) { -+ if (priv->chip_type == FT2232C || priv->chip_type == FT2232H || -+ priv->chip_type == FT4232H || priv->chip_type == FT232H || -+ priv->chip_type == FTX) { - /* Probably the BM type needs the MSB of the encoded fractional - * divider also moved like for the chips above. Any infos? */ - index = (u16)((index << 8) | priv->interface); -diff --git a/drivers/usb/serial/mos7720.c b/drivers/usb/serial/mos7720.c -index 55b2879f27bdc..aefc1b58d9563 100644 ---- a/drivers/usb/serial/mos7720.c -+++ b/drivers/usb/serial/mos7720.c -@@ -1250,8 +1250,10 @@ static int mos7720_write(struct tty_struct *tty, struct usb_serial_port *port, - if (urb->transfer_buffer == NULL) { - urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, - GFP_ATOMIC); -- if (!urb->transfer_buffer) -+ if (!urb->transfer_buffer) { -+ bytes_sent = -ENOMEM; - goto exit; -+ } - } - transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); - -diff --git a/drivers/usb/serial/mos7840.c b/drivers/usb/serial/mos7840.c -index ab4bf8d6d7df0..2b8a0d4b66fce 100644 ---- a/drivers/usb/serial/mos7840.c -+++ b/drivers/usb/serial/mos7840.c -@@ -1330,8 +1330,10 @@ static int mos7840_write(struct tty_struct *tty, struct usb_serial_port *port, - if (urb->transfer_buffer == NULL) { - urb->transfer_buffer = kmalloc(URB_TRANSFER_BUFFER_SIZE, - GFP_ATOMIC); -- if (!urb->transfer_buffer) -+ if (!urb->transfer_buffer) { -+ bytes_sent = -ENOMEM; - goto exit; -+ } - } - transfer_size = min(count, URB_TRANSFER_BUFFER_SIZE); - -diff --git a/drivers/usb/serial/option.c b/drivers/usb/serial/option.c -index f49eae18500cc..5c167bc089a08 100644 ---- a/drivers/usb/serial/option.c -+++ b/drivers/usb/serial/option.c -@@ -1569,7 +1569,8 @@ static const struct usb_device_id option_ids[] = { - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1272, 0xff, 0xff, 0xff) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1273, 0xff, 0xff, 0xff) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1274, 0xff, 0xff, 0xff) }, -- { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1275, 0xff, 0xff, 0xff) }, -+ { USB_DEVICE(ZTE_VENDOR_ID, 0x1275), /* ZTE P685M */ -+ .driver_info = RSVD(3) | RSVD(4) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1276, 0xff, 0xff, 0xff) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1277, 0xff, 0xff, 0xff) }, - { USB_DEVICE_AND_INTERFACE_INFO(ZTE_VENDOR_ID, 0x1278, 0xff, 0xff, 0xff) }, -diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c -index bc6ba41686fa3..6b1e8cba17984 100644 ---- a/drivers/vfio/vfio_iommu_type1.c -+++ b/drivers/vfio/vfio_iommu_type1.c -@@ -24,6 +24,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -339,9 +340,11 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm, - unsigned long vaddr, unsigned long *pfn, - bool write_fault) - { -+ pte_t *ptep; -+ spinlock_t *ptl; - int ret; - -- ret = follow_pfn(vma, vaddr, pfn); -+ ret = follow_pte(vma->vm_mm, vaddr, &ptep, &ptl); - if (ret) { - bool unlocked = false; - -@@ -355,9 +358,17 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm, - if (ret) - return ret; - -- ret = follow_pfn(vma, vaddr, pfn); -+ ret = follow_pte(vma->vm_mm, vaddr, &ptep, &ptl); -+ if (ret) -+ return ret; - } - -+ if (write_fault && !pte_write(*ptep)) -+ ret = -EFAULT; -+ else -+ *pfn = pte_pfn(*ptep); -+ -+ pte_unmap_unlock(ptep, ptl); - return ret; - } - -@@ -866,6 +877,7 @@ static long vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma, - - static void vfio_remove_dma(struct vfio_iommu *iommu, struct vfio_dma *dma) - { -+ WARN_ON(!RB_EMPTY_ROOT(&dma->pfn_list)); - vfio_unmap_unpin(iommu, dma, true); - vfio_unlink_dma(iommu, dma); - put_task_struct(dma->task); -@@ -1974,23 +1986,6 @@ static void vfio_iommu_unmap_unpin_reaccount(struct vfio_iommu *iommu) - } - } - --static void vfio_sanity_check_pfn_list(struct vfio_iommu *iommu) --{ -- struct rb_node *n; -- -- n = rb_first(&iommu->dma_list); -- for (; n; n = rb_next(n)) { -- struct vfio_dma *dma; -- -- dma = rb_entry(n, struct vfio_dma, node); -- -- if (WARN_ON(!RB_EMPTY_ROOT(&dma->pfn_list))) -- break; -- } -- /* mdev vendor driver must unregister notifier */ -- WARN_ON(iommu->notifier.head); --} -- - /* - * Called when a domain is removed in detach. It is possible that - * the removed domain decided the iova aperture window. Modify the -@@ -2088,10 +2083,10 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, - kfree(group); - - if (list_empty(&iommu->external_domain->group_list)) { -- vfio_sanity_check_pfn_list(iommu); -- -- if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) -+ if (!IS_IOMMU_CAP_DOMAIN_IN_CONTAINER(iommu)) { -+ WARN_ON(iommu->notifier.head); - vfio_iommu_unmap_unpin_all(iommu); -+ } - - kfree(iommu->external_domain); - iommu->external_domain = NULL; -@@ -2124,10 +2119,12 @@ static void vfio_iommu_type1_detach_group(void *iommu_data, - */ - if (list_empty(&domain->group_list)) { - if (list_is_singular(&iommu->domain_list)) { -- if (!iommu->external_domain) -+ if (!iommu->external_domain) { -+ WARN_ON(iommu->notifier.head); - vfio_iommu_unmap_unpin_all(iommu); -- else -+ } else { - vfio_iommu_unmap_unpin_reaccount(iommu); -+ } - } - iommu_domain_free(domain->domain); - list_del(&domain->next); -@@ -2201,7 +2198,6 @@ static void vfio_iommu_type1_release(void *iommu_data) - - if (iommu->external_domain) { - vfio_release_domain(iommu->external_domain, true); -- vfio_sanity_check_pfn_list(iommu); - kfree(iommu->external_domain); - } - -diff --git a/drivers/video/fbdev/Kconfig b/drivers/video/fbdev/Kconfig -index 1e70e838530ee..a7e5f12687b70 100644 ---- a/drivers/video/fbdev/Kconfig -+++ b/drivers/video/fbdev/Kconfig -@@ -1269,6 +1269,7 @@ config FB_ATY - select FB_CFB_IMAGEBLIT - select FB_BACKLIGHT if FB_ATY_BACKLIGHT - select FB_MACMODES if PPC -+ select FB_ATY_CT if SPARC64 && PCI - help - This driver supports graphics boards with the ATI Mach64 chips. - Say Y if you have such a graphics board. -@@ -1279,7 +1280,6 @@ config FB_ATY - config FB_ATY_CT - bool "Mach64 CT/VT/GT/LT (incl. 3D RAGE) support" - depends on PCI && FB_ATY -- default y if SPARC64 && PCI - help - Say Y here to support use of ATI's 64-bit Rage boards (or other - boards based on the Mach64 CT, VT, GT, and LT chipsets) as a -diff --git a/drivers/virt/vboxguest/vboxguest_utils.c b/drivers/virt/vboxguest/vboxguest_utils.c -index 43c391626a000..bf2945c25ca8f 100644 ---- a/drivers/virt/vboxguest/vboxguest_utils.c -+++ b/drivers/virt/vboxguest/vboxguest_utils.c -@@ -466,7 +466,7 @@ static int hgcm_cancel_call(struct vbg_dev *gdev, struct vmmdev_hgcm_call *call) - * Cancellation fun. - */ - static int vbg_hgcm_do_call(struct vbg_dev *gdev, struct vmmdev_hgcm_call *call, -- u32 timeout_ms, bool *leak_it) -+ u32 timeout_ms, bool interruptible, bool *leak_it) - { - int rc, cancel_rc, ret; - long timeout; -@@ -493,10 +493,15 @@ static int vbg_hgcm_do_call(struct vbg_dev *gdev, struct vmmdev_hgcm_call *call, - else - timeout = msecs_to_jiffies(timeout_ms); - -- timeout = wait_event_interruptible_timeout( -- gdev->hgcm_wq, -- hgcm_req_done(gdev, &call->header), -- timeout); -+ if (interruptible) { -+ timeout = wait_event_interruptible_timeout(gdev->hgcm_wq, -+ hgcm_req_done(gdev, &call->header), -+ timeout); -+ } else { -+ timeout = wait_event_timeout(gdev->hgcm_wq, -+ hgcm_req_done(gdev, &call->header), -+ timeout); -+ } - - /* timeout > 0 means hgcm_req_done has returned true, so success */ - if (timeout > 0) -@@ -629,7 +634,8 @@ int vbg_hgcm_call(struct vbg_dev *gdev, u32 requestor, u32 client_id, - hgcm_call_init_call(call, client_id, function, parms, parm_count, - bounce_bufs); - -- ret = vbg_hgcm_do_call(gdev, call, timeout_ms, &leak_it); -+ ret = vbg_hgcm_do_call(gdev, call, timeout_ms, -+ requestor & VMMDEV_REQUESTOR_USERMODE, &leak_it); - if (ret == 0) { - *vbox_status = call->header.result; - ret = hgcm_call_copy_back_result(call, parms, parm_count, -diff --git a/drivers/watchdog/mei_wdt.c b/drivers/watchdog/mei_wdt.c -index 5391bf3e6b11d..c5967d8b4256a 100644 ---- a/drivers/watchdog/mei_wdt.c -+++ b/drivers/watchdog/mei_wdt.c -@@ -382,6 +382,7 @@ static int mei_wdt_register(struct mei_wdt *wdt) - - watchdog_set_drvdata(&wdt->wdd, wdt); - watchdog_stop_on_reboot(&wdt->wdd); -+ watchdog_stop_on_unregister(&wdt->wdd); - - ret = watchdog_register_device(&wdt->wdd); - if (ret) -diff --git a/drivers/watchdog/qcom-wdt.c b/drivers/watchdog/qcom-wdt.c -index ea8a6abd64ecb..094f096aee0f2 100644 ---- a/drivers/watchdog/qcom-wdt.c -+++ b/drivers/watchdog/qcom-wdt.c -@@ -22,7 +22,6 @@ enum wdt_reg { - }; - - #define QCOM_WDT_ENABLE BIT(0) --#define QCOM_WDT_ENABLE_IRQ BIT(1) - - static const u32 reg_offset_data_apcs_tmr[] = { - [WDT_RST] = 0x38, -@@ -58,16 +57,6 @@ struct qcom_wdt *to_qcom_wdt(struct watchdog_device *wdd) - return container_of(wdd, struct qcom_wdt, wdd); - } - --static inline int qcom_get_enable(struct watchdog_device *wdd) --{ -- int enable = QCOM_WDT_ENABLE; -- -- if (wdd->pretimeout) -- enable |= QCOM_WDT_ENABLE_IRQ; -- -- return enable; --} -- - static irqreturn_t qcom_wdt_isr(int irq, void *arg) - { - struct watchdog_device *wdd = arg; -@@ -86,7 +75,7 @@ static int qcom_wdt_start(struct watchdog_device *wdd) - writel(1, wdt_addr(wdt, WDT_RST)); - writel(bark * wdt->rate, wdt_addr(wdt, WDT_BARK_TIME)); - writel(wdd->timeout * wdt->rate, wdt_addr(wdt, WDT_BITE_TIME)); -- writel(qcom_get_enable(wdd), wdt_addr(wdt, WDT_EN)); -+ writel(QCOM_WDT_ENABLE, wdt_addr(wdt, WDT_EN)); - return 0; - } - -diff --git a/fs/affs/namei.c b/fs/affs/namei.c -index 41c5749f4db78..5400a876d73fb 100644 ---- a/fs/affs/namei.c -+++ b/fs/affs/namei.c -@@ -460,8 +460,10 @@ affs_xrename(struct inode *old_dir, struct dentry *old_dentry, - return -EIO; - - bh_new = affs_bread(sb, d_inode(new_dentry)->i_ino); -- if (!bh_new) -+ if (!bh_new) { -+ affs_brelse(bh_old); - return -EIO; -+ } - - /* Remove old header from its parent directory. */ - affs_lock_dir(old_dir); -diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c -index a32f23981f60f..08ca9441270d2 100644 ---- a/fs/btrfs/block-group.c -+++ b/fs/btrfs/block-group.c -@@ -2391,8 +2391,10 @@ again: - - if (!path) { - path = btrfs_alloc_path(); -- if (!path) -- return -ENOMEM; -+ if (!path) { -+ ret = -ENOMEM; -+ goto out; -+ } - } - - /* -@@ -2487,16 +2489,14 @@ again: - btrfs_put_block_group(cache); - if (drop_reserve) - btrfs_delayed_refs_rsv_release(fs_info, 1); -- -- if (ret) -- break; -- - /* - * Avoid blocking other tasks for too long. It might even save - * us from writing caches for block groups that are going to be - * removed. - */ - mutex_unlock(&trans->transaction->cache_write_mutex); -+ if (ret) -+ goto out; - mutex_lock(&trans->transaction->cache_write_mutex); - } - mutex_unlock(&trans->transaction->cache_write_mutex); -@@ -2520,7 +2520,12 @@ again: - goto again; - } - spin_unlock(&cur_trans->dirty_bgs_lock); -- } else if (ret < 0) { -+ } -+out: -+ if (ret < 0) { -+ spin_lock(&cur_trans->dirty_bgs_lock); -+ list_splice_init(&dirty, &cur_trans->dirty_bgs); -+ spin_unlock(&cur_trans->dirty_bgs_lock); - btrfs_cleanup_dirty_bgs(cur_trans, fs_info); - } - -diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c -index e25133a9e9dfe..1af73367087df 100644 ---- a/fs/btrfs/ctree.c -+++ b/fs/btrfs/ctree.c -@@ -260,9 +260,12 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans, - ret = btrfs_inc_ref(trans, root, cow, 1); - else - ret = btrfs_inc_ref(trans, root, cow, 0); -- -- if (ret) -+ if (ret) { -+ btrfs_tree_unlock(cow); -+ free_extent_buffer(cow); -+ btrfs_abort_transaction(trans, ret); - return ret; -+ } - - btrfs_mark_buffer_dirty(cow); - *cow_ret = cow; -diff --git a/fs/btrfs/free-space-cache.c b/fs/btrfs/free-space-cache.c -index 6e6be922b937d..23f59d463e24e 100644 ---- a/fs/btrfs/free-space-cache.c -+++ b/fs/btrfs/free-space-cache.c -@@ -744,8 +744,10 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, - while (num_entries) { - e = kmem_cache_zalloc(btrfs_free_space_cachep, - GFP_NOFS); -- if (!e) -+ if (!e) { -+ ret = -ENOMEM; - goto free_cache; -+ } - - ret = io_ctl_read_entry(&io_ctl, e, &type); - if (ret) { -@@ -754,6 +756,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, - } - - if (!e->bytes) { -+ ret = -1; - kmem_cache_free(btrfs_free_space_cachep, e); - goto free_cache; - } -@@ -774,6 +777,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode, - e->bitmap = kmem_cache_zalloc( - btrfs_free_space_bitmap_cachep, GFP_NOFS); - if (!e->bitmap) { -+ ret = -ENOMEM; - kmem_cache_free( - btrfs_free_space_cachep, e); - goto free_cache; -diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c -index 001f13cf9ab8f..05b3e27b21d44 100644 ---- a/fs/btrfs/relocation.c -+++ b/fs/btrfs/relocation.c -@@ -1336,9 +1336,7 @@ static void __del_reloc_root(struct btrfs_root *root) - RB_CLEAR_NODE(&node->rb_node); - } - spin_unlock(&rc->reloc_root_tree.lock); -- if (!node) -- return; -- BUG_ON((struct btrfs_root *)node->data != root); -+ ASSERT(!node || (struct btrfs_root *)node->data == root); - } - - spin_lock(&fs_info->trans_lock); -diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c -index 7b975dbb2bb49..1c74a7cbf5b19 100644 ---- a/fs/debugfs/inode.c -+++ b/fs/debugfs/inode.c -@@ -293,7 +293,7 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent) - { - struct dentry *dentry; - -- if (IS_ERR(parent)) -+ if (!debugfs_initialized() || IS_ERR_OR_NULL(name) || IS_ERR(parent)) - return NULL; - - if (!parent) -@@ -315,6 +315,9 @@ static struct dentry *start_creating(const char *name, struct dentry *parent) - struct dentry *dentry; - int error; - -+ if (!debugfs_initialized()) -+ return ERR_PTR(-ENOENT); -+ - pr_debug("creating file '%s'\n", name); - - if (IS_ERR(parent)) -diff --git a/fs/erofs/xattr.c b/fs/erofs/xattr.c -index 503bea20cde26..f78496776e764 100644 ---- a/fs/erofs/xattr.c -+++ b/fs/erofs/xattr.c -@@ -48,8 +48,14 @@ static int init_inode_xattrs(struct inode *inode) - int ret = 0; - - /* the most case is that xattrs of this inode are initialized. */ -- if (test_bit(EROFS_I_EA_INITED_BIT, &vi->flags)) -+ if (test_bit(EROFS_I_EA_INITED_BIT, &vi->flags)) { -+ /* -+ * paired with smp_mb() at the end of the function to ensure -+ * fields will only be observed after the bit is set. -+ */ -+ smp_mb(); - return 0; -+ } - - if (wait_on_bit_lock(&vi->flags, EROFS_I_BL_XATTR_BIT, TASK_KILLABLE)) - return -ERESTARTSYS; -@@ -137,6 +143,8 @@ static int init_inode_xattrs(struct inode *inode) - } - xattr_iter_end(&it, atomic_map); - -+ /* paired with smp_mb() at the beginning of the function. */ -+ smp_mb(); - set_bit(EROFS_I_EA_INITED_BIT, &vi->flags); - - out_unlock: -diff --git a/fs/erofs/zmap.c b/fs/erofs/zmap.c -index 6a26c293ae2d9..fff5741007214 100644 ---- a/fs/erofs/zmap.c -+++ b/fs/erofs/zmap.c -@@ -36,8 +36,14 @@ static int fill_inode_lazy(struct inode *inode) - void *kaddr; - struct z_erofs_map_header *h; - -- if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) -+ if (test_bit(EROFS_I_Z_INITED_BIT, &vi->flags)) { -+ /* -+ * paired with smp_mb() at the end of the function to ensure -+ * fields will only be observed after the bit is set. -+ */ -+ smp_mb(); - return 0; -+ } - - if (wait_on_bit_lock(&vi->flags, EROFS_I_BL_Z_BIT, TASK_KILLABLE)) - return -ERESTARTSYS; -@@ -83,6 +89,8 @@ static int fill_inode_lazy(struct inode *inode) - - vi->z_physical_clusterbits[1] = vi->z_logical_clusterbits + - ((h->h_clusterbits >> 5) & 7); -+ /* paired with smp_mb() at the beginning of the function */ -+ smp_mb(); - set_bit(EROFS_I_Z_INITED_BIT, &vi->flags); - unmap_done: - kunmap_atomic(kaddr); -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index f05ec9bfbf4fd..7f22487d502b5 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -2405,11 +2405,10 @@ again: - (frame - 1)->bh); - if (err) - goto journal_error; -- if (restart) { -- err = ext4_handle_dirty_dx_node(handle, dir, -- frame->bh); -+ err = ext4_handle_dirty_dx_node(handle, dir, -+ frame->bh); -+ if (err) - goto journal_error; -- } - } else { - struct dx_root *dxroot; - memcpy((char *) entries2, (char *) entries, -diff --git a/fs/f2fs/data.c b/fs/f2fs/data.c -index 68be334afc286..64ee2a064e339 100644 ---- a/fs/f2fs/data.c -+++ b/fs/f2fs/data.c -@@ -318,7 +318,7 @@ static inline void __submit_bio(struct f2fs_sb_info *sbi, - if (test_opt(sbi, LFS) && current->plug) - blk_finish_plug(current->plug); - -- if (F2FS_IO_ALIGNED(sbi)) -+ if (!F2FS_IO_ALIGNED(sbi)) - goto submit_io; - - start = bio->bi_iter.bi_size >> F2FS_BLKSIZE_BITS; -diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c -index 5d94abe467a4f..6e58b2e62b189 100644 ---- a/fs/f2fs/file.c -+++ b/fs/f2fs/file.c -@@ -686,6 +686,10 @@ int f2fs_truncate(struct inode *inode) - return -EIO; - } - -+ err = dquot_initialize(inode); -+ if (err) -+ return err; -+ - /* we should check inline_data size */ - if (!f2fs_may_inline_data(inode)) { - err = f2fs_convert_inline_inode(inode); -@@ -761,7 +765,8 @@ static void __setattr_copy(struct inode *inode, const struct iattr *attr) - if (ia_valid & ATTR_MODE) { - umode_t mode = attr->ia_mode; - -- if (!in_group_p(inode->i_gid) && !capable(CAP_FSETID)) -+ if (!in_group_p(inode->i_gid) && -+ !capable_wrt_inode_uidgid(inode, CAP_FSETID)) - mode &= ~S_ISGID; - set_acl_inode(inode, mode); - } -diff --git a/fs/f2fs/inline.c b/fs/f2fs/inline.c -index 183388393c6a8..cbd17e4ff920c 100644 ---- a/fs/f2fs/inline.c -+++ b/fs/f2fs/inline.c -@@ -189,6 +189,10 @@ int f2fs_convert_inline_inode(struct inode *inode) - if (!f2fs_has_inline_data(inode)) - return 0; - -+ err = dquot_initialize(inode); -+ if (err) -+ return err; -+ - page = f2fs_grab_cache_page(inode->i_mapping, 0, false); - if (!page) - return -ENOMEM; -diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c -index 50fa3e08c02f3..aaec3c5b02028 100644 ---- a/fs/gfs2/bmap.c -+++ b/fs/gfs2/bmap.c -@@ -1228,6 +1228,9 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length, - - gfs2_inplace_release(ip); - -+ if (ip->i_qadata && ip->i_qadata->qa_qd_num) -+ gfs2_quota_unlock(ip); -+ - if (length != written && (iomap->flags & IOMAP_F_NEW)) { - /* Deallocate blocks that were just allocated. */ - loff_t blockmask = i_blocksize(inode) - 1; -@@ -1240,9 +1243,6 @@ static int gfs2_iomap_end(struct inode *inode, loff_t pos, loff_t length, - } - } - -- if (ip->i_qadata && ip->i_qadata->qa_qd_num) -- gfs2_quota_unlock(ip); -- - if (unlikely(!written)) - goto out_unlock; - -diff --git a/fs/gfs2/lock_dlm.c b/fs/gfs2/lock_dlm.c -index 7c7197343ee2b..72dec177b3494 100644 ---- a/fs/gfs2/lock_dlm.c -+++ b/fs/gfs2/lock_dlm.c -@@ -280,7 +280,6 @@ static void gdlm_put_lock(struct gfs2_glock *gl) - { - struct gfs2_sbd *sdp = gl->gl_name.ln_sbd; - struct lm_lockstruct *ls = &sdp->sd_lockstruct; -- int lvb_needs_unlock = 0; - int error; - - if (gl->gl_lksb.sb_lkid == 0) { -@@ -293,13 +292,10 @@ static void gdlm_put_lock(struct gfs2_glock *gl) - gfs2_sbstats_inc(gl, GFS2_LKS_DCOUNT); - gfs2_update_request_times(gl); - -- /* don't want to skip dlm_unlock writing the lvb when lock is ex */ -- -- if (gl->gl_lksb.sb_lvbptr && (gl->gl_state == LM_ST_EXCLUSIVE)) -- lvb_needs_unlock = 1; -+ /* don't want to skip dlm_unlock writing the lvb when lock has one */ - - if (test_bit(SDF_SKIP_DLM_UNLOCK, &sdp->sd_flags) && -- !lvb_needs_unlock) { -+ !gl->gl_lksb.sb_lvbptr) { - gfs2_glock_free(gl); - return; - } -diff --git a/fs/isofs/dir.c b/fs/isofs/dir.c -index f0fe641893a5e..b9e6a7ec78be4 100644 ---- a/fs/isofs/dir.c -+++ b/fs/isofs/dir.c -@@ -152,6 +152,7 @@ static int do_isofs_readdir(struct inode *inode, struct file *file, - printk(KERN_NOTICE "iso9660: Corrupted directory entry" - " in block %lu of inode %lu\n", block, - inode->i_ino); -+ brelse(bh); - return -EIO; - } - -diff --git a/fs/isofs/namei.c b/fs/isofs/namei.c -index cac468f04820e..558e7c51ce0d4 100644 ---- a/fs/isofs/namei.c -+++ b/fs/isofs/namei.c -@@ -102,6 +102,7 @@ isofs_find_entry(struct inode *dir, struct dentry *dentry, - printk(KERN_NOTICE "iso9660: Corrupted directory entry" - " in block %lu of inode %lu\n", block, - dir->i_ino); -+ brelse(bh); - return 0; - } - -diff --git a/fs/jffs2/summary.c b/fs/jffs2/summary.c -index be7c8a6a57480..4fe64519870f1 100644 ---- a/fs/jffs2/summary.c -+++ b/fs/jffs2/summary.c -@@ -783,6 +783,8 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock - dbg_summary("Writing unknown RWCOMPAT_COPY node type %x\n", - je16_to_cpu(temp->u.nodetype)); - jffs2_sum_disable_collecting(c->summary); -+ /* The above call removes the list, nothing more to do */ -+ goto bail_rwcompat; - } else { - BUG(); /* unknown node in summary information */ - } -@@ -794,6 +796,7 @@ static int jffs2_sum_write_data(struct jffs2_sb_info *c, struct jffs2_eraseblock - - c->summary->sum_num--; - } -+ bail_rwcompat: - - jffs2_sum_reset_collected(c->summary); - -diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c -index caade185e568d..6fe82ce8663ef 100644 ---- a/fs/jfs/jfs_dmap.c -+++ b/fs/jfs/jfs_dmap.c -@@ -1656,7 +1656,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) - } else if (rc == -ENOSPC) { - /* search for next smaller log2 block */ - l2nb = BLKSTOL2(nblocks) - 1; -- nblocks = 1 << l2nb; -+ nblocks = 1LL << l2nb; - } else { - /* Trim any already allocated blocks */ - jfs_error(bmp->db_ipbmap->i_sb, "-EIO\n"); -diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c -index be418fccc9d86..7f39d6091dfa0 100644 ---- a/fs/nfsd/nfsctl.c -+++ b/fs/nfsd/nfsctl.c -@@ -1523,12 +1523,9 @@ static int __init init_nfsd(void) - int retval; - printk(KERN_INFO "Installing knfsd (copyright (C) 1996 okir@monad.swb.de).\n"); - -- retval = register_pernet_subsys(&nfsd_net_ops); -- if (retval < 0) -- return retval; - retval = register_cld_notifier(); - if (retval) -- goto out_unregister_pernet; -+ return retval; - retval = nfsd4_init_slabs(); - if (retval) - goto out_unregister_notifier; -@@ -1546,9 +1543,14 @@ static int __init init_nfsd(void) - goto out_free_lockd; - retval = register_filesystem(&nfsd_fs_type); - if (retval) -+ goto out_free_exports; -+ retval = register_pernet_subsys(&nfsd_net_ops); -+ if (retval < 0) - goto out_free_all; - return 0; - out_free_all: -+ unregister_pernet_subsys(&nfsd_net_ops); -+out_free_exports: - remove_proc_entry("fs/nfs/exports", NULL); - remove_proc_entry("fs/nfs", NULL); - out_free_lockd: -@@ -1562,13 +1564,12 @@ out_free_slabs: - nfsd4_free_slabs(); - out_unregister_notifier: - unregister_cld_notifier(); --out_unregister_pernet: -- unregister_pernet_subsys(&nfsd_net_ops); - return retval; - } - - static void __exit exit_nfsd(void) - { -+ unregister_pernet_subsys(&nfsd_net_ops); - nfsd_drc_slab_free(); - remove_proc_entry("fs/nfs/exports", NULL); - remove_proc_entry("fs/nfs", NULL); -@@ -1579,7 +1580,6 @@ static void __exit exit_nfsd(void) - nfsd_fault_inject_cleanup(); - unregister_filesystem(&nfsd_fs_type); - unregister_cld_notifier(); -- unregister_pernet_subsys(&nfsd_net_ops); - } - - MODULE_AUTHOR("Olaf Kirch "); -diff --git a/fs/ocfs2/cluster/heartbeat.c b/fs/ocfs2/cluster/heartbeat.c -index a368350d4c279..c843bc318382b 100644 ---- a/fs/ocfs2/cluster/heartbeat.c -+++ b/fs/ocfs2/cluster/heartbeat.c -@@ -2052,7 +2052,7 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g - o2hb_nego_timeout_handler, - reg, NULL, ®->hr_handler_list); - if (ret) -- goto free; -+ goto remove_item; - - ret = o2net_register_handler(O2HB_NEGO_APPROVE_MSG, reg->hr_key, - sizeof(struct o2hb_nego_msg), -@@ -2067,6 +2067,12 @@ static struct config_item *o2hb_heartbeat_group_make_item(struct config_group *g - - unregister_handler: - o2net_unregister_handler_list(®->hr_handler_list); -+remove_item: -+ spin_lock(&o2hb_live_lock); -+ list_del(®->hr_all_item); -+ if (o2hb_global_heartbeat_active()) -+ clear_bit(reg->hr_region_num, o2hb_region_bitmap); -+ spin_unlock(&o2hb_live_lock); - free: - kfree(reg); - return ERR_PTR(ret); -diff --git a/fs/pstore/platform.c b/fs/pstore/platform.c -index 74a60bae2b237..705b79bb9b241 100644 ---- a/fs/pstore/platform.c -+++ b/fs/pstore/platform.c -@@ -275,7 +275,7 @@ static int pstore_compress(const void *in, void *out, - { - int ret; - -- if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION)) -+ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS)) - return -EINVAL; - - ret = crypto_comp_compress(tfm, in, inlen, out, &outlen); -@@ -664,7 +664,7 @@ static void decompress_record(struct pstore_record *record) - int unzipped_len; - char *unzipped, *workspace; - -- if (!IS_ENABLED(CONFIG_PSTORE_COMPRESSION) || !record->compressed) -+ if (!IS_ENABLED(CONFIG_PSTORE_COMPRESS) || !record->compressed) - return; - - /* Only PSTORE_TYPE_DMESG support compression. */ -diff --git a/fs/quota/quota_v2.c b/fs/quota/quota_v2.c -index 36dce17b01016..56aedf4ba8864 100644 ---- a/fs/quota/quota_v2.c -+++ b/fs/quota/quota_v2.c -@@ -166,19 +166,24 @@ static int v2_read_file_info(struct super_block *sb, int type) - quota_error(sb, "Number of blocks too big for quota file size (%llu > %llu).", - (loff_t)qinfo->dqi_blocks << qinfo->dqi_blocksize_bits, - i_size_read(sb_dqopt(sb)->files[type])); -- goto out; -+ goto out_free; - } - if (qinfo->dqi_free_blk >= qinfo->dqi_blocks) { - quota_error(sb, "Free block number too big (%u >= %u).", - qinfo->dqi_free_blk, qinfo->dqi_blocks); -- goto out; -+ goto out_free; - } - if (qinfo->dqi_free_entry >= qinfo->dqi_blocks) { - quota_error(sb, "Block with free entry too big (%u >= %u).", - qinfo->dqi_free_entry, qinfo->dqi_blocks); -- goto out; -+ goto out_free; - } - ret = 0; -+out_free: -+ if (ret) { -+ kfree(info->dqi_priv); -+ info->dqi_priv = NULL; -+ } - out: - up_read(&dqopt->dqio_sem); - return ret; -diff --git a/fs/ubifs/auth.c b/fs/ubifs/auth.c -index b10418b5fb719..8be17a7731961 100644 ---- a/fs/ubifs/auth.c -+++ b/fs/ubifs/auth.c -@@ -342,7 +342,7 @@ int ubifs_init_authentication(struct ubifs_info *c) - ubifs_err(c, "hmac %s is bigger than maximum allowed hmac size (%d > %d)", - hmac_name, c->hmac_desc_len, UBIFS_HMAC_ARR_SZ); - err = -EINVAL; -- goto out_free_hash; -+ goto out_free_hmac; - } - - err = crypto_shash_setkey(c->hmac_tfm, ukp->data, ukp->datalen); -diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c -index e49bd69dfc1c8..701f15ba61352 100644 ---- a/fs/ubifs/super.c -+++ b/fs/ubifs/super.c -@@ -820,8 +820,10 @@ static int alloc_wbufs(struct ubifs_info *c) - c->jheads[i].wbuf.jhead = i; - c->jheads[i].grouped = 1; - c->jheads[i].log_hash = ubifs_hash_get_desc(c); -- if (IS_ERR(c->jheads[i].log_hash)) -+ if (IS_ERR(c->jheads[i].log_hash)) { -+ err = PTR_ERR(c->jheads[i].log_hash); - goto out; -+ } - } - - /* -diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h -index 233a72f169bb7..e1de0fe281644 100644 ---- a/include/acpi/acexcep.h -+++ b/include/acpi/acexcep.h -@@ -59,11 +59,11 @@ struct acpi_exception_info { - - #define AE_OK (acpi_status) 0x0000 - --#define ACPI_ENV_EXCEPTION(status) (status & AE_CODE_ENVIRONMENTAL) --#define ACPI_AML_EXCEPTION(status) (status & AE_CODE_AML) --#define ACPI_PROG_EXCEPTION(status) (status & AE_CODE_PROGRAMMER) --#define ACPI_TABLE_EXCEPTION(status) (status & AE_CODE_ACPI_TABLES) --#define ACPI_CNTL_EXCEPTION(status) (status & AE_CODE_CONTROL) -+#define ACPI_ENV_EXCEPTION(status) (((status) & AE_CODE_MASK) == AE_CODE_ENVIRONMENTAL) -+#define ACPI_AML_EXCEPTION(status) (((status) & AE_CODE_MASK) == AE_CODE_AML) -+#define ACPI_PROG_EXCEPTION(status) (((status) & AE_CODE_MASK) == AE_CODE_PROGRAMMER) -+#define ACPI_TABLE_EXCEPTION(status) (((status) & AE_CODE_MASK) == AE_CODE_ACPI_TABLES) -+#define ACPI_CNTL_EXCEPTION(status) (((status) & AE_CODE_MASK) == AE_CODE_CONTROL) - - /* - * Environmental exceptions -diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h -index 2267b7c763c64..8fe1912e3eeb9 100644 ---- a/include/asm-generic/vmlinux.lds.h -+++ b/include/asm-generic/vmlinux.lds.h -@@ -756,8 +756,13 @@ - /* DWARF 4 */ \ - .debug_types 0 : { *(.debug_types) } \ - /* DWARF 5 */ \ -+ .debug_addr 0 : { *(.debug_addr) } \ -+ .debug_line_str 0 : { *(.debug_line_str) } \ -+ .debug_loclists 0 : { *(.debug_loclists) } \ - .debug_macro 0 : { *(.debug_macro) } \ -- .debug_addr 0 : { *(.debug_addr) } -+ .debug_names 0 : { *(.debug_names) } \ -+ .debug_rnglists 0 : { *(.debug_rnglists) } \ -+ .debug_str_offsets 0 : { *(.debug_str_offsets) } - - /* Stabs debugging sections. */ - #define STABS_DEBUG \ -diff --git a/include/linux/bpf.h b/include/linux/bpf.h -index 7aa0d8b5aaf0c..007147f643908 100644 ---- a/include/linux/bpf.h -+++ b/include/linux/bpf.h -@@ -711,7 +711,10 @@ static inline void bpf_long_memcpy(void *dst, const void *src, u32 size) - /* verify correctness of eBPF program */ - int bpf_check(struct bpf_prog **fp, union bpf_attr *attr, - union bpf_attr __user *uattr); -+ -+#ifndef CONFIG_BPF_JIT_ALWAYS_ON - void bpf_patch_call_args(struct bpf_insn *insn, u32 stack_depth); -+#endif - - /* Map specifics */ - struct xdp_buff; -diff --git a/include/linux/device-mapper.h b/include/linux/device-mapper.h -index e4e1f5c1f4929..a53d7d2c2d95c 100644 ---- a/include/linux/device-mapper.h -+++ b/include/linux/device-mapper.h -@@ -316,6 +316,11 @@ struct dm_target { - * whether or not its underlying devices have support. - */ - bool discards_supported:1; -+ -+ /* -+ * Set if we need to limit the number of in-flight bios when swapping. -+ */ -+ bool limit_swap_bios:1; - }; - - /* Each target can link one of these into the table */ -diff --git a/include/linux/filter.h b/include/linux/filter.h -index 79830bc9e45cf..c53e2fe3c8f7f 100644 ---- a/include/linux/filter.h -+++ b/include/linux/filter.h -@@ -846,7 +846,7 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp); - u64 __bpf_call_base(u64 r1, u64 r2, u64 r3, u64 r4, u64 r5); - #define __bpf_call_base_args \ - ((u64 (*)(u64, u64, u64, u64, u64, const struct bpf_insn *)) \ -- __bpf_call_base) -+ (void *)__bpf_call_base) - - struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog); - void bpf_jit_compile(struct bpf_prog *prog); -diff --git a/include/linux/icmpv6.h b/include/linux/icmpv6.h -index a8f8889761378..0be0d68fbb009 100644 ---- a/include/linux/icmpv6.h -+++ b/include/linux/icmpv6.h -@@ -3,6 +3,7 @@ - #define _LINUX_ICMPV6_H - - #include -+#include - #include - - static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) -@@ -13,21 +14,64 @@ static inline struct icmp6hdr *icmp6_hdr(const struct sk_buff *skb) - #include - - #if IS_ENABLED(CONFIG_IPV6) --extern void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info); - - typedef void ip6_icmp_send_t(struct sk_buff *skb, u8 type, u8 code, __u32 info, -- const struct in6_addr *force_saddr); -+ const struct in6_addr *force_saddr, -+ const struct inet6_skb_parm *parm); -+void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -+ const struct in6_addr *force_saddr, -+ const struct inet6_skb_parm *parm); -+#if IS_BUILTIN(CONFIG_IPV6) -+static inline void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -+ const struct inet6_skb_parm *parm) -+{ -+ icmp6_send(skb, type, code, info, NULL, parm); -+} -+static inline int inet6_register_icmp_sender(ip6_icmp_send_t *fn) -+{ -+ BUILD_BUG_ON(fn != icmp6_send); -+ return 0; -+} -+static inline int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn) -+{ -+ BUILD_BUG_ON(fn != icmp6_send); -+ return 0; -+} -+#else -+extern void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -+ const struct inet6_skb_parm *parm); - extern int inet6_register_icmp_sender(ip6_icmp_send_t *fn); - extern int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn); -+#endif -+ -+static inline void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) -+{ -+ __icmpv6_send(skb, type, code, info, IP6CB(skb)); -+} -+ - int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, - unsigned int data_len); - -+#if IS_ENABLED(CONFIG_NF_NAT) -+void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info); -+#else -+static inline void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info) -+{ -+ struct inet6_skb_parm parm = { 0 }; -+ __icmpv6_send(skb_in, type, code, info, &parm); -+} -+#endif -+ - #else - - static inline void icmpv6_send(struct sk_buff *skb, - u8 type, u8 code, __u32 info) - { -+} - -+static inline void icmpv6_ndo_send(struct sk_buff *skb, -+ u8 type, u8 code, __u32 info) -+{ - } - #endif - -diff --git a/include/linux/ipv6.h b/include/linux/ipv6.h -index ea7c7906591eb..bbe297bbbca52 100644 ---- a/include/linux/ipv6.h -+++ b/include/linux/ipv6.h -@@ -83,7 +83,6 @@ struct ipv6_params { - __s32 autoconf; - }; - extern struct ipv6_params ipv6_defaults; --#include - #include - #include - -diff --git a/include/linux/kexec.h b/include/linux/kexec.h -index 1776eb2e43a44..a1cffce3de8cd 100644 ---- a/include/linux/kexec.h -+++ b/include/linux/kexec.h -@@ -293,6 +293,11 @@ struct kimage { - /* Information for loading purgatory */ - struct purgatory_info purgatory_info; - #endif -+ -+#ifdef CONFIG_IMA_KEXEC -+ /* Virtual address of IMA measurement buffer for kexec syscall */ -+ void *ima_buffer; -+#endif - }; - - /* kexec interface functions */ -diff --git a/include/linux/key.h b/include/linux/key.h -index 6cf8e71cf8b7c..9c26cc9b802a0 100644 ---- a/include/linux/key.h -+++ b/include/linux/key.h -@@ -269,6 +269,7 @@ extern struct key *key_alloc(struct key_type *type, - #define KEY_ALLOC_BUILT_IN 0x0004 /* Key is built into kernel */ - #define KEY_ALLOC_BYPASS_RESTRICTION 0x0008 /* Override the check on restricted keyrings */ - #define KEY_ALLOC_UID_KEYRING 0x0010 /* allocating a user or user session keyring */ -+#define KEY_ALLOC_SET_KEEP 0x0020 /* Set the KEEP flag on the key/keyring */ - - extern void key_revoke(struct key *key); - extern void key_invalidate(struct key *key); -diff --git a/include/linux/rcupdate.h b/include/linux/rcupdate.h -index 75a2eded7aa2c..09e6ac4b669b2 100644 ---- a/include/linux/rcupdate.h -+++ b/include/linux/rcupdate.h -@@ -96,8 +96,10 @@ static inline void rcu_user_exit(void) { } - - #ifdef CONFIG_RCU_NOCB_CPU - void rcu_init_nohz(void); -+void rcu_nocb_flush_deferred_wakeup(void); - #else /* #ifdef CONFIG_RCU_NOCB_CPU */ - static inline void rcu_init_nohz(void) { } -+static inline void rcu_nocb_flush_deferred_wakeup(void) { } - #endif /* #else #ifdef CONFIG_RCU_NOCB_CPU */ - - /** -diff --git a/include/linux/rmap.h b/include/linux/rmap.h -index 988d176472df7..d7d6d4eb17949 100644 ---- a/include/linux/rmap.h -+++ b/include/linux/rmap.h -@@ -214,7 +214,8 @@ struct page_vma_mapped_walk { - - static inline void page_vma_mapped_walk_done(struct page_vma_mapped_walk *pvmw) - { -- if (pvmw->pte) -+ /* HugeTLB pte is set to the relevant page table entry without pte_mapped. */ -+ if (pvmw->pte && !PageHuge(pvmw->page)) - pte_unmap(pvmw->pte); - if (pvmw->ptl) - spin_unlock(pvmw->ptl); -diff --git a/include/net/act_api.h b/include/net/act_api.h -index 05b568b92e59d..4dabe4730f00f 100644 ---- a/include/net/act_api.h -+++ b/include/net/act_api.h -@@ -156,6 +156,7 @@ int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index); - int tcf_idr_create(struct tc_action_net *tn, u32 index, struct nlattr *est, - struct tc_action **a, const struct tc_action_ops *ops, - int bind, bool cpustats); -+void tcf_idr_insert_many(struct tc_action *actions[]); - void tcf_idr_cleanup(struct tc_action_net *tn, u32 index); - int tcf_idr_check_alloc(struct tc_action_net *tn, u32 *index, - struct tc_action **a, int bind); -diff --git a/include/net/icmp.h b/include/net/icmp.h -index 5d4bfdba9adf0..fd84adc479633 100644 ---- a/include/net/icmp.h -+++ b/include/net/icmp.h -@@ -43,6 +43,16 @@ static inline void icmp_send(struct sk_buff *skb_in, int type, int code, __be32 - __icmp_send(skb_in, type, code, info, &IPCB(skb_in)->opt); - } - -+#if IS_ENABLED(CONFIG_NF_NAT) -+void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info); -+#else -+static inline void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info) -+{ -+ struct ip_options opts = { 0 }; -+ __icmp_send(skb_in, type, code, info, &opts); -+} -+#endif -+ - int icmp_rcv(struct sk_buff *skb); - int icmp_err(struct sk_buff *skb, u32 info); - int icmp_init(void); -diff --git a/include/net/tcp.h b/include/net/tcp.h -index 37b51456784f8..b914959cd2c67 100644 ---- a/include/net/tcp.h -+++ b/include/net/tcp.h -@@ -1409,8 +1409,13 @@ static inline int tcp_full_space(const struct sock *sk) - */ - static inline bool tcp_rmem_pressure(const struct sock *sk) - { -- int rcvbuf = READ_ONCE(sk->sk_rcvbuf); -- int threshold = rcvbuf - (rcvbuf >> 3); -+ int rcvbuf, threshold; -+ -+ if (tcp_under_memory_pressure(sk)) -+ return true; -+ -+ rcvbuf = READ_ONCE(sk->sk_rcvbuf); -+ threshold = rcvbuf - (rcvbuf >> 3); - - return atomic_read(&sk->sk_rmem_alloc) > threshold; - } -diff --git a/kernel/bpf/bpf_lru_list.c b/kernel/bpf/bpf_lru_list.c -index 1b6b9349cb857..d99e89f113c43 100644 ---- a/kernel/bpf/bpf_lru_list.c -+++ b/kernel/bpf/bpf_lru_list.c -@@ -502,13 +502,14 @@ struct bpf_lru_node *bpf_lru_pop_free(struct bpf_lru *lru, u32 hash) - static void bpf_common_lru_push_free(struct bpf_lru *lru, - struct bpf_lru_node *node) - { -+ u8 node_type = READ_ONCE(node->type); - unsigned long flags; - -- if (WARN_ON_ONCE(node->type == BPF_LRU_LIST_T_FREE) || -- WARN_ON_ONCE(node->type == BPF_LRU_LOCAL_LIST_T_FREE)) -+ if (WARN_ON_ONCE(node_type == BPF_LRU_LIST_T_FREE) || -+ WARN_ON_ONCE(node_type == BPF_LRU_LOCAL_LIST_T_FREE)) - return; - -- if (node->type == BPF_LRU_LOCAL_LIST_T_PENDING) { -+ if (node_type == BPF_LRU_LOCAL_LIST_T_PENDING) { - struct bpf_lru_locallist *loc_l; - - loc_l = per_cpu_ptr(lru->common_lru.local_list, node->cpu); -diff --git a/kernel/debug/kdb/kdb_private.h b/kernel/debug/kdb/kdb_private.h -index 2118d8258b7c9..ad53b19734e9b 100644 ---- a/kernel/debug/kdb/kdb_private.h -+++ b/kernel/debug/kdb/kdb_private.h -@@ -233,7 +233,7 @@ extern struct task_struct *kdb_curr_task(int); - #define kdb_do_each_thread(g, p) do_each_thread(g, p) - #define kdb_while_each_thread(g, p) while_each_thread(g, p) - --#define GFP_KDB (in_interrupt() ? GFP_ATOMIC : GFP_KERNEL) -+#define GFP_KDB (in_dbg_master() ? GFP_ATOMIC : GFP_KERNEL) - - extern void *debug_kmalloc(size_t size, gfp_t flags); - extern void debug_kfree(void *); -diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c -index 79f252af7dee3..4e74db89bd23f 100644 ---- a/kernel/kexec_file.c -+++ b/kernel/kexec_file.c -@@ -165,6 +165,11 @@ void kimage_file_post_load_cleanup(struct kimage *image) - vfree(pi->sechdrs); - pi->sechdrs = NULL; - -+#ifdef CONFIG_IMA_KEXEC -+ vfree(image->ima_buffer); -+ image->ima_buffer = NULL; -+#endif /* CONFIG_IMA_KEXEC */ -+ - /* See if architecture has anything to cleanup post load */ - arch_kimage_file_post_load_cleanup(image); - -diff --git a/kernel/module.c b/kernel/module.c -index 9e9af40698ffe..ab1f97cfe18dc 100644 ---- a/kernel/module.c -+++ b/kernel/module.c -@@ -2310,6 +2310,21 @@ static int verify_exported_symbols(struct module *mod) - return 0; - } - -+static bool ignore_undef_symbol(Elf_Half emachine, const char *name) -+{ -+ /* -+ * On x86, PIC code and Clang non-PIC code may have call foo@PLT. GNU as -+ * before 2.37 produces an unreferenced _GLOBAL_OFFSET_TABLE_ on x86-64. -+ * i386 has a similar problem but may not deserve a fix. -+ * -+ * If we ever have to ignore many symbols, consider refactoring the code to -+ * only warn if referenced by a relocation. -+ */ -+ if (emachine == EM_386 || emachine == EM_X86_64) -+ return !strcmp(name, "_GLOBAL_OFFSET_TABLE_"); -+ return false; -+} -+ - /* Change all symbols so that st_value encodes the pointer directly. */ - static int simplify_symbols(struct module *mod, const struct load_info *info) - { -@@ -2355,8 +2370,10 @@ static int simplify_symbols(struct module *mod, const struct load_info *info) - break; - } - -- /* Ok if weak. */ -- if (!ksym && ELF_ST_BIND(sym[i].st_info) == STB_WEAK) -+ /* Ok if weak or ignored. */ -+ if (!ksym && -+ (ELF_ST_BIND(sym[i].st_info) == STB_WEAK || -+ ignore_undef_symbol(info->hdr->e_machine, name))) - break; - - ret = PTR_ERR(ksym) ?: -ENOENT; -diff --git a/kernel/printk/printk_safe.c b/kernel/printk/printk_safe.c -index d9a659a686f31..6cfc5a00c67d6 100644 ---- a/kernel/printk/printk_safe.c -+++ b/kernel/printk/printk_safe.c -@@ -43,6 +43,8 @@ struct printk_safe_seq_buf { - static DEFINE_PER_CPU(struct printk_safe_seq_buf, safe_print_seq); - static DEFINE_PER_CPU(int, printk_context); - -+static DEFINE_RAW_SPINLOCK(safe_read_lock); -+ - #ifdef CONFIG_PRINTK_NMI - static DEFINE_PER_CPU(struct printk_safe_seq_buf, nmi_print_seq); - #endif -@@ -178,8 +180,6 @@ static void report_message_lost(struct printk_safe_seq_buf *s) - */ - static void __printk_safe_flush(struct irq_work *work) - { -- static raw_spinlock_t read_lock = -- __RAW_SPIN_LOCK_INITIALIZER(read_lock); - struct printk_safe_seq_buf *s = - container_of(work, struct printk_safe_seq_buf, work); - unsigned long flags; -@@ -193,7 +193,7 @@ static void __printk_safe_flush(struct irq_work *work) - * different CPUs. This is especially important when printing - * a backtrace. - */ -- raw_spin_lock_irqsave(&read_lock, flags); -+ raw_spin_lock_irqsave(&safe_read_lock, flags); - - i = 0; - more: -@@ -230,7 +230,7 @@ more: - - out: - report_message_lost(s); -- raw_spin_unlock_irqrestore(&read_lock, flags); -+ raw_spin_unlock_irqrestore(&safe_read_lock, flags); - } - - /** -@@ -276,6 +276,14 @@ void printk_safe_flush_on_panic(void) - raw_spin_lock_init(&logbuf_lock); - } - -+ if (raw_spin_is_locked(&safe_read_lock)) { -+ if (num_online_cpus() > 1) -+ return; -+ -+ debug_locks_off(); -+ raw_spin_lock_init(&safe_read_lock); -+ } -+ - printk_safe_flush(); - } - -diff --git a/kernel/rcu/tree.c b/kernel/rcu/tree.c -index 1b1d2b09efa9b..4dfa9dd47223a 100644 ---- a/kernel/rcu/tree.c -+++ b/kernel/rcu/tree.c -@@ -579,7 +579,6 @@ static void rcu_eqs_enter(bool user) - trace_rcu_dyntick(TPS("Start"), rdp->dynticks_nesting, 0, atomic_read(&rdp->dynticks)); - WARN_ON_ONCE(IS_ENABLED(CONFIG_RCU_EQS_DEBUG) && !user && !is_idle_task(current)); - rdp = this_cpu_ptr(&rcu_data); -- do_nocb_deferred_wakeup(rdp); - rcu_prepare_for_idle(); - rcu_preempt_deferred_qs(current); - WRITE_ONCE(rdp->dynticks_nesting, 0); /* Avoid irq-access tearing. */ -@@ -618,7 +617,14 @@ void rcu_idle_enter(void) - */ - void rcu_user_enter(void) - { -+ struct rcu_data *rdp = this_cpu_ptr(&rcu_data); -+ - lockdep_assert_irqs_disabled(); -+ -+ instrumentation_begin(); -+ do_nocb_deferred_wakeup(rdp); -+ instrumentation_end(); -+ - rcu_eqs_enter(true); - } - #endif /* CONFIG_NO_HZ_FULL */ -diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h -index f7118842a2b88..a71a4a272515d 100644 ---- a/kernel/rcu/tree_plugin.h -+++ b/kernel/rcu/tree_plugin.h -@@ -2190,6 +2190,11 @@ static void do_nocb_deferred_wakeup(struct rcu_data *rdp) - do_nocb_deferred_wakeup_common(rdp); - } - -+void rcu_nocb_flush_deferred_wakeup(void) -+{ -+ do_nocb_deferred_wakeup(this_cpu_ptr(&rcu_data)); -+} -+ - void __init rcu_init_nohz(void) - { - int cpu; -diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c -index 3dd7c10d6a582..611adca1e6d0c 100644 ---- a/kernel/sched/fair.c -+++ b/kernel/sched/fair.c -@@ -3814,7 +3814,7 @@ static inline void update_misfit_status(struct task_struct *p, struct rq *rq) - if (!static_branch_unlikely(&sched_asym_cpucapacity)) - return; - -- if (!p) { -+ if (!p || p->nr_cpus_allowed == 1) { - rq->misfit_task_load = 0; - return; - } -diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c -index 131e7c86cf06e..3f8c7867c14c1 100644 ---- a/kernel/sched/idle.c -+++ b/kernel/sched/idle.c -@@ -249,6 +249,7 @@ static void do_idle(void) - } - - arch_cpu_idle_enter(); -+ rcu_nocb_flush_deferred_wakeup(); - - /* - * In poll mode we reenable interrupts and spin. Also if we -diff --git a/kernel/seccomp.c b/kernel/seccomp.c -index 4221a4383cfc5..1d62fa2b6b918 100644 ---- a/kernel/seccomp.c -+++ b/kernel/seccomp.c -@@ -921,6 +921,8 @@ static int __seccomp_filter(int this_syscall, const struct seccomp_data *sd, - const bool recheck_after_trace) - { - BUG(); -+ -+ return -1; - } - #endif - -diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c -index 73956eaff8a9c..be51df4508cbe 100644 ---- a/kernel/tracepoint.c -+++ b/kernel/tracepoint.c -@@ -53,6 +53,12 @@ struct tp_probes { - struct tracepoint_func probes[0]; - }; - -+/* Called in removal of a func but failed to allocate a new tp_funcs */ -+static void tp_stub_func(void) -+{ -+ return; -+} -+ - static inline void *allocate_probes(int count) - { - struct tp_probes *p = kmalloc(struct_size(p, probes, count), -@@ -131,6 +137,7 @@ func_add(struct tracepoint_func **funcs, struct tracepoint_func *tp_func, - { - struct tracepoint_func *old, *new; - int nr_probes = 0; -+ int stub_funcs = 0; - int pos = -1; - - if (WARN_ON(!tp_func->func)) -@@ -147,14 +154,34 @@ func_add(struct tracepoint_func **funcs, struct tracepoint_func *tp_func, - if (old[nr_probes].func == tp_func->func && - old[nr_probes].data == tp_func->data) - return ERR_PTR(-EEXIST); -+ if (old[nr_probes].func == tp_stub_func) -+ stub_funcs++; - } - } -- /* + 2 : one for new probe, one for NULL func */ -- new = allocate_probes(nr_probes + 2); -+ /* + 2 : one for new probe, one for NULL func - stub functions */ -+ new = allocate_probes(nr_probes + 2 - stub_funcs); - if (new == NULL) - return ERR_PTR(-ENOMEM); - if (old) { -- if (pos < 0) { -+ if (stub_funcs) { -+ /* Need to copy one at a time to remove stubs */ -+ int probes = 0; -+ -+ pos = -1; -+ for (nr_probes = 0; old[nr_probes].func; nr_probes++) { -+ if (old[nr_probes].func == tp_stub_func) -+ continue; -+ if (pos < 0 && old[nr_probes].prio < prio) -+ pos = probes++; -+ new[probes++] = old[nr_probes]; -+ } -+ nr_probes = probes; -+ if (pos < 0) -+ pos = probes; -+ else -+ nr_probes--; /* Account for insertion */ -+ -+ } else if (pos < 0) { - pos = nr_probes; - memcpy(new, old, nr_probes * sizeof(struct tracepoint_func)); - } else { -@@ -188,8 +215,9 @@ static void *func_remove(struct tracepoint_func **funcs, - /* (N -> M), (N > 1, M >= 0) probes */ - if (tp_func->func) { - for (nr_probes = 0; old[nr_probes].func; nr_probes++) { -- if (old[nr_probes].func == tp_func->func && -- old[nr_probes].data == tp_func->data) -+ if ((old[nr_probes].func == tp_func->func && -+ old[nr_probes].data == tp_func->data) || -+ old[nr_probes].func == tp_stub_func) - nr_del++; - } - } -@@ -208,14 +236,32 @@ static void *func_remove(struct tracepoint_func **funcs, - /* N -> M, (N > 1, M > 0) */ - /* + 1 for NULL */ - new = allocate_probes(nr_probes - nr_del + 1); -- if (new == NULL) -- return ERR_PTR(-ENOMEM); -- for (i = 0; old[i].func; i++) -- if (old[i].func != tp_func->func -- || old[i].data != tp_func->data) -- new[j++] = old[i]; -- new[nr_probes - nr_del].func = NULL; -- *funcs = new; -+ if (new) { -+ for (i = 0; old[i].func; i++) -+ if ((old[i].func != tp_func->func -+ || old[i].data != tp_func->data) -+ && old[i].func != tp_stub_func) -+ new[j++] = old[i]; -+ new[nr_probes - nr_del].func = NULL; -+ *funcs = new; -+ } else { -+ /* -+ * Failed to allocate, replace the old function -+ * with calls to tp_stub_func. -+ */ -+ for (i = 0; old[i].func; i++) -+ if (old[i].func == tp_func->func && -+ old[i].data == tp_func->data) { -+ old[i].func = tp_stub_func; -+ /* Set the prio to the next event. */ -+ if (old[i + 1].func) -+ old[i].prio = -+ old[i + 1].prio; -+ else -+ old[i].prio = -1; -+ } -+ *funcs = old; -+ } - } - debug_print_probes(*funcs); - return old; -@@ -271,10 +317,12 @@ static int tracepoint_remove_func(struct tracepoint *tp, - tp_funcs = rcu_dereference_protected(tp->funcs, - lockdep_is_held(&tracepoints_mutex)); - old = func_remove(&tp_funcs, func); -- if (IS_ERR(old)) { -- WARN_ON_ONCE(PTR_ERR(old) != -ENOMEM); -+ if (WARN_ON_ONCE(IS_ERR(old))) - return PTR_ERR(old); -- } -+ -+ if (tp_funcs == old) -+ /* Failed allocating new tp_funcs, replaced func with stub */ -+ return 0; - - if (!tp_funcs) { - /* Removed last function */ -diff --git a/mm/compaction.c b/mm/compaction.c -index 88c3f6bad1aba..d686887856fee 100644 ---- a/mm/compaction.c -+++ b/mm/compaction.c -@@ -1630,6 +1630,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - unsigned long pfn = cc->migrate_pfn; - unsigned long high_pfn; - int order; -+ bool found_block = false; - - /* Skip hints are relied on to avoid repeats on the fast search */ - if (cc->ignore_skip_hint) -@@ -1672,7 +1673,7 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - high_pfn = pageblock_start_pfn(cc->migrate_pfn + distance); - - for (order = cc->order - 1; -- order >= PAGE_ALLOC_COSTLY_ORDER && pfn == cc->migrate_pfn && nr_scanned < limit; -+ order >= PAGE_ALLOC_COSTLY_ORDER && !found_block && nr_scanned < limit; - order--) { - struct free_area *area = &cc->zone->free_area[order]; - struct list_head *freelist; -@@ -1687,7 +1688,11 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - list_for_each_entry(freepage, freelist, lru) { - unsigned long free_pfn; - -- nr_scanned++; -+ if (nr_scanned++ >= limit) { -+ move_freelist_tail(freelist, freepage); -+ break; -+ } -+ - free_pfn = page_to_pfn(freepage); - if (free_pfn < high_pfn) { - /* -@@ -1696,12 +1701,8 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - * the list assumes an entry is deleted, not - * reordered. - */ -- if (get_pageblock_skip(freepage)) { -- if (list_is_last(freelist, &freepage->lru)) -- break; -- -+ if (get_pageblock_skip(freepage)) - continue; -- } - - /* Reorder to so a future search skips recent pages */ - move_freelist_tail(freelist, freepage); -@@ -1709,15 +1710,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - update_fast_start_pfn(cc, free_pfn); - pfn = pageblock_start_pfn(free_pfn); - cc->fast_search_fail = 0; -+ found_block = true; - set_pageblock_skip(freepage); - break; - } -- -- if (nr_scanned >= limit) { -- cc->fast_search_fail++; -- move_freelist_tail(freelist, freepage); -- break; -- } - } - spin_unlock_irqrestore(&cc->zone->lock, flags); - } -@@ -1728,9 +1724,10 @@ static unsigned long fast_find_migrateblock(struct compact_control *cc) - * If fast scanning failed then use a cached entry for a page block - * that had free pages as the basis for starting a linear scan. - */ -- if (pfn == cc->migrate_pfn) -+ if (!found_block) { -+ cc->fast_search_fail++; - pfn = reinit_migrate_pfn(cc); -- -+ } - return pfn; - } - -diff --git a/mm/hugetlb.c b/mm/hugetlb.c -index d5b03b9262d4f..2cd4c7f43dcd9 100644 ---- a/mm/hugetlb.c -+++ b/mm/hugetlb.c -@@ -1192,14 +1192,16 @@ static inline void destroy_compound_gigantic_page(struct page *page, - static void update_and_free_page(struct hstate *h, struct page *page) - { - int i; -+ struct page *subpage = page; - - if (hstate_is_gigantic(h) && !gigantic_page_runtime_supported()) - return; - - h->nr_huge_pages--; - h->nr_huge_pages_node[page_to_nid(page)]--; -- for (i = 0; i < pages_per_huge_page(h); i++) { -- page[i].flags &= ~(1 << PG_locked | 1 << PG_error | -+ for (i = 0; i < pages_per_huge_page(h); -+ i++, subpage = mem_map_next(subpage, page, i)) { -+ subpage->flags &= ~(1 << PG_locked | 1 << PG_error | - 1 << PG_referenced | 1 << PG_dirty | - 1 << PG_active | 1 << PG_private | - 1 << PG_writeback); -@@ -2812,8 +2814,10 @@ static int hugetlb_sysfs_add_hstate(struct hstate *h, struct kobject *parent, - return -ENOMEM; - - retval = sysfs_create_group(hstate_kobjs[hi], hstate_attr_group); -- if (retval) -+ if (retval) { - kobject_put(hstate_kobjs[hi]); -+ hstate_kobjs[hi] = NULL; -+ } - - return retval; - } -diff --git a/mm/memory.c b/mm/memory.c -index b23831132933a..c432e7c764451 100644 ---- a/mm/memory.c -+++ b/mm/memory.c -@@ -1804,11 +1804,11 @@ static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd, - unsigned long addr, unsigned long end, - unsigned long pfn, pgprot_t prot) - { -- pte_t *pte; -+ pte_t *pte, *mapped_pte; - spinlock_t *ptl; - int err = 0; - -- pte = pte_alloc_map_lock(mm, pmd, addr, &ptl); -+ mapped_pte = pte = pte_alloc_map_lock(mm, pmd, addr, &ptl); - if (!pte) - return -ENOMEM; - arch_enter_lazy_mmu_mode(); -@@ -1822,7 +1822,7 @@ static int remap_pte_range(struct mm_struct *mm, pmd_t *pmd, - pfn++; - } while (pte++, addr += PAGE_SIZE, addr != end); - arch_leave_lazy_mmu_mode(); -- pte_unmap_unlock(pte - 1, ptl); -+ pte_unmap_unlock(mapped_pte, ptl); - return err; - } - -@@ -4718,17 +4718,19 @@ long copy_huge_page_from_user(struct page *dst_page, - void *page_kaddr; - unsigned long i, rc = 0; - unsigned long ret_val = pages_per_huge_page * PAGE_SIZE; -+ struct page *subpage = dst_page; - -- for (i = 0; i < pages_per_huge_page; i++) { -+ for (i = 0; i < pages_per_huge_page; -+ i++, subpage = mem_map_next(subpage, dst_page, i)) { - if (allow_pagefault) -- page_kaddr = kmap(dst_page + i); -+ page_kaddr = kmap(subpage); - else -- page_kaddr = kmap_atomic(dst_page + i); -+ page_kaddr = kmap_atomic(subpage); - rc = copy_from_user(page_kaddr, - (const void __user *)(src + i * PAGE_SIZE), - PAGE_SIZE); - if (allow_pagefault) -- kunmap(dst_page + i); -+ kunmap(subpage); - else - kunmap_atomic(page_kaddr); - -diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c -index da7fd7c8c2dc0..463bad58478b2 100644 ---- a/net/bluetooth/a2mp.c -+++ b/net/bluetooth/a2mp.c -@@ -381,9 +381,9 @@ static int a2mp_getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb, - hdev = hci_dev_get(req->id); - if (!hdev || hdev->amp_type == AMP_TYPE_BREDR || tmp) { - struct a2mp_amp_assoc_rsp rsp; -- rsp.id = req->id; - - memset(&rsp, 0, sizeof(rsp)); -+ rsp.id = req->id; - - if (tmp) { - rsp.status = A2MP_STATUS_COLLISION_OCCURED; -@@ -512,6 +512,7 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb, - assoc = kmemdup(req->amp_assoc, assoc_len, GFP_KERNEL); - if (!assoc) { - amp_ctrl_put(ctrl); -+ hci_dev_put(hdev); - return -ENOMEM; - } - -diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c -index 9e19d5a3aac87..83b324419ad3d 100644 ---- a/net/bluetooth/hci_core.c -+++ b/net/bluetooth/hci_core.c -@@ -1317,8 +1317,10 @@ int hci_inquiry(void __user *arg) - * cleared). If it is interrupted by a signal, return -EINTR. - */ - if (wait_on_bit(&hdev->flags, HCI_INQUIRY, -- TASK_INTERRUPTIBLE)) -- return -EINTR; -+ TASK_INTERRUPTIBLE)) { -+ err = -EINTR; -+ goto done; -+ } - } - - /* for unlimited number of responses we will use buffer with -diff --git a/net/core/filter.c b/net/core/filter.c -index 2fa10fdcf6b1d..524f3364f8a05 100644 ---- a/net/core/filter.c -+++ b/net/core/filter.c -@@ -4880,6 +4880,7 @@ BPF_CALL_4(bpf_skb_fib_lookup, struct sk_buff *, skb, - { - struct net *net = dev_net(skb->dev); - int rc = -EAFNOSUPPORT; -+ bool check_mtu = false; - - if (plen < sizeof(*params)) - return -EINVAL; -@@ -4887,22 +4888,28 @@ BPF_CALL_4(bpf_skb_fib_lookup, struct sk_buff *, skb, - if (flags & ~(BPF_FIB_LOOKUP_DIRECT | BPF_FIB_LOOKUP_OUTPUT)) - return -EINVAL; - -+ if (params->tot_len) -+ check_mtu = true; -+ - switch (params->family) { - #if IS_ENABLED(CONFIG_INET) - case AF_INET: -- rc = bpf_ipv4_fib_lookup(net, params, flags, false); -+ rc = bpf_ipv4_fib_lookup(net, params, flags, check_mtu); - break; - #endif - #if IS_ENABLED(CONFIG_IPV6) - case AF_INET6: -- rc = bpf_ipv6_fib_lookup(net, params, flags, false); -+ rc = bpf_ipv6_fib_lookup(net, params, flags, check_mtu); - break; - #endif - } - -- if (!rc) { -+ if (rc == BPF_FIB_LKUP_RET_SUCCESS && !check_mtu) { - struct net_device *dev; - -+ /* When tot_len isn't provided by user, check skb -+ * against MTU of FIB lookup resulting net_device -+ */ - dev = dev_get_by_index_rcu(net, params->ifindex); - if (!is_skb_forwardable(dev, skb)) - rc = BPF_FIB_LKUP_RET_FRAG_NEEDED; -diff --git a/net/ipv4/icmp.c b/net/ipv4/icmp.c -index d00533aea1f05..dd8fae89be723 100644 ---- a/net/ipv4/icmp.c -+++ b/net/ipv4/icmp.c -@@ -750,6 +750,40 @@ out:; - } - EXPORT_SYMBOL(__icmp_send); - -+#if IS_ENABLED(CONFIG_NF_NAT) -+#include -+void icmp_ndo_send(struct sk_buff *skb_in, int type, int code, __be32 info) -+{ -+ struct sk_buff *cloned_skb = NULL; -+ struct ip_options opts = { 0 }; -+ enum ip_conntrack_info ctinfo; -+ struct nf_conn *ct; -+ __be32 orig_ip; -+ -+ ct = nf_ct_get(skb_in, &ctinfo); -+ if (!ct || !(ct->status & IPS_SRC_NAT)) { -+ __icmp_send(skb_in, type, code, info, &opts); -+ return; -+ } -+ -+ if (skb_shared(skb_in)) -+ skb_in = cloned_skb = skb_clone(skb_in, GFP_ATOMIC); -+ -+ if (unlikely(!skb_in || skb_network_header(skb_in) < skb_in->head || -+ (skb_network_header(skb_in) + sizeof(struct iphdr)) > -+ skb_tail_pointer(skb_in) || skb_ensure_writable(skb_in, -+ skb_network_offset(skb_in) + sizeof(struct iphdr)))) -+ goto out; -+ -+ orig_ip = ip_hdr(skb_in)->saddr; -+ ip_hdr(skb_in)->saddr = ct->tuplehash[0].tuple.src.u3.ip; -+ __icmp_send(skb_in, type, code, info, &opts); -+ ip_hdr(skb_in)->saddr = orig_ip; -+out: -+ consume_skb(cloned_skb); -+} -+EXPORT_SYMBOL(icmp_ndo_send); -+#endif - - static void icmp_socket_deliver(struct sk_buff *skb, u32 info) - { -diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c -index e9bb89131e02a..3db10cae7b178 100644 ---- a/net/ipv6/icmp.c -+++ b/net/ipv6/icmp.c -@@ -312,10 +312,9 @@ static int icmpv6_getfrag(void *from, char *to, int offset, int len, int odd, st - } - - #if IS_ENABLED(CONFIG_IPV6_MIP6) --static void mip6_addr_swap(struct sk_buff *skb) -+static void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt) - { - struct ipv6hdr *iph = ipv6_hdr(skb); -- struct inet6_skb_parm *opt = IP6CB(skb); - struct ipv6_destopt_hao *hao; - struct in6_addr tmp; - int off; -@@ -332,7 +331,7 @@ static void mip6_addr_swap(struct sk_buff *skb) - } - } - #else --static inline void mip6_addr_swap(struct sk_buff *skb) {} -+static inline void mip6_addr_swap(struct sk_buff *skb, const struct inet6_skb_parm *opt) {} - #endif - - static struct dst_entry *icmpv6_route_lookup(struct net *net, -@@ -426,8 +425,9 @@ static int icmp6_iif(const struct sk_buff *skb) - /* - * Send an ICMP message in response to a packet in error - */ --static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -- const struct in6_addr *force_saddr) -+void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -+ const struct in6_addr *force_saddr, -+ const struct inet6_skb_parm *parm) - { - struct inet6_dev *idev = NULL; - struct ipv6hdr *hdr = ipv6_hdr(skb); -@@ -520,7 +520,7 @@ static void icmp6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, - if (!(skb->dev->flags & IFF_LOOPBACK) && !icmpv6_global_allow(net, type)) - goto out_bh_enable; - -- mip6_addr_swap(skb); -+ mip6_addr_swap(skb, parm); - - memset(&fl6, 0, sizeof(fl6)); - fl6.flowi6_proto = IPPROTO_ICMPV6; -@@ -600,12 +600,13 @@ out: - out_bh_enable: - local_bh_enable(); - } -+EXPORT_SYMBOL(icmp6_send); - - /* Slightly more convenient version of icmp6_send. - */ - void icmpv6_param_prob(struct sk_buff *skb, u8 code, int pos) - { -- icmp6_send(skb, ICMPV6_PARAMPROB, code, pos, NULL); -+ icmp6_send(skb, ICMPV6_PARAMPROB, code, pos, NULL, IP6CB(skb)); - kfree_skb(skb); - } - -@@ -662,10 +663,10 @@ int ip6_err_gen_icmpv6_unreach(struct sk_buff *skb, int nhs, int type, - } - if (type == ICMP_TIME_EXCEEDED) - icmp6_send(skb2, ICMPV6_TIME_EXCEED, ICMPV6_EXC_HOPLIMIT, -- info, &temp_saddr); -+ info, &temp_saddr, IP6CB(skb2)); - else - icmp6_send(skb2, ICMPV6_DEST_UNREACH, ICMPV6_ADDR_UNREACH, -- info, &temp_saddr); -+ info, &temp_saddr, IP6CB(skb2)); - if (rt) - ip6_rt_put(rt); - -diff --git a/net/ipv6/ip6_icmp.c b/net/ipv6/ip6_icmp.c -index 02045494c24cc..9e3574880cb03 100644 ---- a/net/ipv6/ip6_icmp.c -+++ b/net/ipv6/ip6_icmp.c -@@ -9,6 +9,8 @@ - - #if IS_ENABLED(CONFIG_IPV6) - -+#if !IS_BUILTIN(CONFIG_IPV6) -+ - static ip6_icmp_send_t __rcu *ip6_icmp_send; - - int inet6_register_icmp_sender(ip6_icmp_send_t *fn) -@@ -31,18 +33,52 @@ int inet6_unregister_icmp_sender(ip6_icmp_send_t *fn) - } - EXPORT_SYMBOL(inet6_unregister_icmp_sender); - --void icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info) -+void __icmpv6_send(struct sk_buff *skb, u8 type, u8 code, __u32 info, -+ const struct inet6_skb_parm *parm) - { - ip6_icmp_send_t *send; - - rcu_read_lock(); - send = rcu_dereference(ip6_icmp_send); -+ if (send) -+ send(skb, type, code, info, NULL, parm); -+ rcu_read_unlock(); -+} -+EXPORT_SYMBOL(__icmpv6_send); -+#endif -+ -+#if IS_ENABLED(CONFIG_NF_NAT) -+#include -+void icmpv6_ndo_send(struct sk_buff *skb_in, u8 type, u8 code, __u32 info) -+{ -+ struct inet6_skb_parm parm = { 0 }; -+ struct sk_buff *cloned_skb = NULL; -+ enum ip_conntrack_info ctinfo; -+ struct in6_addr orig_ip; -+ struct nf_conn *ct; - -- if (!send) -+ ct = nf_ct_get(skb_in, &ctinfo); -+ if (!ct || !(ct->status & IPS_SRC_NAT)) { -+ __icmpv6_send(skb_in, type, code, info, &parm); -+ return; -+ } -+ -+ if (skb_shared(skb_in)) -+ skb_in = cloned_skb = skb_clone(skb_in, GFP_ATOMIC); -+ -+ if (unlikely(!skb_in || skb_network_header(skb_in) < skb_in->head || -+ (skb_network_header(skb_in) + sizeof(struct ipv6hdr)) > -+ skb_tail_pointer(skb_in) || skb_ensure_writable(skb_in, -+ skb_network_offset(skb_in) + sizeof(struct ipv6hdr)))) - goto out; -- send(skb, type, code, info, NULL); -+ -+ orig_ip = ipv6_hdr(skb_in)->saddr; -+ ipv6_hdr(skb_in)->saddr = ct->tuplehash[0].tuple.src.u3.in6; -+ __icmpv6_send(skb_in, type, code, info, &parm); -+ ipv6_hdr(skb_in)->saddr = orig_ip; - out: -- rcu_read_unlock(); -+ consume_skb(cloned_skb); - } --EXPORT_SYMBOL(icmpv6_send); -+EXPORT_SYMBOL(icmpv6_ndo_send); -+#endif - #endif -diff --git a/net/mac80211/mesh_hwmp.c b/net/mac80211/mesh_hwmp.c -index aa5150929996d..b5b728a71ab53 100644 ---- a/net/mac80211/mesh_hwmp.c -+++ b/net/mac80211/mesh_hwmp.c -@@ -356,7 +356,7 @@ u32 airtime_link_metric_get(struct ieee80211_local *local, - */ - tx_time = (device_constant + 10 * test_frame_len / rate); - estimated_retx = ((1 << (2 * ARITH_SHIFT)) / (s_unit - err)); -- result = (tx_time * estimated_retx) >> (2 * ARITH_SHIFT); -+ result = ((u64)tx_time * estimated_retx) >> (2 * ARITH_SHIFT); - return (u32)result; - } - -diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c -index 997af345ce374..cb425e216d461 100644 ---- a/net/qrtr/tun.c -+++ b/net/qrtr/tun.c -@@ -31,6 +31,7 @@ static int qrtr_tun_send(struct qrtr_endpoint *ep, struct sk_buff *skb) - static int qrtr_tun_open(struct inode *inode, struct file *filp) - { - struct qrtr_tun *tun; -+ int ret; - - tun = kzalloc(sizeof(*tun), GFP_KERNEL); - if (!tun) -@@ -43,7 +44,16 @@ static int qrtr_tun_open(struct inode *inode, struct file *filp) - - filp->private_data = tun; - -- return qrtr_endpoint_register(&tun->ep, QRTR_EP_NID_AUTO); -+ ret = qrtr_endpoint_register(&tun->ep, QRTR_EP_NID_AUTO); -+ if (ret) -+ goto out; -+ -+ return 0; -+ -+out: -+ filp->private_data = NULL; -+ kfree(tun); -+ return ret; - } - - static ssize_t qrtr_tun_read_iter(struct kiocb *iocb, struct iov_iter *to) -diff --git a/net/sched/act_api.c b/net/sched/act_api.c -index 1dc642b11443c..43c10a85e8813 100644 ---- a/net/sched/act_api.c -+++ b/net/sched/act_api.c -@@ -823,7 +823,7 @@ static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = { - [TCA_ACT_OPTIONS] = { .type = NLA_NESTED }, - }; - --static void tcf_idr_insert_many(struct tc_action *actions[]) -+void tcf_idr_insert_many(struct tc_action *actions[]) - { - int i; - -diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c -index d7604417367d3..83e5a8aa2fb11 100644 ---- a/net/sched/cls_api.c -+++ b/net/sched/cls_api.c -@@ -3026,6 +3026,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, - act->type = exts->type = TCA_OLD_COMPAT; - exts->actions[0] = act; - exts->nr_actions = 1; -+ tcf_idr_insert_many(exts->actions); - } else if (exts->action && tb[exts->action]) { - int err; - -diff --git a/net/xfrm/xfrm_interface.c b/net/xfrm/xfrm_interface.c -index 00af31d3e7744..01c65f96d2832 100644 ---- a/net/xfrm/xfrm_interface.c -+++ b/net/xfrm/xfrm_interface.c -@@ -300,10 +300,10 @@ xfrmi_xmit2(struct sk_buff *skb, struct net_device *dev, struct flowi *fl) - if (mtu < IPV6_MIN_MTU) - mtu = IPV6_MIN_MTU; - -- icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); -+ icmpv6_ndo_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); - } else { -- icmp_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, -- htonl(mtu)); -+ icmp_ndo_send(skb, ICMP_DEST_UNREACH, ICMP_FRAG_NEEDED, -+ htonl(mtu)); - } - - dst_release(dst); -diff --git a/security/commoncap.c b/security/commoncap.c -index 28a6939bcc4e5..ed89a6dd4f83d 100644 ---- a/security/commoncap.c -+++ b/security/commoncap.c -@@ -500,7 +500,8 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size) - __u32 magic, nsmagic; - struct inode *inode = d_backing_inode(dentry); - struct user_namespace *task_ns = current_user_ns(), -- *fs_ns = inode->i_sb->s_user_ns; -+ *fs_ns = inode->i_sb->s_user_ns, -+ *ancestor; - kuid_t rootid; - size_t newsize; - -@@ -523,6 +524,15 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size) - if (nsrootid == -1) - return -EINVAL; - -+ /* -+ * Do not allow allow adding a v3 filesystem capability xattr -+ * if the rootid field is ambiguous. -+ */ -+ for (ancestor = task_ns->parent; ancestor; ancestor = ancestor->parent) { -+ if (from_kuid(ancestor, rootid) == 0) -+ return -EINVAL; -+ } -+ - newsize = sizeof(struct vfs_ns_cap_data); - nscap = kmalloc(newsize, GFP_ATOMIC); - if (!nscap) -diff --git a/security/integrity/evm/evm_crypto.c b/security/integrity/evm/evm_crypto.c -index ee6bd945f3d6a..25dac691491b1 100644 ---- a/security/integrity/evm/evm_crypto.c -+++ b/security/integrity/evm/evm_crypto.c -@@ -75,7 +75,7 @@ static struct shash_desc *init_desc(char type, uint8_t hash_algo) - { - long rc; - const char *algo; -- struct crypto_shash **tfm, *tmp_tfm; -+ struct crypto_shash **tfm, *tmp_tfm = NULL; - struct shash_desc *desc; - - if (type == EVM_XATTR_HMAC) { -@@ -120,13 +120,16 @@ unlock: - alloc: - desc = kmalloc(sizeof(*desc) + crypto_shash_descsize(*tfm), - GFP_KERNEL); -- if (!desc) -+ if (!desc) { -+ crypto_free_shash(tmp_tfm); - return ERR_PTR(-ENOMEM); -+ } - - desc->tfm = *tfm; - - rc = crypto_shash_init(desc); - if (rc) { -+ crypto_free_shash(tmp_tfm); - kfree(desc); - return ERR_PTR(rc); - } -diff --git a/security/integrity/ima/ima_kexec.c b/security/integrity/ima/ima_kexec.c -index 9e94eca48b898..955e4b4d09e21 100644 ---- a/security/integrity/ima/ima_kexec.c -+++ b/security/integrity/ima/ima_kexec.c -@@ -120,6 +120,7 @@ void ima_add_kexec_buffer(struct kimage *image) - ret = kexec_add_buffer(&kbuf); - if (ret) { - pr_err("Error passing over kexec measurement buffer.\n"); -+ vfree(kexec_buffer); - return; - } - -@@ -129,6 +130,8 @@ void ima_add_kexec_buffer(struct kimage *image) - return; - } - -+ image->ima_buffer = kexec_buffer; -+ - pr_debug("kexec measurement buffer for the loaded kernel at 0x%lx.\n", - kbuf.mem); - } -diff --git a/security/integrity/ima/ima_mok.c b/security/integrity/ima/ima_mok.c -index 36cadadbfba47..1e5c019161738 100644 ---- a/security/integrity/ima/ima_mok.c -+++ b/security/integrity/ima/ima_mok.c -@@ -38,13 +38,12 @@ __init int ima_mok_init(void) - (KEY_POS_ALL & ~KEY_POS_SETATTR) | - KEY_USR_VIEW | KEY_USR_READ | - KEY_USR_WRITE | KEY_USR_SEARCH, -- KEY_ALLOC_NOT_IN_QUOTA, -+ KEY_ALLOC_NOT_IN_QUOTA | -+ KEY_ALLOC_SET_KEEP, - restriction, NULL); - - if (IS_ERR(ima_blacklist_keyring)) - panic("Can't allocate IMA blacklist keyring."); -- -- set_bit(KEY_FLAG_KEEP, &ima_blacklist_keyring->flags); - return 0; - } - device_initcall(ima_mok_init); -diff --git a/security/keys/key.c b/security/keys/key.c -index e9845d0d8d349..623fcb4094dd4 100644 ---- a/security/keys/key.c -+++ b/security/keys/key.c -@@ -302,6 +302,8 @@ struct key *key_alloc(struct key_type *type, const char *desc, - key->flags |= 1 << KEY_FLAG_BUILTIN; - if (flags & KEY_ALLOC_UID_KEYRING) - key->flags |= 1 << KEY_FLAG_UID_KEYRING; -+ if (flags & KEY_ALLOC_SET_KEEP) -+ key->flags |= 1 << KEY_FLAG_KEEP; - - #ifdef KEY_DEBUGGING - key->magic = KEY_DEBUG_MAGIC; -diff --git a/security/keys/trusted.c b/security/keys/trusted.c -index 36afc29aecc3b..92a14ab82f72f 100644 ---- a/security/keys/trusted.c -+++ b/security/keys/trusted.c -@@ -805,7 +805,7 @@ static int getoptions(char *c, struct trusted_key_payload *pay, - case Opt_migratable: - if (*args[0].from == '0') - pay->migratable = 0; -- else -+ else if (*args[0].from != '1') - return -EINVAL; - break; - case Opt_pcrlock: -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index b3667a5efdc1f..7f9f6bbca5489 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -2447,6 +2447,8 @@ static const struct pci_device_id azx_ids[] = { - /* CometLake-H */ - { PCI_DEVICE(0x8086, 0x06C8), - .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, -+ { PCI_DEVICE(0x8086, 0xf1c8), -+ .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, - /* CometLake-S */ - { PCI_DEVICE(0x8086, 0xa3f0), - .driver_data = AZX_DRIVER_SKL | AZX_DCAPS_INTEL_SKYLAKE}, -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index f548bd48bf729..a132fe4537a55 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -1895,6 +1895,7 @@ enum { - ALC889_FIXUP_FRONT_HP_NO_PRESENCE, - ALC889_FIXUP_VAIO_TT, - ALC888_FIXUP_EEE1601, -+ ALC886_FIXUP_EAPD, - ALC882_FIXUP_EAPD, - ALC883_FIXUP_EAPD, - ALC883_FIXUP_ACER_EAPD, -@@ -2228,6 +2229,15 @@ static const struct hda_fixup alc882_fixups[] = { - { } - } - }, -+ [ALC886_FIXUP_EAPD] = { -+ .type = HDA_FIXUP_VERBS, -+ .v.verbs = (const struct hda_verb[]) { -+ /* change to EAPD mode */ -+ { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 }, -+ { 0x20, AC_VERB_SET_PROC_COEF, 0x0068 }, -+ { } -+ } -+ }, - [ALC882_FIXUP_EAPD] = { - .type = HDA_FIXUP_VERBS, - .v.verbs = (const struct hda_verb[]) { -@@ -2500,6 +2510,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { - SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_MBA11_VREF), - - SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD), -+ SND_PCI_QUIRK(0x13fe, 0x1009, "Advantech MIT-W101", ALC886_FIXUP_EAPD), - SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3/Z87X-UD3H", ALC889_FIXUP_FRONT_HP_NO_PRESENCE), - SND_PCI_QUIRK(0x1458, 0xa0b8, "Gigabyte AZ370-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), - SND_PCI_QUIRK(0x1458, 0xa0cd, "Gigabyte X570 Aorus Master", ALC1220_FIXUP_CLEVO_P950), -diff --git a/sound/soc/codecs/cpcap.c b/sound/soc/codecs/cpcap.c -index d7f05b384f1fb..1902689c5ea2c 100644 ---- a/sound/soc/codecs/cpcap.c -+++ b/sound/soc/codecs/cpcap.c -@@ -1263,12 +1263,12 @@ static int cpcap_voice_hw_params(struct snd_pcm_substream *substream, - - if (direction == SNDRV_PCM_STREAM_CAPTURE) { - mask = 0x0000; -- mask |= CPCAP_BIT_MIC1_RX_TIMESLOT0; -- mask |= CPCAP_BIT_MIC1_RX_TIMESLOT1; -- mask |= CPCAP_BIT_MIC1_RX_TIMESLOT2; -- mask |= CPCAP_BIT_MIC2_TIMESLOT0; -- mask |= CPCAP_BIT_MIC2_TIMESLOT1; -- mask |= CPCAP_BIT_MIC2_TIMESLOT2; -+ mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0); -+ mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT1); -+ mask |= BIT(CPCAP_BIT_MIC1_RX_TIMESLOT2); -+ mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT0); -+ mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT1); -+ mask |= BIT(CPCAP_BIT_MIC2_TIMESLOT2); - val = 0x0000; - if (channels >= 2) - val = BIT(CPCAP_BIT_MIC1_RX_TIMESLOT0); -diff --git a/sound/soc/codecs/cs42l56.c b/sound/soc/codecs/cs42l56.c -index ac569ab3d30f4..51d7a87ab4c3b 100644 ---- a/sound/soc/codecs/cs42l56.c -+++ b/sound/soc/codecs/cs42l56.c -@@ -1248,6 +1248,7 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client, - dev_err(&i2c_client->dev, - "CS42L56 Device ID (%X). Expected %X\n", - devid, CS42L56_DEVID); -+ ret = -EINVAL; - goto err_enable; - } - alpha_rev = reg & CS42L56_AREV_MASK; -@@ -1305,7 +1306,7 @@ static int cs42l56_i2c_probe(struct i2c_client *i2c_client, - ret = devm_snd_soc_register_component(&i2c_client->dev, - &soc_component_dev_cs42l56, &cs42l56_dai, 1); - if (ret < 0) -- return ret; -+ goto err_enable; - - return 0; - -diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c -index 9b794775df537..edad6721251f4 100644 ---- a/sound/soc/generic/simple-card-utils.c -+++ b/sound/soc/generic/simple-card-utils.c -@@ -172,16 +172,15 @@ int asoc_simple_parse_clk(struct device *dev, - * or device's module clock. - */ - clk = devm_get_clk_from_child(dev, node, NULL); -- if (!IS_ERR(clk)) { -- simple_dai->sysclk = clk_get_rate(clk); -+ if (IS_ERR(clk)) -+ clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); - -+ if (!IS_ERR(clk)) { - simple_dai->clk = clk; -- } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { -+ simple_dai->sysclk = clk_get_rate(clk); -+ } else if (!of_property_read_u32(node, "system-clock-frequency", -+ &val)) { - simple_dai->sysclk = val; -- } else { -- clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); -- if (!IS_ERR(clk)) -- simple_dai->sysclk = clk_get_rate(clk); - } - - if (of_property_read_bool(node, "system-clock-direction-out")) -diff --git a/sound/soc/sof/debug.c b/sound/soc/sof/debug.c -index 5529e8eeca462..08726034ff090 100644 ---- a/sound/soc/sof/debug.c -+++ b/sound/soc/sof/debug.c -@@ -135,7 +135,7 @@ static ssize_t sof_dfsentry_write(struct file *file, const char __user *buffer, - char *string; - int ret; - -- string = kzalloc(count, GFP_KERNEL); -+ string = kzalloc(count+1, GFP_KERNEL); - if (!string) - return -ENOMEM; - -diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c -index 1a5e555002b2b..75218539fb107 100644 ---- a/sound/usb/pcm.c -+++ b/sound/usb/pcm.c -@@ -1885,7 +1885,7 @@ void snd_usb_preallocate_buffer(struct snd_usb_substream *subs) - { - struct snd_pcm *pcm = subs->stream->pcm; - struct snd_pcm_substream *s = pcm->streams[subs->direction].substream; -- struct device *dev = subs->dev->bus->controller; -+ struct device *dev = subs->dev->bus->sysdev; - - if (!snd_usb_use_vmalloc) - snd_pcm_lib_preallocate_pages(s, SNDRV_DMA_TYPE_DEV_SG, -diff --git a/tools/objtool/check.c b/tools/objtool/check.c -index 1b7e748170e54..06aaf04e629c2 100644 ---- a/tools/objtool/check.c -+++ b/tools/objtool/check.c -@@ -626,8 +626,8 @@ static int add_jump_destinations(struct objtool_file *file) - * case where the parent function's only reference to a - * subfunction is through a jump table. - */ -- if (!strstr(insn->func->name, ".cold.") && -- strstr(insn->jump_dest->func->name, ".cold.")) { -+ if (!strstr(insn->func->name, ".cold") && -+ strstr(insn->jump_dest->func->name, ".cold")) { - insn->func->cfunc = insn->jump_dest->func; - insn->jump_dest->func->pfunc = insn->func; - -@@ -2192,15 +2192,19 @@ static int validate_branch(struct objtool_file *file, struct symbol *func, - break; - - case INSN_STD: -- if (state.df) -+ if (state.df) { - WARN_FUNC("recursive STD", sec, insn->offset); -+ return 1; -+ } - - state.df = true; - break; - - case INSN_CLD: -- if (!state.df && func) -+ if (!state.df && func) { - WARN_FUNC("redundant CLD", sec, insn->offset); -+ return 1; -+ } - - state.df = false; - break; -diff --git a/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json -index df9201434cb6a..b0a10a219b50d 100644 ---- a/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json -+++ b/tools/perf/pmu-events/arch/arm64/ampere/emag/cache.json -@@ -114,7 +114,7 @@ - "PublicDescription": "Level 2 access to instruciton TLB that caused a page table walk. This event counts on any instruciton access which causes L2I_TLB_REFILL to count", - "EventCode": "0x35", - "EventName": "L2I_TLB_ACCESS", -- "BriefDescription": "L2D TLB access" -+ "BriefDescription": "L2I TLB access" - }, - { - "PublicDescription": "Branch target buffer misprediction", -diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c -index 3a02426db9a63..2f76d4a9de860 100644 ---- a/tools/perf/tests/sample-parsing.c -+++ b/tools/perf/tests/sample-parsing.c -@@ -180,7 +180,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format) - .data = {1, 211, 212, 213}, - }; - u64 regs[64]; -- const u64 raw_data[] = {0x123456780a0b0c0dULL, 0x1102030405060708ULL}; -+ const u32 raw_data[] = {0x12345678, 0x0a0b0c0d, 0x11020304, 0x05060708, 0 }; - const u64 data[] = {0x2211443366558877ULL, 0, 0xaabbccddeeff4321ULL}; - struct perf_sample sample = { - .ip = 101, -diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c -index fc1e5a991008d..bfaa9afdb8b4c 100644 ---- a/tools/perf/util/event.c -+++ b/tools/perf/util/event.c -@@ -597,6 +597,8 @@ int machine__resolve(struct machine *machine, struct addr_location *al, - } - - al->sym = map__find_symbol(al->map, al->addr); -+ } else if (symbol_conf.dso_list) { -+ al->filtered |= (1 << HIST_FILTER__DSO); - } - - if (symbol_conf.sym_list && -diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -index 7ffcbd6fcd1ae..7f53b63088b2c 100644 ---- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.c -@@ -1745,6 +1745,9 @@ static int intel_pt_walk_psbend(struct intel_pt_decoder *decoder) - break; - - case INTEL_PT_CYC: -+ intel_pt_calc_cyc_timestamp(decoder); -+ break; -+ - case INTEL_PT_VMCS: - case INTEL_PT_MNT: - case INTEL_PT_PAD: -@@ -2634,9 +2637,18 @@ const struct intel_pt_state *intel_pt_decode(struct intel_pt_decoder *decoder) - } - if (intel_pt_sample_time(decoder->pkt_state)) { - intel_pt_update_sample_time(decoder); -- if (decoder->sample_cyc) -+ if (decoder->sample_cyc) { - decoder->sample_tot_cyc_cnt = decoder->tot_cyc_cnt; -+ decoder->state.flags |= INTEL_PT_SAMPLE_IPC; -+ decoder->sample_cyc = false; -+ } - } -+ /* -+ * When using only TSC/MTC to compute cycles, IPC can be -+ * sampled as soon as the cycle count changes. -+ */ -+ if (!decoder->have_cyc) -+ decoder->state.flags |= INTEL_PT_SAMPLE_IPC; - } - - decoder->state.timestamp = decoder->sample_timestamp; -diff --git a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h -index e289e463d635e..7396da0fa3a7c 100644 ---- a/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h -+++ b/tools/perf/util/intel-pt-decoder/intel-pt-decoder.h -@@ -17,6 +17,7 @@ - #define INTEL_PT_ABORT_TX (1 << 1) - #define INTEL_PT_ASYNC (1 << 2) - #define INTEL_PT_FUP_IP (1 << 3) -+#define INTEL_PT_SAMPLE_IPC (1 << 4) - - enum intel_pt_sample_type { - INTEL_PT_BRANCH = 1 << 0, -diff --git a/tools/perf/util/intel-pt.c b/tools/perf/util/intel-pt.c -index 8aeaeba48a41f..d0e0ce11faf58 100644 ---- a/tools/perf/util/intel-pt.c -+++ b/tools/perf/util/intel-pt.c -@@ -1304,7 +1304,8 @@ static int intel_pt_synth_branch_sample(struct intel_pt_queue *ptq) - sample.branch_stack = (struct branch_stack *)&dummy_bs; - } - -- sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_br_cyc_cnt; -+ if (ptq->state->flags & INTEL_PT_SAMPLE_IPC) -+ sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_br_cyc_cnt; - if (sample.cyc_cnt) { - sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_br_insn_cnt; - ptq->last_br_insn_cnt = ptq->ipc_insn_cnt; -@@ -1366,7 +1367,8 @@ static int intel_pt_synth_instruction_sample(struct intel_pt_queue *ptq) - sample.stream_id = ptq->pt->instructions_id; - sample.period = ptq->state->tot_insn_cnt - ptq->last_insn_cnt; - -- sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_in_cyc_cnt; -+ if (ptq->state->flags & INTEL_PT_SAMPLE_IPC) -+ sample.cyc_cnt = ptq->ipc_cyc_cnt - ptq->last_in_cyc_cnt; - if (sample.cyc_cnt) { - sample.insn_cnt = ptq->ipc_insn_cnt - ptq->last_in_insn_cnt; - ptq->last_in_insn_cnt = ptq->ipc_insn_cnt; -@@ -1901,14 +1903,8 @@ static int intel_pt_sample(struct intel_pt_queue *ptq) - - ptq->have_sample = false; - -- if (ptq->state->tot_cyc_cnt > ptq->ipc_cyc_cnt) { -- /* -- * Cycle count and instruction count only go together to create -- * a valid IPC ratio when the cycle count changes. -- */ -- ptq->ipc_insn_cnt = ptq->state->tot_insn_cnt; -- ptq->ipc_cyc_cnt = ptq->state->tot_cyc_cnt; -- } -+ ptq->ipc_insn_cnt = ptq->state->tot_insn_cnt; -+ ptq->ipc_cyc_cnt = ptq->state->tot_cyc_cnt; - - /* - * Do PEBS first to allow for the possibility that the PEBS timestamp -diff --git a/tools/testing/selftests/powerpc/eeh/eeh-basic.sh b/tools/testing/selftests/powerpc/eeh/eeh-basic.sh -index cf001a2c69420..7c2cb04569dab 100755 ---- a/tools/testing/selftests/powerpc/eeh/eeh-basic.sh -+++ b/tools/testing/selftests/powerpc/eeh/eeh-basic.sh -@@ -81,5 +81,5 @@ echo "$failed devices failed to recover ($dev_count tested)" - lspci | diff -u $pre_lspci - - rm -f $pre_lspci - --test "$failed" == 0 -+test "$failed" -eq 0 - exit $? diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.102-103.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.102-103.patch deleted file mode 100644 index 5bc570a7aa..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.102-103.patch +++ /dev/null @@ -1,3388 +0,0 @@ -diff --git a/Documentation/devicetree/bindings/net/btusb.txt b/Documentation/devicetree/bindings/net/btusb.txt -index b1ad6ee68e909..c51dd99dc0d3c 100644 ---- a/Documentation/devicetree/bindings/net/btusb.txt -+++ b/Documentation/devicetree/bindings/net/btusb.txt -@@ -38,7 +38,7 @@ Following example uses irq pin number 3 of gpio0 for out of band wake-on-bt: - compatible = "usb1286,204e"; - reg = <1>; - interrupt-parent = <&gpio0>; -- interrupt-name = "wakeup"; -+ interrupt-names = "wakeup"; - interrupts = <3 IRQ_TYPE_LEVEL_LOW>; - }; - }; -diff --git a/Documentation/devicetree/bindings/net/ethernet-controller.yaml b/Documentation/devicetree/bindings/net/ethernet-controller.yaml -index 0e7c31794ae6c..4f78e9a6da609 100644 ---- a/Documentation/devicetree/bindings/net/ethernet-controller.yaml -+++ b/Documentation/devicetree/bindings/net/ethernet-controller.yaml -@@ -190,6 +190,11 @@ properties: - Indicates that full-duplex is used. When absent, half - duplex is assumed. - -+ pause: -+ $ref: /schemas/types.yaml#definitions/flag -+ description: -+ Indicates that pause should be enabled. -+ - asym-pause: - $ref: /schemas/types.yaml#definitions/flag - description: -diff --git a/Documentation/filesystems/sysfs.txt b/Documentation/filesystems/sysfs.txt -index ddf15b1b0d5a4..33ec0a01450dd 100644 ---- a/Documentation/filesystems/sysfs.txt -+++ b/Documentation/filesystems/sysfs.txt -@@ -232,12 +232,10 @@ Other notes: - is 4096. - - - show() methods should return the number of bytes printed into the -- buffer. This is the return value of scnprintf(). -+ buffer. - --- show() must not use snprintf() when formatting the value to be -- returned to user space. If you can guarantee that an overflow -- will never happen you can use sprintf() otherwise you must use -- scnprintf(). -+- show() should only use sysfs_emit() or sysfs_emit_at() when formatting -+ the value to be returned to user space. - - - store() should return the number of bytes used from the buffer. If the - entire buffer has been used, just return the count argument. -diff --git a/Makefile b/Makefile -index 80ff67e5f73a6..c95435d78fcbb 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 102 -+SUBLEVEL = 103 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm/xen/p2m.c b/arch/arm/xen/p2m.c -index fd6e3aafe2724..acb464547a54f 100644 ---- a/arch/arm/xen/p2m.c -+++ b/arch/arm/xen/p2m.c -@@ -93,12 +93,39 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, - int i; - - for (i = 0; i < count; i++) { -+ struct gnttab_unmap_grant_ref unmap; -+ int rc; -+ - if (map_ops[i].status) - continue; -- if (unlikely(!set_phys_to_machine(map_ops[i].host_addr >> XEN_PAGE_SHIFT, -- map_ops[i].dev_bus_addr >> XEN_PAGE_SHIFT))) { -- return -ENOMEM; -- } -+ if (likely(set_phys_to_machine(map_ops[i].host_addr >> XEN_PAGE_SHIFT, -+ map_ops[i].dev_bus_addr >> XEN_PAGE_SHIFT))) -+ continue; -+ -+ /* -+ * Signal an error for this slot. This in turn requires -+ * immediate unmapping. -+ */ -+ map_ops[i].status = GNTST_general_error; -+ unmap.host_addr = map_ops[i].host_addr, -+ unmap.handle = map_ops[i].handle; -+ map_ops[i].handle = ~0; -+ if (map_ops[i].flags & GNTMAP_device_map) -+ unmap.dev_bus_addr = map_ops[i].dev_bus_addr; -+ else -+ unmap.dev_bus_addr = 0; -+ -+ /* -+ * Pre-populate the status field, to be recognizable in -+ * the log message below. -+ */ -+ unmap.status = 1; -+ -+ rc = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, -+ &unmap, 1); -+ if (rc || unmap.status != GNTST_okay) -+ pr_err_once("gnttab unmap failed: rc=%d st=%d\n", -+ rc, unmap.status); - } - - return 0; -diff --git a/arch/arm64/kernel/module.lds b/arch/arm64/kernel/module.lds -index 22e36a21c1134..09a0eef71d12b 100644 ---- a/arch/arm64/kernel/module.lds -+++ b/arch/arm64/kernel/module.lds -@@ -1,5 +1,5 @@ - SECTIONS { -- .plt (NOLOAD) : { BYTE(0) } -- .init.plt (NOLOAD) : { BYTE(0) } -- .text.ftrace_trampoline (NOLOAD) : { BYTE(0) } -+ .plt 0 (NOLOAD) : { BYTE(0) } -+ .init.plt 0 (NOLOAD) : { BYTE(0) } -+ .text.ftrace_trampoline 0 (NOLOAD) : { BYTE(0) } - } -diff --git a/arch/mips/include/asm/string.h b/arch/mips/include/asm/string.h -index 29030cb398ee5..1de3bbce8e88a 100644 ---- a/arch/mips/include/asm/string.h -+++ b/arch/mips/include/asm/string.h -@@ -10,127 +10,6 @@ - #ifndef _ASM_STRING_H - #define _ASM_STRING_H - -- --/* -- * Most of the inline functions are rather naive implementations so I just -- * didn't bother updating them for 64-bit ... -- */ --#ifdef CONFIG_32BIT -- --#ifndef IN_STRING_C -- --#define __HAVE_ARCH_STRCPY --static __inline__ char *strcpy(char *__dest, __const__ char *__src) --{ -- char *__xdest = __dest; -- -- __asm__ __volatile__( -- ".set\tnoreorder\n\t" -- ".set\tnoat\n" -- "1:\tlbu\t$1,(%1)\n\t" -- "addiu\t%1,1\n\t" -- "sb\t$1,(%0)\n\t" -- "bnez\t$1,1b\n\t" -- "addiu\t%0,1\n\t" -- ".set\tat\n\t" -- ".set\treorder" -- : "=r" (__dest), "=r" (__src) -- : "0" (__dest), "1" (__src) -- : "memory"); -- -- return __xdest; --} -- --#define __HAVE_ARCH_STRNCPY --static __inline__ char *strncpy(char *__dest, __const__ char *__src, size_t __n) --{ -- char *__xdest = __dest; -- -- if (__n == 0) -- return __xdest; -- -- __asm__ __volatile__( -- ".set\tnoreorder\n\t" -- ".set\tnoat\n" -- "1:\tlbu\t$1,(%1)\n\t" -- "subu\t%2,1\n\t" -- "sb\t$1,(%0)\n\t" -- "beqz\t$1,2f\n\t" -- "addiu\t%0,1\n\t" -- "bnez\t%2,1b\n\t" -- "addiu\t%1,1\n" -- "2:\n\t" -- ".set\tat\n\t" -- ".set\treorder" -- : "=r" (__dest), "=r" (__src), "=r" (__n) -- : "0" (__dest), "1" (__src), "2" (__n) -- : "memory"); -- -- return __xdest; --} -- --#define __HAVE_ARCH_STRCMP --static __inline__ int strcmp(__const__ char *__cs, __const__ char *__ct) --{ -- int __res; -- -- __asm__ __volatile__( -- ".set\tnoreorder\n\t" -- ".set\tnoat\n\t" -- "lbu\t%2,(%0)\n" -- "1:\tlbu\t$1,(%1)\n\t" -- "addiu\t%0,1\n\t" -- "bne\t$1,%2,2f\n\t" -- "addiu\t%1,1\n\t" -- "bnez\t%2,1b\n\t" -- "lbu\t%2,(%0)\n\t" --#if defined(CONFIG_CPU_R3000) -- "nop\n\t" --#endif -- "move\t%2,$1\n" -- "2:\tsubu\t%2,$1\n" -- "3:\t.set\tat\n\t" -- ".set\treorder" -- : "=r" (__cs), "=r" (__ct), "=r" (__res) -- : "0" (__cs), "1" (__ct)); -- -- return __res; --} -- --#endif /* !defined(IN_STRING_C) */ -- --#define __HAVE_ARCH_STRNCMP --static __inline__ int --strncmp(__const__ char *__cs, __const__ char *__ct, size_t __count) --{ -- int __res; -- -- __asm__ __volatile__( -- ".set\tnoreorder\n\t" -- ".set\tnoat\n" -- "1:\tlbu\t%3,(%0)\n\t" -- "beqz\t%2,2f\n\t" -- "lbu\t$1,(%1)\n\t" -- "subu\t%2,1\n\t" -- "bne\t$1,%3,3f\n\t" -- "addiu\t%0,1\n\t" -- "bnez\t%3,1b\n\t" -- "addiu\t%1,1\n" -- "2:\n\t" --#if defined(CONFIG_CPU_R3000) -- "nop\n\t" --#endif -- "move\t%3,$1\n" -- "3:\tsubu\t%3,$1\n\t" -- ".set\tat\n\t" -- ".set\treorder" -- : "=r" (__cs), "=r" (__ct), "=r" (__count), "=r" (__res) -- : "0" (__cs), "1" (__ct), "2" (__count)); -- -- return __res; --} --#endif /* CONFIG_32BIT */ -- - #define __HAVE_ARCH_MEMSET - extern void *memset(void *__s, int __c, size_t __count); - -diff --git a/arch/mips/vdso/Makefile b/arch/mips/vdso/Makefile -index 996a934ece7d6..d3cd9c4cadc28 100644 ---- a/arch/mips/vdso/Makefile -+++ b/arch/mips/vdso/Makefile -@@ -16,12 +16,9 @@ ccflags-vdso := \ - $(filter -march=%,$(KBUILD_CFLAGS)) \ - $(filter -m%-float,$(KBUILD_CFLAGS)) \ - $(filter -mno-loongson-%,$(KBUILD_CFLAGS)) \ -+ $(CLANG_FLAGS) \ - -D__VDSO__ - --ifdef CONFIG_CC_IS_CLANG --ccflags-vdso += $(filter --target=%,$(KBUILD_CFLAGS)) --endif -- - # - # The -fno-jump-tables flag only prevents the compiler from generating - # jump tables but does not prevent the compiler from emitting absolute -diff --git a/arch/parisc/kernel/irq.c b/arch/parisc/kernel/irq.c -index e5fcfb70cc7c0..4d54aa70ea5f3 100644 ---- a/arch/parisc/kernel/irq.c -+++ b/arch/parisc/kernel/irq.c -@@ -376,7 +376,11 @@ static inline int eirr_to_irq(unsigned long eirr) - /* - * IRQ STACK - used for irq handler - */ -+#ifdef CONFIG_64BIT -+#define IRQ_STACK_SIZE (4096 << 4) /* 64k irq stack size */ -+#else - #define IRQ_STACK_SIZE (4096 << 3) /* 32k irq stack size */ -+#endif - - union irq_stack_union { - unsigned long stack[IRQ_STACK_SIZE/sizeof(unsigned long)]; -diff --git a/arch/x86/events/intel/core.c b/arch/x86/events/intel/core.c -index b24c38090dd99..90760393a9643 100644 ---- a/arch/x86/events/intel/core.c -+++ b/arch/x86/events/intel/core.c -@@ -4002,6 +4002,9 @@ static const struct x86_cpu_desc isolation_ucodes[] = { - INTEL_CPU_DESC(INTEL_FAM6_BROADWELL_X, 2, 0x0b000014), - INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_X, 3, 0x00000021), - INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_X, 4, 0x00000000), -+ INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_X, 5, 0x00000000), -+ INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_X, 6, 0x00000000), -+ INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_X, 7, 0x00000000), - INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE_L, 3, 0x0000007c), - INTEL_CPU_DESC(INTEL_FAM6_SKYLAKE, 3, 0x0000007c), - INTEL_CPU_DESC(INTEL_FAM6_KABYLAKE, 9, 0x0000004e), -diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c -index d5c72cb877b31..77dabedaa9d12 100644 ---- a/arch/x86/kernel/module.c -+++ b/arch/x86/kernel/module.c -@@ -114,6 +114,7 @@ int apply_relocate(Elf32_Shdr *sechdrs, - *location += sym->st_value; - break; - case R_386_PC32: -+ case R_386_PLT32: - /* Add the value, subtract its position */ - *location += sym->st_value - (uint32_t)location; - break; -diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c -index 835b6fc0c1bbf..b1b96d461bc76 100644 ---- a/arch/x86/kernel/reboot.c -+++ b/arch/x86/kernel/reboot.c -@@ -477,6 +477,15 @@ static const struct dmi_system_id reboot_dmi_table[] __initconst = { - }, - }, - -+ { /* PCIe Wifi card isn't detected after reboot otherwise */ -+ .callback = set_pci_reboot, -+ .ident = "Zotac ZBOX CI327 nano", -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "NA"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "ZBOX-CI327NANO-GS-01"), -+ }, -+ }, -+ - /* Sony */ - { /* Handle problems with rebooting on Sony VGN-Z540N */ - .callback = set_bios_reboot, -diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c -index ce7188cbdae58..1c3a1962cade6 100644 ---- a/arch/x86/tools/relocs.c -+++ b/arch/x86/tools/relocs.c -@@ -867,9 +867,11 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym, - case R_386_PC32: - case R_386_PC16: - case R_386_PC8: -+ case R_386_PLT32: - /* -- * NONE can be ignored and PC relative relocations don't -- * need to be adjusted. -+ * NONE can be ignored and PC relative relocations don't need -+ * to be adjusted. Because sym must be defined, R_386_PLT32 can -+ * be treated the same way as R_386_PC32. - */ - break; - -@@ -910,9 +912,11 @@ static int do_reloc_real(struct section *sec, Elf_Rel *rel, Elf_Sym *sym, - case R_386_PC32: - case R_386_PC16: - case R_386_PC8: -+ case R_386_PLT32: - /* -- * NONE can be ignored and PC relative relocations don't -- * need to be adjusted. -+ * NONE can be ignored and PC relative relocations don't need -+ * to be adjusted. Because sym must be defined, R_386_PLT32 can -+ * be treated the same way as R_386_PC32. - */ - break; - -diff --git a/arch/x86/xen/p2m.c b/arch/x86/xen/p2m.c -index 7fe5be8e6d3db..12fcb3858303a 100644 ---- a/arch/x86/xen/p2m.c -+++ b/arch/x86/xen/p2m.c -@@ -714,6 +714,8 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, - - for (i = 0; i < count; i++) { - unsigned long mfn, pfn; -+ struct gnttab_unmap_grant_ref unmap[2]; -+ int rc; - - /* Do not add to override if the map failed. */ - if (map_ops[i].status != GNTST_okay || -@@ -731,10 +733,46 @@ int set_foreign_p2m_mapping(struct gnttab_map_grant_ref *map_ops, - - WARN(pfn_to_mfn(pfn) != INVALID_P2M_ENTRY, "page must be ballooned"); - -- if (unlikely(!set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)))) { -- ret = -ENOMEM; -- goto out; -+ if (likely(set_phys_to_machine(pfn, FOREIGN_FRAME(mfn)))) -+ continue; -+ -+ /* -+ * Signal an error for this slot. This in turn requires -+ * immediate unmapping. -+ */ -+ map_ops[i].status = GNTST_general_error; -+ unmap[0].host_addr = map_ops[i].host_addr, -+ unmap[0].handle = map_ops[i].handle; -+ map_ops[i].handle = ~0; -+ if (map_ops[i].flags & GNTMAP_device_map) -+ unmap[0].dev_bus_addr = map_ops[i].dev_bus_addr; -+ else -+ unmap[0].dev_bus_addr = 0; -+ -+ if (kmap_ops) { -+ kmap_ops[i].status = GNTST_general_error; -+ unmap[1].host_addr = kmap_ops[i].host_addr, -+ unmap[1].handle = kmap_ops[i].handle; -+ kmap_ops[i].handle = ~0; -+ if (kmap_ops[i].flags & GNTMAP_device_map) -+ unmap[1].dev_bus_addr = kmap_ops[i].dev_bus_addr; -+ else -+ unmap[1].dev_bus_addr = 0; - } -+ -+ /* -+ * Pre-populate both status fields, to be recognizable in -+ * the log message below. -+ */ -+ unmap[0].status = 1; -+ unmap[1].status = 1; -+ -+ rc = HYPERVISOR_grant_table_op(GNTTABOP_unmap_grant_ref, -+ unmap, 1 + !!kmap_ops); -+ if (rc || unmap[0].status != GNTST_okay || -+ unmap[1].status != GNTST_okay) -+ pr_err_once("gnttab unmap failed: rc=%d st0=%d st1=%d\n", -+ rc, unmap[0].status, unmap[1].status); - } - - out: -diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c -index 83ad0b1fab30a..0cece1f883ebe 100644 ---- a/crypto/tcrypt.c -+++ b/crypto/tcrypt.c -@@ -198,8 +198,8 @@ static int test_mb_aead_jiffies(struct test_mb_aead_data *data, int enc, - goto out; - } - -- pr_cont("%d operations in %d seconds (%ld bytes)\n", -- bcount * num_mb, secs, (long)bcount * blen * num_mb); -+ pr_cont("%d operations in %d seconds (%llu bytes)\n", -+ bcount * num_mb, secs, (u64)bcount * blen * num_mb); - - out: - kfree(rc); -@@ -468,8 +468,8 @@ static int test_aead_jiffies(struct aead_request *req, int enc, - return ret; - } - -- printk("%d operations in %d seconds (%ld bytes)\n", -- bcount, secs, (long)bcount * blen); -+ pr_cont("%d operations in %d seconds (%llu bytes)\n", -+ bcount, secs, (u64)bcount * blen); - return 0; - } - -@@ -759,8 +759,8 @@ static int test_mb_ahash_jiffies(struct test_mb_ahash_data *data, int blen, - goto out; - } - -- pr_cont("%d operations in %d seconds (%ld bytes)\n", -- bcount * num_mb, secs, (long)bcount * blen * num_mb); -+ pr_cont("%d operations in %d seconds (%llu bytes)\n", -+ bcount * num_mb, secs, (u64)bcount * blen * num_mb); - - out: - kfree(rc); -@@ -1196,8 +1196,8 @@ static int test_mb_acipher_jiffies(struct test_mb_skcipher_data *data, int enc, - goto out; - } - -- pr_cont("%d operations in %d seconds (%ld bytes)\n", -- bcount * num_mb, secs, (long)bcount * blen * num_mb); -+ pr_cont("%d operations in %d seconds (%llu bytes)\n", -+ bcount * num_mb, secs, (u64)bcount * blen * num_mb); - - out: - kfree(rc); -@@ -1434,8 +1434,8 @@ static int test_acipher_jiffies(struct skcipher_request *req, int enc, - return ret; - } - -- pr_cont("%d operations in %d seconds (%ld bytes)\n", -- bcount, secs, (long)bcount * blen); -+ pr_cont("%d operations in %d seconds (%llu bytes)\n", -+ bcount, secs, (u64)bcount * blen); - return 0; - } - -diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c -index f068bb5d650eb..e11fddcb73b98 100644 ---- a/drivers/block/nbd.c -+++ b/drivers/block/nbd.c -@@ -78,8 +78,7 @@ struct link_dead_args { - #define NBD_RT_HAS_PID_FILE 3 - #define NBD_RT_HAS_CONFIG_REF 4 - #define NBD_RT_BOUND 5 --#define NBD_RT_DESTROY_ON_DISCONNECT 6 --#define NBD_RT_DISCONNECT_ON_CLOSE 7 -+#define NBD_RT_DISCONNECT_ON_CLOSE 6 - - #define NBD_DESTROY_ON_DISCONNECT 0 - #define NBD_DISCONNECT_REQUESTED 1 -@@ -1940,12 +1939,21 @@ again: - if (info->attrs[NBD_ATTR_CLIENT_FLAGS]) { - u64 flags = nla_get_u64(info->attrs[NBD_ATTR_CLIENT_FLAGS]); - if (flags & NBD_CFLAG_DESTROY_ON_DISCONNECT) { -- set_bit(NBD_RT_DESTROY_ON_DISCONNECT, -- &config->runtime_flags); -- set_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags); -- put_dev = true; -+ /* -+ * We have 1 ref to keep the device around, and then 1 -+ * ref for our current operation here, which will be -+ * inherited by the config. If we already have -+ * DESTROY_ON_DISCONNECT set then we know we don't have -+ * that extra ref already held so we don't need the -+ * put_dev. -+ */ -+ if (!test_and_set_bit(NBD_DESTROY_ON_DISCONNECT, -+ &nbd->flags)) -+ put_dev = true; - } else { -- clear_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags); -+ if (test_and_clear_bit(NBD_DESTROY_ON_DISCONNECT, -+ &nbd->flags)) -+ refcount_inc(&nbd->refs); - } - if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) { - set_bit(NBD_RT_DISCONNECT_ON_CLOSE, -@@ -2116,15 +2124,13 @@ static int nbd_genl_reconfigure(struct sk_buff *skb, struct genl_info *info) - if (info->attrs[NBD_ATTR_CLIENT_FLAGS]) { - u64 flags = nla_get_u64(info->attrs[NBD_ATTR_CLIENT_FLAGS]); - if (flags & NBD_CFLAG_DESTROY_ON_DISCONNECT) { -- if (!test_and_set_bit(NBD_RT_DESTROY_ON_DISCONNECT, -- &config->runtime_flags)) -+ if (!test_and_set_bit(NBD_DESTROY_ON_DISCONNECT, -+ &nbd->flags)) - put_dev = true; -- set_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags); - } else { -- if (test_and_clear_bit(NBD_RT_DESTROY_ON_DISCONNECT, -- &config->runtime_flags)) -+ if (test_and_clear_bit(NBD_DESTROY_ON_DISCONNECT, -+ &nbd->flags)) - refcount_inc(&nbd->refs); -- clear_bit(NBD_DESTROY_ON_DISCONNECT, &nbd->flags); - } - - if (flags & NBD_CFLAG_DISCONNECT_ON_CLOSE) { -diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c -index 36d49159140f4..22aa432a68bf9 100644 ---- a/drivers/block/zram/zram_drv.c -+++ b/drivers/block/zram/zram_drv.c -@@ -1072,7 +1072,7 @@ static ssize_t mm_stat_show(struct device *dev, - zram->limit_pages << PAGE_SHIFT, - max_used << PAGE_SHIFT, - (u64)atomic64_read(&zram->stats.same_pages), -- pool_stats.pages_compacted, -+ atomic_long_read(&pool_stats.pages_compacted), - (u64)atomic64_read(&zram->stats.huge_pages)); - up_read(&zram->init_lock); - -diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c -index e11af747395dd..bf3e23104194a 100644 ---- a/drivers/bluetooth/hci_h5.c -+++ b/drivers/bluetooth/hci_h5.c -@@ -894,6 +894,11 @@ static int h5_btrtl_setup(struct h5 *h5) - /* Give the device some time before the hci-core sends it a reset */ - usleep_range(10000, 20000); - -+ /* Enable controller to do both LE scan and BR/EDR inquiry -+ * simultaneously. -+ */ -+ set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks); -+ - out_free: - btrtl_free(btrtl_dev); - -diff --git a/drivers/gpu/drm/amd/amdgpu/cz_ih.c b/drivers/gpu/drm/amd/amdgpu/cz_ih.c -index 1dca0cabc326a..13520d173296f 100644 ---- a/drivers/gpu/drm/amd/amdgpu/cz_ih.c -+++ b/drivers/gpu/drm/amd/amdgpu/cz_ih.c -@@ -193,19 +193,30 @@ static u32 cz_ih_get_wptr(struct amdgpu_device *adev, - - wptr = le32_to_cpu(*ih->wptr_cpu); - -- if (REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) { -- wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -- /* When a ring buffer overflow happen start parsing interrupt -- * from the last not overwritten vector (wptr + 16). Hopefully -- * this should allow us to catchup. -- */ -- dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -- wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -- ih->rptr = (wptr + 16) & ih->ptr_mask; -- tmp = RREG32(mmIH_RB_CNTL); -- tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -- WREG32(mmIH_RB_CNTL, tmp); -- } -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ /* Double check that the overflow wasn't already cleared. */ -+ wptr = RREG32(mmIH_RB_WPTR); -+ -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -+ -+ /* When a ring buffer overflow happen start parsing interrupt -+ * from the last not overwritten vector (wptr + 16). Hopefully -+ * this should allow us to catchup. -+ */ -+ dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -+ wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -+ ih->rptr = (wptr + 16) & ih->ptr_mask; -+ tmp = RREG32(mmIH_RB_CNTL); -+ tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -+ WREG32(mmIH_RB_CNTL, tmp); -+ -+ -+out: - return (wptr & ih->ptr_mask); - } - -diff --git a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c -index a13dd9a51149a..7d165f024f072 100644 ---- a/drivers/gpu/drm/amd/amdgpu/iceland_ih.c -+++ b/drivers/gpu/drm/amd/amdgpu/iceland_ih.c -@@ -193,19 +193,29 @@ static u32 iceland_ih_get_wptr(struct amdgpu_device *adev, - - wptr = le32_to_cpu(*ih->wptr_cpu); - -- if (REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) { -- wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -- /* When a ring buffer overflow happen start parsing interrupt -- * from the last not overwritten vector (wptr + 16). Hopefully -- * this should allow us to catchup. -- */ -- dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -- wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -- ih->rptr = (wptr + 16) & ih->ptr_mask; -- tmp = RREG32(mmIH_RB_CNTL); -- tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -- WREG32(mmIH_RB_CNTL, tmp); -- } -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ /* Double check that the overflow wasn't already cleared. */ -+ wptr = RREG32(mmIH_RB_WPTR); -+ -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -+ /* When a ring buffer overflow happen start parsing interrupt -+ * from the last not overwritten vector (wptr + 16). Hopefully -+ * this should allow us to catchup. -+ */ -+ dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -+ wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -+ ih->rptr = (wptr + 16) & ih->ptr_mask; -+ tmp = RREG32(mmIH_RB_CNTL); -+ tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -+ WREG32(mmIH_RB_CNTL, tmp); -+ -+ -+out: - return (wptr & ih->ptr_mask); - } - -diff --git a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c -index e40140bf6699c..db0a3bda13fbe 100644 ---- a/drivers/gpu/drm/amd/amdgpu/tonga_ih.c -+++ b/drivers/gpu/drm/amd/amdgpu/tonga_ih.c -@@ -195,19 +195,30 @@ static u32 tonga_ih_get_wptr(struct amdgpu_device *adev, - - wptr = le32_to_cpu(*ih->wptr_cpu); - -- if (REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) { -- wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -- /* When a ring buffer overflow happen start parsing interrupt -- * from the last not overwritten vector (wptr + 16). Hopefully -- * this should allow us to catchup. -- */ -- dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -- wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -- ih->rptr = (wptr + 16) & ih->ptr_mask; -- tmp = RREG32(mmIH_RB_CNTL); -- tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -- WREG32(mmIH_RB_CNTL, tmp); -- } -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ /* Double check that the overflow wasn't already cleared. */ -+ wptr = RREG32(mmIH_RB_WPTR); -+ -+ if (!REG_GET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW)) -+ goto out; -+ -+ wptr = REG_SET_FIELD(wptr, IH_RB_WPTR, RB_OVERFLOW, 0); -+ -+ /* When a ring buffer overflow happen start parsing interrupt -+ * from the last not overwritten vector (wptr + 16). Hopefully -+ * this should allow us to catchup. -+ */ -+ -+ dev_warn(adev->dev, "IH ring buffer overflow (0x%08X, 0x%08X, 0x%08X)\n", -+ wptr, ih->rptr, (wptr + 16) & ih->ptr_mask); -+ ih->rptr = (wptr + 16) & ih->ptr_mask; -+ tmp = RREG32(mmIH_RB_CNTL); -+ tmp = REG_SET_FIELD(tmp, IH_RB_CNTL, WPTR_OVERFLOW_CLEAR, 1); -+ WREG32(mmIH_RB_CNTL, tmp); -+ -+out: - return (wptr & ih->ptr_mask); - } - -diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c b/drivers/gpu/drm/amd/display/dc/core/dc_link.c -index fa92b88bc5a13..40041c61a100e 100644 ---- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c -+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c -@@ -1303,6 +1303,11 @@ static bool construct( - goto ddc_create_fail; - } - -+ if (!link->ddc->ddc_pin) { -+ DC_ERROR("Failed to get I2C info for connector!\n"); -+ goto ddc_create_fail; -+ } -+ - link->ddc_hw_inst = - dal_ddc_get_line( - dal_ddc_service_get_ddc_pin(link->ddc)); -diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c -index c103005b0a33e..a34ef5ec7d429 100644 ---- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c -+++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c -@@ -376,7 +376,6 @@ static void hibmc_pci_remove(struct pci_dev *pdev) - - drm_dev_unregister(dev); - hibmc_unload(dev); -- drm_dev_put(dev); - } - - static struct pci_device_id hibmc_pci_table[] = { -diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c -index 92022a83bbd5e..bb46e7a0f1b5d 100644 ---- a/drivers/gpu/drm/virtio/virtgpu_vq.c -+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c -@@ -992,8 +992,9 @@ int virtio_gpu_object_attach(struct virtio_gpu_device *vgdev, - } - - /* gets freed when the ring has consumed it */ -- ents = kmalloc_array(nents, sizeof(struct virtio_gpu_mem_entry), -- GFP_KERNEL); -+ ents = kvmalloc_array(nents, -+ sizeof(struct virtio_gpu_mem_entry), -+ GFP_KERNEL); - if (!ents) { - DRM_ERROR("failed to allocate ent list\n"); - return -ENOMEM; -diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c -index 2d8434b7b6238..053fe2da1e08f 100644 ---- a/drivers/input/mouse/elantech.c -+++ b/drivers/input/mouse/elantech.c -@@ -89,6 +89,47 @@ static int elantech_ps2_command(struct psmouse *psmouse, - return rc; - } - -+/* -+ * Send an Elantech style special command to read 3 bytes from a register -+ */ -+static int elantech_read_reg_params(struct psmouse *psmouse, u8 reg, u8 *param) -+{ -+ if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) || -+ elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, reg) || -+ elantech_ps2_command(psmouse, param, PSMOUSE_CMD_GETINFO)) { -+ psmouse_err(psmouse, -+ "failed to read register %#02x\n", reg); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ -+/* -+ * Send an Elantech style special command to write a register with a parameter -+ */ -+static int elantech_write_reg_params(struct psmouse *psmouse, u8 reg, u8 *param) -+{ -+ if (elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, ETP_REGISTER_READWRITE) || -+ elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, reg) || -+ elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, param[0]) || -+ elantech_ps2_command(psmouse, NULL, ETP_PS2_CUSTOM_COMMAND) || -+ elantech_ps2_command(psmouse, NULL, param[1]) || -+ elantech_ps2_command(psmouse, NULL, PSMOUSE_CMD_SETSCALE11)) { -+ psmouse_err(psmouse, -+ "failed to write register %#02x with value %#02x%#02x\n", -+ reg, param[0], param[1]); -+ return -EIO; -+ } -+ -+ return 0; -+} -+ - /* - * Send an Elantech style special command to read a value from a register - */ -@@ -1529,19 +1570,35 @@ static const struct dmi_system_id no_hw_res_dmi_table[] = { - { } - }; - -+/* -+ * Change Report id 0x5E to 0x5F. -+ */ -+static int elantech_change_report_id(struct psmouse *psmouse) -+{ -+ unsigned char param[2] = { 0x10, 0x03 }; -+ -+ if (elantech_write_reg_params(psmouse, 0x7, param) || -+ elantech_read_reg_params(psmouse, 0x7, param) || -+ param[0] != 0x10 || param[1] != 0x03) { -+ psmouse_err(psmouse, "Unable to change report ID to 0x5f.\n"); -+ return -EIO; -+ } -+ -+ return 0; -+} - /* - * determine hardware version and set some properties according to it. - */ - static int elantech_set_properties(struct elantech_device_info *info) - { - /* This represents the version of IC body. */ -- int ver = (info->fw_version & 0x0f0000) >> 16; -+ info->ic_version = (info->fw_version & 0x0f0000) >> 16; - - /* Early version of Elan touchpads doesn't obey the rule. */ - if (info->fw_version < 0x020030 || info->fw_version == 0x020600) - info->hw_version = 1; - else { -- switch (ver) { -+ switch (info->ic_version) { - case 2: - case 4: - info->hw_version = 2; -@@ -1557,6 +1614,11 @@ static int elantech_set_properties(struct elantech_device_info *info) - } - } - -+ /* Get information pattern for hw_version 4 */ -+ info->pattern = 0x00; -+ if (info->ic_version == 0x0f && (info->fw_version & 0xff) <= 0x02) -+ info->pattern = info->fw_version & 0xff; -+ - /* decide which send_cmd we're gonna use early */ - info->send_cmd = info->hw_version >= 3 ? elantech_send_cmd : - synaptics_send_cmd; -@@ -1598,6 +1660,7 @@ static int elantech_query_info(struct psmouse *psmouse, - { - unsigned char param[3]; - unsigned char traces; -+ unsigned char ic_body[3]; - - memset(info, 0, sizeof(*info)); - -@@ -1640,6 +1703,21 @@ static int elantech_query_info(struct psmouse *psmouse, - info->samples[2]); - } - -+ if (info->pattern > 0x00 && info->ic_version == 0xf) { -+ if (info->send_cmd(psmouse, ETP_ICBODY_QUERY, ic_body)) { -+ psmouse_err(psmouse, "failed to query ic body\n"); -+ return -EINVAL; -+ } -+ info->ic_version = be16_to_cpup((__be16 *)ic_body); -+ psmouse_info(psmouse, -+ "Elan ic body: %#04x, current fw version: %#02x\n", -+ info->ic_version, ic_body[2]); -+ } -+ -+ info->product_id = be16_to_cpup((__be16 *)info->samples); -+ if (info->pattern == 0x00) -+ info->product_id &= 0xff; -+ - if (info->samples[1] == 0x74 && info->hw_version == 0x03) { - /* - * This module has a bug which makes absolute mode -@@ -1654,6 +1732,23 @@ static int elantech_query_info(struct psmouse *psmouse, - /* The MSB indicates the presence of the trackpoint */ - info->has_trackpoint = (info->capabilities[0] & 0x80) == 0x80; - -+ if (info->has_trackpoint && info->ic_version == 0x0011 && -+ (info->product_id == 0x08 || info->product_id == 0x09 || -+ info->product_id == 0x0d || info->product_id == 0x0e)) { -+ /* -+ * This module has a bug which makes trackpoint in SMBus -+ * mode return invalid data unless trackpoint is switched -+ * from using 0x5e reports to 0x5f. If we are not able to -+ * make the switch, let's abort initialization so we'll be -+ * using standard PS/2 protocol. -+ */ -+ if (elantech_change_report_id(psmouse)) { -+ psmouse_info(psmouse, -+ "Trackpoint report is broken, forcing standard PS/2 protocol\n"); -+ return -ENODEV; -+ } -+ } -+ - info->x_res = 31; - info->y_res = 31; - if (info->hw_version == 4) { -diff --git a/drivers/input/mouse/elantech.h b/drivers/input/mouse/elantech.h -index e0a3e59d4f1bb..571e6ca11d33b 100644 ---- a/drivers/input/mouse/elantech.h -+++ b/drivers/input/mouse/elantech.h -@@ -18,6 +18,7 @@ - #define ETP_CAPABILITIES_QUERY 0x02 - #define ETP_SAMPLE_QUERY 0x03 - #define ETP_RESOLUTION_QUERY 0x04 -+#define ETP_ICBODY_QUERY 0x05 - - /* - * Command values for register reading or writing -@@ -140,7 +141,10 @@ struct elantech_device_info { - unsigned char samples[3]; - unsigned char debug; - unsigned char hw_version; -+ unsigned char pattern; - unsigned int fw_version; -+ unsigned int ic_version; -+ unsigned int product_id; - unsigned int x_min; - unsigned int y_min; - unsigned int x_max; -diff --git a/drivers/media/rc/mceusb.c b/drivers/media/rc/mceusb.c -index 867f5fb6fbe11..c68e52c17ae13 100644 ---- a/drivers/media/rc/mceusb.c -+++ b/drivers/media/rc/mceusb.c -@@ -701,11 +701,18 @@ static void mceusb_dev_printdata(struct mceusb_dev *ir, u8 *buf, int buf_len, - data[0], data[1]); - break; - case MCE_RSP_EQIRCFS: -+ if (!data[0] && !data[1]) { -+ dev_dbg(dev, "%s: no carrier", inout); -+ break; -+ } -+ // prescaler should make sense -+ if (data[0] > 8) -+ break; - period = DIV_ROUND_CLOSEST((1U << data[0] * 2) * - (data[1] + 1), 10); - if (!period) - break; -- carrier = (1000 * 1000) / period; -+ carrier = USEC_PER_SEC / period; - dev_dbg(dev, "%s carrier of %u Hz (period %uus)", - inout, carrier, period); - break; -diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c -index 99883550375e9..40ca1d4e03483 100644 ---- a/drivers/media/usb/uvc/uvc_driver.c -+++ b/drivers/media/usb/uvc/uvc_driver.c -@@ -967,7 +967,10 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, - unsigned int i; - - extra_size = roundup(extra_size, sizeof(*entity->pads)); -- num_inputs = (type & UVC_TERM_OUTPUT) ? num_pads : num_pads - 1; -+ if (num_pads) -+ num_inputs = type & UVC_TERM_OUTPUT ? num_pads : num_pads - 1; -+ else -+ num_inputs = 0; - size = sizeof(*entity) + extra_size + sizeof(*entity->pads) * num_pads - + num_inputs; - entity = kzalloc(size, GFP_KERNEL); -@@ -983,7 +986,7 @@ static struct uvc_entity *uvc_alloc_entity(u16 type, u8 id, - - for (i = 0; i < num_inputs; ++i) - entity->pads[i].flags = MEDIA_PAD_FL_SINK; -- if (!UVC_ENTITY_IS_OTERM(entity)) -+ if (!UVC_ENTITY_IS_OTERM(entity) && num_pads) - entity->pads[num_pads-1].flags = MEDIA_PAD_FL_SOURCE; - - entity->bNrInPins = num_inputs; -diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c -index cd84dbbf6a890..3fe99519fedfb 100644 ---- a/drivers/media/v4l2-core/v4l2-ctrls.c -+++ b/drivers/media/v4l2-core/v4l2-ctrls.c -@@ -1795,7 +1795,8 @@ static int std_validate(const struct v4l2_ctrl *ctrl, u32 idx, - case V4L2_CTRL_TYPE_INTEGER_MENU: - if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) - return -ERANGE; -- if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) -+ if (ptr.p_s32[idx] < BITS_PER_LONG_LONG && -+ (ctrl->menu_skip_mask & BIT_ULL(ptr.p_s32[idx]))) - return -EINVAL; - if (ctrl->type == V4L2_CTRL_TYPE_MENU && - ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') -diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c -index 58868d7129ebd..24db33f803c06 100644 ---- a/drivers/media/v4l2-core/v4l2-ioctl.c -+++ b/drivers/media/v4l2-core/v4l2-ioctl.c -@@ -3016,7 +3016,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, - v4l2_kioctl func) - { - char sbuf[128]; -- void *mbuf = NULL; -+ void *mbuf = NULL, *array_buf = NULL; - void *parg = (void *)arg; - long err = -EINVAL; - bool has_array_args; -@@ -3075,20 +3075,14 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, - has_array_args = err; - - if (has_array_args) { -- /* -- * When adding new types of array args, make sure that the -- * parent argument to ioctl (which contains the pointer to the -- * array) fits into sbuf (so that mbuf will still remain -- * unused up to here). -- */ -- mbuf = kvmalloc(array_size, GFP_KERNEL); -+ array_buf = kvmalloc(array_size, GFP_KERNEL); - err = -ENOMEM; -- if (NULL == mbuf) -+ if (array_buf == NULL) - goto out_array_args; - err = -EFAULT; -- if (copy_from_user(mbuf, user_ptr, array_size)) -+ if (copy_from_user(array_buf, user_ptr, array_size)) - goto out_array_args; -- *kernel_ptr = mbuf; -+ *kernel_ptr = array_buf; - } - - /* Handles IOCTL */ -@@ -3107,7 +3101,7 @@ video_usercopy(struct file *file, unsigned int cmd, unsigned long arg, - - if (has_array_args) { - *kernel_ptr = (void __force *)user_ptr; -- if (copy_to_user(user_ptr, mbuf, array_size)) -+ if (copy_to_user(user_ptr, array_buf, array_size)) - err = -EFAULT; - goto out_array_args; - } -@@ -3129,6 +3123,7 @@ out_array_args: - } - - out: -+ kvfree(array_buf); - kvfree(mbuf); - return err; - } -diff --git a/drivers/net/ethernet/atheros/ag71xx.c b/drivers/net/ethernet/atheros/ag71xx.c -index 78e20f53677d5..58a002dd758cd 100644 ---- a/drivers/net/ethernet/atheros/ag71xx.c -+++ b/drivers/net/ethernet/atheros/ag71xx.c -@@ -222,8 +222,6 @@ - #define AG71XX_REG_RX_SM 0x01b0 - #define AG71XX_REG_TX_SM 0x01b4 - --#define ETH_SWITCH_HEADER_LEN 2 -- - #define AG71XX_DEFAULT_MSG_ENABLE \ - (NETIF_MSG_DRV \ - | NETIF_MSG_PROBE \ -@@ -784,7 +782,7 @@ static void ag71xx_hw_setup(struct ag71xx *ag) - - static unsigned int ag71xx_max_frame_len(unsigned int mtu) - { -- return ETH_SWITCH_HEADER_LEN + ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN; -+ return ETH_HLEN + VLAN_HLEN + mtu + ETH_FCS_LEN; - } - - static void ag71xx_hw_set_macaddr(struct ag71xx *ag, unsigned char *mac) -diff --git a/drivers/net/tap.c b/drivers/net/tap.c -index 3ae70c7e6860c..f285422a80717 100644 ---- a/drivers/net/tap.c -+++ b/drivers/net/tap.c -@@ -1095,10 +1095,9 @@ static long tap_ioctl(struct file *file, unsigned int cmd, - return -ENOLINK; - } - ret = 0; -- u = tap->dev->type; -+ dev_get_mac_address(&sa, dev_net(tap->dev), tap->dev->name); - if (copy_to_user(&ifr->ifr_name, tap->dev->name, IFNAMSIZ) || -- copy_to_user(&ifr->ifr_hwaddr.sa_data, tap->dev->dev_addr, ETH_ALEN) || -- put_user(u, &ifr->ifr_hwaddr.sa_family)) -+ copy_to_user(&ifr->ifr_hwaddr, &sa, sizeof(sa))) - ret = -EFAULT; - tap_put_tap_dev(tap); - rtnl_unlock(); -@@ -1113,7 +1112,7 @@ static long tap_ioctl(struct file *file, unsigned int cmd, - rtnl_unlock(); - return -ENOLINK; - } -- ret = dev_set_mac_address(tap->dev, &sa, NULL); -+ ret = dev_set_mac_address_user(tap->dev, &sa, NULL); - tap_put_tap_dev(tap); - rtnl_unlock(); - return ret; -diff --git a/drivers/net/tun.c b/drivers/net/tun.c -index 84e779f93f0a4..fe6ec22bf3d51 100644 ---- a/drivers/net/tun.c -+++ b/drivers/net/tun.c -@@ -3224,7 +3224,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, - case SIOCGIFHWADDR: - /* Get hw address */ - memcpy(ifr.ifr_hwaddr.sa_data, tun->dev->dev_addr, ETH_ALEN); -- ifr.ifr_hwaddr.sa_family = tun->dev->type; -+ dev_get_mac_address(&ifr.ifr_hwaddr, net, tun->dev->name); - if (copy_to_user(argp, &ifr, ifreq_len)) - ret = -EFAULT; - break; -@@ -3234,7 +3234,7 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd, - tun_debug(KERN_DEBUG, tun, "set hw address: %pM\n", - ifr.ifr_hwaddr.sa_data); - -- ret = dev_set_mac_address(tun->dev, &ifr.ifr_hwaddr, NULL); -+ ret = dev_set_mac_address_user(tun->dev, &ifr.ifr_hwaddr, NULL); - break; - - case TUNGETSNDBUF: -diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c -index 5a1d21aae2a9e..05b85b94d9518 100644 ---- a/drivers/net/usb/qmi_wwan.c -+++ b/drivers/net/usb/qmi_wwan.c -@@ -1280,6 +1280,7 @@ static const struct usb_device_id products[] = { - {QMI_FIXED_INTF(0x19d2, 0x1255, 4)}, - {QMI_FIXED_INTF(0x19d2, 0x1256, 4)}, - {QMI_FIXED_INTF(0x19d2, 0x1270, 5)}, /* ZTE MF667 */ -+ {QMI_FIXED_INTF(0x19d2, 0x1275, 3)}, /* ZTE P685M */ - {QMI_FIXED_INTF(0x19d2, 0x1401, 2)}, - {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */ - {QMI_FIXED_INTF(0x19d2, 0x1424, 2)}, -diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c -index 915ba2a7f7448..47b733fdf4fcb 100644 ---- a/drivers/net/wireless/ath/ath10k/mac.c -+++ b/drivers/net/wireless/ath/ath10k/mac.c -@@ -3624,23 +3624,16 @@ bool ath10k_mac_tx_frm_has_freq(struct ath10k *ar) - static int ath10k_mac_tx_wmi_mgmt(struct ath10k *ar, struct sk_buff *skb) - { - struct sk_buff_head *q = &ar->wmi_mgmt_tx_queue; -- int ret = 0; -- -- spin_lock_bh(&ar->data_lock); - -- if (skb_queue_len(q) == ATH10K_MAX_NUM_MGMT_PENDING) { -+ if (skb_queue_len_lockless(q) >= ATH10K_MAX_NUM_MGMT_PENDING) { - ath10k_warn(ar, "wmi mgmt tx queue is full\n"); -- ret = -ENOSPC; -- goto unlock; -+ return -ENOSPC; - } - -- __skb_queue_tail(q, skb); -+ skb_queue_tail(q, skb); - ieee80211_queue_work(ar->hw, &ar->wmi_mgmt_tx_work); - --unlock: -- spin_unlock_bh(&ar->data_lock); -- -- return ret; -+ return 0; - } - - static enum ath10k_mac_tx_path -diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c -index 4aa2561934d77..6d5188b78f2de 100644 ---- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c -+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/dmi.c -@@ -40,6 +40,18 @@ static const struct brcmf_dmi_data pov_tab_p1006w_data = { - BRCM_CC_43340_CHIP_ID, 2, "pov-tab-p1006w-data" - }; - -+static const struct brcmf_dmi_data predia_basic_data = { -+ BRCM_CC_43341_CHIP_ID, 2, "predia-basic" -+}; -+ -+/* Note the Voyo winpad A15 tablet uses the same Ampak AP6330 module, with the -+ * exact same nvram file as the Prowise-PT301 tablet. Since the nvram for the -+ * Prowise-PT301 is already in linux-firmware we just point to that here. -+ */ -+static const struct brcmf_dmi_data voyo_winpad_a15_data = { -+ BRCM_CC_4330_CHIP_ID, 4, "Prowise-PT301" -+}; -+ - static const struct dmi_system_id dmi_platform_data[] = { - { - /* ACEPC T8 Cherry Trail Z8350 mini PC */ -@@ -111,6 +123,26 @@ static const struct dmi_system_id dmi_platform_data[] = { - }, - .driver_data = (void *)&pov_tab_p1006w_data, - }, -+ { -+ /* Predia Basic tablet (+ with keyboard dock) */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "CherryTrail"), -+ /* Mx.WT107.KUBNGEA02 with the version-nr dropped */ -+ DMI_MATCH(DMI_BIOS_VERSION, "Mx.WT107.KUBNGEA"), -+ }, -+ .driver_data = (void *)&predia_basic_data, -+ }, -+ { -+ /* Voyo winpad A15 tablet */ -+ .matches = { -+ DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), -+ DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), -+ /* Above strings are too generic, also match on BIOS date */ -+ DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"), -+ }, -+ .driver_data = (void *)&voyo_winpad_a15_data, -+ }, - {} - }; - -diff --git a/drivers/net/wireless/rsi/rsi_91x_hal.c b/drivers/net/wireless/rsi/rsi_91x_hal.c -index 6f8d5f9a9f7e6..a07304405b2cc 100644 ---- a/drivers/net/wireless/rsi/rsi_91x_hal.c -+++ b/drivers/net/wireless/rsi/rsi_91x_hal.c -@@ -248,7 +248,8 @@ int rsi_prepare_data_desc(struct rsi_common *common, struct sk_buff *skb) - rsi_set_len_qno(&data_desc->len_qno, - (skb->len - FRAME_DESC_SZ), - RSI_WIFI_MGMT_Q); -- if ((skb->len - header_size) == EAPOL4_PACKET_LEN) { -+ if (((skb->len - header_size) == EAPOL4_PACKET_LEN) || -+ ((skb->len - header_size) == EAPOL4_PACKET_LEN - 2)) { - data_desc->misc_flags |= - RSI_DESC_REQUIRE_CFM_TO_HOST; - xtend_desc->confirm_frame_type = EAPOL4_CONFIRM; -diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio.c b/drivers/net/wireless/rsi/rsi_91x_sdio.c -index 1bebba4e85273..d1e8c6593ef51 100644 ---- a/drivers/net/wireless/rsi/rsi_91x_sdio.c -+++ b/drivers/net/wireless/rsi/rsi_91x_sdio.c -@@ -153,9 +153,7 @@ static void rsi_handle_interrupt(struct sdio_func *function) - if (adapter->priv->fsm_state == FSM_FW_NOT_LOADED) - return; - -- dev->sdio_irq_task = current; -- rsi_interrupt_handler(adapter); -- dev->sdio_irq_task = NULL; -+ rsi_set_event(&dev->rx_thread.event); - } - - /** -@@ -1059,8 +1057,6 @@ static int rsi_probe(struct sdio_func *pfunction, - rsi_dbg(ERR_ZONE, "%s: Unable to init rx thrd\n", __func__); - goto fail_kill_thread; - } -- skb_queue_head_init(&sdev->rx_q.head); -- sdev->rx_q.num_rx_pkts = 0; - - sdio_claim_host(pfunction); - if (sdio_claim_irq(pfunction, rsi_handle_interrupt)) { -diff --git a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c -index 449f6d23c5e36..7c77b09240da2 100644 ---- a/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c -+++ b/drivers/net/wireless/rsi/rsi_91x_sdio_ops.c -@@ -60,39 +60,20 @@ int rsi_sdio_master_access_msword(struct rsi_hw *adapter, u16 ms_word) - return status; - } - -+static void rsi_rx_handler(struct rsi_hw *adapter); -+ - void rsi_sdio_rx_thread(struct rsi_common *common) - { - struct rsi_hw *adapter = common->priv; - struct rsi_91x_sdiodev *sdev = adapter->rsi_dev; -- struct sk_buff *skb; -- int status; - - do { - rsi_wait_event(&sdev->rx_thread.event, EVENT_WAIT_FOREVER); - rsi_reset_event(&sdev->rx_thread.event); -+ rsi_rx_handler(adapter); -+ } while (!atomic_read(&sdev->rx_thread.thread_done)); - -- while (true) { -- if (atomic_read(&sdev->rx_thread.thread_done)) -- goto out; -- -- skb = skb_dequeue(&sdev->rx_q.head); -- if (!skb) -- break; -- if (sdev->rx_q.num_rx_pkts > 0) -- sdev->rx_q.num_rx_pkts--; -- status = rsi_read_pkt(common, skb->data, skb->len); -- if (status) { -- rsi_dbg(ERR_ZONE, "Failed to read the packet\n"); -- dev_kfree_skb(skb); -- break; -- } -- dev_kfree_skb(skb); -- } -- } while (1); -- --out: - rsi_dbg(INFO_ZONE, "%s: Terminated SDIO RX thread\n", __func__); -- skb_queue_purge(&sdev->rx_q.head); - atomic_inc(&sdev->rx_thread.thread_done); - complete_and_exit(&sdev->rx_thread.completion, 0); - } -@@ -113,10 +94,6 @@ static int rsi_process_pkt(struct rsi_common *common) - u32 rcv_pkt_len = 0; - int status = 0; - u8 value = 0; -- struct sk_buff *skb; -- -- if (dev->rx_q.num_rx_pkts >= RSI_MAX_RX_PKTS) -- return 0; - - num_blks = ((adapter->interrupt_status & 1) | - ((adapter->interrupt_status >> RECV_NUM_BLOCKS) << 1)); -@@ -144,22 +121,19 @@ static int rsi_process_pkt(struct rsi_common *common) - - rcv_pkt_len = (num_blks * 256); - -- skb = dev_alloc_skb(rcv_pkt_len); -- if (!skb) -- return -ENOMEM; -- -- status = rsi_sdio_host_intf_read_pkt(adapter, skb->data, rcv_pkt_len); -+ status = rsi_sdio_host_intf_read_pkt(adapter, dev->pktbuffer, -+ rcv_pkt_len); - if (status) { - rsi_dbg(ERR_ZONE, "%s: Failed to read packet from card\n", - __func__); -- dev_kfree_skb(skb); - return status; - } -- skb_put(skb, rcv_pkt_len); -- skb_queue_tail(&dev->rx_q.head, skb); -- dev->rx_q.num_rx_pkts++; - -- rsi_set_event(&dev->rx_thread.event); -+ status = rsi_read_pkt(common, dev->pktbuffer, rcv_pkt_len); -+ if (status) { -+ rsi_dbg(ERR_ZONE, "Failed to read the packet\n"); -+ return status; -+ } - - return 0; - } -@@ -251,12 +225,12 @@ int rsi_init_sdio_slave_regs(struct rsi_hw *adapter) - } - - /** -- * rsi_interrupt_handler() - This function read and process SDIO interrupts. -+ * rsi_rx_handler() - Read and process SDIO interrupts. - * @adapter: Pointer to the adapter structure. - * - * Return: None. - */ --void rsi_interrupt_handler(struct rsi_hw *adapter) -+static void rsi_rx_handler(struct rsi_hw *adapter) - { - struct rsi_common *common = adapter->priv; - struct rsi_91x_sdiodev *dev = -diff --git a/drivers/net/wireless/rsi/rsi_sdio.h b/drivers/net/wireless/rsi/rsi_sdio.h -index c5cfb6238f737..ce6cf65a577a4 100644 ---- a/drivers/net/wireless/rsi/rsi_sdio.h -+++ b/drivers/net/wireless/rsi/rsi_sdio.h -@@ -111,11 +111,6 @@ struct receive_info { - u32 buf_available_counter; - }; - --struct rsi_sdio_rx_q { -- u8 num_rx_pkts; -- struct sk_buff_head head; --}; -- - struct rsi_91x_sdiodev { - struct sdio_func *pfunction; - struct task_struct *sdio_irq_task; -@@ -128,11 +123,10 @@ struct rsi_91x_sdiodev { - u16 tx_blk_size; - u8 write_fail; - bool buff_status_updated; -- struct rsi_sdio_rx_q rx_q; - struct rsi_thread rx_thread; -+ u8 pktbuffer[8192] __aligned(4); - }; - --void rsi_interrupt_handler(struct rsi_hw *adapter); - int rsi_init_sdio_slave_regs(struct rsi_hw *adapter); - int rsi_sdio_read_register(struct rsi_hw *adapter, u32 addr, u8 *data); - int rsi_sdio_host_intf_read_pkt(struct rsi_hw *adapter, u8 *pkt, u32 length); -diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c -index 3c9c623bb4283..9d7dbfe7fe0c3 100644 ---- a/drivers/net/wireless/ti/wl12xx/main.c -+++ b/drivers/net/wireless/ti/wl12xx/main.c -@@ -635,7 +635,6 @@ static int wl12xx_identify_chip(struct wl1271 *wl) - wl->quirks |= WLCORE_QUIRK_LEGACY_NVS | - WLCORE_QUIRK_DUAL_PROBE_TMPL | - WLCORE_QUIRK_TKIP_HEADER_SPACE | -- WLCORE_QUIRK_START_STA_FAILS | - WLCORE_QUIRK_AP_ZERO_SESSION_ID; - wl->sr_fw_name = WL127X_FW_NAME_SINGLE; - wl->mr_fw_name = WL127X_FW_NAME_MULTI; -@@ -659,7 +658,6 @@ static int wl12xx_identify_chip(struct wl1271 *wl) - wl->quirks |= WLCORE_QUIRK_LEGACY_NVS | - WLCORE_QUIRK_DUAL_PROBE_TMPL | - WLCORE_QUIRK_TKIP_HEADER_SPACE | -- WLCORE_QUIRK_START_STA_FAILS | - WLCORE_QUIRK_AP_ZERO_SESSION_ID; - wl->plt_fw_name = WL127X_PLT_FW_NAME; - wl->sr_fw_name = WL127X_FW_NAME_SINGLE; -@@ -688,7 +686,6 @@ static int wl12xx_identify_chip(struct wl1271 *wl) - wl->quirks |= WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN | - WLCORE_QUIRK_DUAL_PROBE_TMPL | - WLCORE_QUIRK_TKIP_HEADER_SPACE | -- WLCORE_QUIRK_START_STA_FAILS | - WLCORE_QUIRK_AP_ZERO_SESSION_ID; - - wlcore_set_min_fw_ver(wl, WL128X_CHIP_VER, -diff --git a/drivers/net/wireless/ti/wlcore/main.c b/drivers/net/wireless/ti/wlcore/main.c -index 5f74cf821068d..be0ed19f93569 100644 ---- a/drivers/net/wireless/ti/wlcore/main.c -+++ b/drivers/net/wireless/ti/wlcore/main.c -@@ -2862,21 +2862,8 @@ static int wlcore_join(struct wl1271 *wl, struct wl12xx_vif *wlvif) - - if (is_ibss) - ret = wl12xx_cmd_role_start_ibss(wl, wlvif); -- else { -- if (wl->quirks & WLCORE_QUIRK_START_STA_FAILS) { -- /* -- * TODO: this is an ugly workaround for wl12xx fw -- * bug - we are not able to tx/rx after the first -- * start_sta, so make dummy start+stop calls, -- * and then call start_sta again. -- * this should be fixed in the fw. -- */ -- wl12xx_cmd_role_start_sta(wl, wlvif); -- wl12xx_cmd_role_stop_sta(wl, wlvif); -- } -- -+ else - ret = wl12xx_cmd_role_start_sta(wl, wlvif); -- } - - return ret; - } -diff --git a/drivers/net/wireless/ti/wlcore/wlcore.h b/drivers/net/wireless/ti/wlcore/wlcore.h -index b7821311ac75b..81c94d390623b 100644 ---- a/drivers/net/wireless/ti/wlcore/wlcore.h -+++ b/drivers/net/wireless/ti/wlcore/wlcore.h -@@ -547,9 +547,6 @@ wlcore_set_min_fw_ver(struct wl1271 *wl, unsigned int chip, - /* Each RX/TX transaction requires an end-of-transaction transfer */ - #define WLCORE_QUIRK_END_OF_TRANSACTION BIT(0) - --/* the first start_role(sta) sometimes doesn't work on wl12xx */ --#define WLCORE_QUIRK_START_STA_FAILS BIT(1) -- - /* wl127x and SPI don't support SDIO block size alignment */ - #define WLCORE_QUIRK_TX_BLOCKSIZE_ALIGN BIT(2) - -diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c -index 4bfafcd6317f4..c213f2b812691 100644 ---- a/drivers/net/xen-netback/netback.c -+++ b/drivers/net/xen-netback/netback.c -@@ -1335,11 +1335,21 @@ int xenvif_tx_action(struct xenvif_queue *queue, int budget) - return 0; - - gnttab_batch_copy(queue->tx_copy_ops, nr_cops); -- if (nr_mops != 0) -+ if (nr_mops != 0) { - ret = gnttab_map_refs(queue->tx_map_ops, - NULL, - queue->pages_to_map, - nr_mops); -+ if (ret) { -+ unsigned int i; -+ -+ netdev_err(queue->vif->dev, "Map fail: nr %u ret %d\n", -+ nr_mops, ret); -+ for (i = 0; i < nr_mops; ++i) -+ WARN_ON_ONCE(queue->tx_map_ops[i].status == -+ GNTST_okay); -+ } -+ } - - work_done = xenvif_tx_submit(queue); - -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index c2cabd77884bf..95d77a17375e1 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -317,6 +317,26 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved) - } - EXPORT_SYMBOL_GPL(nvme_cancel_request); - -+void nvme_cancel_tagset(struct nvme_ctrl *ctrl) -+{ -+ if (ctrl->tagset) { -+ blk_mq_tagset_busy_iter(ctrl->tagset, -+ nvme_cancel_request, ctrl); -+ blk_mq_tagset_wait_completed_request(ctrl->tagset); -+ } -+} -+EXPORT_SYMBOL_GPL(nvme_cancel_tagset); -+ -+void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl) -+{ -+ if (ctrl->admin_tagset) { -+ blk_mq_tagset_busy_iter(ctrl->admin_tagset, -+ nvme_cancel_request, ctrl); -+ blk_mq_tagset_wait_completed_request(ctrl->admin_tagset); -+ } -+} -+EXPORT_SYMBOL_GPL(nvme_cancel_admin_tagset); -+ - bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, - enum nvme_ctrl_state new_state) - { -diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h -index e392d6cd92ced..62e5401865fee 100644 ---- a/drivers/nvme/host/nvme.h -+++ b/drivers/nvme/host/nvme.h -@@ -468,6 +468,8 @@ static inline void nvme_put_ctrl(struct nvme_ctrl *ctrl) - - void nvme_complete_rq(struct request *req); - bool nvme_cancel_request(struct request *req, void *data, bool reserved); -+void nvme_cancel_tagset(struct nvme_ctrl *ctrl); -+void nvme_cancel_admin_tagset(struct nvme_ctrl *ctrl); - bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, - enum nvme_ctrl_state new_state); - bool nvme_wait_reset(struct nvme_ctrl *ctrl); -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index 19e375b59f407..abc342db3b337 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -528,50 +528,71 @@ static inline bool nvme_pci_use_sgls(struct nvme_dev *dev, struct request *req) - return true; - } - --static void nvme_unmap_data(struct nvme_dev *dev, struct request *req) -+static void nvme_free_prps(struct nvme_dev *dev, struct request *req) - { -- struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - const int last_prp = dev->ctrl.page_size / sizeof(__le64) - 1; -- dma_addr_t dma_addr = iod->first_dma, next_dma_addr; -+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req); -+ dma_addr_t dma_addr = iod->first_dma; - int i; - -- if (iod->dma_len) { -- dma_unmap_page(dev->dev, dma_addr, iod->dma_len, -- rq_dma_dir(req)); -- return; -+ for (i = 0; i < iod->npages; i++) { -+ __le64 *prp_list = nvme_pci_iod_list(req)[i]; -+ dma_addr_t next_dma_addr = le64_to_cpu(prp_list[last_prp]); -+ -+ dma_pool_free(dev->prp_page_pool, prp_list, dma_addr); -+ dma_addr = next_dma_addr; - } - -- WARN_ON_ONCE(!iod->nents); -+} - -- if (is_pci_p2pdma_page(sg_page(iod->sg))) -- pci_p2pdma_unmap_sg(dev->dev, iod->sg, iod->nents, -- rq_dma_dir(req)); -- else -- dma_unmap_sg(dev->dev, iod->sg, iod->nents, rq_dma_dir(req)); -+static void nvme_free_sgls(struct nvme_dev *dev, struct request *req) -+{ -+ const int last_sg = SGES_PER_PAGE - 1; -+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req); -+ dma_addr_t dma_addr = iod->first_dma; -+ int i; - -+ for (i = 0; i < iod->npages; i++) { -+ struct nvme_sgl_desc *sg_list = nvme_pci_iod_list(req)[i]; -+ dma_addr_t next_dma_addr = le64_to_cpu((sg_list[last_sg]).addr); - -- if (iod->npages == 0) -- dma_pool_free(dev->prp_small_pool, nvme_pci_iod_list(req)[0], -- dma_addr); -+ dma_pool_free(dev->prp_page_pool, sg_list, dma_addr); -+ dma_addr = next_dma_addr; -+ } - -- for (i = 0; i < iod->npages; i++) { -- void *addr = nvme_pci_iod_list(req)[i]; -+} - -- if (iod->use_sgl) { -- struct nvme_sgl_desc *sg_list = addr; -+static void nvme_unmap_sg(struct nvme_dev *dev, struct request *req) -+{ -+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - -- next_dma_addr = -- le64_to_cpu((sg_list[SGES_PER_PAGE - 1]).addr); -- } else { -- __le64 *prp_list = addr; -+ if (is_pci_p2pdma_page(sg_page(iod->sg))) -+ pci_p2pdma_unmap_sg(dev->dev, iod->sg, iod->nents, -+ rq_dma_dir(req)); -+ else -+ dma_unmap_sg(dev->dev, iod->sg, iod->nents, rq_dma_dir(req)); -+} - -- next_dma_addr = le64_to_cpu(prp_list[last_prp]); -- } -+static void nvme_unmap_data(struct nvme_dev *dev, struct request *req) -+{ -+ struct nvme_iod *iod = blk_mq_rq_to_pdu(req); - -- dma_pool_free(dev->prp_page_pool, addr, dma_addr); -- dma_addr = next_dma_addr; -+ if (iod->dma_len) { -+ dma_unmap_page(dev->dev, iod->first_dma, iod->dma_len, -+ rq_dma_dir(req)); -+ return; - } - -+ WARN_ON_ONCE(!iod->nents); -+ -+ nvme_unmap_sg(dev, req); -+ if (iod->npages == 0) -+ dma_pool_free(dev->prp_small_pool, nvme_pci_iod_list(req)[0], -+ iod->first_dma); -+ else if (iod->use_sgl) -+ nvme_free_sgls(dev, req); -+ else -+ nvme_free_prps(dev, req); - mempool_free(iod->sg, dev->iod_mempool); - } - -@@ -648,7 +669,7 @@ static blk_status_t nvme_pci_setup_prps(struct nvme_dev *dev, - __le64 *old_prp_list = prp_list; - prp_list = dma_pool_alloc(pool, GFP_ATOMIC, &prp_dma); - if (!prp_list) -- return BLK_STS_RESOURCE; -+ goto free_prps; - list[iod->npages++] = prp_list; - prp_list[0] = old_prp_list[i - 1]; - old_prp_list[i - 1] = cpu_to_le64(prp_dma); -@@ -668,14 +689,14 @@ static blk_status_t nvme_pci_setup_prps(struct nvme_dev *dev, - dma_addr = sg_dma_address(sg); - dma_len = sg_dma_len(sg); - } -- - done: - cmnd->dptr.prp1 = cpu_to_le64(sg_dma_address(iod->sg)); - cmnd->dptr.prp2 = cpu_to_le64(iod->first_dma); -- - return BLK_STS_OK; -- -- bad_sgl: -+free_prps: -+ nvme_free_prps(dev, req); -+ return BLK_STS_RESOURCE; -+bad_sgl: - WARN(DO_ONCE(nvme_print_sgl, iod->sg, iod->nents), - "Invalid SGL for payload:%d nents:%d\n", - blk_rq_payload_bytes(req), iod->nents); -@@ -747,7 +768,7 @@ static blk_status_t nvme_pci_setup_sgls(struct nvme_dev *dev, - - sg_list = dma_pool_alloc(pool, GFP_ATOMIC, &sgl_dma); - if (!sg_list) -- return BLK_STS_RESOURCE; -+ goto free_sgls; - - i = 0; - nvme_pci_iod_list(req)[iod->npages++] = sg_list; -@@ -760,6 +781,9 @@ static blk_status_t nvme_pci_setup_sgls(struct nvme_dev *dev, - } while (--entries > 0); - - return BLK_STS_OK; -+free_sgls: -+ nvme_free_sgls(dev, req); -+ return BLK_STS_RESOURCE; - } - - static blk_status_t nvme_setup_prp_simple(struct nvme_dev *dev, -@@ -828,7 +852,7 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, - sg_init_table(iod->sg, blk_rq_nr_phys_segments(req)); - iod->nents = blk_rq_map_sg(req->q, req, iod->sg); - if (!iod->nents) -- goto out; -+ goto out_free_sg; - - if (is_pci_p2pdma_page(sg_page(iod->sg))) - nr_mapped = pci_p2pdma_map_sg_attrs(dev->dev, iod->sg, -@@ -837,16 +861,21 @@ static blk_status_t nvme_map_data(struct nvme_dev *dev, struct request *req, - nr_mapped = dma_map_sg_attrs(dev->dev, iod->sg, iod->nents, - rq_dma_dir(req), DMA_ATTR_NO_WARN); - if (!nr_mapped) -- goto out; -+ goto out_free_sg; - - iod->use_sgl = nvme_pci_use_sgls(dev, req); - if (iod->use_sgl) - ret = nvme_pci_setup_sgls(dev, req, &cmnd->rw, nr_mapped); - else - ret = nvme_pci_setup_prps(dev, req, &cmnd->rw); --out: - if (ret != BLK_STS_OK) -- nvme_unmap_data(dev, req); -+ goto out_unmap_sg; -+ return BLK_STS_OK; -+ -+out_unmap_sg: -+ nvme_unmap_sg(dev, req); -+out_free_sg: -+ mempool_free(iod->sg, dev->iod_mempool); - return ret; - } - -diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c -index 8a62c2fe5a5ec..da60300104322 100644 ---- a/drivers/nvme/host/rdma.c -+++ b/drivers/nvme/host/rdma.c -@@ -835,12 +835,16 @@ static int nvme_rdma_configure_admin_queue(struct nvme_rdma_ctrl *ctrl, - - error = nvme_init_identify(&ctrl->ctrl); - if (error) -- goto out_stop_queue; -+ goto out_quiesce_queue; - - return 0; - -+out_quiesce_queue: -+ blk_mq_quiesce_queue(ctrl->ctrl.admin_q); -+ blk_sync_queue(ctrl->ctrl.admin_q); - out_stop_queue: - nvme_rdma_stop_queue(&ctrl->queues[0]); -+ nvme_cancel_admin_tagset(&ctrl->ctrl); - out_cleanup_queue: - if (new) - blk_cleanup_queue(ctrl->ctrl.admin_q); -@@ -917,8 +921,10 @@ static int nvme_rdma_configure_io_queues(struct nvme_rdma_ctrl *ctrl, bool new) - - out_wait_freeze_timed_out: - nvme_stop_queues(&ctrl->ctrl); -+ nvme_sync_io_queues(&ctrl->ctrl); - nvme_rdma_stop_io_queues(ctrl); - out_cleanup_connect_q: -+ nvme_cancel_tagset(&ctrl->ctrl); - if (new) - blk_cleanup_queue(ctrl->ctrl.connect_q); - out_free_tag_set: -@@ -1054,10 +1060,18 @@ static int nvme_rdma_setup_ctrl(struct nvme_rdma_ctrl *ctrl, bool new) - return 0; - - destroy_io: -- if (ctrl->ctrl.queue_count > 1) -+ if (ctrl->ctrl.queue_count > 1) { -+ nvme_stop_queues(&ctrl->ctrl); -+ nvme_sync_io_queues(&ctrl->ctrl); -+ nvme_rdma_stop_io_queues(ctrl); -+ nvme_cancel_tagset(&ctrl->ctrl); - nvme_rdma_destroy_io_queues(ctrl, new); -+ } - destroy_admin: -+ blk_mq_quiesce_queue(ctrl->ctrl.admin_q); -+ blk_sync_queue(ctrl->ctrl.admin_q); - nvme_rdma_stop_queue(&ctrl->queues[0]); -+ nvme_cancel_admin_tagset(&ctrl->ctrl); - nvme_rdma_destroy_admin_queue(ctrl, new); - return ret; - } -diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c -index a554021e1ab92..77a3c488ec120 100644 ---- a/drivers/nvme/host/tcp.c -+++ b/drivers/nvme/host/tcp.c -@@ -1710,8 +1710,10 @@ static int nvme_tcp_configure_io_queues(struct nvme_ctrl *ctrl, bool new) - - out_wait_freeze_timed_out: - nvme_stop_queues(ctrl); -+ nvme_sync_io_queues(ctrl); - nvme_tcp_stop_io_queues(ctrl); - out_cleanup_connect_q: -+ nvme_cancel_tagset(ctrl); - if (new) - blk_cleanup_queue(ctrl->connect_q); - out_free_tag_set: -@@ -1773,12 +1775,16 @@ static int nvme_tcp_configure_admin_queue(struct nvme_ctrl *ctrl, bool new) - - error = nvme_init_identify(ctrl); - if (error) -- goto out_stop_queue; -+ goto out_quiesce_queue; - - return 0; - -+out_quiesce_queue: -+ blk_mq_quiesce_queue(ctrl->admin_q); -+ blk_sync_queue(ctrl->admin_q); - out_stop_queue: - nvme_tcp_stop_queue(ctrl, 0); -+ nvme_cancel_admin_tagset(ctrl); - out_cleanup_queue: - if (new) - blk_cleanup_queue(ctrl->admin_q); -@@ -1892,10 +1898,18 @@ static int nvme_tcp_setup_ctrl(struct nvme_ctrl *ctrl, bool new) - return 0; - - destroy_io: -- if (ctrl->queue_count > 1) -+ if (ctrl->queue_count > 1) { -+ nvme_stop_queues(ctrl); -+ nvme_sync_io_queues(ctrl); -+ nvme_tcp_stop_io_queues(ctrl); -+ nvme_cancel_tagset(ctrl); - nvme_tcp_destroy_io_queues(ctrl, new); -+ } - destroy_admin: -+ blk_mq_quiesce_queue(ctrl->admin_q); -+ blk_sync_queue(ctrl->admin_q); - nvme_tcp_stop_queue(ctrl, 0); -+ nvme_cancel_admin_tagset(ctrl); - nvme_tcp_destroy_admin_queue(ctrl, new); - return ret; - } -diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c -index 89dece8a41321..9add26438be50 100644 ---- a/drivers/pci/pci.c -+++ b/drivers/pci/pci.c -@@ -3471,7 +3471,14 @@ u32 pci_rebar_get_possible_sizes(struct pci_dev *pdev, int bar) - return 0; - - pci_read_config_dword(pdev, pos + PCI_REBAR_CAP, &cap); -- return (cap & PCI_REBAR_CAP_SIZES) >> 4; -+ cap &= PCI_REBAR_CAP_SIZES; -+ -+ /* Sapphire RX 5600 XT Pulse has an invalid cap dword for BAR 0 */ -+ if (pdev->vendor == PCI_VENDOR_ID_ATI && pdev->device == 0x731f && -+ bar == 0 && cap == 0x7000) -+ cap = 0x3f000; -+ -+ return cap >> 4; - } - - /** -diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c -index f954be3d5ee22..a14057c67a12a 100644 ---- a/drivers/scsi/libiscsi.c -+++ b/drivers/scsi/libiscsi.c -@@ -3331,125 +3331,125 @@ int iscsi_session_get_param(struct iscsi_cls_session *cls_session, - - switch(param) { - case ISCSI_PARAM_FAST_ABORT: -- len = sprintf(buf, "%d\n", session->fast_abort); -+ len = sysfs_emit(buf, "%d\n", session->fast_abort); - break; - case ISCSI_PARAM_ABORT_TMO: -- len = sprintf(buf, "%d\n", session->abort_timeout); -+ len = sysfs_emit(buf, "%d\n", session->abort_timeout); - break; - case ISCSI_PARAM_LU_RESET_TMO: -- len = sprintf(buf, "%d\n", session->lu_reset_timeout); -+ len = sysfs_emit(buf, "%d\n", session->lu_reset_timeout); - break; - case ISCSI_PARAM_TGT_RESET_TMO: -- len = sprintf(buf, "%d\n", session->tgt_reset_timeout); -+ len = sysfs_emit(buf, "%d\n", session->tgt_reset_timeout); - break; - case ISCSI_PARAM_INITIAL_R2T_EN: -- len = sprintf(buf, "%d\n", session->initial_r2t_en); -+ len = sysfs_emit(buf, "%d\n", session->initial_r2t_en); - break; - case ISCSI_PARAM_MAX_R2T: -- len = sprintf(buf, "%hu\n", session->max_r2t); -+ len = sysfs_emit(buf, "%hu\n", session->max_r2t); - break; - case ISCSI_PARAM_IMM_DATA_EN: -- len = sprintf(buf, "%d\n", session->imm_data_en); -+ len = sysfs_emit(buf, "%d\n", session->imm_data_en); - break; - case ISCSI_PARAM_FIRST_BURST: -- len = sprintf(buf, "%u\n", session->first_burst); -+ len = sysfs_emit(buf, "%u\n", session->first_burst); - break; - case ISCSI_PARAM_MAX_BURST: -- len = sprintf(buf, "%u\n", session->max_burst); -+ len = sysfs_emit(buf, "%u\n", session->max_burst); - break; - case ISCSI_PARAM_PDU_INORDER_EN: -- len = sprintf(buf, "%d\n", session->pdu_inorder_en); -+ len = sysfs_emit(buf, "%d\n", session->pdu_inorder_en); - break; - case ISCSI_PARAM_DATASEQ_INORDER_EN: -- len = sprintf(buf, "%d\n", session->dataseq_inorder_en); -+ len = sysfs_emit(buf, "%d\n", session->dataseq_inorder_en); - break; - case ISCSI_PARAM_DEF_TASKMGMT_TMO: -- len = sprintf(buf, "%d\n", session->def_taskmgmt_tmo); -+ len = sysfs_emit(buf, "%d\n", session->def_taskmgmt_tmo); - break; - case ISCSI_PARAM_ERL: -- len = sprintf(buf, "%d\n", session->erl); -+ len = sysfs_emit(buf, "%d\n", session->erl); - break; - case ISCSI_PARAM_TARGET_NAME: -- len = sprintf(buf, "%s\n", session->targetname); -+ len = sysfs_emit(buf, "%s\n", session->targetname); - break; - case ISCSI_PARAM_TARGET_ALIAS: -- len = sprintf(buf, "%s\n", session->targetalias); -+ len = sysfs_emit(buf, "%s\n", session->targetalias); - break; - case ISCSI_PARAM_TPGT: -- len = sprintf(buf, "%d\n", session->tpgt); -+ len = sysfs_emit(buf, "%d\n", session->tpgt); - break; - case ISCSI_PARAM_USERNAME: -- len = sprintf(buf, "%s\n", session->username); -+ len = sysfs_emit(buf, "%s\n", session->username); - break; - case ISCSI_PARAM_USERNAME_IN: -- len = sprintf(buf, "%s\n", session->username_in); -+ len = sysfs_emit(buf, "%s\n", session->username_in); - break; - case ISCSI_PARAM_PASSWORD: -- len = sprintf(buf, "%s\n", session->password); -+ len = sysfs_emit(buf, "%s\n", session->password); - break; - case ISCSI_PARAM_PASSWORD_IN: -- len = sprintf(buf, "%s\n", session->password_in); -+ len = sysfs_emit(buf, "%s\n", session->password_in); - break; - case ISCSI_PARAM_IFACE_NAME: -- len = sprintf(buf, "%s\n", session->ifacename); -+ len = sysfs_emit(buf, "%s\n", session->ifacename); - break; - case ISCSI_PARAM_INITIATOR_NAME: -- len = sprintf(buf, "%s\n", session->initiatorname); -+ len = sysfs_emit(buf, "%s\n", session->initiatorname); - break; - case ISCSI_PARAM_BOOT_ROOT: -- len = sprintf(buf, "%s\n", session->boot_root); -+ len = sysfs_emit(buf, "%s\n", session->boot_root); - break; - case ISCSI_PARAM_BOOT_NIC: -- len = sprintf(buf, "%s\n", session->boot_nic); -+ len = sysfs_emit(buf, "%s\n", session->boot_nic); - break; - case ISCSI_PARAM_BOOT_TARGET: -- len = sprintf(buf, "%s\n", session->boot_target); -+ len = sysfs_emit(buf, "%s\n", session->boot_target); - break; - case ISCSI_PARAM_AUTO_SND_TGT_DISABLE: -- len = sprintf(buf, "%u\n", session->auto_snd_tgt_disable); -+ len = sysfs_emit(buf, "%u\n", session->auto_snd_tgt_disable); - break; - case ISCSI_PARAM_DISCOVERY_SESS: -- len = sprintf(buf, "%u\n", session->discovery_sess); -+ len = sysfs_emit(buf, "%u\n", session->discovery_sess); - break; - case ISCSI_PARAM_PORTAL_TYPE: -- len = sprintf(buf, "%s\n", session->portal_type); -+ len = sysfs_emit(buf, "%s\n", session->portal_type); - break; - case ISCSI_PARAM_CHAP_AUTH_EN: -- len = sprintf(buf, "%u\n", session->chap_auth_en); -+ len = sysfs_emit(buf, "%u\n", session->chap_auth_en); - break; - case ISCSI_PARAM_DISCOVERY_LOGOUT_EN: -- len = sprintf(buf, "%u\n", session->discovery_logout_en); -+ len = sysfs_emit(buf, "%u\n", session->discovery_logout_en); - break; - case ISCSI_PARAM_BIDI_CHAP_EN: -- len = sprintf(buf, "%u\n", session->bidi_chap_en); -+ len = sysfs_emit(buf, "%u\n", session->bidi_chap_en); - break; - case ISCSI_PARAM_DISCOVERY_AUTH_OPTIONAL: -- len = sprintf(buf, "%u\n", session->discovery_auth_optional); -+ len = sysfs_emit(buf, "%u\n", session->discovery_auth_optional); - break; - case ISCSI_PARAM_DEF_TIME2WAIT: -- len = sprintf(buf, "%d\n", session->time2wait); -+ len = sysfs_emit(buf, "%d\n", session->time2wait); - break; - case ISCSI_PARAM_DEF_TIME2RETAIN: -- len = sprintf(buf, "%d\n", session->time2retain); -+ len = sysfs_emit(buf, "%d\n", session->time2retain); - break; - case ISCSI_PARAM_TSID: -- len = sprintf(buf, "%u\n", session->tsid); -+ len = sysfs_emit(buf, "%u\n", session->tsid); - break; - case ISCSI_PARAM_ISID: -- len = sprintf(buf, "%02x%02x%02x%02x%02x%02x\n", -+ len = sysfs_emit(buf, "%02x%02x%02x%02x%02x%02x\n", - session->isid[0], session->isid[1], - session->isid[2], session->isid[3], - session->isid[4], session->isid[5]); - break; - case ISCSI_PARAM_DISCOVERY_PARENT_IDX: -- len = sprintf(buf, "%u\n", session->discovery_parent_idx); -+ len = sysfs_emit(buf, "%u\n", session->discovery_parent_idx); - break; - case ISCSI_PARAM_DISCOVERY_PARENT_TYPE: - if (session->discovery_parent_type) -- len = sprintf(buf, "%s\n", -+ len = sysfs_emit(buf, "%s\n", - session->discovery_parent_type); - else -- len = sprintf(buf, "\n"); -+ len = sysfs_emit(buf, "\n"); - break; - default: - return -ENOSYS; -@@ -3481,16 +3481,16 @@ int iscsi_conn_get_addr_param(struct sockaddr_storage *addr, - case ISCSI_PARAM_CONN_ADDRESS: - case ISCSI_HOST_PARAM_IPADDRESS: - if (sin) -- len = sprintf(buf, "%pI4\n", &sin->sin_addr.s_addr); -+ len = sysfs_emit(buf, "%pI4\n", &sin->sin_addr.s_addr); - else -- len = sprintf(buf, "%pI6\n", &sin6->sin6_addr); -+ len = sysfs_emit(buf, "%pI6\n", &sin6->sin6_addr); - break; - case ISCSI_PARAM_CONN_PORT: - case ISCSI_PARAM_LOCAL_PORT: - if (sin) -- len = sprintf(buf, "%hu\n", be16_to_cpu(sin->sin_port)); -+ len = sysfs_emit(buf, "%hu\n", be16_to_cpu(sin->sin_port)); - else -- len = sprintf(buf, "%hu\n", -+ len = sysfs_emit(buf, "%hu\n", - be16_to_cpu(sin6->sin6_port)); - break; - default: -@@ -3509,88 +3509,88 @@ int iscsi_conn_get_param(struct iscsi_cls_conn *cls_conn, - - switch(param) { - case ISCSI_PARAM_PING_TMO: -- len = sprintf(buf, "%u\n", conn->ping_timeout); -+ len = sysfs_emit(buf, "%u\n", conn->ping_timeout); - break; - case ISCSI_PARAM_RECV_TMO: -- len = sprintf(buf, "%u\n", conn->recv_timeout); -+ len = sysfs_emit(buf, "%u\n", conn->recv_timeout); - break; - case ISCSI_PARAM_MAX_RECV_DLENGTH: -- len = sprintf(buf, "%u\n", conn->max_recv_dlength); -+ len = sysfs_emit(buf, "%u\n", conn->max_recv_dlength); - break; - case ISCSI_PARAM_MAX_XMIT_DLENGTH: -- len = sprintf(buf, "%u\n", conn->max_xmit_dlength); -+ len = sysfs_emit(buf, "%u\n", conn->max_xmit_dlength); - break; - case ISCSI_PARAM_HDRDGST_EN: -- len = sprintf(buf, "%d\n", conn->hdrdgst_en); -+ len = sysfs_emit(buf, "%d\n", conn->hdrdgst_en); - break; - case ISCSI_PARAM_DATADGST_EN: -- len = sprintf(buf, "%d\n", conn->datadgst_en); -+ len = sysfs_emit(buf, "%d\n", conn->datadgst_en); - break; - case ISCSI_PARAM_IFMARKER_EN: -- len = sprintf(buf, "%d\n", conn->ifmarker_en); -+ len = sysfs_emit(buf, "%d\n", conn->ifmarker_en); - break; - case ISCSI_PARAM_OFMARKER_EN: -- len = sprintf(buf, "%d\n", conn->ofmarker_en); -+ len = sysfs_emit(buf, "%d\n", conn->ofmarker_en); - break; - case ISCSI_PARAM_EXP_STATSN: -- len = sprintf(buf, "%u\n", conn->exp_statsn); -+ len = sysfs_emit(buf, "%u\n", conn->exp_statsn); - break; - case ISCSI_PARAM_PERSISTENT_PORT: -- len = sprintf(buf, "%d\n", conn->persistent_port); -+ len = sysfs_emit(buf, "%d\n", conn->persistent_port); - break; - case ISCSI_PARAM_PERSISTENT_ADDRESS: -- len = sprintf(buf, "%s\n", conn->persistent_address); -+ len = sysfs_emit(buf, "%s\n", conn->persistent_address); - break; - case ISCSI_PARAM_STATSN: -- len = sprintf(buf, "%u\n", conn->statsn); -+ len = sysfs_emit(buf, "%u\n", conn->statsn); - break; - case ISCSI_PARAM_MAX_SEGMENT_SIZE: -- len = sprintf(buf, "%u\n", conn->max_segment_size); -+ len = sysfs_emit(buf, "%u\n", conn->max_segment_size); - break; - case ISCSI_PARAM_KEEPALIVE_TMO: -- len = sprintf(buf, "%u\n", conn->keepalive_tmo); -+ len = sysfs_emit(buf, "%u\n", conn->keepalive_tmo); - break; - case ISCSI_PARAM_LOCAL_PORT: -- len = sprintf(buf, "%u\n", conn->local_port); -+ len = sysfs_emit(buf, "%u\n", conn->local_port); - break; - case ISCSI_PARAM_TCP_TIMESTAMP_STAT: -- len = sprintf(buf, "%u\n", conn->tcp_timestamp_stat); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_timestamp_stat); - break; - case ISCSI_PARAM_TCP_NAGLE_DISABLE: -- len = sprintf(buf, "%u\n", conn->tcp_nagle_disable); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_nagle_disable); - break; - case ISCSI_PARAM_TCP_WSF_DISABLE: -- len = sprintf(buf, "%u\n", conn->tcp_wsf_disable); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_wsf_disable); - break; - case ISCSI_PARAM_TCP_TIMER_SCALE: -- len = sprintf(buf, "%u\n", conn->tcp_timer_scale); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_timer_scale); - break; - case ISCSI_PARAM_TCP_TIMESTAMP_EN: -- len = sprintf(buf, "%u\n", conn->tcp_timestamp_en); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_timestamp_en); - break; - case ISCSI_PARAM_IP_FRAGMENT_DISABLE: -- len = sprintf(buf, "%u\n", conn->fragment_disable); -+ len = sysfs_emit(buf, "%u\n", conn->fragment_disable); - break; - case ISCSI_PARAM_IPV4_TOS: -- len = sprintf(buf, "%u\n", conn->ipv4_tos); -+ len = sysfs_emit(buf, "%u\n", conn->ipv4_tos); - break; - case ISCSI_PARAM_IPV6_TC: -- len = sprintf(buf, "%u\n", conn->ipv6_traffic_class); -+ len = sysfs_emit(buf, "%u\n", conn->ipv6_traffic_class); - break; - case ISCSI_PARAM_IPV6_FLOW_LABEL: -- len = sprintf(buf, "%u\n", conn->ipv6_flow_label); -+ len = sysfs_emit(buf, "%u\n", conn->ipv6_flow_label); - break; - case ISCSI_PARAM_IS_FW_ASSIGNED_IPV6: -- len = sprintf(buf, "%u\n", conn->is_fw_assigned_ipv6); -+ len = sysfs_emit(buf, "%u\n", conn->is_fw_assigned_ipv6); - break; - case ISCSI_PARAM_TCP_XMIT_WSF: -- len = sprintf(buf, "%u\n", conn->tcp_xmit_wsf); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_xmit_wsf); - break; - case ISCSI_PARAM_TCP_RECV_WSF: -- len = sprintf(buf, "%u\n", conn->tcp_recv_wsf); -+ len = sysfs_emit(buf, "%u\n", conn->tcp_recv_wsf); - break; - case ISCSI_PARAM_LOCAL_IPADDR: -- len = sprintf(buf, "%s\n", conn->local_ipaddr); -+ len = sysfs_emit(buf, "%s\n", conn->local_ipaddr); - break; - default: - return -ENOSYS; -@@ -3608,13 +3608,13 @@ int iscsi_host_get_param(struct Scsi_Host *shost, enum iscsi_host_param param, - - switch (param) { - case ISCSI_HOST_PARAM_NETDEV_NAME: -- len = sprintf(buf, "%s\n", ihost->netdev); -+ len = sysfs_emit(buf, "%s\n", ihost->netdev); - break; - case ISCSI_HOST_PARAM_HWADDRESS: -- len = sprintf(buf, "%s\n", ihost->hwaddress); -+ len = sysfs_emit(buf, "%s\n", ihost->hwaddress); - break; - case ISCSI_HOST_PARAM_INITIATOR_NAME: -- len = sprintf(buf, "%s\n", ihost->initiatorname); -+ len = sysfs_emit(buf, "%s\n", ihost->initiatorname); - break; - default: - return -ENOSYS; -diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c -index dbad926e8f87f..a26df7d6d5d18 100644 ---- a/drivers/scsi/scsi_transport_iscsi.c -+++ b/drivers/scsi/scsi_transport_iscsi.c -@@ -124,7 +124,11 @@ show_transport_handle(struct device *dev, struct device_attribute *attr, - char *buf) - { - struct iscsi_internal *priv = dev_to_iscsi_internal(dev); -- return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); -+ -+ if (!capable(CAP_SYS_ADMIN)) -+ return -EACCES; -+ return sysfs_emit(buf, "%llu\n", -+ (unsigned long long)iscsi_handle(priv->iscsi_transport)); - } - static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); - -@@ -134,7 +138,7 @@ show_transport_##name(struct device *dev, \ - struct device_attribute *attr,char *buf) \ - { \ - struct iscsi_internal *priv = dev_to_iscsi_internal(dev); \ -- return sprintf(buf, format"\n", priv->iscsi_transport->name); \ -+ return sysfs_emit(buf, format"\n", priv->iscsi_transport->name);\ - } \ - static DEVICE_ATTR(name, S_IRUGO, show_transport_##name, NULL); - -@@ -175,7 +179,7 @@ static ssize_t - show_ep_handle(struct device *dev, struct device_attribute *attr, char *buf) - { - struct iscsi_endpoint *ep = iscsi_dev_to_endpoint(dev); -- return sprintf(buf, "%llu\n", (unsigned long long) ep->id); -+ return sysfs_emit(buf, "%llu\n", (unsigned long long) ep->id); - } - static ISCSI_ATTR(ep, handle, S_IRUGO, show_ep_handle, NULL); - -@@ -2765,6 +2769,9 @@ iscsi_set_param(struct iscsi_transport *transport, struct iscsi_uevent *ev) - struct iscsi_cls_session *session; - int err = 0, value = 0; - -+ if (ev->u.set_param.len > PAGE_SIZE) -+ return -EINVAL; -+ - session = iscsi_session_lookup(ev->u.set_param.sid); - conn = iscsi_conn_lookup(ev->u.set_param.sid, ev->u.set_param.cid); - if (!conn || !session) -@@ -2912,6 +2919,9 @@ iscsi_set_host_param(struct iscsi_transport *transport, - if (!transport->set_host_param) - return -ENOSYS; - -+ if (ev->u.set_host_param.len > PAGE_SIZE) -+ return -EINVAL; -+ - shost = scsi_host_lookup(ev->u.set_host_param.host_no); - if (!shost) { - printk(KERN_ERR "set_host_param could not find host no %u\n", -@@ -3499,6 +3509,7 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) - { - int err = 0; - u32 portid; -+ u32 pdu_len; - struct iscsi_uevent *ev = nlmsg_data(nlh); - struct iscsi_transport *transport = NULL; - struct iscsi_internal *priv; -@@ -3506,6 +3517,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) - struct iscsi_cls_conn *conn; - struct iscsi_endpoint *ep = NULL; - -+ if (!netlink_capable(skb, CAP_SYS_ADMIN)) -+ return -EPERM; -+ - if (nlh->nlmsg_type == ISCSI_UEVENT_PATH_UPDATE) - *group = ISCSI_NL_GRP_UIP; - else -@@ -3613,6 +3627,14 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group) - err = -EINVAL; - break; - case ISCSI_UEVENT_SEND_PDU: -+ pdu_len = nlh->nlmsg_len - sizeof(*nlh) - sizeof(*ev); -+ -+ if ((ev->u.send_pdu.hdr_size > pdu_len) || -+ (ev->u.send_pdu.data_size > (pdu_len - ev->u.send_pdu.hdr_size))) { -+ err = -EINVAL; -+ break; -+ } -+ - conn = iscsi_conn_lookup(ev->u.send_pdu.sid, ev->u.send_pdu.cid); - if (conn) - ev->r.retcode = transport->send_pdu(conn, -@@ -4019,7 +4041,7 @@ show_priv_session_state(struct device *dev, struct device_attribute *attr, - char *buf) - { - struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); -- return sprintf(buf, "%s\n", iscsi_session_state_name(session->state)); -+ return sysfs_emit(buf, "%s\n", iscsi_session_state_name(session->state)); - } - static ISCSI_CLASS_ATTR(priv_sess, state, S_IRUGO, show_priv_session_state, - NULL); -@@ -4028,7 +4050,7 @@ show_priv_session_creator(struct device *dev, struct device_attribute *attr, - char *buf) - { - struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); -- return sprintf(buf, "%d\n", session->creator); -+ return sysfs_emit(buf, "%d\n", session->creator); - } - static ISCSI_CLASS_ATTR(priv_sess, creator, S_IRUGO, show_priv_session_creator, - NULL); -@@ -4037,7 +4059,7 @@ show_priv_session_target_id(struct device *dev, struct device_attribute *attr, - char *buf) - { - struct iscsi_cls_session *session = iscsi_dev_to_session(dev->parent); -- return sprintf(buf, "%d\n", session->target_id); -+ return sysfs_emit(buf, "%d\n", session->target_id); - } - static ISCSI_CLASS_ATTR(priv_sess, target_id, S_IRUGO, - show_priv_session_target_id, NULL); -@@ -4050,8 +4072,8 @@ show_priv_session_##field(struct device *dev, \ - struct iscsi_cls_session *session = \ - iscsi_dev_to_session(dev->parent); \ - if (session->field == -1) \ -- return sprintf(buf, "off\n"); \ -- return sprintf(buf, format"\n", session->field); \ -+ return sysfs_emit(buf, "off\n"); \ -+ return sysfs_emit(buf, format"\n", session->field); \ - } - - #define iscsi_priv_session_attr_store(field) \ -diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c -index aec0f19597a94..4df6e3c1ea96c 100644 ---- a/drivers/staging/fwserial/fwserial.c -+++ b/drivers/staging/fwserial/fwserial.c -@@ -2189,6 +2189,7 @@ static int fwserial_create(struct fw_unit *unit) - err = fw_core_add_address_handler(&port->rx_handler, - &fw_high_memory_region); - if (err) { -+ tty_port_destroy(&port->port); - kfree(port); - goto free_ports; - } -@@ -2271,6 +2272,7 @@ unregister_ttys: - - free_ports: - for (--i; i >= 0; --i) { -+ fw_core_remove_address_handler(&serial->ports[i]->rx_handler); - tty_port_destroy(&serial->ports[i]->port); - kfree(serial->ports[i]); - } -diff --git a/drivers/staging/most/sound/sound.c b/drivers/staging/most/sound/sound.c -index 79817061fcfa4..4225ee9fcf7bf 100644 ---- a/drivers/staging/most/sound/sound.c -+++ b/drivers/staging/most/sound/sound.c -@@ -98,6 +98,8 @@ static void swap_copy24(u8 *dest, const u8 *source, unsigned int bytes) - { - unsigned int i = 0; - -+ if (bytes < 2) -+ return; - while (i < bytes - 2) { - dest[i] = source[i + 2]; - dest[i + 1] = source[i + 1]; -diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c -index 4c2cae99776b9..3703409715dab 100644 ---- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c -+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-ctl.c -@@ -224,7 +224,7 @@ int snd_bcm2835_new_ctl(struct bcm2835_chip *chip) - { - int err; - -- strcpy(chip->card->mixername, "Broadcom Mixer"); -+ strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); - err = create_ctls(chip, ARRAY_SIZE(snd_bcm2835_ctl), snd_bcm2835_ctl); - if (err < 0) - return err; -@@ -261,7 +261,7 @@ static const struct snd_kcontrol_new snd_bcm2835_headphones_ctl[] = { - - int snd_bcm2835_new_headphones_ctl(struct bcm2835_chip *chip) - { -- strcpy(chip->card->mixername, "Broadcom Mixer"); -+ strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); - return create_ctls(chip, ARRAY_SIZE(snd_bcm2835_headphones_ctl), - snd_bcm2835_headphones_ctl); - } -@@ -295,7 +295,7 @@ static const struct snd_kcontrol_new snd_bcm2835_hdmi[] = { - - int snd_bcm2835_new_hdmi_ctl(struct bcm2835_chip *chip) - { -- strcpy(chip->card->mixername, "Broadcom Mixer"); -+ strscpy(chip->card->mixername, "Broadcom Mixer", sizeof(chip->card->mixername)); - return create_ctls(chip, ARRAY_SIZE(snd_bcm2835_hdmi), - snd_bcm2835_hdmi); - } -diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c -index 826016c3431a1..8708f97b46f3a 100644 ---- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c -+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835-pcm.c -@@ -351,7 +351,7 @@ int snd_bcm2835_new_pcm(struct bcm2835_chip *chip, const char *name, - - pcm->private_data = chip; - pcm->nonatomic = true; -- strcpy(pcm->name, name); -+ strscpy(pcm->name, name, sizeof(pcm->name)); - if (!spdif) { - chip->dest = route; - chip->volume = 0; -diff --git a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c -index cf5f80f5ca6b0..c250fbef2fa3d 100644 ---- a/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c -+++ b/drivers/staging/vc04_services/bcm2835-audio/bcm2835.c -@@ -185,9 +185,9 @@ static int snd_add_child_device(struct device *dev, - goto error; - } - -- strcpy(card->driver, audio_driver->driver.name); -- strcpy(card->shortname, audio_driver->shortname); -- strcpy(card->longname, audio_driver->longname); -+ strscpy(card->driver, audio_driver->driver.name, sizeof(card->driver)); -+ strscpy(card->shortname, audio_driver->shortname, sizeof(card->shortname)); -+ strscpy(card->longname, audio_driver->longname, sizeof(card->longname)); - - err = audio_driver->newpcm(chip, audio_driver->shortname, - audio_driver->route, -diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c -index b28aa0d289f89..251c02af1fc3e 100644 ---- a/drivers/tty/vt/consolemap.c -+++ b/drivers/tty/vt/consolemap.c -@@ -495,7 +495,7 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) - - p2[unicode & 0x3f] = fontpos; - -- p->sum += (fontpos << 20) + unicode; -+ p->sum += (fontpos << 20U) + unicode; - - return 0; - } -diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c -index fe373b63ddd6d..ecbfbbf1c1a79 100644 ---- a/drivers/video/fbdev/udlfb.c -+++ b/drivers/video/fbdev/udlfb.c -@@ -1017,6 +1017,7 @@ static void dlfb_ops_destroy(struct fb_info *info) - } - vfree(dlfb->backing_buffer); - kfree(dlfb->edid); -+ dlfb_free_urb_list(dlfb); - usb_put_dev(dlfb->udev); - kfree(dlfb); - -diff --git a/fs/btrfs/transaction.c b/fs/btrfs/transaction.c -index c346ee7ec18d4..aca6c467d7761 100644 ---- a/fs/btrfs/transaction.c -+++ b/fs/btrfs/transaction.c -@@ -1212,7 +1212,6 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) - struct btrfs_root *gang[8]; - int i; - int ret; -- int err = 0; - - spin_lock(&fs_info->fs_roots_radix_lock); - while (1) { -@@ -1224,6 +1223,8 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) - break; - for (i = 0; i < ret; i++) { - struct btrfs_root *root = gang[i]; -+ int ret2; -+ - radix_tree_tag_clear(&fs_info->fs_roots_radix, - (unsigned long)root->root_key.objectid, - BTRFS_ROOT_TRANS_TAG); -@@ -1245,17 +1246,17 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans) - root->node); - } - -- err = btrfs_update_root(trans, fs_info->tree_root, -+ ret2 = btrfs_update_root(trans, fs_info->tree_root, - &root->root_key, - &root->root_item); -+ if (ret2) -+ return ret2; - spin_lock(&fs_info->fs_roots_radix_lock); -- if (err) -- break; - btrfs_qgroup_free_meta_all_pertrans(root); - } - } - spin_unlock(&fs_info->fs_roots_radix_lock); -- return err; -+ return 0; - } - - /* -diff --git a/fs/erofs/super.c b/fs/erofs/super.c -index 0e369494f2f2c..22e059b4f745c 100644 ---- a/fs/erofs/super.c -+++ b/fs/erofs/super.c -@@ -124,8 +124,8 @@ static int erofs_read_superblock(struct super_block *sb) - blkszbits = dsb->blkszbits; - /* 9(512 bytes) + LOG_SECTORS_PER_BLOCK == LOG_BLOCK_SIZE */ - if (blkszbits != LOG_BLOCK_SIZE) { -- erofs_err(sb, "blksize %u isn't supported on this platform", -- 1 << blkszbits); -+ erofs_err(sb, "blkszbits %u isn't supported on this platform", -+ blkszbits); - goto out; - } - -diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c -index 5d9584281935f..3a97ac56821ba 100644 ---- a/fs/f2fs/namei.c -+++ b/fs/f2fs/namei.c -@@ -797,7 +797,11 @@ static int __f2fs_tmpfile(struct inode *dir, struct dentry *dentry, - - if (whiteout) { - f2fs_i_links_write(inode, false); -+ -+ spin_lock(&inode->i_lock); - inode->i_state |= I_LINKABLE; -+ spin_unlock(&inode->i_lock); -+ - *whiteout = inode; - } else { - d_tmpfile(dentry, inode); -@@ -996,7 +1000,11 @@ static int f2fs_rename(struct inode *old_dir, struct dentry *old_dentry, - err = f2fs_add_link(old_dentry, whiteout); - if (err) - goto put_out_dir; -+ -+ spin_lock(&whiteout->i_lock); - whiteout->i_state &= ~I_LINKABLE; -+ spin_unlock(&whiteout->i_lock); -+ - iput(whiteout); - } - -diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h -index 325781a1ae4d6..2034b9a07d632 100644 ---- a/fs/f2fs/segment.h -+++ b/fs/f2fs/segment.h -@@ -88,11 +88,11 @@ - #define BLKS_PER_SEC(sbi) \ - ((sbi)->segs_per_sec * (sbi)->blocks_per_seg) - #define GET_SEC_FROM_SEG(sbi, segno) \ -- ((segno) / (sbi)->segs_per_sec) -+ (((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec) - #define GET_SEG_FROM_SEC(sbi, secno) \ - ((secno) * (sbi)->segs_per_sec) - #define GET_ZONE_FROM_SEC(sbi, secno) \ -- ((secno) / (sbi)->secs_per_zone) -+ (((secno) == -1) ? -1: (secno) / (sbi)->secs_per_zone) - #define GET_ZONE_FROM_SEG(sbi, segno) \ - GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno)) - -diff --git a/fs/jfs/jfs_filsys.h b/fs/jfs/jfs_filsys.h -index 1e899298f7f00..b5d702df7111a 100644 ---- a/fs/jfs/jfs_filsys.h -+++ b/fs/jfs/jfs_filsys.h -@@ -268,5 +268,6 @@ - * fsck() must be run to repair - */ - #define FM_EXTENDFS 0x00000008 /* file system extendfs() in progress */ -+#define FM_STATE_MAX 0x0000000f /* max value of s_state */ - - #endif /* _H_JFS_FILSYS */ -diff --git a/fs/jfs/jfs_mount.c b/fs/jfs/jfs_mount.c -index eb8b9e233d73d..616de103dccc5 100644 ---- a/fs/jfs/jfs_mount.c -+++ b/fs/jfs/jfs_mount.c -@@ -36,6 +36,7 @@ - - #include - #include -+#include - - #include "jfs_incore.h" - #include "jfs_filsys.h" -@@ -365,6 +366,15 @@ static int chkSuper(struct super_block *sb) - sbi->bsize = bsize; - sbi->l2bsize = le16_to_cpu(j_sb->s_l2bsize); - -+ /* check some fields for possible corruption */ -+ if (sbi->l2bsize != ilog2((u32)bsize) || -+ j_sb->pad != 0 || -+ le32_to_cpu(j_sb->s_state) > FM_STATE_MAX) { -+ rc = -EINVAL; -+ jfs_err("jfs_mount: Mount Failure: superblock is corrupt!"); -+ goto out; -+ } -+ - /* - * For now, ignore s_pbsize, l2bfactor. All I/O going through buffer - * cache. -diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c -index 130fc6fbcc038..4f7cf975b27c2 100644 ---- a/fs/sysfs/file.c -+++ b/fs/sysfs/file.c -@@ -15,6 +15,7 @@ - #include - #include - #include -+#include - - #include "sysfs.h" - -@@ -558,3 +559,57 @@ void sysfs_remove_bin_file(struct kobject *kobj, - kernfs_remove_by_name(kobj->sd, attr->attr.name); - } - EXPORT_SYMBOL_GPL(sysfs_remove_bin_file); -+ -+/** -+ * sysfs_emit - scnprintf equivalent, aware of PAGE_SIZE buffer. -+ * @buf: start of PAGE_SIZE buffer. -+ * @fmt: format -+ * @...: optional arguments to @format -+ * -+ * -+ * Returns number of characters written to @buf. -+ */ -+int sysfs_emit(char *buf, const char *fmt, ...) -+{ -+ va_list args; -+ int len; -+ -+ if (WARN(!buf || offset_in_page(buf), -+ "invalid sysfs_emit: buf:%p\n", buf)) -+ return 0; -+ -+ va_start(args, fmt); -+ len = vscnprintf(buf, PAGE_SIZE, fmt, args); -+ va_end(args); -+ -+ return len; -+} -+EXPORT_SYMBOL_GPL(sysfs_emit); -+ -+/** -+ * sysfs_emit_at - scnprintf equivalent, aware of PAGE_SIZE buffer. -+ * @buf: start of PAGE_SIZE buffer. -+ * @at: offset in @buf to start write in bytes -+ * @at must be >= 0 && < PAGE_SIZE -+ * @fmt: format -+ * @...: optional arguments to @fmt -+ * -+ * -+ * Returns number of characters written starting at &@buf[@at]. -+ */ -+int sysfs_emit_at(char *buf, int at, const char *fmt, ...) -+{ -+ va_list args; -+ int len; -+ -+ if (WARN(!buf || offset_in_page(buf) || at < 0 || at >= PAGE_SIZE, -+ "invalid sysfs_emit_at: buf:%p at:%d\n", buf, at)) -+ return 0; -+ -+ va_start(args, fmt); -+ len = vscnprintf(buf + at, PAGE_SIZE - at, fmt, args); -+ va_end(args); -+ -+ return len; -+} -+EXPORT_SYMBOL_GPL(sysfs_emit_at); -diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c -index dec511823fcbc..ca8c763902b96 100644 ---- a/fs/xfs/xfs_iops.c -+++ b/fs/xfs/xfs_iops.c -@@ -839,7 +839,7 @@ xfs_setattr_size( - ASSERT(xfs_isilocked(ip, XFS_MMAPLOCK_EXCL)); - ASSERT(S_ISREG(inode->i_mode)); - ASSERT((iattr->ia_valid & (ATTR_UID|ATTR_GID|ATTR_ATIME|ATTR_ATIME_SET| -- ATTR_MTIME_SET|ATTR_KILL_PRIV|ATTR_TIMES_SET)) == 0); -+ ATTR_MTIME_SET|ATTR_TIMES_SET)) == 0); - - oldsize = inode->i_size; - newsize = iattr->ia_size; -diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h -index 3e0692fd6282c..db1b9623977c8 100644 ---- a/include/linux/netdevice.h -+++ b/include/linux/netdevice.h -@@ -3679,6 +3679,9 @@ int dev_pre_changeaddr_notify(struct net_device *dev, const char *addr, - struct netlink_ext_ack *extack); - int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, - struct netlink_ext_ack *extack); -+int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa, -+ struct netlink_ext_ack *extack); -+int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name); - int dev_change_carrier(struct net_device *, bool new_carrier); - int dev_get_phys_port_id(struct net_device *dev, - struct netdev_phys_item_id *ppid); -diff --git a/include/linux/swap.h b/include/linux/swap.h -index 063c0c1e112bd..136a929648ef4 100644 ---- a/include/linux/swap.h -+++ b/include/linux/swap.h -@@ -473,6 +473,7 @@ struct backing_dev_info; - extern int init_swap_address_space(unsigned int type, unsigned long nr_pages); - extern void exit_swap_address_space(unsigned int type); - extern struct swap_info_struct *get_swap_device(swp_entry_t entry); -+sector_t swap_page_sector(struct page *page); - - static inline void put_swap_device(struct swap_info_struct *si) - { -diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h -index fa7ee503fb763..428707ac3c0bd 100644 ---- a/include/linux/sysfs.h -+++ b/include/linux/sysfs.h -@@ -310,6 +310,11 @@ static inline void sysfs_enable_ns(struct kernfs_node *kn) - return kernfs_enable_ns(kn); - } - -+__printf(2, 3) -+int sysfs_emit(char *buf, const char *fmt, ...); -+__printf(3, 4) -+int sysfs_emit_at(char *buf, int at, const char *fmt, ...); -+ - #else /* CONFIG_SYSFS */ - - static inline int sysfs_create_dir_ns(struct kobject *kobj, const void *ns) -@@ -522,6 +527,17 @@ static inline void sysfs_enable_ns(struct kernfs_node *kn) - { - } - -+__printf(2, 3) -+static inline int sysfs_emit(char *buf, const char *fmt, ...) -+{ -+ return 0; -+} -+ -+__printf(3, 4) -+static inline int sysfs_emit_at(char *buf, int at, const char *fmt, ...) -+{ -+ return 0; -+} - #endif /* CONFIG_SYSFS */ - - static inline int __must_check sysfs_create_file(struct kobject *kobj, -diff --git a/include/linux/zsmalloc.h b/include/linux/zsmalloc.h -index 4807ca4d52e03..2a430e713ce51 100644 ---- a/include/linux/zsmalloc.h -+++ b/include/linux/zsmalloc.h -@@ -35,7 +35,7 @@ enum zs_mapmode { - - struct zs_pool_stats { - /* How many pages were migrated (freed) */ -- unsigned long pages_compacted; -+ atomic_long_t pages_compacted; - }; - - struct zs_pool; -diff --git a/kernel/sched/core.c b/kernel/sched/core.c -index 7841e738e38f0..2ce61018e33b6 100644 ---- a/kernel/sched/core.c -+++ b/kernel/sched/core.c -@@ -254,8 +254,9 @@ static enum hrtimer_restart hrtick(struct hrtimer *timer) - static void __hrtick_restart(struct rq *rq) - { - struct hrtimer *timer = &rq->hrtick_timer; -+ ktime_t time = rq->hrtick_time; - -- hrtimer_start_expires(timer, HRTIMER_MODE_ABS_PINNED_HARD); -+ hrtimer_start(timer, time, HRTIMER_MODE_ABS_PINNED_HARD); - } - - /* -@@ -280,7 +281,6 @@ static void __hrtick_start(void *arg) - void hrtick_start(struct rq *rq, u64 delay) - { - struct hrtimer *timer = &rq->hrtick_timer; -- ktime_t time; - s64 delta; - - /* -@@ -288,9 +288,7 @@ void hrtick_start(struct rq *rq, u64 delay) - * doesn't make sense and can cause timer DoS. - */ - delta = max_t(s64, delay, 10000LL); -- time = ktime_add_ns(timer->base->get_time(), delta); -- -- hrtimer_set_expires(timer, time); -+ rq->hrtick_time = ktime_add_ns(timer->base->get_time(), delta); - - if (rq == this_rq()) { - __hrtick_restart(rq); -diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h -index e10fb9bf2988c..4e490e3db2f86 100644 ---- a/kernel/sched/sched.h -+++ b/kernel/sched/sched.h -@@ -973,6 +973,7 @@ struct rq { - call_single_data_t hrtick_csd; - #endif - struct hrtimer hrtick_timer; -+ ktime_t hrtick_time; - #endif - - #ifdef CONFIG_SCHEDSTATS -diff --git a/mm/hugetlb.c b/mm/hugetlb.c -index 2cd4c7f43dcd9..4033b6ce01c40 100644 ---- a/mm/hugetlb.c -+++ b/mm/hugetlb.c -@@ -4902,21 +4902,23 @@ static bool vma_shareable(struct vm_area_struct *vma, unsigned long addr) - void adjust_range_if_pmd_sharing_possible(struct vm_area_struct *vma, - unsigned long *start, unsigned long *end) - { -- unsigned long a_start, a_end; -+ unsigned long v_start = ALIGN(vma->vm_start, PUD_SIZE), -+ v_end = ALIGN_DOWN(vma->vm_end, PUD_SIZE); - -- if (!(vma->vm_flags & VM_MAYSHARE)) -+ /* -+ * vma need span at least one aligned PUD size and the start,end range -+ * must at least partialy within it. -+ */ -+ if (!(vma->vm_flags & VM_MAYSHARE) || !(v_end > v_start) || -+ (*end <= v_start) || (*start >= v_end)) - return; - - /* Extend the range to be PUD aligned for a worst case scenario */ -- a_start = ALIGN_DOWN(*start, PUD_SIZE); -- a_end = ALIGN(*end, PUD_SIZE); -+ if (*start > v_start) -+ *start = ALIGN_DOWN(*start, PUD_SIZE); - -- /* -- * Intersect the range with the vma range, since pmd sharing won't be -- * across vma after all -- */ -- *start = max(vma->vm_start, a_start); -- *end = min(vma->vm_end, a_end); -+ if (*end < v_end) -+ *end = ALIGN(*end, PUD_SIZE); - } - - /* -diff --git a/mm/page_io.c b/mm/page_io.c -index 60a66a58b9bf9..bcf27d0572534 100644 ---- a/mm/page_io.c -+++ b/mm/page_io.c -@@ -260,11 +260,6 @@ out: - return ret; - } - --static sector_t swap_page_sector(struct page *page) --{ -- return (sector_t)__page_file_index(page) << (PAGE_SHIFT - 9); --} -- - static inline void count_swpout_vm_event(struct page *page) - { - #ifdef CONFIG_TRANSPARENT_HUGEPAGE -diff --git a/mm/swapfile.c b/mm/swapfile.c -index 7947633d3cede..f6964212c6c8f 100644 ---- a/mm/swapfile.c -+++ b/mm/swapfile.c -@@ -221,6 +221,19 @@ offset_to_swap_extent(struct swap_info_struct *sis, unsigned long offset) - BUG(); - } - -+sector_t swap_page_sector(struct page *page) -+{ -+ struct swap_info_struct *sis = page_swap_info(page); -+ struct swap_extent *se; -+ sector_t sector; -+ pgoff_t offset; -+ -+ offset = __page_file_index(page); -+ se = offset_to_swap_extent(sis, offset); -+ sector = se->start_block + (offset - se->start_page); -+ return sector << (PAGE_SHIFT - 9); -+} -+ - /* - * swap allocation tell device that a cluster of swap can now be discarded, - * to allow the swap device to optimize its wear-levelling. -diff --git a/mm/zsmalloc.c b/mm/zsmalloc.c -index 8a72a3b3837b4..443b3b1c95818 100644 ---- a/mm/zsmalloc.c -+++ b/mm/zsmalloc.c -@@ -2216,11 +2216,13 @@ static unsigned long zs_can_compact(struct size_class *class) - return obj_wasted * class->pages_per_zspage; - } - --static void __zs_compact(struct zs_pool *pool, struct size_class *class) -+static unsigned long __zs_compact(struct zs_pool *pool, -+ struct size_class *class) - { - struct zs_compact_control cc; - struct zspage *src_zspage; - struct zspage *dst_zspage = NULL; -+ unsigned long pages_freed = 0; - - spin_lock(&class->lock); - while ((src_zspage = isolate_zspage(class, true))) { -@@ -2250,7 +2252,7 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class) - putback_zspage(class, dst_zspage); - if (putback_zspage(class, src_zspage) == ZS_EMPTY) { - free_zspage(pool, class, src_zspage); -- pool->stats.pages_compacted += class->pages_per_zspage; -+ pages_freed += class->pages_per_zspage; - } - spin_unlock(&class->lock); - cond_resched(); -@@ -2261,12 +2263,15 @@ static void __zs_compact(struct zs_pool *pool, struct size_class *class) - putback_zspage(class, src_zspage); - - spin_unlock(&class->lock); -+ -+ return pages_freed; - } - - unsigned long zs_compact(struct zs_pool *pool) - { - int i; - struct size_class *class; -+ unsigned long pages_freed = 0; - - for (i = ZS_SIZE_CLASSES - 1; i >= 0; i--) { - class = pool->size_class[i]; -@@ -2274,10 +2279,11 @@ unsigned long zs_compact(struct zs_pool *pool) - continue; - if (class->index != i) - continue; -- __zs_compact(pool, class); -+ pages_freed += __zs_compact(pool, class); - } -+ atomic_long_add(pages_freed, &pool->stats.pages_compacted); - -- return pool->stats.pages_compacted; -+ return pages_freed; - } - EXPORT_SYMBOL_GPL(zs_compact); - -@@ -2294,13 +2300,12 @@ static unsigned long zs_shrinker_scan(struct shrinker *shrinker, - struct zs_pool *pool = container_of(shrinker, struct zs_pool, - shrinker); - -- pages_freed = pool->stats.pages_compacted; - /* - * Compact classes and calculate compaction delta. - * Can run concurrently with a manually triggered - * (by user) compaction. - */ -- pages_freed = zs_compact(pool) - pages_freed; -+ pages_freed = zs_compact(pool); - - return pages_freed ? pages_freed : SHRINK_STOP; - } -diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c -index 9c711f0dfae35..be2d469d6369d 100644 ---- a/net/bluetooth/amp.c -+++ b/net/bluetooth/amp.c -@@ -297,6 +297,9 @@ void amp_read_loc_assoc_final_data(struct hci_dev *hdev, - struct hci_request req; - int err; - -+ if (!mgr) -+ return; -+ - cp.phy_handle = hcon->handle; - cp.len_so_far = cpu_to_le16(0); - cp.max_len = cpu_to_le16(hdev->amp_assoc_size); -diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c -index 7a59cdddd3ce3..5047e9c2333a2 100644 ---- a/net/bridge/br_sysfs_if.c -+++ b/net/bridge/br_sysfs_if.c -@@ -55,9 +55,8 @@ static BRPORT_ATTR(_name, 0644, \ - static int store_flag(struct net_bridge_port *p, unsigned long v, - unsigned long mask) - { -- unsigned long flags; -- -- flags = p->flags; -+ unsigned long flags = p->flags; -+ int err; - - if (v) - flags |= mask; -@@ -65,6 +64,10 @@ static int store_flag(struct net_bridge_port *p, unsigned long v, - flags &= ~mask; - - if (flags != p->flags) { -+ err = br_switchdev_set_port_flag(p, flags, mask); -+ if (err) -+ return err; -+ - p->flags = flags; - br_port_flags_change(p, mask); - } -diff --git a/net/core/dev.c b/net/core/dev.c -index d90e8bd87df83..e732faade5dca 100644 ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -8144,6 +8144,48 @@ int dev_set_mac_address(struct net_device *dev, struct sockaddr *sa, - } - EXPORT_SYMBOL(dev_set_mac_address); - -+static DECLARE_RWSEM(dev_addr_sem); -+ -+int dev_set_mac_address_user(struct net_device *dev, struct sockaddr *sa, -+ struct netlink_ext_ack *extack) -+{ -+ int ret; -+ -+ down_write(&dev_addr_sem); -+ ret = dev_set_mac_address(dev, sa, extack); -+ up_write(&dev_addr_sem); -+ return ret; -+} -+EXPORT_SYMBOL(dev_set_mac_address_user); -+ -+int dev_get_mac_address(struct sockaddr *sa, struct net *net, char *dev_name) -+{ -+ size_t size = sizeof(sa->sa_data); -+ struct net_device *dev; -+ int ret = 0; -+ -+ down_read(&dev_addr_sem); -+ rcu_read_lock(); -+ -+ dev = dev_get_by_name_rcu(net, dev_name); -+ if (!dev) { -+ ret = -ENODEV; -+ goto unlock; -+ } -+ if (!dev->addr_len) -+ memset(sa->sa_data, 0, size); -+ else -+ memcpy(sa->sa_data, dev->dev_addr, -+ min_t(size_t, size, dev->addr_len)); -+ sa->sa_family = dev->type; -+ -+unlock: -+ rcu_read_unlock(); -+ up_read(&dev_addr_sem); -+ return ret; -+} -+EXPORT_SYMBOL(dev_get_mac_address); -+ - /** - * dev_change_carrier - Change device carrier - * @dev: device -diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c -index 5163d900bb4fb..69fb9219d51dd 100644 ---- a/net/core/dev_ioctl.c -+++ b/net/core/dev_ioctl.c -@@ -122,17 +122,6 @@ static int dev_ifsioc_locked(struct net *net, struct ifreq *ifr, unsigned int cm - ifr->ifr_mtu = dev->mtu; - return 0; - -- case SIOCGIFHWADDR: -- if (!dev->addr_len) -- memset(ifr->ifr_hwaddr.sa_data, 0, -- sizeof(ifr->ifr_hwaddr.sa_data)); -- else -- memcpy(ifr->ifr_hwaddr.sa_data, dev->dev_addr, -- min(sizeof(ifr->ifr_hwaddr.sa_data), -- (size_t)dev->addr_len)); -- ifr->ifr_hwaddr.sa_family = dev->type; -- return 0; -- - case SIOCGIFSLAVE: - err = -EINVAL; - break; -@@ -246,7 +235,7 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, unsigned int cmd) - case SIOCSIFHWADDR: - if (dev->addr_len > sizeof(struct sockaddr)) - return -EINVAL; -- return dev_set_mac_address(dev, &ifr->ifr_hwaddr, NULL); -+ return dev_set_mac_address_user(dev, &ifr->ifr_hwaddr, NULL); - - case SIOCSIFHWBROADCAST: - if (ifr->ifr_hwaddr.sa_family != dev->type) -@@ -396,6 +385,12 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c - */ - - switch (cmd) { -+ case SIOCGIFHWADDR: -+ dev_load(net, ifr->ifr_name); -+ ret = dev_get_mac_address(&ifr->ifr_hwaddr, net, ifr->ifr_name); -+ if (colon) -+ *colon = ':'; -+ return ret; - /* - * These ioctl calls: - * - can be done by all. -@@ -405,7 +400,6 @@ int dev_ioctl(struct net *net, unsigned int cmd, struct ifreq *ifr, bool *need_c - case SIOCGIFFLAGS: - case SIOCGIFMETRIC: - case SIOCGIFMTU: -- case SIOCGIFHWADDR: - case SIOCGIFSLAVE: - case SIOCGIFMAP: - case SIOCGIFINDEX: -diff --git a/net/core/pktgen.c b/net/core/pktgen.c -index cb3b565ff5adc..1d20dd70879bb 100644 ---- a/net/core/pktgen.c -+++ b/net/core/pktgen.c -@@ -3465,7 +3465,7 @@ static int pktgen_thread_worker(void *arg) - struct pktgen_dev *pkt_dev = NULL; - int cpu = t->cpu; - -- BUG_ON(smp_processor_id() != cpu); -+ WARN_ON(smp_processor_id() != cpu); - - init_waitqueue_head(&t->queue); - complete(&t->start_done); -diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c -index b0c06a0637765..73c09b5864d70 100644 ---- a/net/core/rtnetlink.c -+++ b/net/core/rtnetlink.c -@@ -2471,7 +2471,7 @@ static int do_setlink(const struct sk_buff *skb, - sa->sa_family = dev->type; - memcpy(sa->sa_data, nla_data(tb[IFLA_ADDRESS]), - dev->addr_len); -- err = dev_set_mac_address(dev, sa, extack); -+ err = dev_set_mac_address_user(dev, sa, extack); - kfree(sa); - if (err) - goto errout; -diff --git a/net/core/skbuff.c b/net/core/skbuff.c -index 45117fa299837..99d6f4d1297ca 100644 ---- a/net/core/skbuff.c -+++ b/net/core/skbuff.c -@@ -3290,7 +3290,19 @@ EXPORT_SYMBOL(skb_split); - */ - static int skb_prepare_for_shift(struct sk_buff *skb) - { -- return skb_cloned(skb) && pskb_expand_head(skb, 0, 0, GFP_ATOMIC); -+ int ret = 0; -+ -+ if (skb_cloned(skb)) { -+ /* Save and restore truesize: pskb_expand_head() may reallocate -+ * memory where ksize(kmalloc(S)) != ksize(kmalloc(S)), but we -+ * cannot change truesize at this point. -+ */ -+ unsigned int save_truesize = skb->truesize; -+ -+ ret = pskb_expand_head(skb, 0, 0, GFP_ATOMIC); -+ skb->truesize = save_truesize; -+ } -+ return ret; - } - - /** -diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c -index fdced0a7bd776..bbc1924d64e51 100644 ---- a/net/iucv/af_iucv.c -+++ b/net/iucv/af_iucv.c -@@ -2176,7 +2176,6 @@ static int afiucv_hs_rcv(struct sk_buff *skb, struct net_device *dev, - char nullstring[8]; - - if (!pskb_may_pull(skb, sizeof(*trans_hdr))) { -- WARN_ONCE(1, "AF_IUCV failed to receive skb, len=%u", skb->len); - kfree_skb(skb); - return NET_RX_SUCCESS; - } -diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c -index 9c4308077574c..5e75ff2e1b14f 100644 ---- a/security/smack/smackfs.c -+++ b/security/smack/smackfs.c -@@ -1163,7 +1163,7 @@ static ssize_t smk_write_net4addr(struct file *file, const char __user *buf, - return -EPERM; - if (*ppos != 0) - return -EINVAL; -- if (count < SMK_NETLBLADDRMIN) -+ if (count < SMK_NETLBLADDRMIN || count > PAGE_SIZE - 1) - return -EINVAL; - - data = memdup_user_nul(buf, count); -@@ -1423,7 +1423,7 @@ static ssize_t smk_write_net6addr(struct file *file, const char __user *buf, - return -EPERM; - if (*ppos != 0) - return -EINVAL; -- if (count < SMK_NETLBLADDRMIN) -+ if (count < SMK_NETLBLADDRMIN || count > PAGE_SIZE - 1) - return -EINVAL; - - data = memdup_user_nul(buf, count); -@@ -1830,6 +1830,10 @@ static ssize_t smk_write_ambient(struct file *file, const char __user *buf, - if (!smack_privileged(CAP_MAC_ADMIN)) - return -EPERM; - -+ /* Enough data must be present */ -+ if (count == 0 || count > PAGE_SIZE) -+ return -EINVAL; -+ - data = memdup_user_nul(buf, count); - if (IS_ERR(data)) - return PTR_ERR(data); -@@ -2001,6 +2005,9 @@ static ssize_t smk_write_onlycap(struct file *file, const char __user *buf, - if (!smack_privileged(CAP_MAC_ADMIN)) - return -EPERM; - -+ if (count > PAGE_SIZE) -+ return -EINVAL; -+ - data = memdup_user_nul(buf, count); - if (IS_ERR(data)) - return PTR_ERR(data); -@@ -2088,6 +2095,9 @@ static ssize_t smk_write_unconfined(struct file *file, const char __user *buf, - if (!smack_privileged(CAP_MAC_ADMIN)) - return -EPERM; - -+ if (count > PAGE_SIZE) -+ return -EINVAL; -+ - data = memdup_user_nul(buf, count); - if (IS_ERR(data)) - return PTR_ERR(data); -@@ -2643,6 +2653,10 @@ static ssize_t smk_write_syslog(struct file *file, const char __user *buf, - if (!smack_privileged(CAP_MAC_ADMIN)) - return -EPERM; - -+ /* Enough data must be present */ -+ if (count == 0 || count > PAGE_SIZE) -+ return -EINVAL; -+ - data = memdup_user_nul(buf, count); - if (IS_ERR(data)) - return PTR_ERR(data); -@@ -2735,10 +2749,13 @@ static ssize_t smk_write_relabel_self(struct file *file, const char __user *buf, - return -EPERM; - - /* -+ * No partial write. - * Enough data must be present. - */ - if (*ppos != 0) - return -EINVAL; -+ if (count == 0 || count > PAGE_SIZE) -+ return -EINVAL; - - data = memdup_user_nul(buf, count); - if (IS_ERR(data)) -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index a132fe4537a55..1283796316b62 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -2522,6 +2522,7 @@ static const struct snd_pci_quirk alc882_fixup_tbl[] = { - SND_PCI_QUIRK(0x1462, 0x1276, "MSI-GL73", ALC1220_FIXUP_CLEVO_P950), - SND_PCI_QUIRK(0x1462, 0x1293, "MSI-GP65", ALC1220_FIXUP_CLEVO_P950), - SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD), -+ SND_PCI_QUIRK(0x1462, 0xcc34, "MSI Godlike X570", ALC1220_FIXUP_GB_DUAL_CODECS), - SND_PCI_QUIRK(0x1462, 0xda57, "MSI Z270-Gaming", ALC1220_FIXUP_GB_DUAL_CODECS), - SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3), - SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX), -@@ -6320,6 +6321,7 @@ enum { - ALC269_FIXUP_LEMOTE_A1802, - ALC269_FIXUP_LEMOTE_A190X, - ALC256_FIXUP_INTEL_NUC8_RUGGED, -+ ALC256_FIXUP_INTEL_NUC10, - ALC255_FIXUP_XIAOMI_HEADSET_MIC, - ALC274_FIXUP_HP_MIC, - ALC274_FIXUP_HP_HEADSET_MIC, -@@ -7697,6 +7699,15 @@ static const struct hda_fixup alc269_fixups[] = { - .chained = true, - .chain_id = ALC269_FIXUP_HEADSET_MODE - }, -+ [ALC256_FIXUP_INTEL_NUC10] = { -+ .type = HDA_FIXUP_PINS, -+ .v.pins = (const struct hda_pintbl[]) { -+ { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */ -+ { } -+ }, -+ .chained = true, -+ .chain_id = ALC269_FIXUP_HEADSET_MODE -+ }, - [ALC255_FIXUP_XIAOMI_HEADSET_MIC] = { - .type = HDA_FIXUP_VERBS, - .v.verbs = (const struct hda_verb[]) { -@@ -8001,6 +8012,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1558, 0x8551, "System76 Gazelle (gaze14)", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1558, 0x8560, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC), - SND_PCI_QUIRK(0x1558, 0x8561, "System76 Gazelle (gaze14)", ALC269_FIXUP_HEADSET_MIC), -+ SND_PCI_QUIRK(0x1558, 0x8562, "Clevo NH[5|7][0-9]RZ[Q]", ALC269_FIXUP_DMIC), - SND_PCI_QUIRK(0x1558, 0x8668, "Clevo NP50B[BE]", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1558, 0x8680, "Clevo NJ50LU", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1558, 0x8686, "Clevo NH50[CZ]U", ALC293_FIXUP_SYSTEM76_MIC_NO_PRESENCE), -@@ -8095,6 +8107,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802), - SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X), - SND_PCI_QUIRK(0x8086, 0x2080, "Intel NUC 8 Rugged", ALC256_FIXUP_INTEL_NUC8_RUGGED), -+ SND_PCI_QUIRK(0x8086, 0x2081, "Intel NUC 10", ALC256_FIXUP_INTEL_NUC10), - - #if 0 - /* Below is a quirk table taken from the old code. -diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c -index 6012367f6fe48..9ee610504bac9 100644 ---- a/sound/soc/intel/boards/bytcr_rt5640.c -+++ b/sound/soc/intel/boards/bytcr_rt5640.c -@@ -400,6 +400,19 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { - BYT_RT5640_SSP0_AIF1 | - BYT_RT5640_MCLK_EN), - }, -+ { /* Acer One 10 S1002 */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "One S1002"), -+ }, -+ .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_DIFF_MIC | -+ BYT_RT5640_SSP0_AIF2 | -+ BYT_RT5640_MCLK_EN), -+ }, - { - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Acer"), -@@ -513,6 +526,16 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { - BYT_RT5640_MONO_SPEAKER | - BYT_RT5640_MCLK_EN), - }, -+ { /* Estar Beauty HD MID 7316R */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Estar"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "eSTAR BEAUTY HD Intel Quad core"), -+ }, -+ .driver_data = (void *)(BYTCR_INPUT_DEFAULTS | -+ BYT_RT5640_MONO_SPEAKER | -+ BYT_RT5640_SSP0_AIF1 | -+ BYT_RT5640_MCLK_EN), -+ }, - { - .matches = { - DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Hewlett-Packard"), -@@ -776,6 +799,20 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { - BYT_RT5640_SSP0_AIF2 | - BYT_RT5640_MCLK_EN), - }, -+ { /* Voyo Winpad A15 */ -+ .matches = { -+ DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), -+ DMI_MATCH(DMI_BOARD_NAME, "Aptio CRB"), -+ /* Above strings are too generic, also match on BIOS date */ -+ DMI_MATCH(DMI_BIOS_DATE, "11/20/2014"), -+ }, -+ .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_DIFF_MIC | -+ BYT_RT5640_MCLK_EN), -+ }, - { /* Catch-all for generic Insyde tablets, must be last */ - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Insyde"), -diff --git a/sound/soc/intel/boards/bytcr_rt5651.c b/sound/soc/intel/boards/bytcr_rt5651.c -index 4606f6f582d6f..921c09cdb4800 100644 ---- a/sound/soc/intel/boards/bytcr_rt5651.c -+++ b/sound/soc/intel/boards/bytcr_rt5651.c -@@ -435,6 +435,19 @@ static const struct dmi_system_id byt_rt5651_quirk_table[] = { - BYT_RT5651_SSP0_AIF1 | - BYT_RT5651_MONO_SPEAKER), - }, -+ { -+ /* Jumper EZpad 7 */ -+ .callback = byt_rt5651_quirk_cb, -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Jumper"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "EZpad"), -+ /* Jumper12x.WJ2012.bsBKRCP05 with the version dropped */ -+ DMI_MATCH(DMI_BIOS_VERSION, "Jumper12x.WJ2012.bsBKRCP"), -+ }, -+ .driver_data = (void *)(BYT_RT5651_DEFAULT_QUIRKS | -+ BYT_RT5651_IN2_MAP | -+ BYT_RT5651_JD_NOT_INV), -+ }, - { - /* KIANO SlimNote 14.2 */ - .callback = byt_rt5651_quirk_cb, -diff --git a/sound/soc/intel/common/soc-intel-quirks.h b/sound/soc/intel/common/soc-intel-quirks.h -index 863a477d34051..645baf0ed3dd1 100644 ---- a/sound/soc/intel/common/soc-intel-quirks.h -+++ b/sound/soc/intel/common/soc-intel-quirks.h -@@ -11,6 +11,7 @@ - - #if IS_ENABLED(CONFIG_X86) - -+#include - #include - #include - #include -@@ -40,12 +41,36 @@ SOC_INTEL_IS_CPU(cml, INTEL_FAM6_KABYLAKE_L); - - static inline bool soc_intel_is_byt_cr(struct platform_device *pdev) - { -+ /* -+ * List of systems which: -+ * 1. Use a non CR version of the Bay Trail SoC -+ * 2. Contain at least 6 interrupt resources so that the -+ * platform_get_resource(pdev, IORESOURCE_IRQ, 5) check below -+ * succeeds -+ * 3. Despite 1. and 2. still have their IPC IRQ at index 0 rather then 5 -+ * -+ * This needs to be here so that it can be shared between the SST and -+ * SOF drivers. We rely on the compiler to optimize this out in files -+ * where soc_intel_is_byt_cr is not used. -+ */ -+ static const struct dmi_system_id force_bytcr_table[] = { -+ { /* Lenovo Yoga Tablet 2 series */ -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), -+ DMI_MATCH(DMI_PRODUCT_FAMILY, "YOGATablet2"), -+ }, -+ }, -+ {} -+ }; - struct device *dev = &pdev->dev; - int status = 0; - - if (!soc_intel_is_byt()) - return false; - -+ if (dmi_check_system(force_bytcr_table)) -+ return true; -+ - if (iosf_mbi_available()) { - u32 bios_status; - diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.103-104.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.103-104.patch deleted file mode 100644 index a2152a6dfe..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.103-104.patch +++ /dev/null @@ -1,781 +0,0 @@ -diff --git a/Makefile b/Makefile -index c95435d78fcbb..e94dcf2d77f55 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 103 -+SUBLEVEL = 104 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c -index 30b877f8b85ef..0cfd685774891 100644 ---- a/arch/arm64/kernel/ptrace.c -+++ b/arch/arm64/kernel/ptrace.c -@@ -1844,7 +1844,7 @@ int syscall_trace_enter(struct pt_regs *regs) - - if (flags & (_TIF_SYSCALL_EMU | _TIF_SYSCALL_TRACE)) { - tracehook_report_syscall(regs, PTRACE_SYSCALL_ENTER); -- if (!in_syscall(regs) || (flags & _TIF_SYSCALL_EMU)) -+ if (flags & _TIF_SYSCALL_EMU) - return -1; - } - -diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c -index 137a7ba053d78..8e3d0228b05bb 100644 ---- a/drivers/base/power/runtime.c -+++ b/drivers/base/power/runtime.c -@@ -325,22 +325,22 @@ static void rpm_put_suppliers(struct device *dev) - static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - __releases(&dev->power.lock) __acquires(&dev->power.lock) - { -- int retval, idx; - bool use_links = dev->power.links_count > 0; -+ bool get = false; -+ int retval, idx; -+ bool put; - - if (dev->power.irq_safe) { - spin_unlock(&dev->power.lock); -+ } else if (!use_links) { -+ spin_unlock_irq(&dev->power.lock); - } else { -+ get = dev->power.runtime_status == RPM_RESUMING; -+ - spin_unlock_irq(&dev->power.lock); - -- /* -- * Resume suppliers if necessary. -- * -- * The device's runtime PM status cannot change until this -- * routine returns, so it is safe to read the status outside of -- * the lock. -- */ -- if (use_links && dev->power.runtime_status == RPM_RESUMING) { -+ /* Resume suppliers if necessary. */ -+ if (get) { - idx = device_links_read_lock(); - - retval = rpm_get_suppliers(dev); -@@ -355,24 +355,36 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - - if (dev->power.irq_safe) { - spin_lock(&dev->power.lock); -- } else { -- /* -- * If the device is suspending and the callback has returned -- * success, drop the usage counters of the suppliers that have -- * been reference counted on its resume. -- * -- * Do that if resume fails too. -- */ -- if (use_links -- && ((dev->power.runtime_status == RPM_SUSPENDING && !retval) -- || (dev->power.runtime_status == RPM_RESUMING && retval))) { -- idx = device_links_read_lock(); -+ return retval; -+ } - -- fail: -- rpm_put_suppliers(dev); -+ spin_lock_irq(&dev->power.lock); - -- device_links_read_unlock(idx); -- } -+ if (!use_links) -+ return retval; -+ -+ /* -+ * If the device is suspending and the callback has returned success, -+ * drop the usage counters of the suppliers that have been reference -+ * counted on its resume. -+ * -+ * Do that if the resume fails too. -+ */ -+ put = dev->power.runtime_status == RPM_SUSPENDING && !retval; -+ if (put) -+ __update_runtime_status(dev, RPM_SUSPENDED); -+ else -+ put = get && retval; -+ -+ if (put) { -+ spin_unlock_irq(&dev->power.lock); -+ -+ idx = device_links_read_lock(); -+ -+fail: -+ rpm_put_suppliers(dev); -+ -+ device_links_read_unlock(idx); - - spin_lock_irq(&dev->power.lock); - } -diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c -index 10f6368117d81..804d28faa97b0 100644 ---- a/drivers/block/rsxx/core.c -+++ b/drivers/block/rsxx/core.c -@@ -165,15 +165,17 @@ static ssize_t rsxx_cram_read(struct file *fp, char __user *ubuf, - { - struct rsxx_cardinfo *card = file_inode(fp)->i_private; - char *buf; -- ssize_t st; -+ int st; - - buf = kzalloc(cnt, GFP_KERNEL); - if (!buf) - return -ENOMEM; - - st = rsxx_creg_read(card, CREG_ADD_CRAM + (u32)*ppos, cnt, buf, 1); -- if (!st) -- st = copy_to_user(ubuf, buf, cnt); -+ if (!st) { -+ if (copy_to_user(ubuf, buf, cnt)) -+ st = -EFAULT; -+ } - kfree(buf); - if (st) - return st; -diff --git a/drivers/char/tpm/tpm_tis_core.c b/drivers/char/tpm/tpm_tis_core.c -index 46d1fac247db7..7da35867b6ad3 100644 ---- a/drivers/char/tpm/tpm_tis_core.c -+++ b/drivers/char/tpm/tpm_tis_core.c -@@ -618,12 +618,22 @@ static int tpm_tis_gen_interrupt(struct tpm_chip *chip) - const char *desc = "attempting to generate an interrupt"; - u32 cap2; - cap_t cap; -+ int ret; - -+ /* TPM 2.0 */ - if (chip->flags & TPM_CHIP_FLAG_TPM2) - return tpm2_get_tpm_pt(chip, 0x100, &cap2, desc); -- else -- return tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, -- 0); -+ -+ /* TPM 1.2 */ -+ ret = request_locality(chip, 0); -+ if (ret < 0) -+ return ret; -+ -+ ret = tpm1_getcap(chip, TPM_CAP_PROP_TIS_TIMEOUT, &cap, desc, 0); -+ -+ release_locality(chip, 0); -+ -+ return ret; - } - - /* Register the IRQ and issue a command that will cause an interrupt. If an -@@ -929,11 +939,21 @@ int tpm_tis_core_init(struct device *dev, struct tpm_tis_data *priv, int irq, - init_waitqueue_head(&priv->read_queue); - init_waitqueue_head(&priv->int_queue); - if (irq != -1) { -- /* Before doing irq testing issue a command to the TPM in polling mode -+ /* -+ * Before doing irq testing issue a command to the TPM in polling mode - * to make sure it works. May as well use that command to set the - * proper timeouts for the driver. - */ -- if (tpm_get_timeouts(chip)) { -+ -+ rc = request_locality(chip, 0); -+ if (rc < 0) -+ goto out_err; -+ -+ rc = tpm_get_timeouts(chip); -+ -+ release_locality(chip, 0); -+ -+ if (rc) { - dev_err(dev, "Could not get TPM timeouts and durations\n"); - rc = -ENODEV; - goto out_err; -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c -index 700e26b69abca..a9a81e55777bf 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_debugfs.c -@@ -240,7 +240,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_read(struct file *f, char __user *buf, - while (size) { - uint32_t value; - -- value = RREG32_PCIE(*pos >> 2); -+ value = RREG32_PCIE(*pos); - r = put_user(value, (uint32_t *)buf); - if (r) - return r; -@@ -283,7 +283,7 @@ static ssize_t amdgpu_debugfs_regs_pcie_write(struct file *f, const char __user - if (r) - return r; - -- WREG32_PCIE(*pos >> 2, value); -+ WREG32_PCIE(*pos, value); - - result += 4; - buf += 4; -diff --git a/drivers/infiniband/hw/mlx5/devx.c b/drivers/infiniband/hw/mlx5/devx.c -index 4d6f25fdcc0ef..664e0f374ac00 100644 ---- a/drivers/infiniband/hw/mlx5/devx.c -+++ b/drivers/infiniband/hw/mlx5/devx.c -@@ -2022,8 +2022,10 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_DEVX_SUBSCRIBE_EVENT)( - - num_alloc_xa_entries++; - event_sub = kzalloc(sizeof(*event_sub), GFP_KERNEL); -- if (!event_sub) -+ if (!event_sub) { -+ err = -ENOMEM; - goto err; -+ } - - list_add_tail(&event_sub->event_list, &sub_list); - if (use_eventfd) { -diff --git a/drivers/infiniband/sw/rxe/Kconfig b/drivers/infiniband/sw/rxe/Kconfig -index 71a773f607bbc..0e8f1d05dfb2a 100644 ---- a/drivers/infiniband/sw/rxe/Kconfig -+++ b/drivers/infiniband/sw/rxe/Kconfig -@@ -4,6 +4,7 @@ config RDMA_RXE - depends on INET && PCI && INFINIBAND - depends on INFINIBAND_VIRT_DMA - select NET_UDP_TUNNEL -+ select CRYPTO - select CRYPTO_CRC32 - select DMA_VIRT_OPS - ---help--- -diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c -index a9529dc2b26e6..e8c37d9a652dc 100644 ---- a/drivers/md/dm-bufio.c -+++ b/drivers/md/dm-bufio.c -@@ -1438,6 +1438,10 @@ EXPORT_SYMBOL_GPL(dm_bufio_get_block_size); - sector_t dm_bufio_get_device_size(struct dm_bufio_client *c) - { - sector_t s = i_size_read(c->bdev->bd_inode) >> SECTOR_SHIFT; -+ if (s >= c->start) -+ s -= c->start; -+ else -+ s = 0; - if (likely(c->sectors_per_block_bits >= 0)) - s >>= c->sectors_per_block_bits; - else -diff --git a/drivers/md/dm-verity-fec.c b/drivers/md/dm-verity-fec.c -index fb41b4f23c489..66f4c6398f670 100644 ---- a/drivers/md/dm-verity-fec.c -+++ b/drivers/md/dm-verity-fec.c -@@ -61,19 +61,18 @@ static int fec_decode_rs8(struct dm_verity *v, struct dm_verity_fec_io *fio, - static u8 *fec_read_parity(struct dm_verity *v, u64 rsb, int index, - unsigned *offset, struct dm_buffer **buf) - { -- u64 position, block; -+ u64 position, block, rem; - u8 *res; - - position = (index + rsb) * v->fec->roots; -- block = position >> v->data_dev_block_bits; -- *offset = (unsigned)(position - (block << v->data_dev_block_bits)); -+ block = div64_u64_rem(position, v->fec->roots << SECTOR_SHIFT, &rem); -+ *offset = (unsigned)rem; - -- res = dm_bufio_read(v->fec->bufio, v->fec->start + block, buf); -+ res = dm_bufio_read(v->fec->bufio, block, buf); - if (IS_ERR(res)) { - DMERR("%s: FEC %llu: parity read failed (block %llu): %ld", - v->data_dev->name, (unsigned long long)rsb, -- (unsigned long long)(v->fec->start + block), -- PTR_ERR(res)); -+ (unsigned long long)block, PTR_ERR(res)); - *buf = NULL; - } - -@@ -155,7 +154,7 @@ static int fec_decode_bufs(struct dm_verity *v, struct dm_verity_fec_io *fio, - - /* read the next block when we run out of parity bytes */ - offset += v->fec->roots; -- if (offset >= 1 << v->data_dev_block_bits) { -+ if (offset >= v->fec->roots << SECTOR_SHIFT) { - dm_bufio_release(buf); - - par = fec_read_parity(v, rsb, block_offset, &offset, &buf); -@@ -674,7 +673,7 @@ int verity_fec_ctr(struct dm_verity *v) - { - struct dm_verity_fec *f = v->fec; - struct dm_target *ti = v->ti; -- u64 hash_blocks; -+ u64 hash_blocks, fec_blocks; - int ret; - - if (!verity_fec_is_enabled(v)) { -@@ -744,15 +743,17 @@ int verity_fec_ctr(struct dm_verity *v) - } - - f->bufio = dm_bufio_client_create(f->dev->bdev, -- 1 << v->data_dev_block_bits, -+ f->roots << SECTOR_SHIFT, - 1, 0, NULL, NULL); - if (IS_ERR(f->bufio)) { - ti->error = "Cannot initialize FEC bufio client"; - return PTR_ERR(f->bufio); - } - -- if (dm_bufio_get_device_size(f->bufio) < -- ((f->start + f->rounds * f->roots) >> v->data_dev_block_bits)) { -+ dm_bufio_set_sector_offset(f->bufio, f->start << (v->data_dev_block_bits - SECTOR_SHIFT)); -+ -+ fec_blocks = div64_u64(f->rounds * f->roots, v->fec->roots << SECTOR_SHIFT); -+ if (dm_bufio_get_device_size(f->bufio) < fec_blocks) { - ti->error = "FEC device is too small"; - return -E2BIG; - } -diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c -index 131be1fa770cb..bd8decc54b871 100644 ---- a/drivers/net/ethernet/realtek/r8169_main.c -+++ b/drivers/net/ethernet/realtek/r8169_main.c -@@ -3959,6 +3959,7 @@ static void rtl_pll_power_down(struct rtl8169_private *tp) - - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26: -+ case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30: - case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_33: - case RTL_GIGA_MAC_VER_37: - case RTL_GIGA_MAC_VER_39: -@@ -3989,6 +3990,7 @@ static void rtl_pll_power_up(struct rtl8169_private *tp) - { - switch (tp->mac_version) { - case RTL_GIGA_MAC_VER_25 ... RTL_GIGA_MAC_VER_26: -+ case RTL_GIGA_MAC_VER_29 ... RTL_GIGA_MAC_VER_30: - case RTL_GIGA_MAC_VER_32 ... RTL_GIGA_MAC_VER_33: - case RTL_GIGA_MAC_VER_37: - case RTL_GIGA_MAC_VER_39: -diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c -index bef62b01824de..7dad8794ee388 100644 ---- a/fs/btrfs/delayed-inode.c -+++ b/fs/btrfs/delayed-inode.c -@@ -649,7 +649,7 @@ static int btrfs_delayed_inode_reserve_metadata( - btrfs_ino(inode), - num_bytes, 1); - } else { -- btrfs_qgroup_free_meta_prealloc(root, fs_info->nodesize); -+ btrfs_qgroup_free_meta_prealloc(root, num_bytes); - } - return ret; - } -diff --git a/fs/btrfs/file.c b/fs/btrfs/file.c -index 4126513e2429c..f8e5c47b95e40 100644 ---- a/fs/btrfs/file.c -+++ b/fs/btrfs/file.c -@@ -3151,8 +3151,11 @@ reserve_space: - goto out; - ret = btrfs_qgroup_reserve_data(inode, &data_reserved, - alloc_start, bytes_to_reserve); -- if (ret) -+ if (ret) { -+ unlock_extent_cached(&BTRFS_I(inode)->io_tree, lockstart, -+ lockend, &cached_state); - goto out; -+ } - ret = btrfs_prealloc_file_range(inode, mode, alloc_start, - alloc_end - alloc_start, - i_blocksize(inode), -diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c -index 8ed71b3b25466..4bbd4b09fb96f 100644 ---- a/fs/btrfs/ioctl.c -+++ b/fs/btrfs/ioctl.c -@@ -1907,7 +1907,10 @@ static noinline int btrfs_ioctl_snap_create_v2(struct file *file, - if (vol_args->flags & BTRFS_SUBVOL_RDONLY) - readonly = true; - if (vol_args->flags & BTRFS_SUBVOL_QGROUP_INHERIT) { -- if (vol_args->size > PAGE_SIZE) { -+ u64 nums; -+ -+ if (vol_args->size < sizeof(*inherit) || -+ vol_args->size > PAGE_SIZE) { - ret = -EINVAL; - goto free_args; - } -@@ -1916,6 +1919,20 @@ static noinline int btrfs_ioctl_snap_create_v2(struct file *file, - ret = PTR_ERR(inherit); - goto free_args; - } -+ -+ if (inherit->num_qgroups > PAGE_SIZE || -+ inherit->num_ref_copies > PAGE_SIZE || -+ inherit->num_excl_copies > PAGE_SIZE) { -+ ret = -EINVAL; -+ goto free_inherit; -+ } -+ -+ nums = inherit->num_qgroups + 2 * inherit->num_ref_copies + -+ 2 * inherit->num_excl_copies; -+ if (vol_args->size != struct_size(inherit, qgroups, nums)) { -+ ret = -EINVAL; -+ goto free_inherit; -+ } - } - - ret = btrfs_ioctl_snap_create_transid(file, vol_args->name, -diff --git a/fs/btrfs/raid56.c b/fs/btrfs/raid56.c -index 8f47a85944eb7..7ac679ed2b6c6 100644 ---- a/fs/btrfs/raid56.c -+++ b/fs/btrfs/raid56.c -@@ -1198,22 +1198,19 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) - int nr_data = rbio->nr_data; - int stripe; - int pagenr; -- int p_stripe = -1; -- int q_stripe = -1; -+ bool has_qstripe; - struct bio_list bio_list; - struct bio *bio; - int ret; - - bio_list_init(&bio_list); - -- if (rbio->real_stripes - rbio->nr_data == 1) { -- p_stripe = rbio->real_stripes - 1; -- } else if (rbio->real_stripes - rbio->nr_data == 2) { -- p_stripe = rbio->real_stripes - 2; -- q_stripe = rbio->real_stripes - 1; -- } else { -+ if (rbio->real_stripes - rbio->nr_data == 1) -+ has_qstripe = false; -+ else if (rbio->real_stripes - rbio->nr_data == 2) -+ has_qstripe = true; -+ else - BUG(); -- } - - /* at this point we either have a full stripe, - * or we've read the full stripe from the drive. -@@ -1257,7 +1254,7 @@ static noinline void finish_rmw(struct btrfs_raid_bio *rbio) - SetPageUptodate(p); - pointers[stripe++] = kmap(p); - -- if (q_stripe != -1) { -+ if (has_qstripe) { - - /* - * raid6, add the qstripe and call the -@@ -2355,8 +2352,7 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, - int nr_data = rbio->nr_data; - int stripe; - int pagenr; -- int p_stripe = -1; -- int q_stripe = -1; -+ bool has_qstripe; - struct page *p_page = NULL; - struct page *q_page = NULL; - struct bio_list bio_list; -@@ -2366,14 +2362,12 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, - - bio_list_init(&bio_list); - -- if (rbio->real_stripes - rbio->nr_data == 1) { -- p_stripe = rbio->real_stripes - 1; -- } else if (rbio->real_stripes - rbio->nr_data == 2) { -- p_stripe = rbio->real_stripes - 2; -- q_stripe = rbio->real_stripes - 1; -- } else { -+ if (rbio->real_stripes - rbio->nr_data == 1) -+ has_qstripe = false; -+ else if (rbio->real_stripes - rbio->nr_data == 2) -+ has_qstripe = true; -+ else - BUG(); -- } - - if (bbio->num_tgtdevs && bbio->tgtdev_map[rbio->scrubp]) { - is_replace = 1; -@@ -2395,17 +2389,22 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, - goto cleanup; - SetPageUptodate(p_page); - -- if (q_stripe != -1) { -+ if (has_qstripe) { -+ /* RAID6, allocate and map temp space for the Q stripe */ - q_page = alloc_page(GFP_NOFS | __GFP_HIGHMEM); - if (!q_page) { - __free_page(p_page); - goto cleanup; - } - SetPageUptodate(q_page); -+ pointers[rbio->real_stripes - 1] = kmap(q_page); - } - - atomic_set(&rbio->error, 0); - -+ /* Map the parity stripe just once */ -+ pointers[nr_data] = kmap(p_page); -+ - for_each_set_bit(pagenr, rbio->dbitmap, rbio->stripe_npages) { - struct page *p; - void *parity; -@@ -2415,17 +2414,8 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, - pointers[stripe] = kmap(p); - } - -- /* then add the parity stripe */ -- pointers[stripe++] = kmap(p_page); -- -- if (q_stripe != -1) { -- -- /* -- * raid6, add the qstripe and call the -- * library function to fill in our p/q -- */ -- pointers[stripe++] = kmap(q_page); -- -+ if (has_qstripe) { -+ /* RAID6, call the library function to fill in our P/Q */ - raid6_call.gen_syndrome(rbio->real_stripes, PAGE_SIZE, - pointers); - } else { -@@ -2446,12 +2436,14 @@ static noinline void finish_parity_scrub(struct btrfs_raid_bio *rbio, - - for (stripe = 0; stripe < nr_data; stripe++) - kunmap(page_in_rbio(rbio, stripe, pagenr, 0)); -- kunmap(p_page); - } - -+ kunmap(p_page); - __free_page(p_page); -- if (q_page) -+ if (q_page) { -+ kunmap(q_page); - __free_page(q_page); -+ } - - writeback: - /* -diff --git a/fs/btrfs/xattr.c b/fs/btrfs/xattr.c -index 95d9aebff2c4b..48858510739b2 100644 ---- a/fs/btrfs/xattr.c -+++ b/fs/btrfs/xattr.c -@@ -227,11 +227,33 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name, - { - struct btrfs_root *root = BTRFS_I(inode)->root; - struct btrfs_trans_handle *trans; -+ const bool start_trans = (current->journal_info == NULL); - int ret; - -- trans = btrfs_start_transaction(root, 2); -- if (IS_ERR(trans)) -- return PTR_ERR(trans); -+ if (start_trans) { -+ /* -+ * 1 unit for inserting/updating/deleting the xattr -+ * 1 unit for the inode item update -+ */ -+ trans = btrfs_start_transaction(root, 2); -+ if (IS_ERR(trans)) -+ return PTR_ERR(trans); -+ } else { -+ /* -+ * This can happen when smack is enabled and a directory is being -+ * created. It happens through d_instantiate_new(), which calls -+ * smack_d_instantiate(), which in turn calls __vfs_setxattr() to -+ * set the transmute xattr (XATTR_NAME_SMACKTRANSMUTE) on the -+ * inode. We have already reserved space for the xattr and inode -+ * update at btrfs_mkdir(), so just use the transaction handle. -+ * We don't join or start a transaction, as that will reset the -+ * block_rsv of the handle and trigger a warning for the start -+ * case. -+ */ -+ ASSERT(strncmp(name, XATTR_SECURITY_PREFIX, -+ XATTR_SECURITY_PREFIX_LEN) == 0); -+ trans = current->journal_info; -+ } - - ret = btrfs_setxattr(trans, inode, name, value, size, flags); - if (ret) -@@ -242,7 +264,8 @@ int btrfs_setxattr_trans(struct inode *inode, const char *name, - ret = btrfs_update_inode(trans, root, inode); - BUG_ON(ret); - out: -- btrfs_end_transaction(trans); -+ if (start_trans) -+ btrfs_end_transaction(trans); - return ret; - } - -diff --git a/include/crypto/hash.h b/include/crypto/hash.h -index d52b95b75ae4d..84e9f2380edf2 100644 ---- a/include/crypto/hash.h -+++ b/include/crypto/hash.h -@@ -141,7 +141,7 @@ struct ahash_alg { - - struct shash_desc { - struct crypto_shash *tfm; -- void *__ctx[] CRYPTO_MINALIGN_ATTR; -+ void *__ctx[] __aligned(ARCH_SLAB_MINALIGN); - }; - - #define HASH_MAX_DIGESTSIZE 64 -@@ -154,9 +154,9 @@ struct shash_desc { - - #define HASH_MAX_STATESIZE 512 - --#define SHASH_DESC_ON_STACK(shash, ctx) \ -- char __##shash##_desc[sizeof(struct shash_desc) + \ -- HASH_MAX_DESCSIZE] CRYPTO_MINALIGN_ATTR; \ -+#define SHASH_DESC_ON_STACK(shash, ctx) \ -+ char __##shash##_desc[sizeof(struct shash_desc) + HASH_MAX_DESCSIZE] \ -+ __aligned(__alignof__(struct shash_desc)); \ - struct shash_desc *shash = (struct shash_desc *)__##shash##_desc - - /** -diff --git a/include/linux/crypto.h b/include/linux/crypto.h -index 19ea3a371d7bb..0c720a2982ae4 100644 ---- a/include/linux/crypto.h -+++ b/include/linux/crypto.h -@@ -130,9 +130,12 @@ - * The macro CRYPTO_MINALIGN_ATTR (along with the void * type in the actual - * declaration) is used to ensure that the crypto_tfm context structure is - * aligned correctly for the given architecture so that there are no alignment -- * faults for C data types. In particular, this is required on platforms such -- * as arm where pointers are 32-bit aligned but there are data types such as -- * u64 which require 64-bit alignment. -+ * faults for C data types. On architectures that support non-cache coherent -+ * DMA, such as ARM or arm64, it also takes into account the minimal alignment -+ * that is required to ensure that the context struct member does not share any -+ * cachelines with the rest of the struct. This is needed to ensure that cache -+ * maintenance for non-coherent DMA (cache invalidation in particular) does not -+ * affect data that may be accessed by the CPU concurrently. - */ - #define CRYPTO_MINALIGN ARCH_KMALLOC_MINALIGN - -diff --git a/include/sound/intel-nhlt.h b/include/sound/intel-nhlt.h -index f657fd8fc0add..f38947b9a1b9b 100644 ---- a/include/sound/intel-nhlt.h -+++ b/include/sound/intel-nhlt.h -@@ -112,6 +112,11 @@ struct nhlt_vendor_dmic_array_config { - /* TODO add vendor mic config */ - } __packed; - -+enum { -+ NHLT_CONFIG_TYPE_GENERIC = 0, -+ NHLT_CONFIG_TYPE_MIC_ARRAY = 1 -+}; -+ - enum { - NHLT_MIC_ARRAY_2CH_SMALL = 0xa, - NHLT_MIC_ARRAY_2CH_BIG = 0xb, -diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c -index b9c2ee7ab43fa..cce12e1971d85 100644 ---- a/scripts/recordmcount.c -+++ b/scripts/recordmcount.c -@@ -438,7 +438,7 @@ static int arm_is_fake_mcount(Elf32_Rel const *rp) - - static int arm64_is_fake_mcount(Elf64_Rel const *rp) - { -- return ELF64_R_TYPE(w(rp->r_info)) != R_AARCH64_CALL26; -+ return ELF64_R_TYPE(w8(rp->r_info)) != R_AARCH64_CALL26; - } - - /* 64-bit EM_MIPS has weird ELF64_Rela.r_info. -diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c -index daede96f28ee3..baeda6c9716a1 100644 ---- a/sound/hda/intel-nhlt.c -+++ b/sound/hda/intel-nhlt.c -@@ -64,18 +64,44 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) - struct nhlt_endpoint *epnt; - struct nhlt_dmic_array_config *cfg; - struct nhlt_vendor_dmic_array_config *cfg_vendor; -+ struct nhlt_fmt *fmt_configs; - unsigned int dmic_geo = 0; -- u8 j; -+ u16 max_ch = 0; -+ u8 i, j; - - if (!nhlt) - return 0; - -- epnt = (struct nhlt_endpoint *)nhlt->desc; -+ for (j = 0, epnt = nhlt->desc; j < nhlt->endpoint_count; j++, -+ epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length)) { - -- for (j = 0; j < nhlt->endpoint_count; j++) { -- if (epnt->linktype == NHLT_LINK_DMIC) { -- cfg = (struct nhlt_dmic_array_config *) -- (epnt->config.caps); -+ if (epnt->linktype != NHLT_LINK_DMIC) -+ continue; -+ -+ cfg = (struct nhlt_dmic_array_config *)(epnt->config.caps); -+ fmt_configs = (struct nhlt_fmt *)(epnt->config.caps + epnt->config.size); -+ -+ /* find max number of channels based on format_configuration */ -+ if (fmt_configs->fmt_count) { -+ dev_dbg(dev, "%s: found %d format definitions\n", -+ __func__, fmt_configs->fmt_count); -+ -+ for (i = 0; i < fmt_configs->fmt_count; i++) { -+ struct wav_fmt_ext *fmt_ext; -+ -+ fmt_ext = &fmt_configs->fmt_config[i].fmt_ext; -+ -+ if (fmt_ext->fmt.channels > max_ch) -+ max_ch = fmt_ext->fmt.channels; -+ } -+ dev_dbg(dev, "%s: max channels found %d\n", __func__, max_ch); -+ } else { -+ dev_dbg(dev, "%s: No format information found\n", __func__); -+ } -+ -+ if (cfg->device_config.config_type != NHLT_CONFIG_TYPE_MIC_ARRAY) { -+ dmic_geo = max_ch; -+ } else { - switch (cfg->array_type) { - case NHLT_MIC_ARRAY_2CH_SMALL: - case NHLT_MIC_ARRAY_2CH_BIG: -@@ -92,13 +118,23 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) - dmic_geo = cfg_vendor->nb_mics; - break; - default: -- dev_warn(dev, "undefined DMIC array_type 0x%0x\n", -- cfg->array_type); -+ dev_warn(dev, "%s: undefined DMIC array_type 0x%0x\n", -+ __func__, cfg->array_type); -+ } -+ -+ if (dmic_geo > 0) { -+ dev_dbg(dev, "%s: Array with %d dmics\n", __func__, dmic_geo); -+ } -+ if (max_ch > dmic_geo) { -+ dev_dbg(dev, "%s: max channels %d exceed dmic number %d\n", -+ __func__, max_ch, dmic_geo); - } - } -- epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length); - } - -+ dev_dbg(dev, "%s: dmic number %d max_ch %d\n", -+ __func__, dmic_geo, max_ch); -+ - return dmic_geo; - } - EXPORT_SYMBOL_GPL(intel_nhlt_get_dmic_geo); -diff --git a/sound/pci/ctxfi/cthw20k2.c b/sound/pci/ctxfi/cthw20k2.c -index 3cd4b7dad945d..b1cc4cdc6c41f 100644 ---- a/sound/pci/ctxfi/cthw20k2.c -+++ b/sound/pci/ctxfi/cthw20k2.c -@@ -991,7 +991,7 @@ static int daio_mgr_dao_init(void *blk, unsigned int idx, unsigned int conf) - - if (idx < 4) { - /* S/PDIF output */ -- switch ((conf & 0x7)) { -+ switch ((conf & 0xf)) { - case 1: - set_field(&ctl->txctl[idx], ATXCTL_NUC, 0); - break; -diff --git a/tools/usb/usbip/libsrc/usbip_host_common.c b/tools/usb/usbip/libsrc/usbip_host_common.c -index d1d8ba2a4a40c..ca78aa3684762 100644 ---- a/tools/usb/usbip/libsrc/usbip_host_common.c -+++ b/tools/usb/usbip/libsrc/usbip_host_common.c -@@ -23,7 +23,7 @@ - #include "list.h" - #include "sysfs_utils.h" - --struct udev *udev_context; -+extern struct udev *udev_context; - - static int32_t read_attr_usbip_status(struct usbip_usb_device *udev) - { diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.104-105.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.104-105.patch deleted file mode 100644 index d24dd8b00c..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.104-105.patch +++ /dev/null @@ -1,1283 +0,0 @@ -diff --git a/Makefile b/Makefile -index e94dcf2d77f55..e27d031f3241e 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 104 -+SUBLEVEL = 105 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/drivers/acpi/acpica/acobject.h b/drivers/acpi/acpica/acobject.h -index 8def0e3d690fd..b0b9bb31c3364 100644 ---- a/drivers/acpi/acpica/acobject.h -+++ b/drivers/acpi/acpica/acobject.h -@@ -283,6 +283,7 @@ struct acpi_object_addr_handler { - acpi_adr_space_handler handler; - struct acpi_namespace_node *node; /* Parent device */ - void *context; -+ acpi_mutex context_mutex; - acpi_adr_space_setup setup; - union acpi_operand_object *region_list; /* Regions using this handler */ - union acpi_operand_object *next; -diff --git a/drivers/acpi/acpica/evhandler.c b/drivers/acpi/acpica/evhandler.c -index 3ef4e27995f0d..78550f5004c9e 100644 ---- a/drivers/acpi/acpica/evhandler.c -+++ b/drivers/acpi/acpica/evhandler.c -@@ -489,6 +489,13 @@ acpi_ev_install_space_handler(struct acpi_namespace_node *node, - - /* Init handler obj */ - -+ status = -+ acpi_os_create_mutex(&handler_obj->address_space.context_mutex); -+ if (ACPI_FAILURE(status)) { -+ acpi_ut_remove_reference(handler_obj); -+ goto unlock_and_exit; -+ } -+ - handler_obj->address_space.space_id = (u8)space_id; - handler_obj->address_space.handler_flags = flags; - handler_obj->address_space.region_list = NULL; -diff --git a/drivers/acpi/acpica/evregion.c b/drivers/acpi/acpica/evregion.c -index 45dc797df05de..50782033012b2 100644 ---- a/drivers/acpi/acpica/evregion.c -+++ b/drivers/acpi/acpica/evregion.c -@@ -111,6 +111,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - union acpi_operand_object *region_obj2; - void *region_context = NULL; - struct acpi_connection_info *context; -+ acpi_mutex context_mutex; -+ u8 context_locked; - acpi_physical_address address; - - ACPI_FUNCTION_TRACE(ev_address_space_dispatch); -@@ -135,6 +137,8 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - } - - context = handler_desc->address_space.context; -+ context_mutex = handler_desc->address_space.context_mutex; -+ context_locked = FALSE; - - /* - * It may be the case that the region has never been initialized. -@@ -203,6 +207,23 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - handler = handler_desc->address_space.handler; - address = (region_obj->region.address + region_offset); - -+ ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, -+ "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", -+ ®ion_obj->region.handler->address_space, handler, -+ ACPI_FORMAT_UINT64(address), -+ acpi_ut_get_region_name(region_obj->region. -+ space_id))); -+ -+ if (!(handler_desc->address_space.handler_flags & -+ ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { -+ /* -+ * For handlers other than the default (supplied) handlers, we must -+ * exit the interpreter because the handler *might* block -- we don't -+ * know what it will do, so we can't hold the lock on the interpreter. -+ */ -+ acpi_ex_exit_interpreter(); -+ } -+ - /* - * Special handling for generic_serial_bus and general_purpose_io: - * There are three extra parameters that must be passed to the -@@ -211,6 +232,11 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - * 2) Length of the above buffer - * 3) Actual access length from the access_as() op - * -+ * Since we pass these extra parameters via the context, which is -+ * shared between threads, we must lock the context to avoid these -+ * parameters being changed from another thread before the handler -+ * has completed running. -+ * - * In addition, for general_purpose_io, the Address and bit_width fields - * are defined as follows: - * 1) Address is the pin number index of the field (bit offset from -@@ -220,6 +246,14 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - if ((region_obj->region.space_id == ACPI_ADR_SPACE_GSBUS) && - context && field_obj) { - -+ status = -+ acpi_os_acquire_mutex(context_mutex, ACPI_WAIT_FOREVER); -+ if (ACPI_FAILURE(status)) { -+ goto re_enter_interpreter; -+ } -+ -+ context_locked = TRUE; -+ - /* Get the Connection (resource_template) buffer */ - - context->connection = field_obj->field.resource_buffer; -@@ -229,6 +263,14 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - if ((region_obj->region.space_id == ACPI_ADR_SPACE_GPIO) && - context && field_obj) { - -+ status = -+ acpi_os_acquire_mutex(context_mutex, ACPI_WAIT_FOREVER); -+ if (ACPI_FAILURE(status)) { -+ goto re_enter_interpreter; -+ } -+ -+ context_locked = TRUE; -+ - /* Get the Connection (resource_template) buffer */ - - context->connection = field_obj->field.resource_buffer; -@@ -238,28 +280,15 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - bit_width = field_obj->field.bit_length; - } - -- ACPI_DEBUG_PRINT((ACPI_DB_OPREGION, -- "Handler %p (@%p) Address %8.8X%8.8X [%s]\n", -- ®ion_obj->region.handler->address_space, handler, -- ACPI_FORMAT_UINT64(address), -- acpi_ut_get_region_name(region_obj->region. -- space_id))); -- -- if (!(handler_desc->address_space.handler_flags & -- ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { -- /* -- * For handlers other than the default (supplied) handlers, we must -- * exit the interpreter because the handler *might* block -- we don't -- * know what it will do, so we can't hold the lock on the interpreter. -- */ -- acpi_ex_exit_interpreter(); -- } -- - /* Call the handler */ - - status = handler(function, address, bit_width, value, context, - region_obj2->extra.region_context); - -+ if (context_locked) { -+ acpi_os_release_mutex(context_mutex); -+ } -+ - if (ACPI_FAILURE(status)) { - ACPI_EXCEPTION((AE_INFO, status, "Returned by Handler for [%s]", - acpi_ut_get_region_name(region_obj->region. -@@ -276,6 +305,7 @@ acpi_ev_address_space_dispatch(union acpi_operand_object *region_obj, - } - } - -+re_enter_interpreter: - if (!(handler_desc->address_space.handler_flags & - ACPI_ADDR_HANDLER_DEFAULT_INSTALLED)) { - /* -diff --git a/drivers/acpi/acpica/evxfregn.c b/drivers/acpi/acpica/evxfregn.c -index 47265b073e6ff..6e0d2a98c4ade 100644 ---- a/drivers/acpi/acpica/evxfregn.c -+++ b/drivers/acpi/acpica/evxfregn.c -@@ -201,6 +201,8 @@ acpi_remove_address_space_handler(acpi_handle device, - - /* Now we can delete the handler object */ - -+ acpi_os_release_mutex(handler_obj->address_space. -+ context_mutex); - acpi_ut_remove_reference(handler_obj); - goto unlock_and_exit; - } -diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c -index 55af78b55c513..301ffe5b8feb0 100644 ---- a/drivers/acpi/video_detect.c -+++ b/drivers/acpi/video_detect.c -@@ -143,6 +143,13 @@ static const struct dmi_system_id video_detect_dmi_table[] = { - }, - { - .callback = video_detect_force_vendor, -+ .ident = "GIGABYTE GB-BXBT-2807", -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "GIGABYTE"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "GB-BXBT-2807"), -+ }, -+ }, -+ { - .ident = "Sony VPCEH3U1E", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), -diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c -index c8fb21cc0d6ff..f84049119f1c1 100644 ---- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c -+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c -@@ -581,8 +581,6 @@ static int a5xx_hw_init(struct msm_gpu *gpu) - if (adreno_gpu->info->quirks & ADRENO_QUIRK_TWO_PASS_USE_WFI) - gpu_rmw(gpu, REG_A5XX_PC_DBG_ECO_CNTL, 0, (1 << 8)); - -- gpu_write(gpu, REG_A5XX_PC_DBG_ECO_CNTL, 0xc0200100); -- - /* Enable USE_RETENTION_FLOPS */ - gpu_write(gpu, REG_A5XX_CP_CHICKEN_DBG, 0x02000000); - -diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h -index 33183933337af..d004f5645b30c 100644 ---- a/drivers/hid/hid-ids.h -+++ b/drivers/hid/hid-ids.h -@@ -365,6 +365,7 @@ - #define USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR 0x1803 - #define USB_DEVICE_ID_DRAGONRISE_GAMECUBE1 0x1843 - #define USB_DEVICE_ID_DRAGONRISE_GAMECUBE2 0x1844 -+#define USB_DEVICE_ID_DRAGONRISE_GAMECUBE3 0x1846 - - #define USB_VENDOR_ID_DWAV 0x0eef - #define USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER 0x0001 -@@ -640,6 +641,8 @@ - #define USB_DEVICE_ID_INNEX_GENESIS_ATARI 0x4745 - - #define USB_VENDOR_ID_ITE 0x048d -+#define I2C_VENDOR_ID_ITE 0x103c -+#define I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15 0x184f - #define USB_DEVICE_ID_ITE_LENOVO_YOGA 0x8386 - #define USB_DEVICE_ID_ITE_LENOVO_YOGA2 0x8350 - #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720 0x837a -diff --git a/drivers/hid/hid-mf.c b/drivers/hid/hid-mf.c -index fc75f30f537c9..92d7ecd41a78f 100644 ---- a/drivers/hid/hid-mf.c -+++ b/drivers/hid/hid-mf.c -@@ -153,6 +153,8 @@ static const struct hid_device_id mf_devices[] = { - .driver_data = HID_QUIRK_MULTI_INPUT }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE2), - .driver_data = 0 }, /* No quirk required */ -+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3), -+ .driver_data = HID_QUIRK_MULTI_INPUT }, - { } - }; - MODULE_DEVICE_TABLE(hid, mf_devices); -diff --git a/drivers/hid/hid-quirks.c b/drivers/hid/hid-quirks.c -index 60d188a704e5e..f35d919c4ebab 100644 ---- a/drivers/hid/hid-quirks.c -+++ b/drivers/hid/hid-quirks.c -@@ -72,6 +72,7 @@ static const struct hid_device_id hid_quirks[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_REDRAGON_SEYMUR2), HID_QUIRK_INCREMENT_USAGE_ON_DUPLICATE }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR), HID_QUIRK_MULTI_INPUT }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1), HID_QUIRK_MULTI_INPUT }, -+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3), HID_QUIRK_MULTI_INPUT }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_PS3), HID_QUIRK_MULTI_INPUT }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU), HID_QUIRK_MULTI_INPUT }, - { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_EGALAX_TOUCHCONTROLLER), HID_QUIRK_MULTI_INPUT | HID_QUIRK_NOGET }, -@@ -491,6 +492,7 @@ static const struct hid_device_id hid_have_special_driver[] = { - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_DOLPHINBAR) }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE1) }, - { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE2) }, -+ { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_GAMECUBE3) }, - #endif - #if IS_ENABLED(CONFIG_HID_MICROSOFT) - { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_COMFORT_MOUSE_4500) }, -diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c -index 592176aff0270..96898983db990 100644 ---- a/drivers/hid/i2c-hid/i2c-hid-core.c -+++ b/drivers/hid/i2c-hid/i2c-hid-core.c -@@ -173,6 +173,8 @@ static const struct i2c_hid_quirks { - I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV }, - { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288, - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, -+ { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15, -+ I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, - { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118, - I2C_HID_QUIRK_NO_IRQ_AFTER_RESET }, - { USB_VENDOR_ID_ELAN, HID_ANY_ID, -diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c -index 7b724f7b27a99..c392930253a30 100644 ---- a/drivers/iommu/amd_iommu.c -+++ b/drivers/iommu/amd_iommu.c -@@ -1469,25 +1469,27 @@ static bool increase_address_space(struct protection_domain *domain, - bool ret = false; - u64 *pte; - -+ pte = (void *)get_zeroed_page(gfp); -+ if (!pte) -+ return false; -+ - spin_lock_irqsave(&domain->lock, flags); - - if (address <= PM_LEVEL_SIZE(domain->mode) || - WARN_ON_ONCE(domain->mode == PAGE_MODE_6_LEVEL)) - goto out; - -- pte = (void *)get_zeroed_page(gfp); -- if (!pte) -- goto out; -- - *pte = PM_LEVEL_PDE(domain->mode, - iommu_virt_to_phys(domain->pt_root)); - domain->pt_root = pte; - domain->mode += 1; - -+ pte = NULL; - ret = true; - - out: - spin_unlock_irqrestore(&domain->lock, flags); -+ free_page((unsigned long)pte); - - return ret; - } -diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c -index 98be040cf958c..06b382304d926 100644 ---- a/drivers/md/dm-table.c -+++ b/drivers/md/dm-table.c -@@ -888,24 +888,24 @@ void dm_table_set_type(struct dm_table *t, enum dm_queue_mode type) - EXPORT_SYMBOL_GPL(dm_table_set_type); - - /* validate the dax capability of the target device span */ --int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, -+int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) - { - int blocksize = *(int *) data, id; - bool rc; - - id = dax_read_lock(); -- rc = dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len); -+ rc = !dax_supported(dev->dax_dev, dev->bdev, blocksize, start, len); - dax_read_unlock(id); - - return rc; - } - - /* Check devices support synchronous DAX */ --static int device_dax_synchronous(struct dm_target *ti, struct dm_dev *dev, -- sector_t start, sector_t len, void *data) -+static int device_not_dax_synchronous_capable(struct dm_target *ti, struct dm_dev *dev, -+ sector_t start, sector_t len, void *data) - { -- return dev->dax_dev && dax_synchronous(dev->dax_dev); -+ return !dev->dax_dev || !dax_synchronous(dev->dax_dev); - } - - bool dm_table_supports_dax(struct dm_table *t, -@@ -922,7 +922,7 @@ bool dm_table_supports_dax(struct dm_table *t, - return false; - - if (!ti->type->iterate_devices || -- !ti->type->iterate_devices(ti, iterate_fn, blocksize)) -+ ti->type->iterate_devices(ti, iterate_fn, blocksize)) - return false; - } - -@@ -996,7 +996,7 @@ static int dm_table_determine_type(struct dm_table *t) - verify_bio_based: - /* We must use this table as bio-based */ - t->type = DM_TYPE_BIO_BASED; -- if (dm_table_supports_dax(t, device_supports_dax, &page_size) || -+ if (dm_table_supports_dax(t, device_not_dax_capable, &page_size) || - (list_empty(devices) && live_md_type == DM_TYPE_DAX_BIO_BASED)) { - t->type = DM_TYPE_DAX_BIO_BASED; - } else { -@@ -1376,6 +1376,46 @@ struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector) - return &t->targets[(KEYS_PER_NODE * n) + k]; - } - -+/* -+ * type->iterate_devices() should be called when the sanity check needs to -+ * iterate and check all underlying data devices. iterate_devices() will -+ * iterate all underlying data devices until it encounters a non-zero return -+ * code, returned by whether the input iterate_devices_callout_fn, or -+ * iterate_devices() itself internally. -+ * -+ * For some target type (e.g. dm-stripe), one call of iterate_devices() may -+ * iterate multiple underlying devices internally, in which case a non-zero -+ * return code returned by iterate_devices_callout_fn will stop the iteration -+ * in advance. -+ * -+ * Cases requiring _any_ underlying device supporting some kind of attribute, -+ * should use the iteration structure like dm_table_any_dev_attr(), or call -+ * it directly. @func should handle semantics of positive examples, e.g. -+ * capable of something. -+ * -+ * Cases requiring _all_ underlying devices supporting some kind of attribute, -+ * should use the iteration structure like dm_table_supports_nowait() or -+ * dm_table_supports_discards(). Or introduce dm_table_all_devs_attr() that -+ * uses an @anti_func that handle semantics of counter examples, e.g. not -+ * capable of something. So: return !dm_table_any_dev_attr(t, anti_func, data); -+ */ -+static bool dm_table_any_dev_attr(struct dm_table *t, -+ iterate_devices_callout_fn func, void *data) -+{ -+ struct dm_target *ti; -+ unsigned int i; -+ -+ for (i = 0; i < dm_table_get_num_targets(t); i++) { -+ ti = dm_table_get_target(t, i); -+ -+ if (ti->type->iterate_devices && -+ ti->type->iterate_devices(ti, func, data)) -+ return true; -+ } -+ -+ return false; -+} -+ - static int count_device(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) - { -@@ -1412,13 +1452,13 @@ bool dm_table_has_no_data_devices(struct dm_table *table) - return true; - } - --static int device_is_zoned_model(struct dm_target *ti, struct dm_dev *dev, -- sector_t start, sector_t len, void *data) -+static int device_not_zoned_model(struct dm_target *ti, struct dm_dev *dev, -+ sector_t start, sector_t len, void *data) - { - struct request_queue *q = bdev_get_queue(dev->bdev); - enum blk_zoned_model *zoned_model = data; - -- return q && blk_queue_zoned_model(q) == *zoned_model; -+ return !q || blk_queue_zoned_model(q) != *zoned_model; - } - - static bool dm_table_supports_zoned_model(struct dm_table *t, -@@ -1435,37 +1475,20 @@ static bool dm_table_supports_zoned_model(struct dm_table *t, - return false; - - if (!ti->type->iterate_devices || -- !ti->type->iterate_devices(ti, device_is_zoned_model, &zoned_model)) -+ ti->type->iterate_devices(ti, device_not_zoned_model, &zoned_model)) - return false; - } - - return true; - } - --static int device_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev, -- sector_t start, sector_t len, void *data) -+static int device_not_matches_zone_sectors(struct dm_target *ti, struct dm_dev *dev, -+ sector_t start, sector_t len, void *data) - { - struct request_queue *q = bdev_get_queue(dev->bdev); - unsigned int *zone_sectors = data; - -- return q && blk_queue_zone_sectors(q) == *zone_sectors; --} -- --static bool dm_table_matches_zone_sectors(struct dm_table *t, -- unsigned int zone_sectors) --{ -- struct dm_target *ti; -- unsigned i; -- -- for (i = 0; i < dm_table_get_num_targets(t); i++) { -- ti = dm_table_get_target(t, i); -- -- if (!ti->type->iterate_devices || -- !ti->type->iterate_devices(ti, device_matches_zone_sectors, &zone_sectors)) -- return false; -- } -- -- return true; -+ return !q || blk_queue_zone_sectors(q) != *zone_sectors; - } - - static int validate_hardware_zoned_model(struct dm_table *table, -@@ -1485,7 +1508,7 @@ static int validate_hardware_zoned_model(struct dm_table *table, - if (!zone_sectors || !is_power_of_2(zone_sectors)) - return -EINVAL; - -- if (!dm_table_matches_zone_sectors(table, zone_sectors)) { -+ if (dm_table_any_dev_attr(table, device_not_matches_zone_sectors, &zone_sectors)) { - DMERR("%s: zone sectors is not consistent across all devices", - dm_device_name(table->md)); - return -EINVAL; -@@ -1675,29 +1698,12 @@ static int device_dax_write_cache_enabled(struct dm_target *ti, - return false; - } - --static int dm_table_supports_dax_write_cache(struct dm_table *t) --{ -- struct dm_target *ti; -- unsigned i; -- -- for (i = 0; i < dm_table_get_num_targets(t); i++) { -- ti = dm_table_get_target(t, i); -- -- if (ti->type->iterate_devices && -- ti->type->iterate_devices(ti, -- device_dax_write_cache_enabled, NULL)) -- return true; -- } -- -- return false; --} -- --static int device_is_nonrot(struct dm_target *ti, struct dm_dev *dev, -- sector_t start, sector_t len, void *data) -+static int device_is_rotational(struct dm_target *ti, struct dm_dev *dev, -+ sector_t start, sector_t len, void *data) - { - struct request_queue *q = bdev_get_queue(dev->bdev); - -- return q && blk_queue_nonrot(q); -+ return q && !blk_queue_nonrot(q); - } - - static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev, -@@ -1708,35 +1714,18 @@ static int device_is_not_random(struct dm_target *ti, struct dm_dev *dev, - return q && !blk_queue_add_random(q); - } - --static bool dm_table_all_devices_attribute(struct dm_table *t, -- iterate_devices_callout_fn func) --{ -- struct dm_target *ti; -- unsigned i; -- -- for (i = 0; i < dm_table_get_num_targets(t); i++) { -- ti = dm_table_get_target(t, i); -- -- if (!ti->type->iterate_devices || -- !ti->type->iterate_devices(ti, func, NULL)) -- return false; -- } -- -- return true; --} -- --static int device_no_partial_completion(struct dm_target *ti, struct dm_dev *dev, -+static int device_is_partial_completion(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data) - { - char b[BDEVNAME_SIZE]; - - /* For now, NVMe devices are the only devices of this class */ -- return (strncmp(bdevname(dev->bdev, b), "nvme", 4) == 0); -+ return (strncmp(bdevname(dev->bdev, b), "nvme", 4) != 0); - } - - static bool dm_table_does_not_support_partial_completion(struct dm_table *t) - { -- return dm_table_all_devices_attribute(t, device_no_partial_completion); -+ return !dm_table_any_dev_attr(t, device_is_partial_completion, NULL); - } - - static int device_not_write_same_capable(struct dm_target *ti, struct dm_dev *dev, -@@ -1863,27 +1852,6 @@ static int device_requires_stable_pages(struct dm_target *ti, - return q && bdi_cap_stable_pages_required(q->backing_dev_info); - } - --/* -- * If any underlying device requires stable pages, a table must require -- * them as well. Only targets that support iterate_devices are considered: -- * don't want error, zero, etc to require stable pages. -- */ --static bool dm_table_requires_stable_pages(struct dm_table *t) --{ -- struct dm_target *ti; -- unsigned i; -- -- for (i = 0; i < dm_table_get_num_targets(t); i++) { -- ti = dm_table_get_target(t, i); -- -- if (ti->type->iterate_devices && -- ti->type->iterate_devices(ti, device_requires_stable_pages, NULL)) -- return true; -- } -- -- return false; --} -- - void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, - struct queue_limits *limits) - { -@@ -1916,22 +1884,22 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, - } - blk_queue_write_cache(q, wc, fua); - -- if (dm_table_supports_dax(t, device_supports_dax, &page_size)) { -+ if (dm_table_supports_dax(t, device_not_dax_capable, &page_size)) { - blk_queue_flag_set(QUEUE_FLAG_DAX, q); -- if (dm_table_supports_dax(t, device_dax_synchronous, NULL)) -+ if (dm_table_supports_dax(t, device_not_dax_synchronous_capable, NULL)) - set_dax_synchronous(t->md->dax_dev); - } - else - blk_queue_flag_clear(QUEUE_FLAG_DAX, q); - -- if (dm_table_supports_dax_write_cache(t)) -+ if (dm_table_any_dev_attr(t, device_dax_write_cache_enabled, NULL)) - dax_write_cache(t->md->dax_dev, true); - - /* Ensure that all underlying devices are non-rotational. */ -- if (dm_table_all_devices_attribute(t, device_is_nonrot)) -- blk_queue_flag_set(QUEUE_FLAG_NONROT, q); -- else -+ if (dm_table_any_dev_attr(t, device_is_rotational, NULL)) - blk_queue_flag_clear(QUEUE_FLAG_NONROT, q); -+ else -+ blk_queue_flag_set(QUEUE_FLAG_NONROT, q); - - if (!dm_table_supports_write_same(t)) - q->limits.max_write_same_sectors = 0; -@@ -1943,8 +1911,11 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, - /* - * Some devices don't use blk_integrity but still want stable pages - * because they do their own checksumming. -+ * If any underlying device requires stable pages, a table must require -+ * them as well. Only targets that support iterate_devices are considered: -+ * don't want error, zero, etc to require stable pages. - */ -- if (dm_table_requires_stable_pages(t)) -+ if (dm_table_any_dev_attr(t, device_requires_stable_pages, NULL)) - q->backing_dev_info->capabilities |= BDI_CAP_STABLE_WRITES; - else - q->backing_dev_info->capabilities &= ~BDI_CAP_STABLE_WRITES; -@@ -1955,7 +1926,8 @@ void dm_table_set_restrictions(struct dm_table *t, struct request_queue *q, - * Clear QUEUE_FLAG_ADD_RANDOM if any underlying device does not - * have it set. - */ -- if (blk_queue_add_random(q) && dm_table_all_devices_attribute(t, device_is_not_random)) -+ if (blk_queue_add_random(q) && -+ dm_table_any_dev_attr(t, device_is_not_random, NULL)) - blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q); - - /* -diff --git a/drivers/md/dm.c b/drivers/md/dm.c -index de32f8553735f..530c0fe142291 100644 ---- a/drivers/md/dm.c -+++ b/drivers/md/dm.c -@@ -1139,7 +1139,7 @@ static bool dm_dax_supported(struct dax_device *dax_dev, struct block_device *bd - if (!map) - goto out; - -- ret = dm_table_supports_dax(map, device_supports_dax, &blocksize); -+ ret = dm_table_supports_dax(map, device_not_dax_capable, &blocksize); - - out: - dm_put_live_table(md, srcu_idx); -diff --git a/drivers/md/dm.h b/drivers/md/dm.h -index d7c4f6606b5fc..9fbf87e04019c 100644 ---- a/drivers/md/dm.h -+++ b/drivers/md/dm.h -@@ -74,7 +74,7 @@ void dm_table_free_md_mempools(struct dm_table *t); - struct dm_md_mempools *dm_table_get_md_mempools(struct dm_table *t); - bool dm_table_supports_dax(struct dm_table *t, iterate_devices_callout_fn fn, - int *blocksize); --int device_supports_dax(struct dm_target *ti, struct dm_dev *dev, -+int device_not_dax_capable(struct dm_target *ti, struct dm_dev *dev, - sector_t start, sector_t len, void *data); - - void dm_lock_md_type(struct mapped_device *md); -diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c -index 7e0b0b7cc2a35..ead0acb7807c8 100644 ---- a/drivers/media/pci/cx23885/cx23885-core.c -+++ b/drivers/media/pci/cx23885/cx23885-core.c -@@ -2074,6 +2074,10 @@ static struct { - * 0x1451 is PCI ID for the IOMMU found on Ryzen - */ - { PCI_VENDOR_ID_AMD, 0x1451 }, -+ /* According to sudo lspci -nn, -+ * 0x1423 is the PCI ID for the IOMMU found on Kaveri -+ */ -+ { PCI_VENDOR_ID_AMD, 0x1423 }, - }; - - static bool cx23885_does_need_dma_reset(void) -diff --git a/drivers/misc/eeprom/eeprom_93xx46.c b/drivers/misc/eeprom/eeprom_93xx46.c -index 414dcbd3c3c25..8b355fc0607b7 100644 ---- a/drivers/misc/eeprom/eeprom_93xx46.c -+++ b/drivers/misc/eeprom/eeprom_93xx46.c -@@ -35,6 +35,10 @@ static const struct eeprom_93xx46_devtype_data atmel_at93c46d_data = { - EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH, - }; - -+static const struct eeprom_93xx46_devtype_data microchip_93lc46b_data = { -+ .quirks = EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE, -+}; -+ - struct eeprom_93xx46_dev { - struct spi_device *spi; - struct eeprom_93xx46_platform_data *pdata; -@@ -55,6 +59,11 @@ static inline bool has_quirk_instruction_length(struct eeprom_93xx46_dev *edev) - return edev->pdata->quirks & EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH; - } - -+static inline bool has_quirk_extra_read_cycle(struct eeprom_93xx46_dev *edev) -+{ -+ return edev->pdata->quirks & EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE; -+} -+ - static int eeprom_93xx46_read(void *priv, unsigned int off, - void *val, size_t count) - { -@@ -96,6 +105,11 @@ static int eeprom_93xx46_read(void *priv, unsigned int off, - dev_dbg(&edev->spi->dev, "read cmd 0x%x, %d Hz\n", - cmd_addr, edev->spi->max_speed_hz); - -+ if (has_quirk_extra_read_cycle(edev)) { -+ cmd_addr <<= 1; -+ bits += 1; -+ } -+ - spi_message_init(&m); - - t[0].tx_buf = (char *)&cmd_addr; -@@ -363,6 +377,7 @@ static void select_deassert(void *context) - static const struct of_device_id eeprom_93xx46_of_table[] = { - { .compatible = "eeprom-93xx46", }, - { .compatible = "atmel,at93c46d", .data = &atmel_at93c46d_data, }, -+ { .compatible = "microchip,93lc46b", .data = µchip_93lc46b_data, }, - {} - }; - MODULE_DEVICE_TABLE(of, eeprom_93xx46_of_table); -diff --git a/drivers/mmc/host/sdhci-of-dwcmshc.c b/drivers/mmc/host/sdhci-of-dwcmshc.c -index a5137845a1c78..6793fb8fe976b 100644 ---- a/drivers/mmc/host/sdhci-of-dwcmshc.c -+++ b/drivers/mmc/host/sdhci-of-dwcmshc.c -@@ -58,6 +58,7 @@ static const struct sdhci_ops sdhci_dwcmshc_ops = { - static const struct sdhci_pltfm_data sdhci_dwcmshc_pdata = { - .ops = &sdhci_dwcmshc_ops, - .quirks = SDHCI_QUIRK_CAP_CLOCK_BASE_BROKEN, -+ .quirks2 = SDHCI_QUIRK2_PRESET_VALUE_BROKEN, - }; - - static int dwcmshc_probe(struct platform_device *pdev) -diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c -index fc1706d0647d7..58c9623c3a916 100644 ---- a/drivers/net/wireless/marvell/mwifiex/pcie.c -+++ b/drivers/net/wireless/marvell/mwifiex/pcie.c -@@ -377,6 +377,8 @@ static void mwifiex_pcie_reset_prepare(struct pci_dev *pdev) - clear_bit(MWIFIEX_IFACE_WORK_DEVICE_DUMP, &card->work_flags); - clear_bit(MWIFIEX_IFACE_WORK_CARD_RESET, &card->work_flags); - mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); -+ -+ card->pci_reset_ongoing = true; - } - - /* -@@ -405,6 +407,8 @@ static void mwifiex_pcie_reset_done(struct pci_dev *pdev) - dev_err(&pdev->dev, "reinit failed: %d\n", ret); - else - mwifiex_dbg(adapter, INFO, "%s, successful\n", __func__); -+ -+ card->pci_reset_ongoing = false; - } - - static const struct pci_error_handlers mwifiex_pcie_err_handler = { -@@ -2995,7 +2999,19 @@ static void mwifiex_cleanup_pcie(struct mwifiex_adapter *adapter) - int ret; - u32 fw_status; - -- cancel_work_sync(&card->work); -+ /* Perform the cancel_work_sync() only when we're not resetting -+ * the card. It's because that function never returns if we're -+ * in reset path. If we're here when resetting the card, it means -+ * that we failed to reset the card (reset failure path). -+ */ -+ if (!card->pci_reset_ongoing) { -+ mwifiex_dbg(adapter, MSG, "performing cancel_work_sync()...\n"); -+ cancel_work_sync(&card->work); -+ mwifiex_dbg(adapter, MSG, "cancel_work_sync() done\n"); -+ } else { -+ mwifiex_dbg(adapter, MSG, -+ "skipped cancel_work_sync() because we're in card reset failure path\n"); -+ } - - ret = mwifiex_read_reg(adapter, reg->fw_status, &fw_status); - if (fw_status == FIRMWARE_READY_PCIE) { -diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.h b/drivers/net/wireless/marvell/mwifiex/pcie.h -index f7ce9b6db6b41..72d0c01ff3592 100644 ---- a/drivers/net/wireless/marvell/mwifiex/pcie.h -+++ b/drivers/net/wireless/marvell/mwifiex/pcie.h -@@ -391,6 +391,8 @@ struct pcie_service_card { - struct mwifiex_msix_context share_irq_ctx; - struct work_struct work; - unsigned long work_flags; -+ -+ bool pci_reset_ongoing; - }; - - static inline int -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index abc342db3b337..fc18738dcf8ff 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -3164,7 +3164,8 @@ static const struct pci_device_id nvme_id_table[] = { - { PCI_DEVICE(0x126f, 0x2263), /* Silicon Motion unidentified */ - .driver_data = NVME_QUIRK_NO_NS_DESC_LIST, }, - { PCI_DEVICE(0x1bb1, 0x0100), /* Seagate Nytro Flash Storage */ -- .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, -+ .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY | -+ NVME_QUIRK_NO_NS_DESC_LIST, }, - { PCI_DEVICE(0x1c58, 0x0003), /* HGST adapter */ - .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, - { PCI_DEVICE(0x1c58, 0x0023), /* WDC SN200 adapter */ -@@ -3178,6 +3179,9 @@ static const struct pci_device_id nvme_id_table[] = { - NVME_QUIRK_IGNORE_DEV_SUBNQN, }, - { PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */ - .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, }, -+ { PCI_DEVICE(0x1b4b, 0x1092), /* Lexar 256 GB SSD */ -+ .driver_data = NVME_QUIRK_NO_NS_DESC_LIST | -+ NVME_QUIRK_IGNORE_DEV_SUBNQN, }, - { PCI_DEVICE(0x1d1d, 0x1f1f), /* LighNVM qemu device */ - .driver_data = NVME_QUIRK_LIGHTNVM, }, - { PCI_DEVICE(0x1d1d, 0x2807), /* CNEX WL */ -diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c -index c98067579e9f3..53376bcda1f3f 100644 ---- a/drivers/pci/quirks.c -+++ b/drivers/pci/quirks.c -@@ -4055,6 +4055,9 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9183, - /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c46 */ - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x91a0, - quirk_dma_func1_alias); -+/* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c135 */ -+DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9215, -+ quirk_dma_func1_alias); - /* https://bugzilla.kernel.org/show_bug.cgi?id=42679#c127 */ - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL_EXT, 0x9220, - quirk_dma_func1_alias); -diff --git a/drivers/platform/x86/acer-wmi.c b/drivers/platform/x86/acer-wmi.c -index 7fa27e7536917..d27a564389a47 100644 ---- a/drivers/platform/x86/acer-wmi.c -+++ b/drivers/platform/x86/acer-wmi.c -@@ -30,6 +30,7 @@ - #include - #include - -+ACPI_MODULE_NAME(KBUILD_MODNAME); - MODULE_AUTHOR("Carlos Corbacho"); - MODULE_DESCRIPTION("Acer Laptop WMI Extras Driver"); - MODULE_LICENSE("GPL"); -@@ -80,7 +81,7 @@ MODULE_ALIAS("wmi:676AA15E-6A47-4D9F-A2CC-1E6D18D14026"); - - enum acer_wmi_event_ids { - WMID_HOTKEY_EVENT = 0x1, -- WMID_ACCEL_EVENT = 0x5, -+ WMID_ACCEL_OR_KBD_DOCK_EVENT = 0x5, - }; - - static const struct key_entry acer_wmi_keymap[] __initconst = { -@@ -128,7 +129,9 @@ struct event_return_value { - u8 function; - u8 key_num; - u16 device_state; -- u32 reserved; -+ u16 reserved1; -+ u8 kbd_dock_state; -+ u8 reserved2; - } __attribute__((packed)); - - /* -@@ -206,14 +209,13 @@ struct hotkey_function_type_aa { - /* - * Interface capability flags - */ --#define ACER_CAP_MAILLED (1<<0) --#define ACER_CAP_WIRELESS (1<<1) --#define ACER_CAP_BLUETOOTH (1<<2) --#define ACER_CAP_BRIGHTNESS (1<<3) --#define ACER_CAP_THREEG (1<<4) --#define ACER_CAP_ACCEL (1<<5) --#define ACER_CAP_RFBTN (1<<6) --#define ACER_CAP_ANY (0xFFFFFFFF) -+#define ACER_CAP_MAILLED BIT(0) -+#define ACER_CAP_WIRELESS BIT(1) -+#define ACER_CAP_BLUETOOTH BIT(2) -+#define ACER_CAP_BRIGHTNESS BIT(3) -+#define ACER_CAP_THREEG BIT(4) -+#define ACER_CAP_SET_FUNCTION_MODE BIT(5) -+#define ACER_CAP_KBD_DOCK BIT(6) - - /* - * Interface type flags -@@ -236,6 +238,7 @@ static int mailled = -1; - static int brightness = -1; - static int threeg = -1; - static int force_series; -+static int force_caps = -1; - static bool ec_raw_mode; - static bool has_type_aa; - static u16 commun_func_bitmap; -@@ -245,11 +248,13 @@ module_param(mailled, int, 0444); - module_param(brightness, int, 0444); - module_param(threeg, int, 0444); - module_param(force_series, int, 0444); -+module_param(force_caps, int, 0444); - module_param(ec_raw_mode, bool, 0444); - MODULE_PARM_DESC(mailled, "Set initial state of Mail LED"); - MODULE_PARM_DESC(brightness, "Set initial LCD backlight brightness"); - MODULE_PARM_DESC(threeg, "Set initial state of 3G hardware"); - MODULE_PARM_DESC(force_series, "Force a different laptop series"); -+MODULE_PARM_DESC(force_caps, "Force the capability bitmask to this value"); - MODULE_PARM_DESC(ec_raw_mode, "Enable EC raw mode"); - - struct acer_data { -@@ -319,6 +324,15 @@ static int __init dmi_matched(const struct dmi_system_id *dmi) - return 1; - } - -+static int __init set_force_caps(const struct dmi_system_id *dmi) -+{ -+ if (force_caps == -1) { -+ force_caps = (uintptr_t)dmi->driver_data; -+ pr_info("Found %s, set force_caps to 0x%x\n", dmi->ident, force_caps); -+ } -+ return 1; -+} -+ - static struct quirk_entry quirk_unknown = { - }; - -@@ -497,6 +511,33 @@ static const struct dmi_system_id acer_quirks[] __initconst = { - }, - .driver_data = &quirk_acer_travelmate_2490, - }, -+ { -+ .callback = set_force_caps, -+ .ident = "Acer Aspire Switch 10E SW3-016", -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW3-016"), -+ }, -+ .driver_data = (void *)ACER_CAP_KBD_DOCK, -+ }, -+ { -+ .callback = set_force_caps, -+ .ident = "Acer Aspire Switch 10 SW5-012", -+ .matches = { -+ DMI_MATCH(DMI_SYS_VENDOR, "Acer"), -+ DMI_MATCH(DMI_PRODUCT_NAME, "Aspire SW5-012"), -+ }, -+ .driver_data = (void *)ACER_CAP_KBD_DOCK, -+ }, -+ { -+ .callback = set_force_caps, -+ .ident = "Acer One 10 (S1003)", -+ .matches = { -+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "Acer"), -+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "One S1003"), -+ }, -+ .driver_data = (void *)ACER_CAP_KBD_DOCK, -+ }, - {} - }; - -@@ -1253,10 +1294,8 @@ static void __init type_aa_dmi_decode(const struct dmi_header *header, void *d) - interface->capability |= ACER_CAP_THREEG; - if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_BLUETOOTH) - interface->capability |= ACER_CAP_BLUETOOTH; -- if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_RFBTN) { -- interface->capability |= ACER_CAP_RFBTN; -+ if (type_aa->commun_func_bitmap & ACER_WMID3_GDS_RFBTN) - commun_func_bitmap &= ~ACER_WMID3_GDS_RFBTN; -- } - - commun_fn_key_number = type_aa->commun_fn_key_number; - } -@@ -1520,7 +1559,7 @@ static int acer_gsensor_event(void) - struct acpi_buffer output; - union acpi_object out_obj[5]; - -- if (!has_cap(ACER_CAP_ACCEL)) -+ if (!acer_wmi_accel_dev) - return -1; - - output.length = sizeof(out_obj); -@@ -1543,6 +1582,71 @@ static int acer_gsensor_event(void) - return 0; - } - -+/* -+ * Switch series keyboard dock status -+ */ -+static int acer_kbd_dock_state_to_sw_tablet_mode(u8 kbd_dock_state) -+{ -+ switch (kbd_dock_state) { -+ case 0x01: /* Docked, traditional clamshell laptop mode */ -+ return 0; -+ case 0x04: /* Stand-alone tablet */ -+ case 0x40: /* Docked, tent mode, keyboard not usable */ -+ return 1; -+ default: -+ pr_warn("Unknown kbd_dock_state 0x%02x\n", kbd_dock_state); -+ } -+ -+ return 0; -+} -+ -+static void acer_kbd_dock_get_initial_state(void) -+{ -+ u8 *output, input[8] = { 0x05, 0x00, }; -+ struct acpi_buffer input_buf = { sizeof(input), input }; -+ struct acpi_buffer output_buf = { ACPI_ALLOCATE_BUFFER, NULL }; -+ union acpi_object *obj; -+ acpi_status status; -+ int sw_tablet_mode; -+ -+ status = wmi_evaluate_method(WMID_GUID3, 0, 0x2, &input_buf, &output_buf); -+ if (ACPI_FAILURE(status)) { -+ ACPI_EXCEPTION((AE_INFO, status, "Error getting keyboard-dock initial status")); -+ return; -+ } -+ -+ obj = output_buf.pointer; -+ if (!obj || obj->type != ACPI_TYPE_BUFFER || obj->buffer.length != 8) { -+ pr_err("Unexpected output format getting keyboard-dock initial status\n"); -+ goto out_free_obj; -+ } -+ -+ output = obj->buffer.pointer; -+ if (output[0] != 0x00 || (output[3] != 0x05 && output[3] != 0x45)) { -+ pr_err("Unexpected output [0]=0x%02x [3]=0x%02x getting keyboard-dock initial status\n", -+ output[0], output[3]); -+ goto out_free_obj; -+ } -+ -+ sw_tablet_mode = acer_kbd_dock_state_to_sw_tablet_mode(output[4]); -+ input_report_switch(acer_wmi_input_dev, SW_TABLET_MODE, sw_tablet_mode); -+ -+out_free_obj: -+ kfree(obj); -+} -+ -+static void acer_kbd_dock_event(const struct event_return_value *event) -+{ -+ int sw_tablet_mode; -+ -+ if (!has_cap(ACER_CAP_KBD_DOCK)) -+ return; -+ -+ sw_tablet_mode = acer_kbd_dock_state_to_sw_tablet_mode(event->kbd_dock_state); -+ input_report_switch(acer_wmi_input_dev, SW_TABLET_MODE, sw_tablet_mode); -+ input_sync(acer_wmi_input_dev); -+} -+ - /* - * Rfkill devices - */ -@@ -1770,8 +1874,9 @@ static void acer_wmi_notify(u32 value, void *context) - sparse_keymap_report_event(acer_wmi_input_dev, scancode, 1, true); - } - break; -- case WMID_ACCEL_EVENT: -+ case WMID_ACCEL_OR_KBD_DOCK_EVENT: - acer_gsensor_event(); -+ acer_kbd_dock_event(&return_value); - break; - default: - pr_warn("Unknown function number - %d - %d\n", -@@ -1894,8 +1999,6 @@ static int __init acer_wmi_accel_setup(void) - gsensor_handle = acpi_device_handle(adev); - acpi_dev_put(adev); - -- interface->capability |= ACER_CAP_ACCEL; -- - acer_wmi_accel_dev = input_allocate_device(); - if (!acer_wmi_accel_dev) - return -ENOMEM; -@@ -1921,11 +2024,6 @@ err_free_dev: - return err; - } - --static void acer_wmi_accel_destroy(void) --{ -- input_unregister_device(acer_wmi_accel_dev); --} -- - static int __init acer_wmi_input_setup(void) - { - acpi_status status; -@@ -1943,6 +2041,9 @@ static int __init acer_wmi_input_setup(void) - if (err) - goto err_free_dev; - -+ if (has_cap(ACER_CAP_KBD_DOCK)) -+ input_set_capability(acer_wmi_input_dev, EV_SW, SW_TABLET_MODE); -+ - status = wmi_install_notify_handler(ACERWMID_EVENT_GUID, - acer_wmi_notify, NULL); - if (ACPI_FAILURE(status)) { -@@ -1950,6 +2051,9 @@ static int __init acer_wmi_input_setup(void) - goto err_free_dev; - } - -+ if (has_cap(ACER_CAP_KBD_DOCK)) -+ acer_kbd_dock_get_initial_state(); -+ - err = input_register_device(acer_wmi_input_dev); - if (err) - goto err_uninstall_notifier; -@@ -2080,7 +2184,7 @@ static int acer_resume(struct device *dev) - if (has_cap(ACER_CAP_BRIGHTNESS)) - set_u32(data->brightness, ACER_CAP_BRIGHTNESS); - -- if (has_cap(ACER_CAP_ACCEL)) -+ if (acer_wmi_accel_dev) - acer_gsensor_init(); - - return 0; -@@ -2181,7 +2285,7 @@ static int __init acer_wmi_init(void) - } - /* WMID always provides brightness methods */ - interface->capability |= ACER_CAP_BRIGHTNESS; -- } else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa) { -+ } else if (!wmi_has_guid(WMID_GUID2) && interface && !has_type_aa && force_caps == -1) { - pr_err("No WMID device detection method found\n"); - return -ENODEV; - } -@@ -2211,7 +2315,14 @@ static int __init acer_wmi_init(void) - if (acpi_video_get_backlight_type() != acpi_backlight_vendor) - interface->capability &= ~ACER_CAP_BRIGHTNESS; - -- if (wmi_has_guid(WMID_GUID3)) { -+ if (wmi_has_guid(WMID_GUID3)) -+ interface->capability |= ACER_CAP_SET_FUNCTION_MODE; -+ -+ if (force_caps != -1) -+ interface->capability = force_caps; -+ -+ if (wmi_has_guid(WMID_GUID3) && -+ (interface->capability & ACER_CAP_SET_FUNCTION_MODE)) { - if (ACPI_FAILURE(acer_wmi_enable_rf_button())) - pr_warn("Cannot enable RF Button Driver\n"); - -@@ -2270,8 +2381,8 @@ error_device_alloc: - error_platform_register: - if (wmi_has_guid(ACERWMID_EVENT_GUID)) - acer_wmi_input_destroy(); -- if (has_cap(ACER_CAP_ACCEL)) -- acer_wmi_accel_destroy(); -+ if (acer_wmi_accel_dev) -+ input_unregister_device(acer_wmi_accel_dev); - - return err; - } -@@ -2281,8 +2392,8 @@ static void __exit acer_wmi_exit(void) - if (wmi_has_guid(ACERWMID_EVENT_GUID)) - acer_wmi_input_destroy(); - -- if (has_cap(ACER_CAP_ACCEL)) -- acer_wmi_accel_destroy(); -+ if (acer_wmi_accel_dev) -+ input_unregister_device(acer_wmi_accel_dev); - - remove_debugfs(); - platform_device_unregister(acer_platform_device); -diff --git a/include/linux/eeprom_93xx46.h b/include/linux/eeprom_93xx46.h -index eec7928ff8fe0..99580c22f91a4 100644 ---- a/include/linux/eeprom_93xx46.h -+++ b/include/linux/eeprom_93xx46.h -@@ -16,6 +16,8 @@ struct eeprom_93xx46_platform_data { - #define EEPROM_93XX46_QUIRK_SINGLE_WORD_READ (1 << 0) - /* Instructions such as EWEN are (addrlen + 2) in length. */ - #define EEPROM_93XX46_QUIRK_INSTRUCTION_LENGTH (1 << 1) -+/* Add extra cycle after address during a read */ -+#define EEPROM_93XX46_QUIRK_EXTRA_READ_CYCLE BIT(2) - - /* - * optional hooks to control additional logic -diff --git a/net/dsa/Kconfig b/net/dsa/Kconfig -index 29e2bd5cc5af7..7dce11ab28062 100644 ---- a/net/dsa/Kconfig -+++ b/net/dsa/Kconfig -@@ -9,6 +9,7 @@ menuconfig NET_DSA - tristate "Distributed Switch Architecture" - depends on HAVE_NET_DSA - depends on BRIDGE || BRIDGE=n -+ select GRO_CELLS - select NET_SWITCHDEV - select PHYLINK - select NET_DEVLINK -diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c -index 43120a3fb06f3..ca80f86995e68 100644 ---- a/net/dsa/dsa.c -+++ b/net/dsa/dsa.c -@@ -238,7 +238,7 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, - if (dsa_skb_defer_rx_timestamp(p, skb)) - return 0; - -- netif_receive_skb(skb); -+ gro_cells_receive(&p->gcells, skb); - - return 0; - } -diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h -index bf9947c577b6d..d8e850724d13c 100644 ---- a/net/dsa/dsa_priv.h -+++ b/net/dsa/dsa_priv.h -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - - enum { - DSA_NOTIFIER_AGEING_TIME, -@@ -68,6 +69,8 @@ struct dsa_slave_priv { - - struct pcpu_sw_netstats *stats64; - -+ struct gro_cells gcells; -+ - /* DSA port data, such as switch, port index, etc. */ - struct dsa_port *dp; - -diff --git a/net/dsa/slave.c b/net/dsa/slave.c -index f734ce0bcb56e..06f8874d53eea 100644 ---- a/net/dsa/slave.c -+++ b/net/dsa/slave.c -@@ -1431,6 +1431,11 @@ int dsa_slave_create(struct dsa_port *port) - free_netdev(slave_dev); - return -ENOMEM; - } -+ -+ ret = gro_cells_init(&p->gcells, slave_dev); -+ if (ret) -+ goto out_free; -+ - p->dp = port; - INIT_LIST_HEAD(&p->mall_tc_list); - INIT_WORK(&port->xmit_work, dsa_port_xmit_work); -@@ -1443,7 +1448,7 @@ int dsa_slave_create(struct dsa_port *port) - ret = dsa_slave_phy_setup(slave_dev); - if (ret) { - netdev_err(master, "error %d setting up slave phy\n", ret); -- goto out_free; -+ goto out_gcells; - } - - dsa_slave_notify(slave_dev, DSA_PORT_REGISTER); -@@ -1462,6 +1467,8 @@ out_phy: - phylink_disconnect_phy(p->dp->pl); - rtnl_unlock(); - phylink_destroy(p->dp->pl); -+out_gcells: -+ gro_cells_destroy(&p->gcells); - out_free: - free_percpu(p->stats64); - free_netdev(slave_dev); -@@ -1482,6 +1489,7 @@ void dsa_slave_destroy(struct net_device *slave_dev) - dsa_slave_notify(slave_dev, DSA_PORT_UNREGISTER); - unregister_netdev(slave_dev); - phylink_destroy(dp->pl); -+ gro_cells_destroy(&p->gcells); - free_percpu(p->stats64); - free_netdev(slave_dev); - } -diff --git a/sound/soc/intel/boards/bytcr_rt5640.c b/sound/soc/intel/boards/bytcr_rt5640.c -index 9ee610504bac9..cfd3077174731 100644 ---- a/sound/soc/intel/boards/bytcr_rt5640.c -+++ b/sound/soc/intel/boards/bytcr_rt5640.c -@@ -435,6 +435,18 @@ static const struct dmi_system_id byt_rt5640_quirk_table[] = { - BYT_RT5640_SSP0_AIF1 | - BYT_RT5640_MCLK_EN), - }, -+ { -+ .matches = { -+ DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ARCHOS"), -+ DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "ARCHOS 140 CESIUM"), -+ }, -+ .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_SSP0_AIF1 | -+ BYT_RT5640_MCLK_EN), -+ }, - { - .matches = { - DMI_EXACT_MATCH(DMI_SYS_VENDOR, "ASUSTeK COMPUTER INC."), diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.105-106.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.105-106.patch deleted file mode 100644 index 9fcde759f6..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.105-106.patch +++ /dev/null @@ -1,5187 +0,0 @@ -diff --git a/Documentation/virt/kvm/api.txt b/Documentation/virt/kvm/api.txt -index 7064efd3b5ea3..fd22224853e58 100644 ---- a/Documentation/virt/kvm/api.txt -+++ b/Documentation/virt/kvm/api.txt -@@ -172,6 +172,9 @@ is dependent on the CPU capability and the kernel configuration. The limit can - be retrieved using KVM_CAP_ARM_VM_IPA_SIZE of the KVM_CHECK_EXTENSION - ioctl() at run-time. - -+Creation of the VM will fail if the requested IPA size (whether it is -+implicit or explicit) is unsupported on the host. -+ - Please note that configuring the IPA size does not affect the capability - exposed by the guest CPUs in ID_AA64MMFR0_EL1[PARange]. It only affects - size of the address translated by the stage2 level (guest physical to -diff --git a/Makefile b/Makefile -index e27d031f3241e..a333b378f1f71 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 105 -+SUBLEVEL = 106 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -@@ -1175,9 +1175,15 @@ define filechk_utsrelease.h - endef - - define filechk_version.h -- echo \#define LINUX_VERSION_CODE $(shell \ -- expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 0$(SUBLEVEL)); \ -- echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' -+ if [ $(SUBLEVEL) -gt 255 ]; then \ -+ echo \#define LINUX_VERSION_CODE $(shell \ -+ expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \ -+ else \ -+ echo \#define LINUX_VERSION_CODE $(shell \ -+ expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ -+ fi; \ -+ echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \ -+ ((c) > 255 ? 255 : (c)))' - endef - - $(version_h): FORCE -diff --git a/arch/arm/include/asm/kvm_asm.h b/arch/arm/include/asm/kvm_asm.h -index f615830f9f57b..9d0b7e677faac 100644 ---- a/arch/arm/include/asm/kvm_asm.h -+++ b/arch/arm/include/asm/kvm_asm.h -@@ -56,7 +56,7 @@ extern char __kvm_hyp_init_end[]; - extern void __kvm_flush_vm_context(void); - extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); - extern void __kvm_tlb_flush_vmid(struct kvm *kvm); --extern void __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu); -+extern void __kvm_flush_cpu_context(struct kvm_vcpu *vcpu); - - extern void __kvm_timer_set_cntvoff(u32 cntvoff_low, u32 cntvoff_high); - -diff --git a/arch/arm/kvm/hyp/tlb.c b/arch/arm/kvm/hyp/tlb.c -index 848f27bbad9db..80e67108d39d1 100644 ---- a/arch/arm/kvm/hyp/tlb.c -+++ b/arch/arm/kvm/hyp/tlb.c -@@ -45,7 +45,7 @@ void __hyp_text __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa) - __kvm_tlb_flush_vmid(kvm); - } - --void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu) -+void __hyp_text __kvm_flush_cpu_context(struct kvm_vcpu *vcpu) - { - struct kvm *kvm = kern_hyp_va(kern_hyp_va(vcpu)->kvm); - -@@ -54,6 +54,7 @@ void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu) - isb(); - - write_sysreg(0, TLBIALL); -+ write_sysreg(0, ICIALLU); - dsb(nsh); - isb(); - -diff --git a/arch/arm64/include/asm/kvm_asm.h b/arch/arm64/include/asm/kvm_asm.h -index 64d79b2884344..c54e759896c1a 100644 ---- a/arch/arm64/include/asm/kvm_asm.h -+++ b/arch/arm64/include/asm/kvm_asm.h -@@ -60,7 +60,7 @@ extern char __kvm_hyp_vector[]; - extern void __kvm_flush_vm_context(void); - extern void __kvm_tlb_flush_vmid_ipa(struct kvm *kvm, phys_addr_t ipa); - extern void __kvm_tlb_flush_vmid(struct kvm *kvm); --extern void __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu); -+extern void __kvm_flush_cpu_context(struct kvm_vcpu *vcpu); - - extern void __kvm_timer_set_cntvoff(u32 cntvoff_low, u32 cntvoff_high); - -diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h -index 6c295a231882a..67b6b90f37eed 100644 ---- a/arch/arm64/include/asm/memory.h -+++ b/arch/arm64/include/asm/memory.h -@@ -315,6 +315,11 @@ static inline void *phys_to_virt(phys_addr_t x) - #define ARCH_PFN_OFFSET ((unsigned long)PHYS_PFN_OFFSET) - - #if !defined(CONFIG_SPARSEMEM_VMEMMAP) || defined(CONFIG_DEBUG_VIRTUAL) -+#define page_to_virt(x) ({ \ -+ __typeof__(x) __page = x; \ -+ void *__addr = __va(page_to_phys(__page)); \ -+ (void *)__tag_set((const void *)__addr, page_kasan_tag(__page));\ -+}) - #define virt_to_page(x) pfn_to_page(virt_to_pfn(x)) - #else - #define page_to_virt(x) ({ \ -diff --git a/arch/arm64/include/asm/mmu_context.h b/arch/arm64/include/asm/mmu_context.h -index 3827ff4040a3f..3a5d9f1c91b6d 100644 ---- a/arch/arm64/include/asm/mmu_context.h -+++ b/arch/arm64/include/asm/mmu_context.h -@@ -63,10 +63,7 @@ extern u64 idmap_ptrs_per_pgd; - - static inline bool __cpu_uses_extended_idmap(void) - { -- if (IS_ENABLED(CONFIG_ARM64_VA_BITS_52)) -- return false; -- -- return unlikely(idmap_t0sz != TCR_T0SZ(VA_BITS)); -+ return unlikely(idmap_t0sz != TCR_T0SZ(vabits_actual)); - } - - /* -diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S -index 438de2301cfe3..a2e0b37549433 100644 ---- a/arch/arm64/kernel/head.S -+++ b/arch/arm64/kernel/head.S -@@ -337,7 +337,7 @@ __create_page_tables: - */ - adrp x5, __idmap_text_end - clz x5, x5 -- cmp x5, TCR_T0SZ(VA_BITS) // default T0SZ small enough? -+ cmp x5, TCR_T0SZ(VA_BITS_MIN) // default T0SZ small enough? - b.ge 1f // .. then skip VA range extension - - adr_l x6, idmap_t0sz -diff --git a/arch/arm64/kvm/hyp/tlb.c b/arch/arm64/kvm/hyp/tlb.c -index eb0efc5557f30..7b7213fc17d95 100644 ---- a/arch/arm64/kvm/hyp/tlb.c -+++ b/arch/arm64/kvm/hyp/tlb.c -@@ -182,7 +182,7 @@ void __hyp_text __kvm_tlb_flush_vmid(struct kvm *kvm) - __tlb_switch_to_host(kvm, &cxt); - } - --void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu) -+void __hyp_text __kvm_flush_cpu_context(struct kvm_vcpu *vcpu) - { - struct kvm *kvm = kern_hyp_va(kern_hyp_va(vcpu)->kvm); - struct tlb_inv_context cxt; -@@ -191,6 +191,7 @@ void __hyp_text __kvm_tlb_flush_local_vmid(struct kvm_vcpu *vcpu) - __tlb_switch_to_guest(kvm, &cxt); - - __tlbi(vmalle1); -+ asm volatile("ic iallu"); - dsb(nsh); - isb(); - -diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c -index 784d485218ca1..a3105ae464be1 100644 ---- a/arch/arm64/kvm/reset.c -+++ b/arch/arm64/kvm/reset.c -@@ -378,10 +378,10 @@ void kvm_set_ipa_limit(void) - pr_info("kvm: Limiting the IPA size due to kernel %s Address limit\n", - (va_max < pa_max) ? "Virtual" : "Physical"); - -- WARN(ipa_max < KVM_PHYS_SHIFT, -- "KVM IPA limit (%d bit) is smaller than default size\n", ipa_max); - kvm_ipa_limit = ipa_max; -- kvm_info("IPA Size Limit: %dbits\n", kvm_ipa_limit); -+ kvm_info("IPA Size Limit: %d bits%s\n", kvm_ipa_limit, -+ ((kvm_ipa_limit < KVM_PHYS_SHIFT) ? -+ " (Reduced IPA size, limited VM/VMM compatibility)" : "")); - } - - /* -@@ -408,6 +408,11 @@ int kvm_arm_setup_stage2(struct kvm *kvm, unsigned long type) - return -EINVAL; - } else { - phys_shift = KVM_PHYS_SHIFT; -+ if (phys_shift > kvm_ipa_limit) { -+ pr_warn_once("%s using unsupported default IPA limit, upgrade your VMM\n", -+ current->comm); -+ return -EINVAL; -+ } - } - - parange = read_sanitised_ftr_reg(SYS_ID_AA64MMFR0_EL1) & 7; -diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c -index 602bd19630ff8..cbcac03c0e0da 100644 ---- a/arch/arm64/mm/init.c -+++ b/arch/arm64/mm/init.c -@@ -245,6 +245,18 @@ int pfn_valid(unsigned long pfn) - - if (!valid_section(__nr_to_section(pfn_to_section_nr(pfn)))) - return 0; -+ -+ /* -+ * ZONE_DEVICE memory does not have the memblock entries. -+ * memblock_is_map_memory() check for ZONE_DEVICE based -+ * addresses will always fail. Even the normal hotplugged -+ * memory will never have MEMBLOCK_NOMAP flag set in their -+ * memblock entries. Skip memblock search for all non early -+ * memory sections covering all of hotplug memory including -+ * both normal and ZONE_DEVICE based. -+ */ -+ if (!early_section(__pfn_to_section(pfn))) -+ return pfn_section_valid(__pfn_to_section(pfn), pfn); - #endif - return memblock_is_map_memory(addr); - } -diff --git a/arch/arm64/mm/mmu.c b/arch/arm64/mm/mmu.c -index d10247fab0fdf..99bc0289ab2b6 100644 ---- a/arch/arm64/mm/mmu.c -+++ b/arch/arm64/mm/mmu.c -@@ -38,7 +38,7 @@ - #define NO_BLOCK_MAPPINGS BIT(0) - #define NO_CONT_MAPPINGS BIT(1) - --u64 idmap_t0sz = TCR_T0SZ(VA_BITS); -+u64 idmap_t0sz = TCR_T0SZ(VA_BITS_MIN); - u64 idmap_ptrs_per_pgd = PTRS_PER_PGD; - - u64 __section(".mmuoff.data.write") vabits_actual; -diff --git a/arch/powerpc/include/asm/code-patching.h b/arch/powerpc/include/asm/code-patching.h -index 898b542628815..be0f7257b13c8 100644 ---- a/arch/powerpc/include/asm/code-patching.h -+++ b/arch/powerpc/include/asm/code-patching.h -@@ -72,7 +72,7 @@ void __patch_exception(int exc, unsigned long addr); - #endif - - #define OP_RT_RA_MASK 0xffff0000UL --#define LIS_R2 0x3c020000UL -+#define LIS_R2 0x3c400000UL - #define ADDIS_R2_R12 0x3c4c0000UL - #define ADDI_R2_R2 0x38420000UL - -diff --git a/arch/powerpc/include/asm/machdep.h b/arch/powerpc/include/asm/machdep.h -index 7bcb64444a394..f71c361dc356f 100644 ---- a/arch/powerpc/include/asm/machdep.h -+++ b/arch/powerpc/include/asm/machdep.h -@@ -59,6 +59,9 @@ struct machdep_calls { - int (*pcibios_root_bridge_prepare)(struct pci_host_bridge - *bridge); - -+ /* finds all the pci_controllers present at boot */ -+ void (*discover_phbs)(void); -+ - /* To setup PHBs when using automatic OF platform driver for PCI */ - int (*pci_setup_phb)(struct pci_controller *host); - -diff --git a/arch/powerpc/include/asm/ptrace.h b/arch/powerpc/include/asm/ptrace.h -index c41220f4aad9e..5a424f867c828 100644 ---- a/arch/powerpc/include/asm/ptrace.h -+++ b/arch/powerpc/include/asm/ptrace.h -@@ -62,6 +62,9 @@ struct pt_regs - }; - #endif - -+ -+#define STACK_FRAME_WITH_PT_REGS (STACK_FRAME_OVERHEAD + sizeof(struct pt_regs)) -+ - #ifdef __powerpc64__ - - /* -diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c -index 5c0a1e17219b7..af399675248ed 100644 ---- a/arch/powerpc/kernel/asm-offsets.c -+++ b/arch/powerpc/kernel/asm-offsets.c -@@ -285,7 +285,7 @@ int main(void) - - /* Interrupt register frame */ - DEFINE(INT_FRAME_SIZE, STACK_INT_FRAME_SIZE); -- DEFINE(SWITCH_FRAME_SIZE, STACK_FRAME_OVERHEAD + sizeof(struct pt_regs)); -+ DEFINE(SWITCH_FRAME_SIZE, STACK_FRAME_WITH_PT_REGS); - STACK_PT_REGS_OFFSET(GPR0, gpr[0]); - STACK_PT_REGS_OFFSET(GPR1, gpr[1]); - STACK_PT_REGS_OFFSET(GPR2, gpr[2]); -diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S -index 126ba54384300..edaab1142498c 100644 ---- a/arch/powerpc/kernel/head_32.S -+++ b/arch/powerpc/kernel/head_32.S -@@ -418,10 +418,11 @@ InstructionTLBMiss: - cmplw 0,r1,r3 - #endif - mfspr r2, SPRN_SPRG_PGDIR -- li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC -+ li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC | _PAGE_USER - #if defined(CONFIG_MODULES) || defined(CONFIG_DEBUG_PAGEALLOC) - bge- 112f - lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ -+ li r1,_PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_EXEC - addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */ - #endif - 112: rlwimi r2,r3,12,20,29 /* insert top 10 bits of address */ -@@ -480,9 +481,10 @@ DataLoadTLBMiss: - lis r1,PAGE_OFFSET@h /* check if kernel address */ - cmplw 0,r1,r3 - mfspr r2, SPRN_SPRG_PGDIR -- li r1, _PAGE_PRESENT | _PAGE_ACCESSED -+ li r1, _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER - bge- 112f - lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ -+ li r1, _PAGE_PRESENT | _PAGE_ACCESSED - addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */ - 112: rlwimi r2,r3,12,20,29 /* insert top 10 bits of address */ - lwz r2,0(r2) /* get pmd entry */ -@@ -556,9 +558,10 @@ DataStoreTLBMiss: - lis r1,PAGE_OFFSET@h /* check if kernel address */ - cmplw 0,r1,r3 - mfspr r2, SPRN_SPRG_PGDIR -- li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED -+ li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED | _PAGE_USER - bge- 112f - lis r2, (swapper_pg_dir - PAGE_OFFSET)@ha /* if kernel address, use */ -+ li r1, _PAGE_RW | _PAGE_DIRTY | _PAGE_PRESENT | _PAGE_ACCESSED - addi r2, r2, (swapper_pg_dir - PAGE_OFFSET)@l /* kernel page table */ - 112: rlwimi r2,r3,12,20,29 /* insert top 10 bits of address */ - lwz r2,0(r2) /* get pmd entry */ -diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-common.c -index 1c448cf255061..a2c258a8d7367 100644 ---- a/arch/powerpc/kernel/pci-common.c -+++ b/arch/powerpc/kernel/pci-common.c -@@ -1669,3 +1669,13 @@ static void fixup_hide_host_resource_fsl(struct pci_dev *dev) - } - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MOTOROLA, PCI_ANY_ID, fixup_hide_host_resource_fsl); - DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_FREESCALE, PCI_ANY_ID, fixup_hide_host_resource_fsl); -+ -+ -+static int __init discover_phbs(void) -+{ -+ if (ppc_md.discover_phbs) -+ ppc_md.discover_phbs(); -+ -+ return 0; -+} -+core_initcall(discover_phbs); -diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c -index bd0c258a1d5dd..c94bba9142e7e 100644 ---- a/arch/powerpc/kernel/process.c -+++ b/arch/powerpc/kernel/process.c -@@ -2081,7 +2081,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack) - * See if this is an exception frame. - * We look for the "regshere" marker in the current frame. - */ -- if (validate_sp(sp, tsk, STACK_INT_FRAME_SIZE) -+ if (validate_sp(sp, tsk, STACK_FRAME_WITH_PT_REGS) - && stack[STACK_FRAME_MARKER] == STACK_FRAME_REGS_MARKER) { - struct pt_regs *regs = (struct pt_regs *) - (sp + STACK_FRAME_OVERHEAD); -diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c -index 206032c9b5458..ecfa460f66d17 100644 ---- a/arch/powerpc/kernel/traps.c -+++ b/arch/powerpc/kernel/traps.c -@@ -513,8 +513,11 @@ out: - die("Unrecoverable nested System Reset", regs, SIGABRT); - #endif - /* Must die if the interrupt is not recoverable */ -- if (!(regs->msr & MSR_RI)) -+ if (!(regs->msr & MSR_RI)) { -+ /* For the reason explained in die_mce, nmi_exit before die */ -+ nmi_exit(); - die("Unrecoverable System Reset", regs, SIGABRT); -+ } - - if (saved_hsrrs) { - mtspr(SPRN_HSRR0, hsrr0); -diff --git a/arch/powerpc/perf/core-book3s.c b/arch/powerpc/perf/core-book3s.c -index 02fc75ddcbb36..6f013e4188349 100644 ---- a/arch/powerpc/perf/core-book3s.c -+++ b/arch/powerpc/perf/core-book3s.c -@@ -2077,7 +2077,17 @@ static void record_and_restart(struct perf_event *event, unsigned long val, - left += period; - if (left <= 0) - left = period; -- record = siar_valid(regs); -+ -+ /* -+ * If address is not requested in the sample via -+ * PERF_SAMPLE_IP, just record that sample irrespective -+ * of SIAR valid check. -+ */ -+ if (event->attr.sample_type & PERF_SAMPLE_IP) -+ record = siar_valid(regs); -+ else -+ record = 1; -+ - event->hw.last_period = event->hw.sample_period; - } - if (left < 0x80000000LL) -@@ -2095,9 +2105,10 @@ static void record_and_restart(struct perf_event *event, unsigned long val, - * MMCR2. Check attr.exclude_kernel and address to drop the sample in - * these cases. - */ -- if (event->attr.exclude_kernel && record) -- if (is_kernel_addr(mfspr(SPRN_SIAR))) -- record = 0; -+ if (event->attr.exclude_kernel && -+ (event->attr.sample_type & PERF_SAMPLE_IP) && -+ is_kernel_addr(mfspr(SPRN_SIAR))) -+ record = 0; - - /* - * Finally record data if requested. -diff --git a/arch/powerpc/platforms/pseries/msi.c b/arch/powerpc/platforms/pseries/msi.c -index b3ac2455faadc..637300330507f 100644 ---- a/arch/powerpc/platforms/pseries/msi.c -+++ b/arch/powerpc/platforms/pseries/msi.c -@@ -4,6 +4,7 @@ - * Copyright 2006-2007 Michael Ellerman, IBM Corp. - */ - -+#include - #include - #include - #include -@@ -458,8 +459,28 @@ again: - return hwirq; - } - -- virq = irq_create_mapping_affinity(NULL, hwirq, -- entry->affinity); -+ /* -+ * Depending on the number of online CPUs in the original -+ * kernel, it is likely for CPU #0 to be offline in a kdump -+ * kernel. The associated IRQs in the affinity mappings -+ * provided by irq_create_affinity_masks() are thus not -+ * started by irq_startup(), as per-design for managed IRQs. -+ * This can be a problem with multi-queue block devices driven -+ * by blk-mq : such a non-started IRQ is very likely paired -+ * with the single queue enforced by blk-mq during kdump (see -+ * blk_mq_alloc_tag_set()). This causes the device to remain -+ * silent and likely hangs the guest at some point. -+ * -+ * We don't really care for fine-grained affinity when doing -+ * kdump actually : simply ignore the pre-computed affinity -+ * masks in this case and let the default mask with all CPUs -+ * be used when creating the IRQ mappings. -+ */ -+ if (is_kdump_kernel()) -+ virq = irq_create_mapping(NULL, hwirq); -+ else -+ virq = irq_create_mapping_affinity(NULL, hwirq, -+ entry->affinity); - - if (!virq) { - pr_debug("rtas_msi: Failed mapping hwirq %d\n", hwirq); -diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c -index 659d99af91566..8c51462f13fd1 100644 ---- a/arch/s390/kernel/smp.c -+++ b/arch/s390/kernel/smp.c -@@ -765,7 +765,7 @@ static int smp_add_core(struct sclp_core_entry *core, cpumask_t *avail, - static int __smp_rescan_cpus(struct sclp_core_info *info, bool early) - { - struct sclp_core_entry *core; -- cpumask_t avail; -+ static cpumask_t avail; - bool configured; - u16 core_id; - int nr, i; -diff --git a/arch/sparc/include/asm/mman.h b/arch/sparc/include/asm/mman.h -index f94532f25db14..274217e7ed702 100644 ---- a/arch/sparc/include/asm/mman.h -+++ b/arch/sparc/include/asm/mman.h -@@ -57,35 +57,39 @@ static inline int sparc_validate_prot(unsigned long prot, unsigned long addr) - { - if (prot & ~(PROT_READ | PROT_WRITE | PROT_EXEC | PROT_SEM | PROT_ADI)) - return 0; -- if (prot & PROT_ADI) { -- if (!adi_capable()) -- return 0; -+ return 1; -+} - -- if (addr) { -- struct vm_area_struct *vma; -+#define arch_validate_flags(vm_flags) arch_validate_flags(vm_flags) -+/* arch_validate_flags() - Ensure combination of flags is valid for a -+ * VMA. -+ */ -+static inline bool arch_validate_flags(unsigned long vm_flags) -+{ -+ /* If ADI is being enabled on this VMA, check for ADI -+ * capability on the platform and ensure VMA is suitable -+ * for ADI -+ */ -+ if (vm_flags & VM_SPARC_ADI) { -+ if (!adi_capable()) -+ return false; - -- vma = find_vma(current->mm, addr); -- if (vma) { -- /* ADI can not be enabled on PFN -- * mapped pages -- */ -- if (vma->vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) -- return 0; -+ /* ADI can not be enabled on PFN mapped pages */ -+ if (vm_flags & (VM_PFNMAP | VM_MIXEDMAP)) -+ return false; - -- /* Mergeable pages can become unmergeable -- * if ADI is enabled on them even if they -- * have identical data on them. This can be -- * because ADI enabled pages with identical -- * data may still not have identical ADI -- * tags on them. Disallow ADI on mergeable -- * pages. -- */ -- if (vma->vm_flags & VM_MERGEABLE) -- return 0; -- } -- } -+ /* Mergeable pages can become unmergeable -+ * if ADI is enabled on them even if they -+ * have identical data on them. This can be -+ * because ADI enabled pages with identical -+ * data may still not have identical ADI -+ * tags on them. Disallow ADI on mergeable -+ * pages. -+ */ -+ if (vm_flags & VM_MERGEABLE) -+ return false; - } -- return 1; -+ return true; - } - #endif /* CONFIG_SPARC64 */ - -diff --git a/arch/sparc/mm/init_32.c b/arch/sparc/mm/init_32.c -index 906eda1158b4d..40dd6cb4a4133 100644 ---- a/arch/sparc/mm/init_32.c -+++ b/arch/sparc/mm/init_32.c -@@ -197,6 +197,9 @@ unsigned long __init bootmem_init(unsigned long *pages_avail) - size = memblock_phys_mem_size() - memblock_reserved_size(); - *pages_avail = (size >> PAGE_SHIFT) - high_pages; - -+ /* Only allow low memory to be allocated via memblock allocation */ -+ memblock_set_current_limit(max_low_pfn << PAGE_SHIFT); -+ - return max_pfn; - } - -diff --git a/arch/x86/kernel/unwind_orc.c b/arch/x86/kernel/unwind_orc.c -index f29f015a5e7f3..b934f9f68a168 100644 ---- a/arch/x86/kernel/unwind_orc.c -+++ b/arch/x86/kernel/unwind_orc.c -@@ -357,8 +357,8 @@ static bool deref_stack_regs(struct unwind_state *state, unsigned long addr, - if (!stack_access_ok(state, addr, sizeof(struct pt_regs))) - return false; - -- *ip = regs->ip; -- *sp = regs->sp; -+ *ip = READ_ONCE_NOCHECK(regs->ip); -+ *sp = READ_ONCE_NOCHECK(regs->sp); - return true; - } - -@@ -370,8 +370,8 @@ static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr - if (!stack_access_ok(state, addr, IRET_FRAME_SIZE)) - return false; - -- *ip = regs->ip; -- *sp = regs->sp; -+ *ip = READ_ONCE_NOCHECK(regs->ip); -+ *sp = READ_ONCE_NOCHECK(regs->sp); - return true; - } - -@@ -392,12 +392,12 @@ static bool get_reg(struct unwind_state *state, unsigned int reg_off, - return false; - - if (state->full_regs) { -- *val = ((unsigned long *)state->regs)[reg]; -+ *val = READ_ONCE_NOCHECK(((unsigned long *)state->regs)[reg]); - return true; - } - - if (state->prev_regs) { -- *val = ((unsigned long *)state->prev_regs)[reg]; -+ *val = READ_ONCE_NOCHECK(((unsigned long *)state->prev_regs)[reg]); - return true; - } - -diff --git a/drivers/base/swnode.c b/drivers/base/swnode.c -index 7d5236eafe845..4c3b9813b2843 100644 ---- a/drivers/base/swnode.c -+++ b/drivers/base/swnode.c -@@ -812,6 +812,9 @@ int software_node_register(const struct software_node *node) - if (software_node_to_swnode(node)) - return -EEXIST; - -+ if (node->parent && !parent) -+ return -EINVAL; -+ - return PTR_ERR_OR_ZERO(swnode_register(node, parent, 0)); - } - EXPORT_SYMBOL_GPL(software_node_register); -diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c -index 804d28faa97b0..a1824bb080446 100644 ---- a/drivers/block/rsxx/core.c -+++ b/drivers/block/rsxx/core.c -@@ -869,6 +869,7 @@ static int rsxx_pci_probe(struct pci_dev *dev, - card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event"); - if (!card->event_wq) { - dev_err(CARD_TO_DEV(card), "Failed card event setup.\n"); -+ st = -ENOMEM; - goto failed_event_handler; - } - -diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c -index 22aa432a68bf9..719c6b7741afa 100644 ---- a/drivers/block/zram/zram_drv.c -+++ b/drivers/block/zram/zram_drv.c -@@ -627,7 +627,7 @@ static ssize_t writeback_store(struct device *dev, - struct bio_vec bio_vec; - struct page *page; - ssize_t ret = len; -- int mode; -+ int mode, err; - unsigned long blk_idx = 0; - - if (sysfs_streq(buf, "idle")) -@@ -719,12 +719,17 @@ static ssize_t writeback_store(struct device *dev, - * XXX: A single page IO would be inefficient for write - * but it would be not bad as starter. - */ -- ret = submit_bio_wait(&bio); -- if (ret) { -+ err = submit_bio_wait(&bio); -+ if (err) { - zram_slot_lock(zram, index); - zram_clear_flag(zram, index, ZRAM_UNDER_WB); - zram_clear_flag(zram, index, ZRAM_IDLE); - zram_slot_unlock(zram, index); -+ /* -+ * Return last IO error unless every IO were -+ * not suceeded. -+ */ -+ ret = err; - continue; - } - -diff --git a/drivers/gpu/drm/drm_gem_shmem_helper.c b/drivers/gpu/drm/drm_gem_shmem_helper.c -index f5918707672f1..d88f4230c2219 100644 ---- a/drivers/gpu/drm/drm_gem_shmem_helper.c -+++ b/drivers/gpu/drm/drm_gem_shmem_helper.c -@@ -474,14 +474,28 @@ static vm_fault_t drm_gem_shmem_fault(struct vm_fault *vmf) - struct drm_gem_object *obj = vma->vm_private_data; - struct drm_gem_shmem_object *shmem = to_drm_gem_shmem_obj(obj); - loff_t num_pages = obj->size >> PAGE_SHIFT; -+ vm_fault_t ret; - struct page *page; -+ pgoff_t page_offset; - -- if (vmf->pgoff >= num_pages || WARN_ON_ONCE(!shmem->pages)) -- return VM_FAULT_SIGBUS; -+ /* We don't use vmf->pgoff since that has the fake offset */ -+ page_offset = (vmf->address - vma->vm_start) >> PAGE_SHIFT; - -- page = shmem->pages[vmf->pgoff]; -+ mutex_lock(&shmem->pages_lock); -+ -+ if (page_offset >= num_pages || -+ WARN_ON_ONCE(!shmem->pages) || -+ shmem->madv < 0) { -+ ret = VM_FAULT_SIGBUS; -+ } else { -+ page = shmem->pages[page_offset]; -+ -+ ret = vmf_insert_page(vma, vmf->address, page); -+ } - -- return vmf_insert_page(vma, vmf->address, page); -+ mutex_unlock(&shmem->pages_lock); -+ -+ return ret; - } - - static void drm_gem_shmem_vm_open(struct vm_area_struct *vma) -@@ -549,9 +563,6 @@ int drm_gem_shmem_mmap(struct file *filp, struct vm_area_struct *vma) - vma->vm_flags &= ~VM_PFNMAP; - vma->vm_flags |= VM_MIXEDMAP; - -- /* Remove the fake offset */ -- vma->vm_pgoff -= drm_vma_node_start(&shmem->base.vma_node); -- - return 0; - } - EXPORT_SYMBOL_GPL(drm_gem_shmem_mmap); -diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c -index 22c7fd7196c82..2cf053fb8d54b 100644 ---- a/drivers/gpu/drm/drm_ioc32.c -+++ b/drivers/gpu/drm/drm_ioc32.c -@@ -99,6 +99,8 @@ static int compat_drm_version(struct file *file, unsigned int cmd, - if (copy_from_user(&v32, (void __user *)arg, sizeof(v32))) - return -EFAULT; - -+ memset(&v, 0, sizeof(v)); -+ - v = (struct drm_version) { - .name_len = v32.name_len, - .name = compat_ptr(v32.name), -@@ -137,6 +139,9 @@ static int compat_drm_getunique(struct file *file, unsigned int cmd, - - if (copy_from_user(&uq32, (void __user *)arg, sizeof(uq32))) - return -EFAULT; -+ -+ memset(&uq, 0, sizeof(uq)); -+ - uq = (struct drm_unique){ - .unique_len = uq32.unique_len, - .unique = compat_ptr(uq32.unique), -@@ -265,6 +270,8 @@ static int compat_drm_getclient(struct file *file, unsigned int cmd, - if (copy_from_user(&c32, argp, sizeof(c32))) - return -EFAULT; - -+ memset(&client, 0, sizeof(client)); -+ - client.idx = c32.idx; - - err = drm_ioctl_kernel(file, drm_getclient, &client, 0); -@@ -850,6 +857,8 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd, - if (copy_from_user(&req32, argp, sizeof(req32))) - return -EFAULT; - -+ memset(&req, 0, sizeof(req)); -+ - req.request.type = req32.request.type; - req.request.sequence = req32.request.sequence; - req.request.signal = req32.request.signal; -@@ -887,6 +896,8 @@ static int compat_drm_mode_addfb2(struct file *file, unsigned int cmd, - struct drm_mode_fb_cmd2 req64; - int err; - -+ memset(&req64, 0, sizeof(req64)); -+ - if (copy_from_user(&req64, argp, - offsetof(drm_mode_fb_cmd232_t, modifier))) - return -EFAULT; -diff --git a/drivers/gpu/drm/meson/meson_drv.c b/drivers/gpu/drm/meson/meson_drv.c -index a24f8dec5adc9..86d0961112773 100644 ---- a/drivers/gpu/drm/meson/meson_drv.c -+++ b/drivers/gpu/drm/meson/meson_drv.c -@@ -420,6 +420,16 @@ static int meson_probe_remote(struct platform_device *pdev, - return count; - } - -+static void meson_drv_shutdown(struct platform_device *pdev) -+{ -+ struct meson_drm *priv = dev_get_drvdata(&pdev->dev); -+ struct drm_device *drm = priv->drm; -+ -+ DRM_DEBUG_DRIVER("\n"); -+ drm_kms_helper_poll_fini(drm); -+ drm_atomic_helper_shutdown(drm); -+} -+ - static int meson_drv_probe(struct platform_device *pdev) - { - struct component_match *match = NULL; -@@ -469,6 +479,7 @@ MODULE_DEVICE_TABLE(of, dt_match); - - static struct platform_driver meson_drm_platform_driver = { - .probe = meson_drv_probe, -+ .shutdown = meson_drv_shutdown, - .driver = { - .name = "meson-drm", - .of_match_table = dt_match, -diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c -index 92d84280096e0..9abf3dc5ef990 100644 ---- a/drivers/gpu/drm/qxl/qxl_display.c -+++ b/drivers/gpu/drm/qxl/qxl_display.c -@@ -325,6 +325,7 @@ static void qxl_crtc_update_monitors_config(struct drm_crtc *crtc, - - head.id = i; - head.flags = 0; -+ head.surface_id = 0; - oldcount = qdev->monitors_config->count; - if (crtc->state->active) { - struct drm_display_mode *mode = &crtc->mode; -diff --git a/drivers/hid/hid-logitech-dj.c b/drivers/hid/hid-logitech-dj.c -index 86001cfbdb6f1..b499ac37dc7b0 100644 ---- a/drivers/hid/hid-logitech-dj.c -+++ b/drivers/hid/hid-logitech-dj.c -@@ -995,7 +995,12 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev, - workitem.reports_supported |= STD_KEYBOARD; - break; - case 0x0d: -- device_type = "eQUAD Lightspeed 1_1"; -+ device_type = "eQUAD Lightspeed 1.1"; -+ logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); -+ workitem.reports_supported |= STD_KEYBOARD; -+ break; -+ case 0x0f: -+ device_type = "eQUAD Lightspeed 1.2"; - logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem); - workitem.reports_supported |= STD_KEYBOARD; - break; -diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c -index 9c162a01a5849..d0c4b3019e41e 100644 ---- a/drivers/i2c/busses/i2c-rcar.c -+++ b/drivers/i2c/busses/i2c-rcar.c -@@ -89,7 +89,6 @@ - - #define RCAR_BUS_PHASE_START (MDBS | MIE | ESG) - #define RCAR_BUS_PHASE_DATA (MDBS | MIE) --#define RCAR_BUS_MASK_DATA (~(ESG | FSB) & 0xFF) - #define RCAR_BUS_PHASE_STOP (MDBS | MIE | FSB) - - #define RCAR_IRQ_SEND (MNR | MAL | MST | MAT | MDE) -@@ -117,6 +116,7 @@ enum rcar_i2c_type { - }; - - struct rcar_i2c_priv { -+ u32 flags; - void __iomem *io; - struct i2c_adapter adap; - struct i2c_msg *msg; -@@ -127,7 +127,6 @@ struct rcar_i2c_priv { - - int pos; - u32 icccr; -- u32 flags; - u8 recovery_icmcr; /* protected by adapter lock */ - enum rcar_i2c_type devtype; - struct i2c_client *slave; -@@ -616,7 +615,7 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) - /* - * This driver has a lock-free design because there are IP cores (at least - * R-Car Gen2) which have an inherent race condition in their hardware design. -- * There, we need to clear RCAR_BUS_MASK_DATA bits as soon as possible after -+ * There, we need to switch to RCAR_BUS_PHASE_DATA as soon as possible after - * the interrupt was generated, otherwise an unwanted repeated message gets - * generated. It turned out that taking a spinlock at the beginning of the ISR - * was already causing repeated messages. Thus, this driver was converted to -@@ -625,13 +624,11 @@ static bool rcar_i2c_slave_irq(struct rcar_i2c_priv *priv) - static irqreturn_t rcar_i2c_irq(int irq, void *ptr) - { - struct rcar_i2c_priv *priv = ptr; -- u32 msr, val; -+ u32 msr; - - /* Clear START or STOP immediately, except for REPSTART after read */ -- if (likely(!(priv->flags & ID_P_REP_AFTER_RD))) { -- val = rcar_i2c_read(priv, ICMCR); -- rcar_i2c_write(priv, ICMCR, val & RCAR_BUS_MASK_DATA); -- } -+ if (likely(!(priv->flags & ID_P_REP_AFTER_RD))) -+ rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_DATA); - - msr = rcar_i2c_read(priv, ICMSR); - -diff --git a/drivers/input/keyboard/applespi.c b/drivers/input/keyboard/applespi.c -index d38398526965d..a4b7422de534e 100644 ---- a/drivers/input/keyboard/applespi.c -+++ b/drivers/input/keyboard/applespi.c -@@ -48,6 +48,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -400,7 +401,7 @@ struct applespi_data { - unsigned int cmd_msg_cntr; - /* lock to protect the above parameters and flags below */ - spinlock_t cmd_msg_lock; -- bool cmd_msg_queued; -+ ktime_t cmd_msg_queued; - enum applespi_evt_type cmd_evt_type; - - struct led_classdev backlight_info; -@@ -716,7 +717,7 @@ static void applespi_msg_complete(struct applespi_data *applespi, - wake_up_all(&applespi->drain_complete); - - if (is_write_msg) { -- applespi->cmd_msg_queued = false; -+ applespi->cmd_msg_queued = 0; - applespi_send_cmd_msg(applespi); - } - -@@ -758,8 +759,16 @@ static int applespi_send_cmd_msg(struct applespi_data *applespi) - return 0; - - /* check whether send is in progress */ -- if (applespi->cmd_msg_queued) -- return 0; -+ if (applespi->cmd_msg_queued) { -+ if (ktime_ms_delta(ktime_get(), applespi->cmd_msg_queued) < 1000) -+ return 0; -+ -+ dev_warn(&applespi->spi->dev, "Command %d timed out\n", -+ applespi->cmd_evt_type); -+ -+ applespi->cmd_msg_queued = 0; -+ applespi->write_active = false; -+ } - - /* set up packet */ - memset(packet, 0, APPLESPI_PACKET_SIZE); -@@ -856,7 +865,7 @@ static int applespi_send_cmd_msg(struct applespi_data *applespi) - return sts; - } - -- applespi->cmd_msg_queued = true; -+ applespi->cmd_msg_queued = ktime_get_coarse(); - applespi->write_active = true; - - return 0; -@@ -1908,7 +1917,7 @@ static int __maybe_unused applespi_resume(struct device *dev) - applespi->drain = false; - applespi->have_cl_led_on = false; - applespi->have_bl_level = 0; -- applespi->cmd_msg_queued = false; -+ applespi->cmd_msg_queued = 0; - applespi->read_active = false; - applespi->write_active = false; - -diff --git a/drivers/iommu/amd_iommu_init.c b/drivers/iommu/amd_iommu_init.c -index 31d7e2d4f3040..ad714ff375f85 100644 ---- a/drivers/iommu/amd_iommu_init.c -+++ b/drivers/iommu/amd_iommu_init.c -@@ -12,6 +12,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -253,6 +254,8 @@ static enum iommu_init_state init_state = IOMMU_START_STATE; - static int amd_iommu_enable_interrupts(void); - static int __init iommu_go_to_state(enum iommu_init_state state); - static void init_device_table_dma(void); -+static int iommu_pc_get_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, -+ u8 fxn, u64 *value, bool is_write); - - static bool amd_iommu_pre_enabled = true; - -@@ -1672,13 +1675,11 @@ static int __init init_iommu_all(struct acpi_table_header *table) - return 0; - } - --static int iommu_pc_get_set_reg(struct amd_iommu *iommu, u8 bank, u8 cntr, -- u8 fxn, u64 *value, bool is_write); -- --static void init_iommu_perf_ctr(struct amd_iommu *iommu) -+static void __init init_iommu_perf_ctr(struct amd_iommu *iommu) - { -+ int retry; - struct pci_dev *pdev = iommu->dev; -- u64 val = 0xabcd, val2 = 0, save_reg = 0; -+ u64 val = 0xabcd, val2 = 0, save_reg, save_src; - - if (!iommu_feature(iommu, FEATURE_PC)) - return; -@@ -1686,17 +1687,39 @@ static void init_iommu_perf_ctr(struct amd_iommu *iommu) - amd_iommu_pc_present = true; - - /* save the value to restore, if writable */ -- if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, false)) -+ if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, false) || -+ iommu_pc_get_set_reg(iommu, 0, 0, 8, &save_src, false)) - goto pc_false; - -- /* Check if the performance counters can be written to */ -- if ((iommu_pc_get_set_reg(iommu, 0, 0, 0, &val, true)) || -- (iommu_pc_get_set_reg(iommu, 0, 0, 0, &val2, false)) || -- (val != val2)) -+ /* -+ * Disable power gating by programing the performance counter -+ * source to 20 (i.e. counts the reads and writes from/to IOMMU -+ * Reserved Register [MMIO Offset 1FF8h] that are ignored.), -+ * which never get incremented during this init phase. -+ * (Note: The event is also deprecated.) -+ */ -+ val = 20; -+ if (iommu_pc_get_set_reg(iommu, 0, 0, 8, &val, true)) - goto pc_false; - -+ /* Check if the performance counters can be written to */ -+ val = 0xabcd; -+ for (retry = 5; retry; retry--) { -+ if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &val, true) || -+ iommu_pc_get_set_reg(iommu, 0, 0, 0, &val2, false) || -+ val2) -+ break; -+ -+ /* Wait about 20 msec for power gating to disable and retry. */ -+ msleep(20); -+ } -+ - /* restore */ -- if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, true)) -+ if (iommu_pc_get_set_reg(iommu, 0, 0, 0, &save_reg, true) || -+ iommu_pc_get_set_reg(iommu, 0, 0, 8, &save_src, true)) -+ goto pc_false; -+ -+ if (val != val2) - goto pc_false; - - pci_info(pdev, "IOMMU performance counters supported\n"); -diff --git a/drivers/media/platform/vsp1/vsp1_drm.c b/drivers/media/platform/vsp1/vsp1_drm.c -index a4a45d68a6efc..1c00688c71c24 100644 ---- a/drivers/media/platform/vsp1/vsp1_drm.c -+++ b/drivers/media/platform/vsp1/vsp1_drm.c -@@ -245,7 +245,7 @@ static int vsp1_du_pipeline_setup_brx(struct vsp1_device *vsp1, - brx = &vsp1->bru->entity; - else if (pipe->brx && !drm_pipe->force_brx_release) - brx = pipe->brx; -- else if (!vsp1->bru->entity.pipe) -+ else if (vsp1_feature(vsp1, VSP1_HAS_BRU) && !vsp1->bru->entity.pipe) - brx = &vsp1->bru->entity; - else - brx = &vsp1->brs->entity; -@@ -462,9 +462,9 @@ static int vsp1_du_pipeline_setup_inputs(struct vsp1_device *vsp1, - * make sure it is present in the pipeline's list of entities if it - * wasn't already. - */ -- if (!use_uif) { -+ if (drm_pipe->uif && !use_uif) { - drm_pipe->uif->pipe = NULL; -- } else if (!drm_pipe->uif->pipe) { -+ } else if (drm_pipe->uif && !drm_pipe->uif->pipe) { - drm_pipe->uif->pipe = pipe; - list_add_tail(&drm_pipe->uif->list_pipe, &pipe->entities); - } -diff --git a/drivers/media/rc/Makefile b/drivers/media/rc/Makefile -index 48d23433b3c06..caeb51def782c 100644 ---- a/drivers/media/rc/Makefile -+++ b/drivers/media/rc/Makefile -@@ -5,6 +5,7 @@ obj-y += keymaps/ - obj-$(CONFIG_RC_CORE) += rc-core.o - rc-core-y := rc-main.o rc-ir-raw.o - rc-core-$(CONFIG_LIRC) += lirc_dev.o -+rc-core-$(CONFIG_MEDIA_CEC_RC) += keymaps/rc-cec.o - rc-core-$(CONFIG_BPF_LIRC_MODE2) += bpf-lirc.o - obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o - obj-$(CONFIG_IR_RC5_DECODER) += ir-rc5-decoder.o -diff --git a/drivers/media/rc/keymaps/Makefile b/drivers/media/rc/keymaps/Makefile -index ea91a9afa6a02..d89dcc4481229 100644 ---- a/drivers/media/rc/keymaps/Makefile -+++ b/drivers/media/rc/keymaps/Makefile -@@ -20,7 +20,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ - rc-behold.o \ - rc-behold-columbus.o \ - rc-budget-ci-old.o \ -- rc-cec.o \ - rc-cinergy-1400.o \ - rc-cinergy.o \ - rc-d680-dmb.o \ -diff --git a/drivers/media/rc/keymaps/rc-cec.c b/drivers/media/rc/keymaps/rc-cec.c -index 3e3bd11092b45..068e22aeac8c3 100644 ---- a/drivers/media/rc/keymaps/rc-cec.c -+++ b/drivers/media/rc/keymaps/rc-cec.c -@@ -1,5 +1,15 @@ - // SPDX-License-Identifier: GPL-2.0-or-later - /* Keytable for the CEC remote control -+ * -+ * This keymap is unusual in that it can't be built as a module, -+ * instead it is registered directly in rc-main.c if CONFIG_MEDIA_CEC_RC -+ * is set. This is because it can be called from drm_dp_cec_set_edid() via -+ * cec_register_adapter() in an asynchronous context, and it is not -+ * allowed to use request_module() to load rc-cec.ko in that case. -+ * -+ * Since this keymap is only used if CONFIG_MEDIA_CEC_RC is set, we -+ * just compile this keymap into the rc-core module and never as a -+ * separate module. - * - * Copyright (c) 2015 by Kamil Debski - */ -@@ -152,7 +162,7 @@ static struct rc_map_table cec[] = { - /* 0x77-0xff: Reserved */ - }; - --static struct rc_map_list cec_map = { -+struct rc_map_list cec_map = { - .map = { - .scan = cec, - .size = ARRAY_SIZE(cec), -@@ -160,19 +170,3 @@ static struct rc_map_list cec_map = { - .name = RC_MAP_CEC, - } - }; -- --static int __init init_rc_map_cec(void) --{ -- return rc_map_register(&cec_map); --} -- --static void __exit exit_rc_map_cec(void) --{ -- rc_map_unregister(&cec_map); --} -- --module_init(init_rc_map_cec); --module_exit(exit_rc_map_cec); -- --MODULE_LICENSE("GPL"); --MODULE_AUTHOR("Kamil Debski"); -diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c -index c4d7e06974d2c..ee80f38970bc4 100644 ---- a/drivers/media/rc/rc-main.c -+++ b/drivers/media/rc/rc-main.c -@@ -2033,6 +2033,9 @@ static int __init rc_core_init(void) - - led_trigger_register_simple("rc-feedback", &led_feedback); - rc_map_register(&empty_map); -+#ifdef CONFIG_MEDIA_CEC_RC -+ rc_map_register(&cec_map); -+#endif - - return 0; - } -@@ -2042,6 +2045,9 @@ static void __exit rc_core_exit(void) - lirc_dev_exit(); - class_unregister(&rc_class); - led_trigger_unregister_simple(led_feedback); -+#ifdef CONFIG_MEDIA_CEC_RC -+ rc_map_unregister(&cec_map); -+#endif - rc_map_unregister(&empty_map); - } - -diff --git a/drivers/media/usb/usbtv/usbtv-audio.c b/drivers/media/usb/usbtv/usbtv-audio.c -index 6f108996142d7..bbfaec2e6ef61 100644 ---- a/drivers/media/usb/usbtv/usbtv-audio.c -+++ b/drivers/media/usb/usbtv/usbtv-audio.c -@@ -399,7 +399,7 @@ void usbtv_audio_free(struct usbtv *usbtv) - cancel_work_sync(&usbtv->snd_trigger); - - if (usbtv->snd && usbtv->udev) { -- snd_card_free(usbtv->snd); -+ snd_card_free_when_closed(usbtv->snd); - usbtv->snd = NULL; - } - } -diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c -index 3a5d2890fe2aa..beaf15807f789 100644 ---- a/drivers/misc/fastrpc.c -+++ b/drivers/misc/fastrpc.c -@@ -924,6 +924,11 @@ static int fastrpc_internal_invoke(struct fastrpc_user *fl, u32 kernel, - if (!fl->cctx->rpdev) - return -EPIPE; - -+ if (handle == FASTRPC_INIT_HANDLE && !kernel) { -+ dev_warn_ratelimited(fl->sctx->dev, "user app trying to send a kernel RPC message (%d)\n", handle); -+ return -EPERM; -+ } -+ - ctx = fastrpc_context_alloc(fl, kernel, sc, args); - if (IS_ERR(ctx)) - return PTR_ERR(ctx); -diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c -index 95ff7c5a1dfb6..0a5e5b841aeb1 100644 ---- a/drivers/misc/pvpanic.c -+++ b/drivers/misc/pvpanic.c -@@ -166,6 +166,7 @@ static const struct of_device_id pvpanic_mmio_match[] = { - { .compatible = "qemu,pvpanic-mmio", }, - {} - }; -+MODULE_DEVICE_TABLE(of, pvpanic_mmio_match); - - static struct platform_driver pvpanic_mmio_driver = { - .driver = { -diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c -index 74de3f2dda38e..28501f165d457 100644 ---- a/drivers/mmc/core/bus.c -+++ b/drivers/mmc/core/bus.c -@@ -373,11 +373,6 @@ void mmc_remove_card(struct mmc_card *card) - mmc_remove_card_debugfs(card); - #endif - -- if (host->cqe_enabled) { -- host->cqe_ops->cqe_disable(host); -- host->cqe_enabled = false; -- } -- - if (mmc_card_present(card)) { - if (mmc_host_is_spi(card->host)) { - pr_info("%s: SPI card removed\n", -@@ -390,6 +385,10 @@ void mmc_remove_card(struct mmc_card *card) - of_node_put(card->dev.of_node); - } - -+ if (host->cqe_enabled) { -+ host->cqe_ops->cqe_disable(host); -+ host->cqe_enabled = false; -+ } -+ - put_device(&card->dev); - } -- -diff --git a/drivers/mmc/core/mmc.c b/drivers/mmc/core/mmc.c -index de14b5845f525..9f29288f2c9a9 100644 ---- a/drivers/mmc/core/mmc.c -+++ b/drivers/mmc/core/mmc.c -@@ -423,10 +423,6 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) - - /* EXT_CSD value is in units of 10ms, but we store in ms */ - card->ext_csd.part_time = 10 * ext_csd[EXT_CSD_PART_SWITCH_TIME]; -- /* Some eMMC set the value too low so set a minimum */ -- if (card->ext_csd.part_time && -- card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME) -- card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME; - - /* Sleep / awake timeout in 100ns units */ - if (sa_shift > 0 && sa_shift <= 0x17) -@@ -616,6 +612,17 @@ static int mmc_decode_ext_csd(struct mmc_card *card, u8 *ext_csd) - card->ext_csd.data_sector_size = 512; - } - -+ /* -+ * GENERIC_CMD6_TIME is to be used "unless a specific timeout is defined -+ * when accessing a specific field", so use it here if there is no -+ * PARTITION_SWITCH_TIME. -+ */ -+ if (!card->ext_csd.part_time) -+ card->ext_csd.part_time = card->ext_csd.generic_cmd6_time; -+ /* Some eMMC set the value too low so set a minimum */ -+ if (card->ext_csd.part_time < MMC_MIN_PART_SWITCH_TIME) -+ card->ext_csd.part_time = MMC_MIN_PART_SWITCH_TIME; -+ - /* eMMC v5 or later */ - if (card->ext_csd.rev >= 7) { - memcpy(card->ext_csd.fwrev, &ext_csd[EXT_CSD_FIRMWARE_VERSION], -diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c -index 9d47a2bd2546b..1254a5650cfff 100644 ---- a/drivers/mmc/host/mtk-sd.c -+++ b/drivers/mmc/host/mtk-sd.c -@@ -1020,13 +1020,13 @@ static void msdc_track_cmd_data(struct msdc_host *host, - static void msdc_request_done(struct msdc_host *host, struct mmc_request *mrq) - { - unsigned long flags; -- bool ret; - -- ret = cancel_delayed_work(&host->req_timeout); -- if (!ret) { -- /* delay work already running */ -- return; -- } -+ /* -+ * No need check the return value of cancel_delayed_work, as only ONE -+ * path will go here! -+ */ -+ cancel_delayed_work(&host->req_timeout); -+ - spin_lock_irqsave(&host->lock, flags); - host->mrq = NULL; - spin_unlock_irqrestore(&host->lock, flags); -@@ -1046,7 +1046,7 @@ static bool msdc_cmd_done(struct msdc_host *host, int events, - bool done = false; - bool sbc_error; - unsigned long flags; -- u32 *rsp = cmd->resp; -+ u32 *rsp; - - if (mrq->sbc && cmd == mrq->cmd && - (events & (MSDC_INT_ACMDRDY | MSDC_INT_ACMDCRCERR -@@ -1067,6 +1067,7 @@ static bool msdc_cmd_done(struct msdc_host *host, int events, - - if (done) - return true; -+ rsp = cmd->resp; - - sdr_clr_bits(host->base + MSDC_INTEN, cmd_ints_mask); - -@@ -1254,7 +1255,7 @@ static void msdc_data_xfer_next(struct msdc_host *host, - static bool msdc_data_xfer_done(struct msdc_host *host, u32 events, - struct mmc_request *mrq, struct mmc_data *data) - { -- struct mmc_command *stop = data->stop; -+ struct mmc_command *stop; - unsigned long flags; - bool done; - unsigned int check_data = events & -@@ -1270,6 +1271,7 @@ static bool msdc_data_xfer_done(struct msdc_host *host, u32 events, - - if (done) - return true; -+ stop = data->stop; - - if (check_data || (stop && stop->error)) { - dev_dbg(host->dev, "DMA status: 0x%8X\n", -diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c -index 4031217d21c37..52054931c3507 100644 ---- a/drivers/mmc/host/mxs-mmc.c -+++ b/drivers/mmc/host/mxs-mmc.c -@@ -644,7 +644,7 @@ static int mxs_mmc_probe(struct platform_device *pdev) - - ret = mmc_of_parse(mmc); - if (ret) -- goto out_clk_disable; -+ goto out_free_dma; - - mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34; - -diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c -index 1bd955e4c7d66..b6d00dfa8b8f6 100644 ---- a/drivers/net/can/flexcan.c -+++ b/drivers/net/can/flexcan.c -@@ -548,7 +548,7 @@ static int flexcan_chip_freeze(struct flexcan_priv *priv) - u32 reg; - - reg = priv->read(®s->mcr); -- reg |= FLEXCAN_MCR_HALT; -+ reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT; - priv->write(reg, ®s->mcr); - - while (timeout-- && !(priv->read(®s->mcr) & FLEXCAN_MCR_FRZ_ACK)) -@@ -1057,10 +1057,13 @@ static int flexcan_chip_start(struct net_device *dev) - - flexcan_set_bittiming(dev); - -+ /* set freeze, halt */ -+ err = flexcan_chip_freeze(priv); -+ if (err) -+ goto out_chip_disable; -+ - /* MCR - * -- * enable freeze -- * halt now - * only supervisor access - * enable warning int - * enable individual RX masking -@@ -1069,9 +1072,8 @@ static int flexcan_chip_start(struct net_device *dev) - */ - reg_mcr = priv->read(®s->mcr); - reg_mcr &= ~FLEXCAN_MCR_MAXMB(0xff); -- reg_mcr |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | FLEXCAN_MCR_SUPV | -- FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | FLEXCAN_MCR_IDAM_C | -- FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); -+ reg_mcr |= FLEXCAN_MCR_SUPV | FLEXCAN_MCR_WRN_EN | FLEXCAN_MCR_IRMQ | -+ FLEXCAN_MCR_IDAM_C | FLEXCAN_MCR_MAXMB(priv->tx_mb_idx); - - /* MCR - * -@@ -1432,10 +1434,14 @@ static int register_flexcandev(struct net_device *dev) - if (err) - goto out_chip_disable; - -- /* set freeze, halt and activate FIFO, restrict register access */ -+ /* set freeze, halt */ -+ err = flexcan_chip_freeze(priv); -+ if (err) -+ goto out_chip_disable; -+ -+ /* activate FIFO, restrict register access */ - reg = priv->read(®s->mcr); -- reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT | -- FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV; -+ reg |= FLEXCAN_MCR_FEN | FLEXCAN_MCR_SUPV; - priv->write(reg, ®s->mcr); - - /* Currently we only support newer versions of this core -diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c -index 1f8710b35c6d7..32cb479fe6ac8 100644 ---- a/drivers/net/can/m_can/tcan4x5x.c -+++ b/drivers/net/can/m_can/tcan4x5x.c -@@ -325,14 +325,14 @@ static int tcan4x5x_init(struct m_can_classdev *cdev) - if (ret) - return ret; - -+ /* Zero out the MCAN buffers */ -+ m_can_init_ram(cdev); -+ - ret = regmap_update_bits(tcan4x5x->regmap, TCAN4X5X_CONFIG, - TCAN4X5X_MODE_SEL_MASK, TCAN4X5X_MODE_NORMAL); - if (ret) - return ret; - -- /* Zero out the MCAN buffers */ -- m_can_init_ram(cdev); -- - return ret; - } - -diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c -index aa693c8e285ab..bde8ec75ac4e9 100644 ---- a/drivers/net/ethernet/atheros/alx/main.c -+++ b/drivers/net/ethernet/atheros/alx/main.c -@@ -1897,13 +1897,16 @@ static int alx_resume(struct device *dev) - - if (!netif_running(alx->dev)) - return 0; -- netif_device_attach(alx->dev); - - rtnl_lock(); - err = __alx_open(alx, true); - rtnl_unlock(); -+ if (err) -+ return err; - -- return err; -+ netif_device_attach(alx->dev); -+ -+ return 0; - } - - static SIMPLE_DEV_PM_OPS(alx_pm_ops, alx_suspend, alx_resume); -diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -index 4ae49d92c1eed..5a7831a97a132 100644 ---- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c -+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c -@@ -7925,10 +7925,18 @@ static void bnxt_setup_inta(struct bnxt *bp) - bp->irq_tbl[0].handler = bnxt_inta; - } - -+static int bnxt_init_int_mode(struct bnxt *bp); -+ - static int bnxt_setup_int_mode(struct bnxt *bp) - { - int rc; - -+ if (!bp->irq_tbl) { -+ rc = bnxt_init_int_mode(bp); -+ if (rc || !bp->irq_tbl) -+ return rc ?: -ENODEV; -+ } -+ - if (bp->flags & BNXT_FLAG_USING_MSIX) - bnxt_setup_msix(bp); - else -@@ -8113,7 +8121,7 @@ static int bnxt_init_inta(struct bnxt *bp) - - static int bnxt_init_int_mode(struct bnxt *bp) - { -- int rc = 0; -+ int rc = -ENODEV; - - if (bp->flags & BNXT_FLAG_MSIX_CAP) - rc = bnxt_init_msix(bp); -@@ -8748,7 +8756,8 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) - { - struct hwrm_func_drv_if_change_output *resp = bp->hwrm_cmd_resp_addr; - struct hwrm_func_drv_if_change_input req = {0}; -- bool resc_reinit = false, fw_reset = false; -+ bool fw_reset = !bp->irq_tbl; -+ bool resc_reinit = false; - u32 flags = 0; - int rc; - -@@ -8776,6 +8785,7 @@ static int bnxt_hwrm_if_change(struct bnxt *bp, bool up) - - if (test_bit(BNXT_STATE_IN_FW_RESET, &bp->state) && !fw_reset) { - netdev_err(bp->dev, "RESET_DONE not set during FW reset.\n"); -+ set_bit(BNXT_STATE_ABORT_ERR, &bp->state); - return -ENODEV; - } - if (resc_reinit || fw_reset) { -diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c -index 70060c51854fd..0928bec79fe4b 100644 ---- a/drivers/net/ethernet/davicom/dm9000.c -+++ b/drivers/net/ethernet/davicom/dm9000.c -@@ -134,6 +134,8 @@ struct board_info { - u32 wake_state; - - int ip_summed; -+ -+ struct regulator *power_supply; - }; - - /* debug code */ -@@ -1454,7 +1456,7 @@ dm9000_probe(struct platform_device *pdev) - if (ret) { - dev_err(dev, "failed to request reset gpio %d: %d\n", - reset_gpios, ret); -- return -ENODEV; -+ goto out_regulator_disable; - } - - /* According to manual PWRST# Low Period Min 1ms */ -@@ -1466,8 +1468,10 @@ dm9000_probe(struct platform_device *pdev) - - if (!pdata) { - pdata = dm9000_parse_dt(&pdev->dev); -- if (IS_ERR(pdata)) -- return PTR_ERR(pdata); -+ if (IS_ERR(pdata)) { -+ ret = PTR_ERR(pdata); -+ goto out_regulator_disable; -+ } - } - - /* Init network device */ -@@ -1484,6 +1488,8 @@ dm9000_probe(struct platform_device *pdev) - - db->dev = &pdev->dev; - db->ndev = ndev; -+ if (!IS_ERR(power)) -+ db->power_supply = power; - - spin_lock_init(&db->lock); - mutex_init(&db->addr_lock); -@@ -1708,6 +1714,10 @@ out: - dm9000_release_board(pdev, db); - free_netdev(ndev); - -+out_regulator_disable: -+ if (!IS_ERR(power)) -+ regulator_disable(power); -+ - return ret; - } - -@@ -1765,10 +1775,13 @@ static int - dm9000_drv_remove(struct platform_device *pdev) - { - struct net_device *ndev = platform_get_drvdata(pdev); -+ struct board_info *dm = to_dm9000_board(ndev); - - unregister_netdev(ndev); -- dm9000_release_board(pdev, netdev_priv(ndev)); -+ dm9000_release_board(pdev, dm); - free_netdev(ndev); /* free device structure */ -+ if (dm->power_supply) -+ regulator_disable(dm->power_supply); - - dev_dbg(&pdev->dev, "released and freed device\n"); - return 0; -diff --git a/drivers/net/ethernet/freescale/enetc/enetc.c b/drivers/net/ethernet/freescale/enetc/enetc.c -index 4ef4d41b0d8d6..b77eaf31bd4ed 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc.c -+++ b/drivers/net/ethernet/freescale/enetc/enetc.c -@@ -942,7 +942,7 @@ static void enetc_free_rxtx_rings(struct enetc_ndev_priv *priv) - enetc_free_tx_ring(priv->tx_ring[i]); - } - --static int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) -+int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) - { - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - -@@ -963,7 +963,7 @@ static int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr) - return 0; - } - --static void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) -+void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) - { - int size = cbdr->bd_count * sizeof(struct enetc_cbd); - -@@ -971,7 +971,7 @@ static void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr) - cbdr->bd_base = NULL; - } - --static void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) -+void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) - { - /* set CBDR cache attributes */ - enetc_wr(hw, ENETC_SICAR2, -@@ -991,7 +991,7 @@ static void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr) - cbdr->cir = hw->reg + ENETC_SICBDRCIR; - } - --static void enetc_clear_cbdr(struct enetc_hw *hw) -+void enetc_clear_cbdr(struct enetc_hw *hw) - { - enetc_wr(hw, ENETC_SICBDRMR, 0); - } -@@ -1016,13 +1016,12 @@ static int enetc_setup_default_rss_table(struct enetc_si *si, int num_groups) - return 0; - } - --static int enetc_configure_si(struct enetc_ndev_priv *priv) -+int enetc_configure_si(struct enetc_ndev_priv *priv) - { - struct enetc_si *si = priv->si; - struct enetc_hw *hw = &si->hw; - int err; - -- enetc_setup_cbdr(hw, &si->cbd_ring); - /* set SI cache attributes */ - enetc_wr(hw, ENETC_SICAR0, - ENETC_SICAR_RD_COHERENT | ENETC_SICAR_WR_COHERENT); -@@ -1068,6 +1067,8 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) - if (err) - return err; - -+ enetc_setup_cbdr(&si->hw, &si->cbd_ring); -+ - priv->cls_rules = kcalloc(si->num_fs_entries, sizeof(*priv->cls_rules), - GFP_KERNEL); - if (!priv->cls_rules) { -@@ -1075,14 +1076,8 @@ int enetc_alloc_si_resources(struct enetc_ndev_priv *priv) - goto err_alloc_cls; - } - -- err = enetc_configure_si(priv); -- if (err) -- goto err_config_si; -- - return 0; - --err_config_si: -- kfree(priv->cls_rules); - err_alloc_cls: - enetc_clear_cbdr(&si->hw); - enetc_free_cbdr(priv->dev, &si->cbd_ring); -diff --git a/drivers/net/ethernet/freescale/enetc/enetc.h b/drivers/net/ethernet/freescale/enetc/enetc.h -index 541b4e2073fe3..b8801a2b6a025 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc.h -+++ b/drivers/net/ethernet/freescale/enetc/enetc.h -@@ -221,6 +221,7 @@ void enetc_get_si_caps(struct enetc_si *si); - void enetc_init_si_rings_params(struct enetc_ndev_priv *priv); - int enetc_alloc_si_resources(struct enetc_ndev_priv *priv); - void enetc_free_si_resources(struct enetc_ndev_priv *priv); -+int enetc_configure_si(struct enetc_ndev_priv *priv); - - int enetc_open(struct net_device *ndev); - int enetc_close(struct net_device *ndev); -@@ -236,6 +237,10 @@ int enetc_setup_tc(struct net_device *ndev, enum tc_setup_type type, - void enetc_set_ethtool_ops(struct net_device *ndev); - - /* control buffer descriptor ring (CBDR) */ -+int enetc_alloc_cbdr(struct device *dev, struct enetc_cbdr *cbdr); -+void enetc_free_cbdr(struct device *dev, struct enetc_cbdr *cbdr); -+void enetc_setup_cbdr(struct enetc_hw *hw, struct enetc_cbdr *cbdr); -+void enetc_clear_cbdr(struct enetc_hw *hw); - int enetc_set_mac_flt_entry(struct enetc_si *si, int index, - char *mac_addr, int si_map); - int enetc_clear_mac_flt_entry(struct enetc_si *si, int index); -diff --git a/drivers/net/ethernet/freescale/enetc/enetc_pf.c b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -index 22f70638a4055..ac62464e0416a 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc_pf.c -+++ b/drivers/net/ethernet/freescale/enetc/enetc_pf.c -@@ -854,6 +854,26 @@ static int enetc_init_port_rss_memory(struct enetc_si *si) - return err; - } - -+static void enetc_init_unused_port(struct enetc_si *si) -+{ -+ struct device *dev = &si->pdev->dev; -+ struct enetc_hw *hw = &si->hw; -+ int err; -+ -+ si->cbd_ring.bd_count = ENETC_CBDR_DEFAULT_SIZE; -+ err = enetc_alloc_cbdr(dev, &si->cbd_ring); -+ if (err) -+ return; -+ -+ enetc_setup_cbdr(hw, &si->cbd_ring); -+ -+ enetc_init_port_rfs_memory(si); -+ enetc_init_port_rss_memory(si); -+ -+ enetc_clear_cbdr(hw); -+ enetc_free_cbdr(dev, &si->cbd_ring); -+} -+ - static int enetc_pf_probe(struct pci_dev *pdev, - const struct pci_device_id *ent) - { -@@ -863,11 +883,6 @@ static int enetc_pf_probe(struct pci_dev *pdev, - struct enetc_pf *pf; - int err; - -- if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) { -- dev_info(&pdev->dev, "device is disabled, skipping\n"); -- return -ENODEV; -- } -- - err = enetc_pci_probe(pdev, KBUILD_MODNAME, sizeof(*pf)); - if (err) { - dev_err(&pdev->dev, "PCI probing failed\n"); -@@ -881,6 +896,13 @@ static int enetc_pf_probe(struct pci_dev *pdev, - goto err_map_pf_space; - } - -+ if (pdev->dev.of_node && !of_device_is_available(pdev->dev.of_node)) { -+ enetc_init_unused_port(si); -+ dev_info(&pdev->dev, "device is disabled, skipping\n"); -+ err = -ENODEV; -+ goto err_device_disabled; -+ } -+ - pf = enetc_si_priv(si); - pf->si = si; - pf->total_vfs = pci_sriov_get_totalvfs(pdev); -@@ -920,6 +942,12 @@ static int enetc_pf_probe(struct pci_dev *pdev, - goto err_init_port_rss; - } - -+ err = enetc_configure_si(priv); -+ if (err) { -+ dev_err(&pdev->dev, "Failed to configure SI\n"); -+ goto err_config_si; -+ } -+ - err = enetc_alloc_msix(priv); - if (err) { - dev_err(&pdev->dev, "MSIX alloc failed\n"); -@@ -945,6 +973,7 @@ err_reg_netdev: - enetc_mdio_remove(pf); - enetc_of_put_phy(priv); - enetc_free_msix(priv); -+err_config_si: - err_init_port_rss: - err_init_port_rfs: - err_alloc_msix: -@@ -953,6 +982,7 @@ err_alloc_si_res: - si->ndev = NULL; - free_netdev(ndev); - err_alloc_netdev: -+err_device_disabled: - err_map_pf_space: - enetc_pci_remove(pdev); - -diff --git a/drivers/net/ethernet/freescale/enetc/enetc_vf.c b/drivers/net/ethernet/freescale/enetc/enetc_vf.c -index ebd21bf4cfa1e..3a8c2049b417c 100644 ---- a/drivers/net/ethernet/freescale/enetc/enetc_vf.c -+++ b/drivers/net/ethernet/freescale/enetc/enetc_vf.c -@@ -189,6 +189,12 @@ static int enetc_vf_probe(struct pci_dev *pdev, - goto err_alloc_si_res; - } - -+ err = enetc_configure_si(priv); -+ if (err) { -+ dev_err(&pdev->dev, "Failed to configure SI\n"); -+ goto err_config_si; -+ } -+ - err = enetc_alloc_msix(priv); - if (err) { - dev_err(&pdev->dev, "MSIX alloc failed\n"); -@@ -208,6 +214,7 @@ static int enetc_vf_probe(struct pci_dev *pdev, - - err_reg_netdev: - enetc_free_msix(priv); -+err_config_si: - err_alloc_msix: - enetc_free_si_resources(priv); - err_alloc_si_res: -diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h -index 1426eb5ddf3df..e34e0854635c3 100644 ---- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h -+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_cmd.h -@@ -1018,16 +1018,16 @@ struct hclge_fd_tcam_config_3_cmd { - #define HCLGE_FD_AD_DROP_B 0 - #define HCLGE_FD_AD_DIRECT_QID_B 1 - #define HCLGE_FD_AD_QID_S 2 --#define HCLGE_FD_AD_QID_M GENMASK(12, 2) -+#define HCLGE_FD_AD_QID_M GENMASK(11, 2) - #define HCLGE_FD_AD_USE_COUNTER_B 12 - #define HCLGE_FD_AD_COUNTER_NUM_S 13 - #define HCLGE_FD_AD_COUNTER_NUM_M GENMASK(20, 13) - #define HCLGE_FD_AD_NXT_STEP_B 20 - #define HCLGE_FD_AD_NXT_KEY_S 21 --#define HCLGE_FD_AD_NXT_KEY_M GENMASK(26, 21) -+#define HCLGE_FD_AD_NXT_KEY_M GENMASK(25, 21) - #define HCLGE_FD_AD_WR_RULE_ID_B 0 - #define HCLGE_FD_AD_RULE_ID_S 1 --#define HCLGE_FD_AD_RULE_ID_M GENMASK(13, 1) -+#define HCLGE_FD_AD_RULE_ID_M GENMASK(12, 1) - - struct hclge_fd_ad_config_cmd { - u8 stage; -diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -index 08040cafc06bc..93f3865b679bf 100644 ---- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -+++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c -@@ -4908,9 +4908,9 @@ static bool hclge_fd_convert_tuple(u32 tuple_bit, u8 *key_x, u8 *key_y, - case BIT(INNER_SRC_MAC): - for (i = 0; i < ETH_ALEN; i++) { - calc_x(key_x[ETH_ALEN - 1 - i], rule->tuples.src_mac[i], -- rule->tuples.src_mac[i]); -+ rule->tuples_mask.src_mac[i]); - calc_y(key_y[ETH_ALEN - 1 - i], rule->tuples.src_mac[i], -- rule->tuples.src_mac[i]); -+ rule->tuples_mask.src_mac[i]); - } - - return true; -@@ -5939,8 +5939,7 @@ static int hclge_get_fd_rule_info(struct hnae3_handle *handle, - fs->h_ext.vlan_tci = cpu_to_be16(rule->tuples.vlan_tag1); - fs->m_ext.vlan_tci = - rule->unused_tuple & BIT(INNER_VLAN_TAG_FST) ? -- cpu_to_be16(VLAN_VID_MASK) : -- cpu_to_be16(rule->tuples_mask.vlan_tag1); -+ 0 : cpu_to_be16(rule->tuples_mask.vlan_tag1); - } - - if (fs->flow_type & FLOW_MAC_EXT) { -diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c -index 309cdc5ebc1ff..79b13750fa2d2 100644 ---- a/drivers/net/ethernet/ibm/ibmvnic.c -+++ b/drivers/net/ethernet/ibm/ibmvnic.c -@@ -1753,10 +1753,9 @@ static int ibmvnic_set_mac(struct net_device *netdev, void *p) - if (!is_valid_ether_addr(addr->sa_data)) - return -EADDRNOTAVAIL; - -- if (adapter->state != VNIC_PROBED) { -- ether_addr_copy(adapter->mac_addr, addr->sa_data); -+ ether_addr_copy(adapter->mac_addr, addr->sa_data); -+ if (adapter->state != VNIC_PROBED) - rc = __ibmvnic_set_mac(netdev, addr->sa_data); -- } - - return rc; - } -diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c -index 0604b5aaad86f..58211590229b1 100644 ---- a/drivers/net/ethernet/intel/i40e/i40e_main.c -+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c -@@ -15142,6 +15142,8 @@ static int i40e_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - if (err) { - dev_info(&pdev->dev, - "setup of misc vector failed: %d\n", err); -+ i40e_cloud_filter_exit(pf); -+ i40e_fdir_teardown(pf); - goto err_vsis; - } - } -diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c -index 113f6087c7c9a..b14b164c9601f 100644 ---- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c -+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ipsec.c -@@ -575,6 +575,11 @@ static int ixgbe_ipsec_add_sa(struct xfrm_state *xs) - return -EINVAL; - } - -+ if (xs->props.mode != XFRM_MODE_TRANSPORT) { -+ netdev_err(dev, "Unsupported mode for ipsec offload\n"); -+ return -EINVAL; -+ } -+ - if (ixgbe_ipsec_check_mgmt_ip(xs)) { - netdev_err(dev, "IPsec IP addr clash with mgmt filters\n"); - return -EINVAL; -diff --git a/drivers/net/ethernet/intel/ixgbevf/ipsec.c b/drivers/net/ethernet/intel/ixgbevf/ipsec.c -index 5170dd9d8705b..caaea2c920a6e 100644 ---- a/drivers/net/ethernet/intel/ixgbevf/ipsec.c -+++ b/drivers/net/ethernet/intel/ixgbevf/ipsec.c -@@ -272,6 +272,11 @@ static int ixgbevf_ipsec_add_sa(struct xfrm_state *xs) - return -EINVAL; - } - -+ if (xs->props.mode != XFRM_MODE_TRANSPORT) { -+ netdev_err(dev, "Unsupported mode for ipsec offload\n"); -+ return -EINVAL; -+ } -+ - if (xs->xso.flags & XFRM_OFFLOAD_INBOUND) { - struct rx_sa rsa; - -diff --git a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -index a1202e53710cd..5582fba2f5823 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -+++ b/drivers/net/ethernet/mellanox/mlx4/en_ethtool.c -@@ -47,7 +47,7 @@ - #define EN_ETHTOOL_SHORT_MASK cpu_to_be16(0xffff) - #define EN_ETHTOOL_WORD_MASK cpu_to_be32(0xffffffff) - --static int mlx4_en_moderation_update(struct mlx4_en_priv *priv) -+int mlx4_en_moderation_update(struct mlx4_en_priv *priv) - { - int i, t; - int err = 0; -diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -index b5eb116249dda..cd165e52ed33c 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c -@@ -3657,6 +3657,8 @@ int mlx4_en_reset_config(struct net_device *dev, - en_err(priv, "Failed starting port\n"); - } - -+ if (!err) -+ err = mlx4_en_moderation_update(priv); - out: - mutex_unlock(&mdev->state_lock); - kfree(tmp); -diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h -index a2f69c6f0c79f..17a5bd4c68b2b 100644 ---- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h -+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h -@@ -797,6 +797,7 @@ void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev); - #define DEV_FEATURE_CHANGED(dev, new_features, feature) \ - ((dev->features & feature) ^ (new_features & feature)) - -+int mlx4_en_moderation_update(struct mlx4_en_priv *priv); - int mlx4_en_reset_config(struct net_device *dev, - struct hwtstamp_config ts_config, - netdev_features_t new_features); -diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c -index 18f86e441570c..a042f4607b0d0 100644 ---- a/drivers/net/ethernet/renesas/sh_eth.c -+++ b/drivers/net/ethernet/renesas/sh_eth.c -@@ -610,6 +610,8 @@ static struct sh_eth_cpu_data r7s72100_data = { - EESR_TDE, - .fdr_value = 0x0000070f, - -+ .trscer_err_mask = DESC_I_RINT8 | DESC_I_RINT5, -+ - .no_psr = 1, - .apr = 1, - .mpr = 1, -@@ -828,6 +830,8 @@ static struct sh_eth_cpu_data r7s9210_data = { - - .fdr_value = 0x0000070f, - -+ .trscer_err_mask = DESC_I_RINT8 | DESC_I_RINT5, -+ - .apr = 1, - .mpr = 1, - .tpauser = 1, -@@ -1131,6 +1135,9 @@ static struct sh_eth_cpu_data sh771x_data = { - EESIPR_CEEFIP | EESIPR_CELFIP | - EESIPR_RRFIP | EESIPR_RTLFIP | EESIPR_RTSFIP | - EESIPR_PREIP | EESIPR_CERFIP, -+ -+ .trscer_err_mask = DESC_I_RINT8, -+ - .tsu = 1, - .dual_port = 1, - }; -diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c -index 68c157979b947..a41ac13cc4e55 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c -+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c -@@ -116,6 +116,23 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, - ioaddr + DMA_CHAN_INTR_ENA(chan)); - } - -+static void dwmac410_dma_init_channel(void __iomem *ioaddr, -+ struct stmmac_dma_cfg *dma_cfg, u32 chan) -+{ -+ u32 value; -+ -+ /* common channel control register config */ -+ value = readl(ioaddr + DMA_CHAN_CONTROL(chan)); -+ if (dma_cfg->pblx8) -+ value = value | DMA_BUS_MODE_PBL; -+ -+ writel(value, ioaddr + DMA_CHAN_CONTROL(chan)); -+ -+ /* Mask interrupts by writing to CSR7 */ -+ writel(DMA_CHAN_INTR_DEFAULT_MASK_4_10, -+ ioaddr + DMA_CHAN_INTR_ENA(chan)); -+} -+ - static void dwmac4_dma_init(void __iomem *ioaddr, - struct stmmac_dma_cfg *dma_cfg, int atds) - { -@@ -462,7 +479,7 @@ const struct stmmac_dma_ops dwmac4_dma_ops = { - const struct stmmac_dma_ops dwmac410_dma_ops = { - .reset = dwmac4_dma_reset, - .init = dwmac4_dma_init, -- .init_chan = dwmac4_dma_init_channel, -+ .init_chan = dwmac410_dma_init_channel, - .init_rx_chan = dwmac4_dma_init_rx_chan, - .init_tx_chan = dwmac4_dma_init_tx_chan, - .axi = dwmac4_dma_axi, -diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c -index f2a29a90e0854..afdea015f4b45 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c -+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c -@@ -60,10 +60,6 @@ void dwmac4_dma_stop_tx(void __iomem *ioaddr, u32 chan) - - value &= ~DMA_CONTROL_ST; - writel(value, ioaddr + DMA_CHAN_TX_CONTROL(chan)); -- -- value = readl(ioaddr + GMAC_CONFIG); -- value &= ~GMAC_CONFIG_TE; -- writel(value, ioaddr + GMAC_CONFIG); - } - - void dwmac4_dma_start_rx(void __iomem *ioaddr, u32 chan) -diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -index ce5d3e9e5dff4..8e7c60e02fa09 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c -@@ -4821,6 +4821,8 @@ static void stmmac_reset_queues_param(struct stmmac_priv *priv) - tx_q->cur_tx = 0; - tx_q->dirty_tx = 0; - tx_q->mss = 0; -+ -+ netdev_tx_reset_queue(netdev_get_tx_queue(priv->dev, queue)); - } - } - -diff --git a/drivers/net/netdevsim/netdev.c b/drivers/net/netdevsim/netdev.c -index a6bbe93f29ef6..917f37c176302 100644 ---- a/drivers/net/netdevsim/netdev.c -+++ b/drivers/net/netdevsim/netdev.c -@@ -292,6 +292,7 @@ nsim_create(struct nsim_dev *nsim_dev, struct nsim_dev_port *nsim_dev_port) - - ns = netdev_priv(dev); - ns->netdev = dev; -+ u64_stats_init(&ns->syncp); - ns->nsim_dev = nsim_dev; - ns->nsim_dev_port = nsim_dev_port; - ns->nsim_bus_dev = nsim_dev->nsim_bus_dev; -diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c -index b718b11607fcd..b0b8a3ce82b68 100644 ---- a/drivers/net/phy/phy.c -+++ b/drivers/net/phy/phy.c -@@ -345,15 +345,16 @@ int phy_ethtool_ksettings_set(struct phy_device *phydev, - - phydev->autoneg = autoneg; - -- phydev->speed = speed; -+ if (autoneg == AUTONEG_DISABLE) { -+ phydev->speed = speed; -+ phydev->duplex = duplex; -+ } - - linkmode_copy(phydev->advertising, advertising); - - linkmode_mod_bit(ETHTOOL_LINK_MODE_Autoneg_BIT, - phydev->advertising, autoneg == AUTONEG_ENABLE); - -- phydev->duplex = duplex; -- - phydev->mdix_ctrl = cmd->base.eth_tp_mdix_ctrl; - - /* Restart the PHY */ -diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c -index 05b85b94d9518..6508d70056b3a 100644 ---- a/drivers/net/usb/qmi_wwan.c -+++ b/drivers/net/usb/qmi_wwan.c -@@ -441,13 +441,6 @@ static ssize_t add_mux_store(struct device *d, struct device_attribute *attr, c - goto err; - } - -- /* we don't want to modify a running netdev */ -- if (netif_running(dev->net)) { -- netdev_err(dev->net, "Cannot change a running device\n"); -- ret = -EBUSY; -- goto err; -- } -- - ret = qmimux_register_device(dev->net, mux_id); - if (!ret) { - info->flags |= QMI_WWAN_FLAG_MUX; -@@ -477,13 +470,6 @@ static ssize_t del_mux_store(struct device *d, struct device_attribute *attr, c - if (!rtnl_trylock()) - return restart_syscall(); - -- /* we don't want to modify a running netdev */ -- if (netif_running(dev->net)) { -- netdev_err(dev->net, "Cannot change a running device\n"); -- ret = -EBUSY; -- goto err; -- } -- - del_dev = qmimux_find_dev(dev, mux_id); - if (!del_dev) { - netdev_err(dev->net, "mux_id not present\n"); -diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c -index 709e3de0f6af1..60f357d2f79fa 100644 ---- a/drivers/net/wan/lapbether.c -+++ b/drivers/net/wan/lapbether.c -@@ -283,7 +283,6 @@ static int lapbeth_open(struct net_device *dev) - return -ENODEV; - } - -- netif_start_queue(dev); - return 0; - } - -@@ -291,8 +290,6 @@ static int lapbeth_close(struct net_device *dev) - { - int err; - -- netif_stop_queue(dev); -- - if ((err = lapb_unregister(dev)) != LAPB_OK) - pr_err("lapb_unregister error: %d\n", err); - -diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h -index a412b352182c8..d50022d264642 100644 ---- a/drivers/net/wireless/ath/ath9k/ath9k.h -+++ b/drivers/net/wireless/ath/ath9k/ath9k.h -@@ -177,7 +177,8 @@ struct ath_frame_info { - s8 txq; - u8 keyix; - u8 rtscts_rate; -- u8 retries : 7; -+ u8 retries : 6; -+ u8 dyn_smps : 1; - u8 baw_tracked : 1; - u8 tx_power; - enum ath9k_key_type keytype:2; -diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c -index 31e7b108279c6..14e6871a14054 100644 ---- a/drivers/net/wireless/ath/ath9k/xmit.c -+++ b/drivers/net/wireless/ath/ath9k/xmit.c -@@ -1271,6 +1271,11 @@ static void ath_buf_set_rate(struct ath_softc *sc, struct ath_buf *bf, - is_40, is_sgi, is_sp); - if (rix < 8 && (tx_info->flags & IEEE80211_TX_CTL_STBC)) - info->rates[i].RateFlags |= ATH9K_RATESERIES_STBC; -+ if (rix >= 8 && fi->dyn_smps) { -+ info->rates[i].RateFlags |= -+ ATH9K_RATESERIES_RTS_CTS; -+ info->flags |= ATH9K_TXDESC_CTSENA; -+ } - - info->txpower[i] = ath_get_rate_txpower(sc, bf, rix, - is_40, false); -@@ -2111,6 +2116,7 @@ static void setup_frame_info(struct ieee80211_hw *hw, - fi->keyix = an->ps_key; - else - fi->keyix = ATH9K_TXKEYIX_INVALID; -+ fi->dyn_smps = sta && sta->smps_mode == IEEE80211_SMPS_DYNAMIC; - fi->keytype = keytype; - fi->framelen = framelen; - fi->tx_power = txpower; -diff --git a/drivers/net/wireless/mediatek/mt76/dma.c b/drivers/net/wireless/mediatek/mt76/dma.c -index 781952b686ed2..d3efcbd48ee1e 100644 ---- a/drivers/net/wireless/mediatek/mt76/dma.c -+++ b/drivers/net/wireless/mediatek/mt76/dma.c -@@ -454,13 +454,13 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, - { - struct sk_buff *skb = q->rx_head; - struct skb_shared_info *shinfo = skb_shinfo(skb); -+ int nr_frags = shinfo->nr_frags; - -- if (shinfo->nr_frags < ARRAY_SIZE(shinfo->frags)) { -+ if (nr_frags < ARRAY_SIZE(shinfo->frags)) { - struct page *page = virt_to_head_page(data); - int offset = data - page_address(page) + q->buf_offset; - -- skb_add_rx_frag(skb, shinfo->nr_frags, page, offset, len, -- q->buf_size); -+ skb_add_rx_frag(skb, nr_frags, page, offset, len, q->buf_size); - } else { - skb_free_frag(data); - } -@@ -469,7 +469,10 @@ mt76_add_fragment(struct mt76_dev *dev, struct mt76_queue *q, void *data, - return; - - q->rx_head = NULL; -- dev->drv->rx_skb(dev, q - dev->q_rx, skb); -+ if (nr_frags < ARRAY_SIZE(shinfo->frags)) -+ dev->drv->rx_skb(dev, q - dev->q_rx, skb); -+ else -+ dev_kfree_skb(skb); - } - - static int -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index 95d77a17375e1..e4e24e7bf4628 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -455,7 +455,6 @@ static void nvme_free_ns_head(struct kref *ref) - - nvme_mpath_remove_disk(head); - ida_simple_remove(&head->subsys->ns_ida, head->instance); -- list_del_init(&head->entry); - cleanup_srcu_struct(&head->srcu); - nvme_put_subsystem(head->subsys); - kfree(head); -@@ -3374,7 +3373,6 @@ static int __nvme_check_ids(struct nvme_subsystem *subsys, - - list_for_each_entry(h, &subsys->nsheads, entry) { - if (nvme_ns_ids_valid(&new->ids) && -- !list_empty(&h->list) && - nvme_ns_ids_equal(&new->ids, &h->ids)) - return -EINVAL; - } -@@ -3469,6 +3467,7 @@ static int nvme_init_ns_head(struct nvme_ns *ns, unsigned nsid, - "IDs don't match for shared namespace %d\n", - nsid); - ret = -EINVAL; -+ nvme_put_ns_head(head); - goto out_unlock; - } - } -@@ -3629,6 +3628,8 @@ static int nvme_alloc_ns(struct nvme_ctrl *ctrl, unsigned nsid) - out_unlink_ns: - mutex_lock(&ctrl->subsys->lock); - list_del_rcu(&ns->siblings); -+ if (list_empty(&ns->head->list)) -+ list_del_init(&ns->head->entry); - mutex_unlock(&ctrl->subsys->lock); - nvme_put_ns_head(ns->head); - out_free_id: -@@ -3651,7 +3652,10 @@ static void nvme_ns_remove(struct nvme_ns *ns) - - mutex_lock(&ns->ctrl->subsys->lock); - list_del_rcu(&ns->siblings); -+ if (list_empty(&ns->head->list)) -+ list_del_init(&ns->head->entry); - mutex_unlock(&ns->ctrl->subsys->lock); -+ - synchronize_rcu(); /* guarantee not available in head->list */ - nvme_mpath_clear_current_path(ns); - synchronize_srcu(&ns->head->srcu); /* wait for concurrent submissions */ -diff --git a/drivers/pci/controller/pci-xgene-msi.c b/drivers/pci/controller/pci-xgene-msi.c -index f4c02da84e599..0bfa5065b4405 100644 ---- a/drivers/pci/controller/pci-xgene-msi.c -+++ b/drivers/pci/controller/pci-xgene-msi.c -@@ -384,13 +384,9 @@ static int xgene_msi_hwirq_alloc(unsigned int cpu) - if (!msi_group->gic_irq) - continue; - -- irq_set_chained_handler(msi_group->gic_irq, -- xgene_msi_isr); -- err = irq_set_handler_data(msi_group->gic_irq, msi_group); -- if (err) { -- pr_err("failed to register GIC IRQ handler\n"); -- return -EINVAL; -- } -+ irq_set_chained_handler_and_data(msi_group->gic_irq, -+ xgene_msi_isr, msi_group); -+ - /* - * Statically allocate MSI GIC IRQs to each CPU core. - * With 8-core X-Gene v1, 2 MSI GIC IRQs are allocated -diff --git a/drivers/pci/controller/pcie-mediatek.c b/drivers/pci/controller/pcie-mediatek.c -index 626a7c352dfdf..728a59655825d 100644 ---- a/drivers/pci/controller/pcie-mediatek.c -+++ b/drivers/pci/controller/pcie-mediatek.c -@@ -1063,14 +1063,14 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) - err = of_pci_get_devfn(child); - if (err < 0) { - dev_err(dev, "failed to parse devfn: %d\n", err); -- return err; -+ goto error_put_node; - } - - slot = PCI_SLOT(err); - - err = mtk_pcie_parse_port(pcie, child, slot); - if (err) -- return err; -+ goto error_put_node; - } - - err = mtk_pcie_subsys_powerup(pcie); -@@ -1086,6 +1086,9 @@ static int mtk_pcie_setup(struct mtk_pcie *pcie) - mtk_pcie_subsys_powerdown(pcie); - - return 0; -+error_put_node: -+ of_node_put(child); -+ return err; - } - - static int mtk_pcie_probe(struct platform_device *pdev) -diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c -index 9add26438be50..3c3bc9f584983 100644 ---- a/drivers/pci/pci.c -+++ b/drivers/pci/pci.c -@@ -3903,6 +3903,10 @@ int pci_register_io_range(struct fwnode_handle *fwnode, phys_addr_t addr, - ret = logic_pio_register_range(range); - if (ret) - kfree(range); -+ -+ /* Ignore duplicates due to deferred probing */ -+ if (ret == -EEXIST) -+ ret = 0; - #endif - - return ret; -diff --git a/drivers/platform/olpc/olpc-ec.c b/drivers/platform/olpc/olpc-ec.c -index f64b82824db28..2db7113383fdc 100644 ---- a/drivers/platform/olpc/olpc-ec.c -+++ b/drivers/platform/olpc/olpc-ec.c -@@ -426,11 +426,8 @@ static int olpc_ec_probe(struct platform_device *pdev) - - /* get the EC revision */ - err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ec->version, 1); -- if (err) { -- ec_priv = NULL; -- kfree(ec); -- return err; -- } -+ if (err) -+ goto error; - - config.dev = pdev->dev.parent; - config.driver_data = ec; -@@ -440,12 +437,16 @@ static int olpc_ec_probe(struct platform_device *pdev) - if (IS_ERR(ec->dcon_rdev)) { - dev_err(&pdev->dev, "failed to register DCON regulator\n"); - err = PTR_ERR(ec->dcon_rdev); -- kfree(ec); -- return err; -+ goto error; - } - - ec->dbgfs_dir = olpc_ec_setup_debugfs(); - -+ return 0; -+ -+error: -+ ec_priv = NULL; -+ kfree(ec); - return err; - } - -diff --git a/drivers/s390/block/dasd.c b/drivers/s390/block/dasd.c -index a0ebc2e603949..b577c8f7e3462 100644 ---- a/drivers/s390/block/dasd.c -+++ b/drivers/s390/block/dasd.c -@@ -3087,7 +3087,8 @@ static blk_status_t do_dasd_request(struct blk_mq_hw_ctx *hctx, - - basedev = block->base; - spin_lock_irq(&dq->lock); -- if (basedev->state < DASD_STATE_READY) { -+ if (basedev->state < DASD_STATE_READY || -+ test_bit(DASD_FLAG_OFFLINE, &basedev->flags)) { - DBF_DEV_EVENT(DBF_ERR, basedev, - "device not ready for request %p", req); - rc = BLK_STS_IOERR; -@@ -3522,8 +3523,6 @@ void dasd_generic_remove(struct ccw_device *cdev) - struct dasd_device *device; - struct dasd_block *block; - -- cdev->handler = NULL; -- - device = dasd_device_from_cdev(cdev); - if (IS_ERR(device)) { - dasd_remove_sysfs_files(cdev); -@@ -3542,6 +3541,7 @@ void dasd_generic_remove(struct ccw_device *cdev) - * no quite down yet. - */ - dasd_set_target_state(device, DASD_STATE_NEW); -+ cdev->handler = NULL; - /* dasd_delete_device destroys the device reference. */ - block = device->block; - dasd_delete_device(device); -diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c -index f0d71ab77c50e..15df0a5c03ecb 100644 ---- a/drivers/s390/cio/vfio_ccw_ops.c -+++ b/drivers/s390/cio/vfio_ccw_ops.c -@@ -506,7 +506,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, - if (ret) - return ret; - -- return copy_to_user((void __user *)arg, &info, minsz); -+ return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; - } - case VFIO_DEVICE_GET_REGION_INFO: - { -@@ -524,7 +524,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, - if (ret) - return ret; - -- return copy_to_user((void __user *)arg, &info, minsz); -+ return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; - } - case VFIO_DEVICE_GET_IRQ_INFO: - { -@@ -545,7 +545,7 @@ static ssize_t vfio_ccw_mdev_ioctl(struct mdev_device *mdev, - if (info.count == -1) - return -EINVAL; - -- return copy_to_user((void __user *)arg, &info, minsz); -+ return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; - } - case VFIO_DEVICE_SET_IRQS: - { -diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c -index 790b0b2b36272..1ec01148018f1 100644 ---- a/drivers/s390/crypto/vfio_ap_ops.c -+++ b/drivers/s390/crypto/vfio_ap_ops.c -@@ -1279,7 +1279,7 @@ static int vfio_ap_mdev_get_device_info(unsigned long arg) - info.num_regions = 0; - info.num_irqs = 0; - -- return copy_to_user((void __user *)arg, &info, minsz); -+ return copy_to_user((void __user *)arg, &info, minsz) ? -EFAULT : 0; - } - - static ssize_t vfio_ap_mdev_ioctl(struct mdev_device *mdev, -diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c -index a14057c67a12a..c5b7d18513b66 100644 ---- a/drivers/scsi/libiscsi.c -+++ b/drivers/scsi/libiscsi.c -@@ -1532,14 +1532,9 @@ check_mgmt: - } - rc = iscsi_prep_scsi_cmd_pdu(conn->task); - if (rc) { -- if (rc == -ENOMEM || rc == -EACCES) { -- spin_lock_bh(&conn->taskqueuelock); -- list_add_tail(&conn->task->running, -- &conn->cmdqueue); -- conn->task = NULL; -- spin_unlock_bh(&conn->taskqueuelock); -- goto done; -- } else -+ if (rc == -ENOMEM || rc == -EACCES) -+ fail_scsi_task(conn->task, DID_IMM_RETRY); -+ else - fail_scsi_task(conn->task, DID_ABORT); - spin_lock_bh(&conn->taskqueuelock); - continue; -diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c -index 8622cf9d3f640..9e7a6de3c43d1 100644 ---- a/drivers/spi/spi-stm32.c -+++ b/drivers/spi/spi-stm32.c -@@ -924,8 +924,8 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id) - mask |= STM32H7_SPI_SR_RXP; - - if (!(sr & mask)) { -- dev_dbg(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n", -- sr, ier); -+ dev_warn(spi->dev, "spurious IT (sr=0x%08x, ier=0x%08x)\n", -+ sr, ier); - spin_unlock_irqrestore(&spi->lock, flags); - return IRQ_NONE; - } -@@ -952,15 +952,8 @@ static irqreturn_t stm32h7_spi_irq_thread(int irq, void *dev_id) - } - - if (sr & STM32H7_SPI_SR_OVR) { -- dev_warn(spi->dev, "Overrun: received value discarded\n"); -- if (!spi->cur_usedma && (spi->rx_buf && (spi->rx_len > 0))) -- stm32h7_spi_read_rxfifo(spi, false); -- /* -- * If overrun is detected while using DMA, it means that -- * something went wrong, so stop the current transfer -- */ -- if (spi->cur_usedma) -- end = true; -+ dev_err(spi->dev, "Overrun: RX data lost\n"); -+ end = true; - } - - if (sr & STM32H7_SPI_SR_EOT) { -diff --git a/drivers/staging/comedi/drivers/addi_apci_1032.c b/drivers/staging/comedi/drivers/addi_apci_1032.c -index e035c9f757a1c..2176d3289eff5 100644 ---- a/drivers/staging/comedi/drivers/addi_apci_1032.c -+++ b/drivers/staging/comedi/drivers/addi_apci_1032.c -@@ -260,6 +260,7 @@ static irqreturn_t apci1032_interrupt(int irq, void *d) - struct apci1032_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; - unsigned int ctrl; -+ unsigned short val; - - /* check interrupt is from this device */ - if ((inl(devpriv->amcc_iobase + AMCC_OP_REG_INTCSR) & -@@ -275,7 +276,8 @@ static irqreturn_t apci1032_interrupt(int irq, void *d) - outl(ctrl & ~APCI1032_CTRL_INT_ENA, dev->iobase + APCI1032_CTRL_REG); - - s->state = inl(dev->iobase + APCI1032_STATUS_REG) & 0xffff; -- comedi_buf_write_samples(s, &s->state, 1); -+ val = s->state; -+ comedi_buf_write_samples(s, &val, 1); - comedi_handle_events(dev, s); - - /* enable the interrupt */ -diff --git a/drivers/staging/comedi/drivers/addi_apci_1500.c b/drivers/staging/comedi/drivers/addi_apci_1500.c -index 816dd25b9d0e4..8c3eff7cf465c 100644 ---- a/drivers/staging/comedi/drivers/addi_apci_1500.c -+++ b/drivers/staging/comedi/drivers/addi_apci_1500.c -@@ -208,7 +208,7 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) - struct comedi_device *dev = d; - struct apci1500_private *devpriv = dev->private; - struct comedi_subdevice *s = dev->read_subdev; -- unsigned int status = 0; -+ unsigned short status = 0; - unsigned int val; - - val = inl(devpriv->amcc + AMCC_OP_REG_INTCSR); -@@ -238,14 +238,14 @@ static irqreturn_t apci1500_interrupt(int irq, void *d) - * - * Mask Meaning - * ---------- ------------------------------------------ -- * 0x00000001 Event 1 has occurred -- * 0x00000010 Event 2 has occurred -- * 0x00000100 Counter/timer 1 has run down (not implemented) -- * 0x00001000 Counter/timer 2 has run down (not implemented) -- * 0x00010000 Counter 3 has run down (not implemented) -- * 0x00100000 Watchdog has run down (not implemented) -- * 0x01000000 Voltage error -- * 0x10000000 Short-circuit error -+ * 0b00000001 Event 1 has occurred -+ * 0b00000010 Event 2 has occurred -+ * 0b00000100 Counter/timer 1 has run down (not implemented) -+ * 0b00001000 Counter/timer 2 has run down (not implemented) -+ * 0b00010000 Counter 3 has run down (not implemented) -+ * 0b00100000 Watchdog has run down (not implemented) -+ * 0b01000000 Voltage error -+ * 0b10000000 Short-circuit error - */ - comedi_buf_write_samples(s, &status, 1); - comedi_handle_events(dev, s); -diff --git a/drivers/staging/comedi/drivers/adv_pci1710.c b/drivers/staging/comedi/drivers/adv_pci1710.c -index ddc0dc93d08b6..eca5fa8a9eb8e 100644 ---- a/drivers/staging/comedi/drivers/adv_pci1710.c -+++ b/drivers/staging/comedi/drivers/adv_pci1710.c -@@ -300,11 +300,11 @@ static int pci1710_ai_eoc(struct comedi_device *dev, - static int pci1710_ai_read_sample(struct comedi_device *dev, - struct comedi_subdevice *s, - unsigned int cur_chan, -- unsigned int *val) -+ unsigned short *val) - { - const struct boardtype *board = dev->board_ptr; - struct pci1710_private *devpriv = dev->private; -- unsigned int sample; -+ unsigned short sample; - unsigned int chan; - - sample = inw(dev->iobase + PCI171X_AD_DATA_REG); -@@ -345,7 +345,7 @@ static int pci1710_ai_insn_read(struct comedi_device *dev, - pci1710_ai_setup_chanlist(dev, s, &insn->chanspec, 1, 1); - - for (i = 0; i < insn->n; i++) { -- unsigned int val; -+ unsigned short val; - - /* start conversion */ - outw(0, dev->iobase + PCI171X_SOFTTRG_REG); -@@ -395,7 +395,7 @@ static void pci1710_handle_every_sample(struct comedi_device *dev, - { - struct comedi_cmd *cmd = &s->async->cmd; - unsigned int status; -- unsigned int val; -+ unsigned short val; - int ret; - - status = inw(dev->iobase + PCI171X_STATUS_REG); -@@ -455,7 +455,7 @@ static void pci1710_handle_fifo(struct comedi_device *dev, - } - - for (i = 0; i < devpriv->max_samples; i++) { -- unsigned int val; -+ unsigned short val; - int ret; - - ret = pci1710_ai_read_sample(dev, s, s->async->cur_chan, &val); -diff --git a/drivers/staging/comedi/drivers/das6402.c b/drivers/staging/comedi/drivers/das6402.c -index f99211ec46deb..0034005bdf8f1 100644 ---- a/drivers/staging/comedi/drivers/das6402.c -+++ b/drivers/staging/comedi/drivers/das6402.c -@@ -186,7 +186,7 @@ static irqreturn_t das6402_interrupt(int irq, void *d) - if (status & DAS6402_STATUS_FFULL) { - async->events |= COMEDI_CB_OVERFLOW; - } else if (status & DAS6402_STATUS_FFNE) { -- unsigned int val; -+ unsigned short val; - - val = das6402_ai_read_sample(dev, s); - comedi_buf_write_samples(s, &val, 1); -diff --git a/drivers/staging/comedi/drivers/das800.c b/drivers/staging/comedi/drivers/das800.c -index 8cf09ef3012fa..4bd8fd5218c8f 100644 ---- a/drivers/staging/comedi/drivers/das800.c -+++ b/drivers/staging/comedi/drivers/das800.c -@@ -427,7 +427,7 @@ static irqreturn_t das800_interrupt(int irq, void *d) - struct comedi_cmd *cmd; - unsigned long irq_flags; - unsigned int status; -- unsigned int val; -+ unsigned short val; - bool fifo_empty; - bool fifo_overflow; - int i; -diff --git a/drivers/staging/comedi/drivers/dmm32at.c b/drivers/staging/comedi/drivers/dmm32at.c -index 75693cdde3138..c180d18ce517f 100644 ---- a/drivers/staging/comedi/drivers/dmm32at.c -+++ b/drivers/staging/comedi/drivers/dmm32at.c -@@ -404,7 +404,7 @@ static irqreturn_t dmm32at_isr(int irq, void *d) - { - struct comedi_device *dev = d; - unsigned char intstat; -- unsigned int val; -+ unsigned short val; - int i; - - if (!dev->attached) { -diff --git a/drivers/staging/comedi/drivers/me4000.c b/drivers/staging/comedi/drivers/me4000.c -index ee53571a89698..ead8000b5929b 100644 ---- a/drivers/staging/comedi/drivers/me4000.c -+++ b/drivers/staging/comedi/drivers/me4000.c -@@ -924,7 +924,7 @@ static irqreturn_t me4000_ai_isr(int irq, void *dev_id) - struct comedi_subdevice *s = dev->read_subdev; - int i; - int c = 0; -- unsigned int lval; -+ unsigned short lval; - - if (!dev->attached) - return IRQ_NONE; -diff --git a/drivers/staging/comedi/drivers/pcl711.c b/drivers/staging/comedi/drivers/pcl711.c -index a5937206bf1cd..e9abae4180625 100644 ---- a/drivers/staging/comedi/drivers/pcl711.c -+++ b/drivers/staging/comedi/drivers/pcl711.c -@@ -184,7 +184,7 @@ static irqreturn_t pcl711_interrupt(int irq, void *d) - struct comedi_device *dev = d; - struct comedi_subdevice *s = dev->read_subdev; - struct comedi_cmd *cmd = &s->async->cmd; -- unsigned int data; -+ unsigned short data; - - if (!dev->attached) { - dev_err(dev->class_dev, "spurious interrupt\n"); -diff --git a/drivers/staging/comedi/drivers/pcl818.c b/drivers/staging/comedi/drivers/pcl818.c -index 0af5315d43575..fc8afffc1815f 100644 ---- a/drivers/staging/comedi/drivers/pcl818.c -+++ b/drivers/staging/comedi/drivers/pcl818.c -@@ -423,7 +423,7 @@ static int pcl818_ai_eoc(struct comedi_device *dev, - - static bool pcl818_ai_write_sample(struct comedi_device *dev, - struct comedi_subdevice *s, -- unsigned int chan, unsigned int val) -+ unsigned int chan, unsigned short val) - { - struct pcl818_private *devpriv = dev->private; - struct comedi_cmd *cmd = &s->async->cmd; -diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c -index 3cffc8be66563..e61bd8e1d246f 100644 ---- a/drivers/staging/ks7010/ks_wlan_net.c -+++ b/drivers/staging/ks7010/ks_wlan_net.c -@@ -1120,6 +1120,7 @@ static int ks_wlan_set_scan(struct net_device *dev, - { - struct ks_wlan_private *priv = netdev_priv(dev); - struct iw_scan_req *req = NULL; -+ int len; - - if (priv->sleep_mode == SLP_SLEEP) - return -EPERM; -@@ -1129,8 +1130,9 @@ static int ks_wlan_set_scan(struct net_device *dev, - if (wrqu->data.length == sizeof(struct iw_scan_req) && - wrqu->data.flags & IW_SCAN_THIS_ESSID) { - req = (struct iw_scan_req *)extra; -- priv->scan_ssid_len = req->essid_len; -- memcpy(priv->scan_ssid, req->essid, priv->scan_ssid_len); -+ len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE); -+ priv->scan_ssid_len = len; -+ memcpy(priv->scan_ssid, req->essid, len); - } else { - priv->scan_ssid_len = 0; - } -diff --git a/drivers/staging/rtl8188eu/core/rtw_ap.c b/drivers/staging/rtl8188eu/core/rtw_ap.c -index 51a5b71f8c256..1c0300ce63369 100644 ---- a/drivers/staging/rtl8188eu/core/rtw_ap.c -+++ b/drivers/staging/rtl8188eu/core/rtw_ap.c -@@ -784,6 +784,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) - /* SSID */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SSID_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_)); - if (p && ie_len > 0) { -+ ie_len = min_t(int, ie_len, sizeof(pbss_network->ssid.ssid)); - memset(&pbss_network->ssid, 0, sizeof(struct ndis_802_11_ssid)); - memcpy(pbss_network->ssid.ssid, (p + 2), ie_len); - pbss_network->ssid.ssid_length = ie_len; -@@ -802,6 +803,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) - /* get supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _SUPPORTEDRATES_IE_, &ie_len, (pbss_network->ie_length - _BEACON_IE_OFFSET_)); - if (p) { -+ ie_len = min_t(int, ie_len, NDIS_802_11_LENGTH_RATES_EX); - memcpy(supportRate, p + 2, ie_len); - supportRateNum = ie_len; - } -@@ -809,6 +811,8 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) - /* get ext_supported rates */ - p = rtw_get_ie(ie + _BEACON_IE_OFFSET_, _EXT_SUPPORTEDRATES_IE_, &ie_len, pbss_network->ie_length - _BEACON_IE_OFFSET_); - if (p) { -+ ie_len = min_t(int, ie_len, -+ NDIS_802_11_LENGTH_RATES_EX - supportRateNum); - memcpy(supportRate + supportRateNum, p + 2, ie_len); - supportRateNum += ie_len; - } -@@ -922,6 +926,7 @@ int rtw_check_beacon_data(struct adapter *padapter, u8 *pbuf, int len) - - pht_cap->mcs.rx_mask[0] = 0xff; - pht_cap->mcs.rx_mask[1] = 0x0; -+ ie_len = min_t(int, ie_len, sizeof(pmlmepriv->htpriv.ht_cap)); - memcpy(&pmlmepriv->htpriv.ht_cap, p + 2, ie_len); - } - -diff --git a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c -index 630e7d933b104..7b83f0920f3c8 100644 ---- a/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c -+++ b/drivers/staging/rtl8188eu/os_dep/ioctl_linux.c -@@ -1160,9 +1160,11 @@ static int rtw_wx_set_scan(struct net_device *dev, struct iw_request_info *a, - break; - } - sec_len = *(pos++); len -= 1; -- if (sec_len > 0 && sec_len <= len) { -+ if (sec_len > 0 && -+ sec_len <= len && -+ sec_len <= 32) { - ssid[ssid_index].ssid_length = sec_len; -- memcpy(ssid[ssid_index].ssid, pos, ssid[ssid_index].ssid_length); -+ memcpy(ssid[ssid_index].ssid, pos, sec_len); - ssid_index++; - } - pos += sec_len; -diff --git a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c -index 16bcee13f64b5..407effde5e71a 100644 ---- a/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c -+++ b/drivers/staging/rtl8192e/rtl8192e/rtl_wx.c -@@ -406,9 +406,10 @@ static int _rtl92e_wx_set_scan(struct net_device *dev, - struct iw_scan_req *req = (struct iw_scan_req *)b; - - if (req->essid_len) { -- ieee->current_network.ssid_len = req->essid_len; -- memcpy(ieee->current_network.ssid, req->essid, -- req->essid_len); -+ int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE); -+ -+ ieee->current_network.ssid_len = len; -+ memcpy(ieee->current_network.ssid, req->essid, len); - } - } - -diff --git a/drivers/staging/rtl8192u/r8192U_wx.c b/drivers/staging/rtl8192u/r8192U_wx.c -index 5822bb7984b91..8f10672ade37e 100644 ---- a/drivers/staging/rtl8192u/r8192U_wx.c -+++ b/drivers/staging/rtl8192u/r8192U_wx.c -@@ -333,8 +333,10 @@ static int r8192_wx_set_scan(struct net_device *dev, struct iw_request_info *a, - struct iw_scan_req *req = (struct iw_scan_req *)b; - - if (req->essid_len) { -- ieee->current_network.ssid_len = req->essid_len; -- memcpy(ieee->current_network.ssid, req->essid, req->essid_len); -+ int len = min_t(int, req->essid_len, IW_ESSID_MAX_SIZE); -+ -+ ieee->current_network.ssid_len = len; -+ memcpy(ieee->current_network.ssid, req->essid, len); - } - } - -diff --git a/drivers/staging/rtl8712/rtl871x_cmd.c b/drivers/staging/rtl8712/rtl871x_cmd.c -index 26b618008fcfe..d989229de88bd 100644 ---- a/drivers/staging/rtl8712/rtl871x_cmd.c -+++ b/drivers/staging/rtl8712/rtl871x_cmd.c -@@ -197,8 +197,10 @@ u8 r8712_sitesurvey_cmd(struct _adapter *padapter, - psurveyPara->ss_ssidlen = 0; - memset(psurveyPara->ss_ssid, 0, IW_ESSID_MAX_SIZE + 1); - if ((pssid != NULL) && (pssid->SsidLength)) { -- memcpy(psurveyPara->ss_ssid, pssid->Ssid, pssid->SsidLength); -- psurveyPara->ss_ssidlen = cpu_to_le32(pssid->SsidLength); -+ int len = min_t(int, pssid->SsidLength, IW_ESSID_MAX_SIZE); -+ -+ memcpy(psurveyPara->ss_ssid, pssid->Ssid, len); -+ psurveyPara->ss_ssidlen = cpu_to_le32(len); - } - set_fwstate(pmlmepriv, _FW_UNDER_SURVEY); - r8712_enqueue_cmd(pcmdpriv, ph2c); -diff --git a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c -index 944336e0d2e2f..cff918d8bcb54 100644 ---- a/drivers/staging/rtl8712/rtl871x_ioctl_linux.c -+++ b/drivers/staging/rtl8712/rtl871x_ioctl_linux.c -@@ -928,7 +928,7 @@ static int r871x_wx_set_priv(struct net_device *dev, - struct iw_point *dwrq = (struct iw_point *)awrq; - - len = dwrq->length; -- ext = memdup_user(dwrq->pointer, len); -+ ext = strndup_user(dwrq->pointer, len); - if (IS_ERR(ext)) - return PTR_ERR(ext); - -diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c -index 5e931690e6979..51e690ab4d295 100644 ---- a/drivers/target/target_core_pr.c -+++ b/drivers/target/target_core_pr.c -@@ -3731,6 +3731,7 @@ core_scsi3_pri_read_keys(struct se_cmd *cmd) - spin_unlock(&dev->t10_pr.registration_lock); - - put_unaligned_be32(add_len, &buf[4]); -+ target_set_cmd_data_length(cmd, 8 + add_len); - - transport_kunmap_data_sg(cmd); - -@@ -3749,7 +3750,7 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) - struct t10_pr_registration *pr_reg; - unsigned char *buf; - u64 pr_res_key; -- u32 add_len = 16; /* Hardcoded to 16 when a reservation is held. */ -+ u32 add_len = 0; - - if (cmd->data_length < 8) { - pr_err("PRIN SA READ_RESERVATIONS SCSI Data Length: %u" -@@ -3767,8 +3768,9 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) - pr_reg = dev->dev_pr_res_holder; - if (pr_reg) { - /* -- * Set the hardcoded Additional Length -+ * Set the Additional Length to 16 when a reservation is held - */ -+ add_len = 16; - put_unaligned_be32(add_len, &buf[4]); - - if (cmd->data_length < 22) -@@ -3804,6 +3806,8 @@ core_scsi3_pri_read_reservation(struct se_cmd *cmd) - (pr_reg->pr_res_type & 0x0f); - } - -+ target_set_cmd_data_length(cmd, 8 + add_len); -+ - err: - spin_unlock(&dev->dev_reservation_lock); - transport_kunmap_data_sg(cmd); -@@ -3822,7 +3826,7 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd) - struct se_device *dev = cmd->se_dev; - struct t10_reservation *pr_tmpl = &dev->t10_pr; - unsigned char *buf; -- u16 add_len = 8; /* Hardcoded to 8. */ -+ u16 len = 8; /* Hardcoded to 8. */ - - if (cmd->data_length < 6) { - pr_err("PRIN SA REPORT_CAPABILITIES SCSI Data Length:" -@@ -3834,7 +3838,7 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd) - if (!buf) - return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; - -- put_unaligned_be16(add_len, &buf[0]); -+ put_unaligned_be16(len, &buf[0]); - buf[2] |= 0x10; /* CRH: Compatible Reservation Hanlding bit. */ - buf[2] |= 0x08; /* SIP_C: Specify Initiator Ports Capable bit */ - buf[2] |= 0x04; /* ATP_C: All Target Ports Capable bit */ -@@ -3863,6 +3867,8 @@ core_scsi3_pri_report_capabilities(struct se_cmd *cmd) - buf[4] |= 0x02; /* PR_TYPE_WRITE_EXCLUSIVE */ - buf[5] |= 0x01; /* PR_TYPE_EXCLUSIVE_ACCESS_ALLREG */ - -+ target_set_cmd_data_length(cmd, len); -+ - transport_kunmap_data_sg(cmd); - - return 0; -@@ -4023,6 +4029,7 @@ core_scsi3_pri_read_full_status(struct se_cmd *cmd) - * Set ADDITIONAL_LENGTH - */ - put_unaligned_be32(add_len, &buf[4]); -+ target_set_cmd_data_length(cmd, 8 + add_len); - - transport_kunmap_data_sg(cmd); - -diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c -index b1f4be055f838..a16835c0bb1dd 100644 ---- a/drivers/target/target_core_transport.c -+++ b/drivers/target/target_core_transport.c -@@ -873,11 +873,9 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) - } - EXPORT_SYMBOL(target_complete_cmd); - --void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length) -+void target_set_cmd_data_length(struct se_cmd *cmd, int length) - { -- if ((scsi_status == SAM_STAT_GOOD || -- cmd->se_cmd_flags & SCF_TREAT_READ_AS_NORMAL) && -- length < cmd->data_length) { -+ if (length < cmd->data_length) { - if (cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) { - cmd->residual_count += cmd->data_length - length; - } else { -@@ -887,6 +885,15 @@ void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int len - - cmd->data_length = length; - } -+} -+EXPORT_SYMBOL(target_set_cmd_data_length); -+ -+void target_complete_cmd_with_length(struct se_cmd *cmd, u8 scsi_status, int length) -+{ -+ if (scsi_status == SAM_STAT_GOOD || -+ cmd->se_cmd_flags & SCF_TREAT_READ_AS_NORMAL) { -+ target_set_cmd_data_length(cmd, length); -+ } - - target_complete_cmd(cmd, scsi_status); - } -diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c -index 681374a3b3684..00bfc81f24702 100644 ---- a/drivers/usb/class/cdc-acm.c -+++ b/drivers/usb/class/cdc-acm.c -@@ -1941,6 +1941,11 @@ static const struct usb_device_id acm_ids[] = { - .driver_info = SEND_ZERO_PACKET, - }, - -+ /* Exclude Goodix Fingerprint Reader */ -+ { USB_DEVICE(0x27c6, 0x5395), -+ .driver_info = IGNORE_DEVICE, -+ }, -+ - /* control interfaces without any protocol set */ - { USB_INTERFACE_INFO(USB_CLASS_COMM, USB_CDC_SUBCLASS_ACM, - USB_CDC_PROTO_NONE) }, -diff --git a/drivers/usb/class/usblp.c b/drivers/usb/class/usblp.c -index c9f6e97582885..f27b4aecff3d4 100644 ---- a/drivers/usb/class/usblp.c -+++ b/drivers/usb/class/usblp.c -@@ -494,16 +494,24 @@ static int usblp_release(struct inode *inode, struct file *file) - /* No kernel lock - fine */ - static __poll_t usblp_poll(struct file *file, struct poll_table_struct *wait) - { -- __poll_t ret; -+ struct usblp *usblp = file->private_data; -+ __poll_t ret = 0; - unsigned long flags; - -- struct usblp *usblp = file->private_data; - /* Should we check file->f_mode & FMODE_WRITE before poll_wait()? */ - poll_wait(file, &usblp->rwait, wait); - poll_wait(file, &usblp->wwait, wait); -+ -+ mutex_lock(&usblp->mut); -+ if (!usblp->present) -+ ret |= EPOLLHUP; -+ mutex_unlock(&usblp->mut); -+ - spin_lock_irqsave(&usblp->lock, flags); -- ret = ((usblp->bidir && usblp->rcomplete) ? EPOLLIN | EPOLLRDNORM : 0) | -- ((usblp->no_paper || usblp->wcomplete) ? EPOLLOUT | EPOLLWRNORM : 0); -+ if (usblp->bidir && usblp->rcomplete) -+ ret |= EPOLLIN | EPOLLRDNORM; -+ if (usblp->no_paper || usblp->wcomplete) -+ ret |= EPOLLOUT | EPOLLWRNORM; - spin_unlock_irqrestore(&usblp->lock, flags); - return ret; - } -diff --git a/drivers/usb/dwc3/dwc3-qcom.c b/drivers/usb/dwc3/dwc3-qcom.c -index 261af9e38dddf..7874b97e33227 100644 ---- a/drivers/usb/dwc3/dwc3-qcom.c -+++ b/drivers/usb/dwc3/dwc3-qcom.c -@@ -251,8 +251,10 @@ static int dwc3_qcom_suspend(struct dwc3_qcom *qcom) - for (i = qcom->num_clocks - 1; i >= 0; i--) - clk_disable_unprepare(qcom->clks[i]); - -+ if (device_may_wakeup(qcom->dev)) -+ dwc3_qcom_enable_interrupts(qcom); -+ - qcom->is_suspended = true; -- dwc3_qcom_enable_interrupts(qcom); - - return 0; - } -@@ -265,7 +267,8 @@ static int dwc3_qcom_resume(struct dwc3_qcom *qcom) - if (!qcom->is_suspended) - return 0; - -- dwc3_qcom_disable_interrupts(qcom); -+ if (device_may_wakeup(qcom->dev)) -+ dwc3_qcom_disable_interrupts(qcom); - - for (i = 0; i < qcom->num_clocks; i++) { - ret = clk_prepare_enable(qcom->clks[i]); -@@ -528,16 +531,19 @@ static int dwc3_qcom_of_register_core(struct platform_device *pdev) - ret = of_platform_populate(np, NULL, NULL, dev); - if (ret) { - dev_err(dev, "failed to register dwc3 core - %d\n", ret); -- return ret; -+ goto node_put; - } - - qcom->dwc3 = of_find_device_by_node(dwc3_np); - if (!qcom->dwc3) { -+ ret = -ENODEV; - dev_err(dev, "failed to get dwc3 platform device\n"); -- return -ENODEV; - } - -- return 0; -+node_put: -+ of_node_put(dwc3_np); -+ -+ return ret; - } - - static const struct dwc3_acpi_pdata sdm845_acpi_pdata = { -diff --git a/drivers/usb/gadget/function/f_uac1.c b/drivers/usb/gadget/function/f_uac1.c -index 00d346965f7a5..560382e0a8f38 100644 ---- a/drivers/usb/gadget/function/f_uac1.c -+++ b/drivers/usb/gadget/function/f_uac1.c -@@ -499,6 +499,7 @@ static void f_audio_disable(struct usb_function *f) - uac1->as_out_alt = 0; - uac1->as_in_alt = 0; - -+ u_audio_stop_playback(&uac1->g_audio); - u_audio_stop_capture(&uac1->g_audio); - } - -diff --git a/drivers/usb/gadget/function/f_uac2.c b/drivers/usb/gadget/function/f_uac2.c -index 5d960b6603b6f..6f03e944e0e31 100644 ---- a/drivers/usb/gadget/function/f_uac2.c -+++ b/drivers/usb/gadget/function/f_uac2.c -@@ -478,7 +478,7 @@ static int set_ep_max_packet_size(const struct f_uac2_opts *uac2_opts, - } - - max_size_bw = num_channels(chmask) * ssize * -- DIV_ROUND_UP(srate, factor / (1 << (ep_desc->bInterval - 1))); -+ ((srate / (factor / (1 << (ep_desc->bInterval - 1)))) + 1); - ep_desc->wMaxPacketSize = cpu_to_le16(min_t(u16, max_size_bw, - max_size_ep)); - -diff --git a/drivers/usb/gadget/function/u_ether_configfs.h b/drivers/usb/gadget/function/u_ether_configfs.h -index d8b92485b727e..5b1d4771d44f4 100644 ---- a/drivers/usb/gadget/function/u_ether_configfs.h -+++ b/drivers/usb/gadget/function/u_ether_configfs.h -@@ -169,12 +169,11 @@ out: \ - size_t len) \ - { \ - struct f_##_f_##_opts *opts = to_f_##_f_##_opts(item); \ -- int ret; \ -+ int ret = -EINVAL; \ - u8 val; \ - \ - mutex_lock(&opts->lock); \ -- ret = sscanf(page, "%02hhx", &val); \ -- if (ret > 0) { \ -+ if (sscanf(page, "%02hhx", &val) > 0) { \ - opts->_n_ = val; \ - ret = len; \ - } \ -diff --git a/drivers/usb/host/xhci-pci.c b/drivers/usb/host/xhci-pci.c -index d08b0079eecb1..71ef473df585f 100644 ---- a/drivers/usb/host/xhci-pci.c -+++ b/drivers/usb/host/xhci-pci.c -@@ -62,6 +62,7 @@ - #define PCI_DEVICE_ID_ASMEDIA_1042A_XHCI 0x1142 - #define PCI_DEVICE_ID_ASMEDIA_1142_XHCI 0x1242 - #define PCI_DEVICE_ID_ASMEDIA_2142_XHCI 0x2142 -+#define PCI_DEVICE_ID_ASMEDIA_3242_XHCI 0x3242 - - static const char hcd_name[] = "xhci_hcd"; - -@@ -258,11 +259,14 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) - pdev->device == PCI_DEVICE_ID_ASMEDIA_1042_XHCI) - xhci->quirks |= XHCI_BROKEN_STREAMS; - if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && -- pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) -+ pdev->device == PCI_DEVICE_ID_ASMEDIA_1042A_XHCI) { - xhci->quirks |= XHCI_TRUST_TX_LENGTH; -+ xhci->quirks |= XHCI_NO_64BIT_SUPPORT; -+ } - if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && - (pdev->device == PCI_DEVICE_ID_ASMEDIA_1142_XHCI || -- pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI)) -+ pdev->device == PCI_DEVICE_ID_ASMEDIA_2142_XHCI || -+ pdev->device == PCI_DEVICE_ID_ASMEDIA_3242_XHCI)) - xhci->quirks |= XHCI_NO_64BIT_SUPPORT; - - if (pdev->vendor == PCI_VENDOR_ID_ASMEDIA && -@@ -277,6 +281,11 @@ static void xhci_pci_quirks(struct device *dev, struct xhci_hcd *xhci) - pdev->device == 0x9026) - xhci->quirks |= XHCI_RESET_PLL_ON_DISCONNECT; - -+ if (pdev->vendor == PCI_VENDOR_ID_AMD && -+ (pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_2 || -+ pdev->device == PCI_DEVICE_ID_AMD_PROMONTORYA_4)) -+ xhci->quirks |= XHCI_NO_SOFT_RETRY; -+ - if (xhci->quirks & XHCI_RESET_ON_RESUME) - xhci_dbg_trace(xhci, trace_xhci_dbg_quirks, - "QUIRK: Resetting on resume"); -diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c -index 900ea91fb3c6b..f6b5010deb735 100644 ---- a/drivers/usb/host/xhci-ring.c -+++ b/drivers/usb/host/xhci-ring.c -@@ -2299,7 +2299,8 @@ static int process_bulk_intr_td(struct xhci_hcd *xhci, struct xhci_td *td, - remaining = 0; - break; - case COMP_USB_TRANSACTION_ERROR: -- if ((ep_ring->err_count++ > MAX_SOFT_RETRY) || -+ if (xhci->quirks & XHCI_NO_SOFT_RETRY || -+ (ep_ring->err_count++ > MAX_SOFT_RETRY) || - le32_to_cpu(slot_ctx->tt_info) & TT_SLOT) - break; - *status = 0; -diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c -index 91330517444e7..b5080bc1689e4 100644 ---- a/drivers/usb/host/xhci.c -+++ b/drivers/usb/host/xhci.c -@@ -883,44 +883,42 @@ static void xhci_clear_command_ring(struct xhci_hcd *xhci) - xhci_set_cmd_ring_deq(xhci); - } - --static void xhci_disable_port_wake_on_bits(struct xhci_hcd *xhci) -+/* -+ * Disable port wake bits if do_wakeup is not set. -+ * -+ * Also clear a possible internal port wake state left hanging for ports that -+ * detected termination but never successfully enumerated (trained to 0U). -+ * Internal wake causes immediate xHCI wake after suspend. PORT_CSC write done -+ * at enumeration clears this wake, force one here as well for unconnected ports -+ */ -+ -+static void xhci_disable_hub_port_wake(struct xhci_hcd *xhci, -+ struct xhci_hub *rhub, -+ bool do_wakeup) - { -- struct xhci_port **ports; -- int port_index; - unsigned long flags; - u32 t1, t2, portsc; -+ int i; - - spin_lock_irqsave(&xhci->lock, flags); - -- /* disable usb3 ports Wake bits */ -- port_index = xhci->usb3_rhub.num_ports; -- ports = xhci->usb3_rhub.ports; -- while (port_index--) { -- t1 = readl(ports[port_index]->addr); -- portsc = t1; -- t1 = xhci_port_state_to_neutral(t1); -- t2 = t1 & ~PORT_WAKE_BITS; -- if (t1 != t2) { -- writel(t2, ports[port_index]->addr); -- xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n", -- xhci->usb3_rhub.hcd->self.busnum, -- port_index + 1, portsc, t2); -- } -- } -+ for (i = 0; i < rhub->num_ports; i++) { -+ portsc = readl(rhub->ports[i]->addr); -+ t1 = xhci_port_state_to_neutral(portsc); -+ t2 = t1; -+ -+ /* clear wake bits if do_wake is not set */ -+ if (!do_wakeup) -+ t2 &= ~PORT_WAKE_BITS; -+ -+ /* Don't touch csc bit if connected or connect change is set */ -+ if (!(portsc & (PORT_CSC | PORT_CONNECT))) -+ t2 |= PORT_CSC; - -- /* disable usb2 ports Wake bits */ -- port_index = xhci->usb2_rhub.num_ports; -- ports = xhci->usb2_rhub.ports; -- while (port_index--) { -- t1 = readl(ports[port_index]->addr); -- portsc = t1; -- t1 = xhci_port_state_to_neutral(t1); -- t2 = t1 & ~PORT_WAKE_BITS; - if (t1 != t2) { -- writel(t2, ports[port_index]->addr); -- xhci_dbg(xhci, "disable wake bits port %d-%d, portsc: 0x%x, write: 0x%x\n", -- xhci->usb2_rhub.hcd->self.busnum, -- port_index + 1, portsc, t2); -+ writel(t2, rhub->ports[i]->addr); -+ xhci_dbg(xhci, "config port %d-%d wake bits, portsc: 0x%x, write: 0x%x\n", -+ rhub->hcd->self.busnum, i + 1, portsc, t2); - } - } - spin_unlock_irqrestore(&xhci->lock, flags); -@@ -983,8 +981,8 @@ int xhci_suspend(struct xhci_hcd *xhci, bool do_wakeup) - return -EINVAL; - - /* Clear root port wake on bits if wakeup not allowed. */ -- if (!do_wakeup) -- xhci_disable_port_wake_on_bits(xhci); -+ xhci_disable_hub_port_wake(xhci, &xhci->usb3_rhub, do_wakeup); -+ xhci_disable_hub_port_wake(xhci, &xhci->usb2_rhub, do_wakeup); - - if (!HCD_HW_ACCESSIBLE(hcd)) - return 0; -@@ -1088,6 +1086,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) - struct usb_hcd *secondary_hcd; - int retval = 0; - bool comp_timer_running = false; -+ bool pending_portevent = false; - - if (!hcd->state) - return 0; -@@ -1226,13 +1225,22 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated) - - done: - if (retval == 0) { -- /* Resume root hubs only when have pending events. */ -- if (xhci_pending_portevent(xhci)) { -+ /* -+ * Resume roothubs only if there are pending events. -+ * USB 3 devices resend U3 LFPS wake after a 100ms delay if -+ * the first wake signalling failed, give it that chance. -+ */ -+ pending_portevent = xhci_pending_portevent(xhci); -+ if (!pending_portevent) { -+ msleep(120); -+ pending_portevent = xhci_pending_portevent(xhci); -+ } -+ -+ if (pending_portevent) { - usb_hcd_resume_root_hub(xhci->shared_hcd); - usb_hcd_resume_root_hub(hcd); - } - } -- - /* - * If system is subject to the Quirk, Compliance Mode Timer needs to - * be re-initialized Always after a system resume. Ports are subject -diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h -index 1ad1d6e9e9979..8798ed0317864 100644 ---- a/drivers/usb/host/xhci.h -+++ b/drivers/usb/host/xhci.h -@@ -1875,6 +1875,7 @@ struct xhci_hcd { - #define XHCI_SNPS_BROKEN_SUSPEND BIT_ULL(35) - #define XHCI_SKIP_PHY_INIT BIT_ULL(37) - #define XHCI_DISABLE_SPARSE BIT_ULL(38) -+#define XHCI_NO_SOFT_RETRY BIT_ULL(40) - - unsigned int num_active_eps; - unsigned int limit_active_eps; -diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c -index 9e5afdde1adbf..40576e7176d8b 100644 ---- a/drivers/usb/renesas_usbhs/pipe.c -+++ b/drivers/usb/renesas_usbhs/pipe.c -@@ -746,6 +746,8 @@ struct usbhs_pipe *usbhs_pipe_malloc(struct usbhs_priv *priv, - - void usbhs_pipe_free(struct usbhs_pipe *pipe) - { -+ usbhsp_pipe_select(pipe); -+ usbhsp_pipe_cfg_set(pipe, 0xFFFF, 0); - usbhsp_put_pipe(pipe); - } - -diff --git a/drivers/usb/serial/ch341.c b/drivers/usb/serial/ch341.c -index fdaefbe924908..a82ba9cc0c724 100644 ---- a/drivers/usb/serial/ch341.c -+++ b/drivers/usb/serial/ch341.c -@@ -85,6 +85,7 @@ static const struct usb_device_id id_table[] = { - { USB_DEVICE(0x1a86, 0x7522) }, - { USB_DEVICE(0x1a86, 0x7523) }, - { USB_DEVICE(0x4348, 0x5523) }, -+ { USB_DEVICE(0x9986, 0x7523) }, - { }, - }; - MODULE_DEVICE_TABLE(usb, id_table); -diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c -index 361a2e3ccad8d..caf27a0d51f03 100644 ---- a/drivers/usb/serial/cp210x.c -+++ b/drivers/usb/serial/cp210x.c -@@ -146,6 +146,7 @@ static const struct usb_device_id id_table[] = { - { USB_DEVICE(0x10C4, 0x8857) }, /* CEL EM357 ZigBee USB Stick */ - { USB_DEVICE(0x10C4, 0x88A4) }, /* MMB Networks ZigBee USB Device */ - { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ -+ { USB_DEVICE(0x10C4, 0x88D8) }, /* Acuity Brands nLight Air Adapter */ - { USB_DEVICE(0x10C4, 0x88FB) }, /* CESINEL MEDCAL STII Network Analyzer */ - { USB_DEVICE(0x10C4, 0x8938) }, /* CESINEL MEDCAL S II Network Analyzer */ - { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ -@@ -202,6 +203,8 @@ static const struct usb_device_id id_table[] = { - { USB_DEVICE(0x1901, 0x0194) }, /* GE Healthcare Remote Alarm Box */ - { USB_DEVICE(0x1901, 0x0195) }, /* GE B850/B650/B450 CP2104 DP UART interface */ - { USB_DEVICE(0x1901, 0x0196) }, /* GE B850 CP2105 DP UART interface */ -+ { USB_DEVICE(0x1901, 0x0197) }, /* GE CS1000 Display serial interface */ -+ { USB_DEVICE(0x1901, 0x0198) }, /* GE CS1000 M.2 Key E serial interface */ - { USB_DEVICE(0x199B, 0xBA30) }, /* LORD WSDA-200-USB */ - { USB_DEVICE(0x19CF, 0x3000) }, /* Parrot NMEA GPS Flight Recorder */ - { USB_DEVICE(0x1ADB, 0x0001) }, /* Schweitzer Engineering C662 Cable */ -diff --git a/drivers/usb/serial/io_edgeport.c b/drivers/usb/serial/io_edgeport.c -index 4cca0b836f430..3b4d1ff9033dd 100644 ---- a/drivers/usb/serial/io_edgeport.c -+++ b/drivers/usb/serial/io_edgeport.c -@@ -3003,26 +3003,32 @@ static int edge_startup(struct usb_serial *serial) - response = -ENODEV; - } - -- usb_free_urb(edge_serial->interrupt_read_urb); -- kfree(edge_serial->interrupt_in_buffer); -- -- usb_free_urb(edge_serial->read_urb); -- kfree(edge_serial->bulk_in_buffer); -- -- kfree(edge_serial); -- -- return response; -+ goto error; - } - - /* start interrupt read for this edgeport this interrupt will - * continue as long as the edgeport is connected */ - response = usb_submit_urb(edge_serial->interrupt_read_urb, - GFP_KERNEL); -- if (response) -+ if (response) { - dev_err(ddev, "%s - Error %d submitting control urb\n", - __func__, response); -+ -+ goto error; -+ } - } - return response; -+ -+error: -+ usb_free_urb(edge_serial->interrupt_read_urb); -+ kfree(edge_serial->interrupt_in_buffer); -+ -+ usb_free_urb(edge_serial->read_urb); -+ kfree(edge_serial->bulk_in_buffer); -+ -+ kfree(edge_serial); -+ -+ return response; - } - - -diff --git a/drivers/usb/usbip/stub_dev.c b/drivers/usb/usbip/stub_dev.c -index 2305d425e6c9a..8f1de1fbbeedf 100644 ---- a/drivers/usb/usbip/stub_dev.c -+++ b/drivers/usb/usbip/stub_dev.c -@@ -46,6 +46,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - int sockfd = 0; - struct socket *socket; - int rv; -+ struct task_struct *tcp_rx = NULL; -+ struct task_struct *tcp_tx = NULL; - - if (!sdev) { - dev_err(dev, "sdev is null\n"); -@@ -69,23 +71,47 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - } - - socket = sockfd_lookup(sockfd, &err); -- if (!socket) -+ if (!socket) { -+ dev_err(dev, "failed to lookup sock"); - goto err; -+ } - -- sdev->ud.tcp_socket = socket; -- sdev->ud.sockfd = sockfd; -+ if (socket->type != SOCK_STREAM) { -+ dev_err(dev, "Expecting SOCK_STREAM - found %d", -+ socket->type); -+ goto sock_err; -+ } - -+ /* unlock and create threads and get tasks */ - spin_unlock_irq(&sdev->ud.lock); -+ tcp_rx = kthread_create(stub_rx_loop, &sdev->ud, "stub_rx"); -+ if (IS_ERR(tcp_rx)) { -+ sockfd_put(socket); -+ return -EINVAL; -+ } -+ tcp_tx = kthread_create(stub_tx_loop, &sdev->ud, "stub_tx"); -+ if (IS_ERR(tcp_tx)) { -+ kthread_stop(tcp_rx); -+ sockfd_put(socket); -+ return -EINVAL; -+ } - -- sdev->ud.tcp_rx = kthread_get_run(stub_rx_loop, &sdev->ud, -- "stub_rx"); -- sdev->ud.tcp_tx = kthread_get_run(stub_tx_loop, &sdev->ud, -- "stub_tx"); -+ /* get task structs now */ -+ get_task_struct(tcp_rx); -+ get_task_struct(tcp_tx); - -+ /* lock and update sdev->ud state */ - spin_lock_irq(&sdev->ud.lock); -+ sdev->ud.tcp_socket = socket; -+ sdev->ud.sockfd = sockfd; -+ sdev->ud.tcp_rx = tcp_rx; -+ sdev->ud.tcp_tx = tcp_tx; - sdev->ud.status = SDEV_ST_USED; - spin_unlock_irq(&sdev->ud.lock); - -+ wake_up_process(sdev->ud.tcp_rx); -+ wake_up_process(sdev->ud.tcp_tx); -+ - } else { - dev_info(dev, "stub down\n"); - -@@ -100,6 +126,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - - return count; - -+sock_err: -+ sockfd_put(socket); - err: - spin_unlock_irq(&sdev->ud.lock); - return -EINVAL; -diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c -index be37aec250c2b..e64ea314930be 100644 ---- a/drivers/usb/usbip/vhci_sysfs.c -+++ b/drivers/usb/usbip/vhci_sysfs.c -@@ -312,6 +312,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr, - struct vhci *vhci; - int err; - unsigned long flags; -+ struct task_struct *tcp_rx = NULL; -+ struct task_struct *tcp_tx = NULL; - - /* - * @rhport: port number of vhci_hcd -@@ -349,12 +351,35 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr, - - /* Extract socket from fd. */ - socket = sockfd_lookup(sockfd, &err); -- if (!socket) -+ if (!socket) { -+ dev_err(dev, "failed to lookup sock"); - return -EINVAL; -+ } -+ if (socket->type != SOCK_STREAM) { -+ dev_err(dev, "Expecting SOCK_STREAM - found %d", -+ socket->type); -+ sockfd_put(socket); -+ return -EINVAL; -+ } -+ -+ /* create threads before locking */ -+ tcp_rx = kthread_create(vhci_rx_loop, &vdev->ud, "vhci_rx"); -+ if (IS_ERR(tcp_rx)) { -+ sockfd_put(socket); -+ return -EINVAL; -+ } -+ tcp_tx = kthread_create(vhci_tx_loop, &vdev->ud, "vhci_tx"); -+ if (IS_ERR(tcp_tx)) { -+ kthread_stop(tcp_rx); -+ sockfd_put(socket); -+ return -EINVAL; -+ } - -- /* now need lock until setting vdev status as used */ -+ /* get task structs now */ -+ get_task_struct(tcp_rx); -+ get_task_struct(tcp_tx); - -- /* begin a lock */ -+ /* now begin lock until setting vdev status set */ - spin_lock_irqsave(&vhci->lock, flags); - spin_lock(&vdev->ud.lock); - -@@ -364,6 +389,8 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr, - spin_unlock_irqrestore(&vhci->lock, flags); - - sockfd_put(socket); -+ kthread_stop_put(tcp_rx); -+ kthread_stop_put(tcp_tx); - - dev_err(dev, "port %d already used\n", rhport); - /* -@@ -382,14 +409,16 @@ static ssize_t attach_store(struct device *dev, struct device_attribute *attr, - vdev->speed = speed; - vdev->ud.sockfd = sockfd; - vdev->ud.tcp_socket = socket; -+ vdev->ud.tcp_rx = tcp_rx; -+ vdev->ud.tcp_tx = tcp_tx; - vdev->ud.status = VDEV_ST_NOTASSIGNED; - - spin_unlock(&vdev->ud.lock); - spin_unlock_irqrestore(&vhci->lock, flags); - /* end the lock */ - -- vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); -- vdev->ud.tcp_tx = kthread_get_run(vhci_tx_loop, &vdev->ud, "vhci_tx"); -+ wake_up_process(vdev->ud.tcp_rx); -+ wake_up_process(vdev->ud.tcp_tx); - - rh_port_connect(vdev, speed); - -diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c -index 100f680c572ae..a3ec39fc61778 100644 ---- a/drivers/usb/usbip/vudc_sysfs.c -+++ b/drivers/usb/usbip/vudc_sysfs.c -@@ -90,8 +90,9 @@ unlock: - } - static BIN_ATTR_RO(dev_desc, sizeof(struct usb_device_descriptor)); - --static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *attr, -- const char *in, size_t count) -+static ssize_t usbip_sockfd_store(struct device *dev, -+ struct device_attribute *attr, -+ const char *in, size_t count) - { - struct vudc *udc = (struct vudc *) dev_get_drvdata(dev); - int rv; -@@ -100,6 +101,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - struct socket *socket; - unsigned long flags; - int ret; -+ struct task_struct *tcp_rx = NULL; -+ struct task_struct *tcp_tx = NULL; - - rv = kstrtoint(in, 0, &sockfd); - if (rv != 0) -@@ -138,24 +141,54 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - goto unlock_ud; - } - -- udc->ud.tcp_socket = socket; -+ if (socket->type != SOCK_STREAM) { -+ dev_err(dev, "Expecting SOCK_STREAM - found %d", -+ socket->type); -+ ret = -EINVAL; -+ goto sock_err; -+ } - -+ /* unlock and create threads and get tasks */ - spin_unlock_irq(&udc->ud.lock); - spin_unlock_irqrestore(&udc->lock, flags); - -- udc->ud.tcp_rx = kthread_get_run(&v_rx_loop, -- &udc->ud, "vudc_rx"); -- udc->ud.tcp_tx = kthread_get_run(&v_tx_loop, -- &udc->ud, "vudc_tx"); -+ tcp_rx = kthread_create(&v_rx_loop, &udc->ud, "vudc_rx"); -+ if (IS_ERR(tcp_rx)) { -+ sockfd_put(socket); -+ return -EINVAL; -+ } -+ tcp_tx = kthread_create(&v_tx_loop, &udc->ud, "vudc_tx"); -+ if (IS_ERR(tcp_tx)) { -+ kthread_stop(tcp_rx); -+ sockfd_put(socket); -+ return -EINVAL; -+ } -+ -+ /* get task structs now */ -+ get_task_struct(tcp_rx); -+ get_task_struct(tcp_tx); - -+ /* lock and update udc->ud state */ - spin_lock_irqsave(&udc->lock, flags); - spin_lock_irq(&udc->ud.lock); -+ -+ udc->ud.tcp_socket = socket; -+ udc->ud.tcp_rx = tcp_rx; -+ udc->ud.tcp_rx = tcp_tx; - udc->ud.status = SDEV_ST_USED; -+ - spin_unlock_irq(&udc->ud.lock); - - ktime_get_ts64(&udc->start_time); - v_start_timer(udc); - udc->connected = 1; -+ -+ spin_unlock_irqrestore(&udc->lock, flags); -+ -+ wake_up_process(udc->ud.tcp_rx); -+ wake_up_process(udc->ud.tcp_tx); -+ return count; -+ - } else { - if (!udc->connected) { - dev_err(dev, "Device not connected"); -@@ -177,6 +210,8 @@ static ssize_t usbip_sockfd_store(struct device *dev, struct device_attribute *a - - return count; - -+sock_err: -+ sockfd_put(socket); - unlock_ud: - spin_unlock_irq(&udc->ud.lock); - unlock: -diff --git a/drivers/xen/events/events_2l.c b/drivers/xen/events/events_2l.c -index f026624898e7a..77cc80bcb479c 100644 ---- a/drivers/xen/events/events_2l.c -+++ b/drivers/xen/events/events_2l.c -@@ -47,6 +47,11 @@ static unsigned evtchn_2l_max_channels(void) - return EVTCHN_2L_NR_CHANNELS; - } - -+static void evtchn_2l_remove(evtchn_port_t evtchn, unsigned int cpu) -+{ -+ clear_bit(evtchn, BM(per_cpu(cpu_evtchn_mask, cpu))); -+} -+ - static void evtchn_2l_bind_to_cpu(struct irq_info *info, unsigned cpu) - { - clear_bit(info->evtchn, BM(per_cpu(cpu_evtchn_mask, info->cpu))); -@@ -71,12 +76,6 @@ static bool evtchn_2l_is_pending(unsigned port) - return sync_test_bit(port, BM(&s->evtchn_pending[0])); - } - --static bool evtchn_2l_test_and_set_mask(unsigned port) --{ -- struct shared_info *s = HYPERVISOR_shared_info; -- return sync_test_and_set_bit(port, BM(&s->evtchn_mask[0])); --} -- - static void evtchn_2l_mask(unsigned port) - { - struct shared_info *s = HYPERVISOR_shared_info; -@@ -354,18 +353,27 @@ static void evtchn_2l_resume(void) - EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD); - } - -+static int evtchn_2l_percpu_deinit(unsigned int cpu) -+{ -+ memset(per_cpu(cpu_evtchn_mask, cpu), 0, sizeof(xen_ulong_t) * -+ EVTCHN_2L_NR_CHANNELS/BITS_PER_EVTCHN_WORD); -+ -+ return 0; -+} -+ - static const struct evtchn_ops evtchn_ops_2l = { - .max_channels = evtchn_2l_max_channels, - .nr_channels = evtchn_2l_max_channels, -+ .remove = evtchn_2l_remove, - .bind_to_cpu = evtchn_2l_bind_to_cpu, - .clear_pending = evtchn_2l_clear_pending, - .set_pending = evtchn_2l_set_pending, - .is_pending = evtchn_2l_is_pending, -- .test_and_set_mask = evtchn_2l_test_and_set_mask, - .mask = evtchn_2l_mask, - .unmask = evtchn_2l_unmask, - .handle_events = evtchn_2l_handle_events, - .resume = evtchn_2l_resume, -+ .percpu_deinit = evtchn_2l_percpu_deinit, - }; - - void __init xen_evtchn_2l_init(void) -diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c -index 7b94a6c316643..e492f5fe5be62 100644 ---- a/drivers/xen/events/events_base.c -+++ b/drivers/xen/events/events_base.c -@@ -99,6 +99,7 @@ static DEFINE_RWLOCK(evtchn_rwlock); - * evtchn_rwlock - * IRQ-desc lock - * percpu eoi_list_lock -+ * irq_info->lock - */ - - static LIST_HEAD(xen_irq_list_head); -@@ -220,6 +221,8 @@ static int xen_irq_info_common_setup(struct irq_info *info, - info->irq = irq; - info->evtchn = evtchn; - info->cpu = cpu; -+ info->mask_reason = EVT_MASK_REASON_EXPLICIT; -+ spin_lock_init(&info->lock); - - ret = set_evtchn_to_irq(evtchn, irq); - if (ret < 0) -@@ -286,6 +289,7 @@ static int xen_irq_info_pirq_setup(unsigned irq, - static void xen_irq_info_cleanup(struct irq_info *info) - { - set_evtchn_to_irq(info->evtchn, -1); -+ xen_evtchn_port_remove(info->evtchn, info->cpu); - info->evtchn = 0; - } - -@@ -366,6 +370,34 @@ unsigned int cpu_from_evtchn(unsigned int evtchn) - return ret; - } - -+static void do_mask(struct irq_info *info, u8 reason) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&info->lock, flags); -+ -+ if (!info->mask_reason) -+ mask_evtchn(info->evtchn); -+ -+ info->mask_reason |= reason; -+ -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ -+static void do_unmask(struct irq_info *info, u8 reason) -+{ -+ unsigned long flags; -+ -+ spin_lock_irqsave(&info->lock, flags); -+ -+ info->mask_reason &= ~reason; -+ -+ if (!info->mask_reason) -+ unmask_evtchn(info->evtchn); -+ -+ spin_unlock_irqrestore(&info->lock, flags); -+} -+ - #ifdef CONFIG_X86 - static bool pirq_check_eoi_map(unsigned irq) - { -@@ -493,7 +525,7 @@ static void xen_irq_lateeoi_locked(struct irq_info *info, bool spurious) - } - - info->eoi_time = 0; -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_EOI_PENDING); - } - - static void xen_irq_lateeoi_worker(struct work_struct *work) -@@ -662,6 +694,12 @@ static void xen_evtchn_close(unsigned int port) - BUG(); - } - -+static void event_handler_exit(struct irq_info *info) -+{ -+ smp_store_release(&info->is_active, 0); -+ clear_evtchn(info->evtchn); -+} -+ - static void pirq_query_unmask(int irq) - { - struct physdev_irq_status_query irq_status; -@@ -680,7 +718,8 @@ static void pirq_query_unmask(int irq) - - static void eoi_pirq(struct irq_data *data) - { -- int evtchn = evtchn_from_irq(data->irq); -+ struct irq_info *info = info_for_irq(data->irq); -+ int evtchn = info ? info->evtchn : 0; - struct physdev_eoi eoi = { .irq = pirq_from_irq(data->irq) }; - int rc = 0; - -@@ -689,16 +728,15 @@ static void eoi_pirq(struct irq_data *data) - - if (unlikely(irqd_is_setaffinity_pending(data)) && - likely(!irqd_irq_disabled(data))) { -- int masked = test_and_set_mask(evtchn); -+ do_mask(info, EVT_MASK_REASON_TEMPORARY); - -- clear_evtchn(evtchn); -+ event_handler_exit(info); - - irq_move_masked_irq(data); - -- if (!masked) -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_TEMPORARY); - } else -- clear_evtchn(evtchn); -+ event_handler_exit(info); - - if (pirq_needs_eoi(data->irq)) { - rc = HYPERVISOR_physdev_op(PHYSDEVOP_eoi, &eoi); -@@ -749,7 +787,8 @@ static unsigned int __startup_pirq(unsigned int irq) - goto err; - - out: -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_EXPLICIT); -+ - eoi_pirq(irq_get_irq_data(irq)); - - return 0; -@@ -776,7 +815,7 @@ static void shutdown_pirq(struct irq_data *data) - if (!VALID_EVTCHN(evtchn)) - return; - -- mask_evtchn(evtchn); -+ do_mask(info, EVT_MASK_REASON_EXPLICIT); - xen_evtchn_close(evtchn); - xen_irq_info_cleanup(info); - } -@@ -1533,6 +1572,8 @@ void handle_irq_for_port(evtchn_port_t port, struct evtchn_loop_ctrl *ctrl) - } - - info = info_for_irq(irq); -+ if (xchg_acquire(&info->is_active, 1)) -+ return; - - if (ctrl->defer_eoi) { - info->eoi_cpu = smp_processor_id(); -@@ -1635,10 +1676,10 @@ void rebind_evtchn_irq(int evtchn, int irq) - } - - /* Rebind an evtchn so that it gets delivered to a specific cpu */ --static int xen_rebind_evtchn_to_cpu(int evtchn, unsigned int tcpu) -+static int xen_rebind_evtchn_to_cpu(struct irq_info *info, unsigned int tcpu) - { - struct evtchn_bind_vcpu bind_vcpu; -- int masked; -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (!VALID_EVTCHN(evtchn)) - return -1; -@@ -1654,7 +1695,7 @@ static int xen_rebind_evtchn_to_cpu(int evtchn, unsigned int tcpu) - * Mask the event while changing the VCPU binding to prevent - * it being delivered on an unexpected VCPU. - */ -- masked = test_and_set_mask(evtchn); -+ do_mask(info, EVT_MASK_REASON_TEMPORARY); - - /* - * If this fails, it usually just indicates that we're dealing with a -@@ -1664,8 +1705,7 @@ static int xen_rebind_evtchn_to_cpu(int evtchn, unsigned int tcpu) - if (HYPERVISOR_event_channel_op(EVTCHNOP_bind_vcpu, &bind_vcpu) >= 0) - bind_evtchn_to_cpu(evtchn, tcpu); - -- if (!masked) -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_TEMPORARY); - - return 0; - } -@@ -1674,7 +1714,7 @@ static int set_affinity_irq(struct irq_data *data, const struct cpumask *dest, - bool force) - { - unsigned tcpu = cpumask_first_and(dest, cpu_online_mask); -- int ret = xen_rebind_evtchn_to_cpu(evtchn_from_irq(data->irq), tcpu); -+ int ret = xen_rebind_evtchn_to_cpu(info_for_irq(data->irq), tcpu); - - if (!ret) - irq_data_update_effective_affinity(data, cpumask_of(tcpu)); -@@ -1693,39 +1733,41 @@ EXPORT_SYMBOL_GPL(xen_set_affinity_evtchn); - - static void enable_dynirq(struct irq_data *data) - { -- int evtchn = evtchn_from_irq(data->irq); -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (VALID_EVTCHN(evtchn)) -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_EXPLICIT); - } - - static void disable_dynirq(struct irq_data *data) - { -- int evtchn = evtchn_from_irq(data->irq); -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (VALID_EVTCHN(evtchn)) -- mask_evtchn(evtchn); -+ do_mask(info, EVT_MASK_REASON_EXPLICIT); - } - - static void ack_dynirq(struct irq_data *data) - { -- int evtchn = evtchn_from_irq(data->irq); -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (!VALID_EVTCHN(evtchn)) - return; - - if (unlikely(irqd_is_setaffinity_pending(data)) && - likely(!irqd_irq_disabled(data))) { -- int masked = test_and_set_mask(evtchn); -+ do_mask(info, EVT_MASK_REASON_TEMPORARY); - -- clear_evtchn(evtchn); -+ event_handler_exit(info); - - irq_move_masked_irq(data); - -- if (!masked) -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_TEMPORARY); - } else -- clear_evtchn(evtchn); -+ event_handler_exit(info); - } - - static void mask_ack_dynirq(struct irq_data *data) -@@ -1734,18 +1776,39 @@ static void mask_ack_dynirq(struct irq_data *data) - ack_dynirq(data); - } - -+static void lateeoi_ack_dynirq(struct irq_data *data) -+{ -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; -+ -+ if (VALID_EVTCHN(evtchn)) { -+ do_mask(info, EVT_MASK_REASON_EOI_PENDING); -+ event_handler_exit(info); -+ } -+} -+ -+static void lateeoi_mask_ack_dynirq(struct irq_data *data) -+{ -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; -+ -+ if (VALID_EVTCHN(evtchn)) { -+ do_mask(info, EVT_MASK_REASON_EXPLICIT); -+ event_handler_exit(info); -+ } -+} -+ - static int retrigger_dynirq(struct irq_data *data) - { -- unsigned int evtchn = evtchn_from_irq(data->irq); -- int masked; -+ struct irq_info *info = info_for_irq(data->irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (!VALID_EVTCHN(evtchn)) - return 0; - -- masked = test_and_set_mask(evtchn); -+ do_mask(info, EVT_MASK_REASON_TEMPORARY); - set_evtchn(evtchn); -- if (!masked) -- unmask_evtchn(evtchn); -+ do_unmask(info, EVT_MASK_REASON_TEMPORARY); - - return 1; - } -@@ -1840,10 +1903,11 @@ static void restore_cpu_ipis(unsigned int cpu) - /* Clear an irq's pending state, in preparation for polling on it */ - void xen_clear_irq_pending(int irq) - { -- int evtchn = evtchn_from_irq(irq); -+ struct irq_info *info = info_for_irq(irq); -+ evtchn_port_t evtchn = info ? info->evtchn : 0; - - if (VALID_EVTCHN(evtchn)) -- clear_evtchn(evtchn); -+ event_handler_exit(info); - } - EXPORT_SYMBOL(xen_clear_irq_pending); - void xen_set_irq_pending(int irq) -@@ -1951,8 +2015,8 @@ static struct irq_chip xen_lateeoi_chip __read_mostly = { - .irq_mask = disable_dynirq, - .irq_unmask = enable_dynirq, - -- .irq_ack = mask_ack_dynirq, -- .irq_mask_ack = mask_ack_dynirq, -+ .irq_ack = lateeoi_ack_dynirq, -+ .irq_mask_ack = lateeoi_mask_ack_dynirq, - - .irq_set_affinity = set_affinity_irq, - .irq_retrigger = retrigger_dynirq, -diff --git a/drivers/xen/events/events_fifo.c b/drivers/xen/events/events_fifo.c -index 33462521bfd0f..360a7f8cdf754 100644 ---- a/drivers/xen/events/events_fifo.c -+++ b/drivers/xen/events/events_fifo.c -@@ -209,12 +209,6 @@ static bool evtchn_fifo_is_pending(unsigned port) - return sync_test_bit(EVTCHN_FIFO_BIT(PENDING, word), BM(word)); - } - --static bool evtchn_fifo_test_and_set_mask(unsigned port) --{ -- event_word_t *word = event_word_from_port(port); -- return sync_test_and_set_bit(EVTCHN_FIFO_BIT(MASKED, word), BM(word)); --} -- - static void evtchn_fifo_mask(unsigned port) - { - event_word_t *word = event_word_from_port(port); -@@ -420,7 +414,6 @@ static const struct evtchn_ops evtchn_ops_fifo = { - .clear_pending = evtchn_fifo_clear_pending, - .set_pending = evtchn_fifo_set_pending, - .is_pending = evtchn_fifo_is_pending, -- .test_and_set_mask = evtchn_fifo_test_and_set_mask, - .mask = evtchn_fifo_mask, - .unmask = evtchn_fifo_unmask, - .handle_events = evtchn_fifo_handle_events, -diff --git a/drivers/xen/events/events_internal.h b/drivers/xen/events/events_internal.h -index a35c8c7ac6066..d3a89b4646b8b 100644 ---- a/drivers/xen/events/events_internal.h -+++ b/drivers/xen/events/events_internal.h -@@ -33,13 +33,19 @@ struct irq_info { - struct list_head eoi_list; - short refcnt; - short spurious_cnt; -- enum xen_irq_type type; /* type */ -+ short type; /* type */ -+ u8 mask_reason; /* Why is event channel masked */ -+#define EVT_MASK_REASON_EXPLICIT 0x01 -+#define EVT_MASK_REASON_TEMPORARY 0x02 -+#define EVT_MASK_REASON_EOI_PENDING 0x04 -+ u8 is_active; /* Is event just being handled? */ - unsigned irq; - unsigned int evtchn; /* event channel */ - unsigned short cpu; /* cpu bound */ - unsigned short eoi_cpu; /* EOI must happen on this cpu */ - unsigned int irq_epoch; /* If eoi_cpu valid: irq_epoch of event */ - u64 eoi_time; /* Time in jiffies when to EOI. */ -+ spinlock_t lock; - - union { - unsigned short virq; -@@ -65,12 +71,12 @@ struct evtchn_ops { - unsigned (*nr_channels)(void); - - int (*setup)(struct irq_info *info); -+ void (*remove)(evtchn_port_t port, unsigned int cpu); - void (*bind_to_cpu)(struct irq_info *info, unsigned cpu); - - void (*clear_pending)(unsigned port); - void (*set_pending)(unsigned port); - bool (*is_pending)(unsigned port); -- bool (*test_and_set_mask)(unsigned port); - void (*mask)(unsigned port); - void (*unmask)(unsigned port); - -@@ -107,6 +113,13 @@ static inline int xen_evtchn_port_setup(struct irq_info *info) - return 0; - } - -+static inline void xen_evtchn_port_remove(evtchn_port_t evtchn, -+ unsigned int cpu) -+{ -+ if (evtchn_ops->remove) -+ evtchn_ops->remove(evtchn, cpu); -+} -+ - static inline void xen_evtchn_port_bind_to_cpu(struct irq_info *info, - unsigned cpu) - { -@@ -128,11 +141,6 @@ static inline bool test_evtchn(unsigned port) - return evtchn_ops->is_pending(port); - } - --static inline bool test_and_set_mask(unsigned port) --{ -- return evtchn_ops->test_and_set_mask(port); --} -- - static inline void mask_evtchn(unsigned port) - { - return evtchn_ops->mask(port); -diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c -index cdb45829354d9..056a68292e152 100644 ---- a/fs/binfmt_misc.c -+++ b/fs/binfmt_misc.c -@@ -696,12 +696,24 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, - struct super_block *sb = file_inode(file)->i_sb; - struct dentry *root = sb->s_root, *dentry; - int err = 0; -+ struct file *f = NULL; - - e = create_entry(buffer, count); - - if (IS_ERR(e)) - return PTR_ERR(e); - -+ if (e->flags & MISC_FMT_OPEN_FILE) { -+ f = open_exec(e->interpreter); -+ if (IS_ERR(f)) { -+ pr_notice("register: failed to install interpreter file %s\n", -+ e->interpreter); -+ kfree(e); -+ return PTR_ERR(f); -+ } -+ e->interp_file = f; -+ } -+ - inode_lock(d_inode(root)); - dentry = lookup_one_len(e->name, root, strlen(e->name)); - err = PTR_ERR(dentry); -@@ -725,21 +737,6 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer, - goto out2; - } - -- if (e->flags & MISC_FMT_OPEN_FILE) { -- struct file *f; -- -- f = open_exec(e->interpreter); -- if (IS_ERR(f)) { -- err = PTR_ERR(f); -- pr_notice("register: failed to install interpreter file %s\n", e->interpreter); -- simple_release_fs(&bm_mnt, &entry_count); -- iput(inode); -- inode = NULL; -- goto out2; -- } -- e->interp_file = f; -- } -- - e->dentry = dget(dentry); - inode->i_private = e; - inode->i_fop = &bm_entry_operations; -@@ -756,6 +753,8 @@ out: - inode_unlock(d_inode(root)); - - if (err) { -+ if (f) -+ filp_close(f, NULL); - kfree(e); - return err; - } -diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c -index 115f063497ffa..41b3c5fc958c7 100644 ---- a/fs/cifs/cifsfs.c -+++ b/fs/cifs/cifsfs.c -@@ -278,7 +278,7 @@ cifs_statfs(struct dentry *dentry, struct kstatfs *buf) - rc = server->ops->queryfs(xid, tcon, buf); - - free_xid(xid); -- return 0; -+ return rc; - } - - static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len) -diff --git a/fs/configfs/file.c b/fs/configfs/file.c -index fb65b706cc0db..84b4d58fc65f7 100644 ---- a/fs/configfs/file.c -+++ b/fs/configfs/file.c -@@ -378,7 +378,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type - - attr = to_attr(dentry); - if (!attr) -- goto out_put_item; -+ goto out_free_buffer; - - if (type & CONFIGFS_ITEM_BIN_ATTR) { - buffer->bin_attr = to_bin_attr(dentry); -@@ -391,7 +391,7 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type - /* Grab the module reference for this attribute if we have one */ - error = -ENODEV; - if (!try_module_get(buffer->owner)) -- goto out_put_item; -+ goto out_free_buffer; - - error = -EACCES; - if (!buffer->item->ci_type) -@@ -435,8 +435,6 @@ static int __configfs_open_file(struct inode *inode, struct file *file, int type - - out_put_module: - module_put(buffer->owner); --out_put_item: -- config_item_put(buffer->item); - out_free_buffer: - up_read(&frag->frag_sem); - kfree(buffer); -diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c -index 188b17a3b19eb..e7c0790308fe0 100644 ---- a/fs/nfs/dir.c -+++ b/fs/nfs/dir.c -@@ -1073,6 +1073,15 @@ out_force: - goto out; - } - -+static void nfs_mark_dir_for_revalidate(struct inode *inode) -+{ -+ struct nfs_inode *nfsi = NFS_I(inode); -+ -+ spin_lock(&inode->i_lock); -+ nfsi->cache_validity |= NFS_INO_REVAL_PAGECACHE; -+ spin_unlock(&inode->i_lock); -+} -+ - /* - * We judge how long we want to trust negative - * dentries by looking at the parent inode mtime. -@@ -1107,19 +1116,14 @@ nfs_lookup_revalidate_done(struct inode *dir, struct dentry *dentry, - __func__, dentry); - return 1; - case 0: -- nfs_mark_for_revalidate(dir); -- if (inode && S_ISDIR(inode->i_mode)) { -- /* Purge readdir caches. */ -- nfs_zap_caches(inode); -- /* -- * We can't d_drop the root of a disconnected tree: -- * its d_hash is on the s_anon list and d_drop() would hide -- * it from shrink_dcache_for_unmount(), leading to busy -- * inodes on unmount and further oopses. -- */ -- if (IS_ROOT(dentry)) -- return 1; -- } -+ /* -+ * We can't d_drop the root of a disconnected tree: -+ * its d_hash is on the s_anon list and d_drop() would hide -+ * it from shrink_dcache_for_unmount(), leading to busy -+ * inodes on unmount and further oopses. -+ */ -+ if (inode && IS_ROOT(dentry)) -+ return 1; - dfprintk(LOOKUPCACHE, "NFS: %s(%pd2) is invalid\n", - __func__, dentry); - return 0; -@@ -1188,6 +1192,13 @@ out: - nfs_free_fattr(fattr); - nfs_free_fhandle(fhandle); - nfs4_label_free(label); -+ -+ /* -+ * If the lookup failed despite the dentry change attribute being -+ * a match, then we should revalidate the directory cache. -+ */ -+ if (!ret && nfs_verify_change_attribute(dir, dentry->d_time)) -+ nfs_mark_dir_for_revalidate(dir); - return nfs_lookup_revalidate_done(dir, dentry, inode, ret); - } - -@@ -1230,7 +1241,7 @@ nfs_do_lookup_revalidate(struct inode *dir, struct dentry *dentry, - error = nfs_lookup_verify_inode(inode, flags); - if (error) { - if (error == -ESTALE) -- nfs_zap_caches(dir); -+ nfs_mark_dir_for_revalidate(dir); - goto out_bad; - } - nfs_advise_use_readdirplus(dir); -@@ -1725,7 +1736,6 @@ out: - dput(parent); - return d; - out_error: -- nfs_mark_for_revalidate(dir); - d = ERR_PTR(error); - goto out; - } -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c -index 30e44b33040a4..b2119159dead2 100644 ---- a/fs/nfs/nfs4proc.c -+++ b/fs/nfs/nfs4proc.c -@@ -5830,7 +5830,7 @@ static int _nfs4_get_security_label(struct inode *inode, void *buf, - return ret; - if (!(fattr.valid & NFS_ATTR_FATTR_V4_SECURITY_LABEL)) - return -ENOENT; -- return 0; -+ return label.len; - } - - static int nfs4_get_security_label(struct inode *inode, void *buf, -diff --git a/fs/pnode.h b/fs/pnode.h -index 26f74e092bd98..988f1aa9b02ae 100644 ---- a/fs/pnode.h -+++ b/fs/pnode.h -@@ -12,7 +12,7 @@ - - #define IS_MNT_SHARED(m) ((m)->mnt.mnt_flags & MNT_SHARED) - #define IS_MNT_SLAVE(m) ((m)->mnt_master) --#define IS_MNT_NEW(m) (!(m)->mnt_ns) -+#define IS_MNT_NEW(m) (!(m)->mnt_ns || is_anon_ns((m)->mnt_ns)) - #define CLEAR_MNT_SHARED(m) ((m)->mnt.mnt_flags &= ~MNT_SHARED) - #define IS_MNT_UNBINDABLE(m) ((m)->mnt.mnt_flags & MNT_UNBINDABLE) - #define IS_MNT_MARKED(m) ((m)->mnt.mnt_flags & MNT_MARKED) -diff --git a/fs/udf/inode.c b/fs/udf/inode.c -index 97a192eb9949c..507f8f9103270 100644 ---- a/fs/udf/inode.c -+++ b/fs/udf/inode.c -@@ -547,11 +547,14 @@ static int udf_do_extend_file(struct inode *inode, - - udf_write_aext(inode, last_pos, &last_ext->extLocation, - last_ext->extLength, 1); -+ - /* -- * We've rewritten the last extent but there may be empty -- * indirect extent after it - enter it. -+ * We've rewritten the last extent. If we are going to add -+ * more extents, we may need to enter possible following -+ * empty indirect extent. - */ -- udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); -+ if (new_block_bytes || prealloc_len) -+ udf_next_aext(inode, last_pos, &tmploc, &tmplen, 0); - } - - /* Managed to do everything necessary? */ -diff --git a/include/linux/can/skb.h b/include/linux/can/skb.h -index 0783b0c6d9e2f..1ef071e5a55ef 100644 ---- a/include/linux/can/skb.h -+++ b/include/linux/can/skb.h -@@ -49,8 +49,12 @@ static inline void can_skb_reserve(struct sk_buff *skb) - - static inline void can_skb_set_owner(struct sk_buff *skb, struct sock *sk) - { -- if (sk) { -- sock_hold(sk); -+ /* If the socket has already been closed by user space, the -+ * refcount may already be 0 (and the socket will be freed -+ * after the last TX skb has been freed). So only increase -+ * socket refcount if the refcount is > 0. -+ */ -+ if (sk && refcount_inc_not_zero(&sk->sk_refcnt)) { - skb->destructor = sock_efree; - skb->sk = sk; - } -diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h -index a132d875d3518..3a1d899019af0 100644 ---- a/include/linux/sched/mm.h -+++ b/include/linux/sched/mm.h -@@ -167,7 +167,8 @@ static inline bool in_vfork(struct task_struct *tsk) - * another oom-unkillable task does this it should blame itself. - */ - rcu_read_lock(); -- ret = tsk->vfork_done && tsk->real_parent->mm == tsk->mm; -+ ret = tsk->vfork_done && -+ rcu_dereference(tsk->real_parent)->mm == tsk->mm; - rcu_read_unlock(); - - return ret; -diff --git a/include/linux/stop_machine.h b/include/linux/stop_machine.h -index f9a0c6189852e..69998fc5ffe9d 100644 ---- a/include/linux/stop_machine.h -+++ b/include/linux/stop_machine.h -@@ -139,7 +139,7 @@ int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data, - const struct cpumask *cpus); - #else /* CONFIG_SMP || CONFIG_HOTPLUG_CPU */ - --static inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, -+static __always_inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, - const struct cpumask *cpus) - { - unsigned long flags; -@@ -150,14 +150,15 @@ static inline int stop_machine_cpuslocked(cpu_stop_fn_t fn, void *data, - return ret; - } - --static inline int stop_machine(cpu_stop_fn_t fn, void *data, -- const struct cpumask *cpus) -+static __always_inline int -+stop_machine(cpu_stop_fn_t fn, void *data, const struct cpumask *cpus) - { - return stop_machine_cpuslocked(fn, data, cpus); - } - --static inline int stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data, -- const struct cpumask *cpus) -+static __always_inline int -+stop_machine_from_inactive_cpu(cpu_stop_fn_t fn, void *data, -+ const struct cpumask *cpus) - { - return stop_machine(fn, data, cpus); - } -diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h -index e8a924eeea3d0..6b5fcfa1e5553 100644 ---- a/include/linux/virtio_net.h -+++ b/include/linux/virtio_net.h -@@ -79,8 +79,13 @@ static inline int virtio_net_hdr_to_skb(struct sk_buff *skb, - if (gso_type && skb->network_header) { - struct flow_keys_basic keys; - -- if (!skb->protocol) -+ if (!skb->protocol) { -+ __be16 protocol = dev_parse_header_protocol(skb); -+ - virtio_net_hdr_set_proto(skb, hdr); -+ if (protocol && protocol != skb->protocol) -+ return -EINVAL; -+ } - retry: - if (!skb_flow_dissect_flow_keys_basic(NULL, skb, &keys, - NULL, 0, 0, 0, -diff --git a/include/media/rc-map.h b/include/media/rc-map.h -index c2ef3906e1cd1..a358c87a65de2 100644 ---- a/include/media/rc-map.h -+++ b/include/media/rc-map.h -@@ -126,6 +126,13 @@ struct rc_map_list { - struct rc_map map; - }; - -+#ifdef CONFIG_MEDIA_CEC_RC -+/* -+ * rc_map_list from rc-cec.c -+ */ -+extern struct rc_map_list cec_map; -+#endif -+ - /* Routines from rc-map.c */ - - /** -diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h -index 51b6f50eabeeb..0deeff9b4496a 100644 ---- a/include/target/target_core_backend.h -+++ b/include/target/target_core_backend.h -@@ -69,6 +69,7 @@ int transport_backend_register(const struct target_backend_ops *); - void target_backend_unregister(const struct target_backend_ops *); - - void target_complete_cmd(struct se_cmd *, u8); -+void target_set_cmd_data_length(struct se_cmd *, int); - void target_complete_cmd_with_length(struct se_cmd *, u8, int); - - void transport_copy_sense_to_cmd(struct se_cmd *, unsigned char *); -diff --git a/include/uapi/linux/netfilter/nfnetlink_cthelper.h b/include/uapi/linux/netfilter/nfnetlink_cthelper.h -index a13137afc4299..70af02092d16e 100644 ---- a/include/uapi/linux/netfilter/nfnetlink_cthelper.h -+++ b/include/uapi/linux/netfilter/nfnetlink_cthelper.h -@@ -5,7 +5,7 @@ - #define NFCT_HELPER_STATUS_DISABLED 0 - #define NFCT_HELPER_STATUS_ENABLED 1 - --enum nfnl_acct_msg_types { -+enum nfnl_cthelper_msg_types { - NFNL_MSG_CTHELPER_NEW, - NFNL_MSG_CTHELPER_GET, - NFNL_MSG_CTHELPER_DEL, -diff --git a/kernel/sched/membarrier.c b/kernel/sched/membarrier.c -index be0ca3306be8c..46c142b695988 100644 ---- a/kernel/sched/membarrier.c -+++ b/kernel/sched/membarrier.c -@@ -265,9 +265,7 @@ static int sync_runqueues_membarrier_state(struct mm_struct *mm) - } - rcu_read_unlock(); - -- preempt_disable(); -- smp_call_function_many(tmpmask, ipi_sync_rq_state, mm, 1); -- preempt_enable(); -+ on_each_cpu_mask(tmpmask, ipi_sync_rq_state, mm, true); - - free_cpumask_var(tmpmask); - cpus_read_unlock(); -diff --git a/kernel/sysctl.c b/kernel/sysctl.c -index 70665934d53e2..eae6a078619f9 100644 ---- a/kernel/sysctl.c -+++ b/kernel/sysctl.c -@@ -1563,7 +1563,7 @@ static struct ctl_table vm_table[] = { - .data = &block_dump, - .maxlen = sizeof(block_dump), - .mode = 0644, -- .proc_handler = proc_dointvec, -+ .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, - { -@@ -1571,7 +1571,7 @@ static struct ctl_table vm_table[] = { - .data = &sysctl_vfs_cache_pressure, - .maxlen = sizeof(sysctl_vfs_cache_pressure), - .mode = 0644, -- .proc_handler = proc_dointvec, -+ .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, - #if defined(HAVE_ARCH_PICK_MMAP_LAYOUT) || \ -@@ -1581,7 +1581,7 @@ static struct ctl_table vm_table[] = { - .data = &sysctl_legacy_va_layout, - .maxlen = sizeof(sysctl_legacy_va_layout), - .mode = 0644, -- .proc_handler = proc_dointvec, -+ .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, - #endif -@@ -1591,7 +1591,7 @@ static struct ctl_table vm_table[] = { - .data = &node_reclaim_mode, - .maxlen = sizeof(node_reclaim_mode), - .mode = 0644, -- .proc_handler = proc_dointvec, -+ .proc_handler = proc_dointvec_minmax, - .extra1 = SYSCTL_ZERO, - }, - { -diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c -index 7f31932216a12..299a4c5b6cf8d 100644 ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -547,8 +547,11 @@ static ktime_t __hrtimer_next_event_base(struct hrtimer_cpu_base *cpu_base, - } - - /* -- * Recomputes cpu_base::*next_timer and returns the earliest expires_next but -- * does not set cpu_base::*expires_next, that is done by hrtimer_reprogram. -+ * Recomputes cpu_base::*next_timer and returns the earliest expires_next -+ * but does not set cpu_base::*expires_next, that is done by -+ * hrtimer[_force]_reprogram and hrtimer_interrupt only. When updating -+ * cpu_base::*expires_next right away, reprogramming logic would no longer -+ * work. - * - * When a softirq is pending, we can ignore the HRTIMER_ACTIVE_SOFT bases, - * those timers will get run whenever the softirq gets handled, at the end of -@@ -589,6 +592,37 @@ __hrtimer_get_next_event(struct hrtimer_cpu_base *cpu_base, unsigned int active_ - return expires_next; - } - -+static ktime_t hrtimer_update_next_event(struct hrtimer_cpu_base *cpu_base) -+{ -+ ktime_t expires_next, soft = KTIME_MAX; -+ -+ /* -+ * If the soft interrupt has already been activated, ignore the -+ * soft bases. They will be handled in the already raised soft -+ * interrupt. -+ */ -+ if (!cpu_base->softirq_activated) { -+ soft = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_SOFT); -+ /* -+ * Update the soft expiry time. clock_settime() might have -+ * affected it. -+ */ -+ cpu_base->softirq_expires_next = soft; -+ } -+ -+ expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_HARD); -+ /* -+ * If a softirq timer is expiring first, update cpu_base->next_timer -+ * and program the hardware with the soft expiry time. -+ */ -+ if (expires_next > soft) { -+ cpu_base->next_timer = cpu_base->softirq_next_timer; -+ expires_next = soft; -+ } -+ -+ return expires_next; -+} -+ - static inline ktime_t hrtimer_update_base(struct hrtimer_cpu_base *base) - { - ktime_t *offs_real = &base->clock_base[HRTIMER_BASE_REALTIME].offset; -@@ -629,23 +663,7 @@ hrtimer_force_reprogram(struct hrtimer_cpu_base *cpu_base, int skip_equal) - { - ktime_t expires_next; - -- /* -- * Find the current next expiration time. -- */ -- expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL); -- -- if (cpu_base->next_timer && cpu_base->next_timer->is_soft) { -- /* -- * When the softirq is activated, hrtimer has to be -- * programmed with the first hard hrtimer because soft -- * timer interrupt could occur too late. -- */ -- if (cpu_base->softirq_activated) -- expires_next = __hrtimer_get_next_event(cpu_base, -- HRTIMER_ACTIVE_HARD); -- else -- cpu_base->softirq_expires_next = expires_next; -- } -+ expires_next = hrtimer_update_next_event(cpu_base); - - if (skip_equal && expires_next == cpu_base->expires_next) - return; -@@ -1640,8 +1658,8 @@ retry: - - __hrtimer_run_queues(cpu_base, now, flags, HRTIMER_ACTIVE_HARD); - -- /* Reevaluate the clock bases for the next expiry */ -- expires_next = __hrtimer_get_next_event(cpu_base, HRTIMER_ACTIVE_ALL); -+ /* Reevaluate the clock bases for the [soft] next expiry */ -+ expires_next = hrtimer_update_next_event(cpu_base); - /* - * Store the new expiry value so the migration code can verify - * against it. -diff --git a/lib/logic_pio.c b/lib/logic_pio.c -index 905027574e5d8..774bb02fff10a 100644 ---- a/lib/logic_pio.c -+++ b/lib/logic_pio.c -@@ -27,6 +27,8 @@ static DEFINE_MUTEX(io_range_mutex); - * @new_range: pointer to the IO range to be registered. - * - * Returns 0 on success, the error code in case of failure. -+ * If the range already exists, -EEXIST will be returned, which should be -+ * considered a success. - * - * Register a new IO range node in the IO range list. - */ -@@ -49,6 +51,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range) - list_for_each_entry(range, &io_range_list, list) { - if (range->fwnode == new_range->fwnode) { - /* range already there */ -+ ret = -EEXIST; - goto end_register; - } - if (range->flags == LOGIC_PIO_CPU_MMIO && -diff --git a/mm/slub.c b/mm/slub.c -index e622e8f4c2ac4..52ded855b4ed0 100644 ---- a/mm/slub.c -+++ b/mm/slub.c -@@ -1887,7 +1887,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, - - t = acquire_slab(s, n, page, object == NULL, &objects); - if (!t) -- continue; /* cmpxchg raced */ -+ break; - - available += objects; - if (!object) { -diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c -index a23094b050f8b..e290a0c9e9282 100644 ---- a/net/ipv4/cipso_ipv4.c -+++ b/net/ipv4/cipso_ipv4.c -@@ -519,16 +519,10 @@ int cipso_v4_doi_remove(u32 doi, struct netlbl_audit *audit_info) - ret_val = -ENOENT; - goto doi_remove_return; - } -- if (!refcount_dec_and_test(&doi_def->refcount)) { -- spin_unlock(&cipso_v4_doi_list_lock); -- ret_val = -EBUSY; -- goto doi_remove_return; -- } - list_del_rcu(&doi_def->list); - spin_unlock(&cipso_v4_doi_list_lock); - -- cipso_v4_cache_invalidate(); -- call_rcu(&doi_def->rcu, cipso_v4_doi_free_rcu); -+ cipso_v4_doi_putdef(doi_def); - ret_val = 0; - - doi_remove_return: -@@ -585,9 +579,6 @@ void cipso_v4_doi_putdef(struct cipso_v4_doi *doi_def) - - if (!refcount_dec_and_test(&doi_def->refcount)) - return; -- spin_lock(&cipso_v4_doi_list_lock); -- list_del_rcu(&doi_def->list); -- spin_unlock(&cipso_v4_doi_list_lock); - - cipso_v4_cache_invalidate(); - call_rcu(&doi_def->rcu, cipso_v4_doi_free_rcu); -diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c -index c2b7d43d92b0e..f5f4369c131c9 100644 ---- a/net/ipv4/nexthop.c -+++ b/net/ipv4/nexthop.c -@@ -1065,7 +1065,7 @@ out: - - /* rtnl */ - /* remove all nexthops tied to a device being deleted */ --static void nexthop_flush_dev(struct net_device *dev) -+static void nexthop_flush_dev(struct net_device *dev, unsigned long event) - { - unsigned int hash = nh_dev_hashfn(dev->ifindex); - struct net *net = dev_net(dev); -@@ -1077,6 +1077,10 @@ static void nexthop_flush_dev(struct net_device *dev) - if (nhi->fib_nhc.nhc_dev != dev) - continue; - -+ if (nhi->reject_nh && -+ (event == NETDEV_DOWN || event == NETDEV_CHANGE)) -+ continue; -+ - remove_nexthop(net, nhi->nh_parent, NULL); - } - } -@@ -1794,11 +1798,11 @@ static int nh_netdev_event(struct notifier_block *this, - switch (event) { - case NETDEV_DOWN: - case NETDEV_UNREGISTER: -- nexthop_flush_dev(dev); -+ nexthop_flush_dev(dev, event); - break; - case NETDEV_CHANGE: - if (!(dev_get_flags(dev) & (IFF_RUNNING | IFF_LOWER_UP))) -- nexthop_flush_dev(dev); -+ nexthop_flush_dev(dev, event); - break; - case NETDEV_CHANGEMTU: - info_ext = ptr; -diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c -index 6ddec8a23942b..5c8d0fb498256 100644 ---- a/net/ipv4/tcp.c -+++ b/net/ipv4/tcp.c -@@ -2957,16 +2957,23 @@ static int do_tcp_setsockopt(struct sock *sk, int level, - break; - - case TCP_QUEUE_SEQ: -- if (sk->sk_state != TCP_CLOSE) -+ if (sk->sk_state != TCP_CLOSE) { - err = -EPERM; -- else if (tp->repair_queue == TCP_SEND_QUEUE) -- WRITE_ONCE(tp->write_seq, val); -- else if (tp->repair_queue == TCP_RECV_QUEUE) { -- WRITE_ONCE(tp->rcv_nxt, val); -- WRITE_ONCE(tp->copied_seq, val); -- } -- else -+ } else if (tp->repair_queue == TCP_SEND_QUEUE) { -+ if (!tcp_rtx_queue_empty(sk)) -+ err = -EPERM; -+ else -+ WRITE_ONCE(tp->write_seq, val); -+ } else if (tp->repair_queue == TCP_RECV_QUEUE) { -+ if (tp->rcv_nxt != tp->copied_seq) { -+ err = -EPERM; -+ } else { -+ WRITE_ONCE(tp->rcv_nxt, val); -+ WRITE_ONCE(tp->copied_seq, val); -+ } -+ } else { - err = -EINVAL; -+ } - break; - - case TCP_REPAIR_OPTIONS: -diff --git a/net/ipv4/udp_offload.c b/net/ipv4/udp_offload.c -index d7c64e953e9a5..c463eebdc8fe2 100644 ---- a/net/ipv4/udp_offload.c -+++ b/net/ipv4/udp_offload.c -@@ -426,7 +426,7 @@ struct sk_buff *udp_gro_receive(struct list_head *head, struct sk_buff *skb, - } - - if (NAPI_GRO_CB(skb)->encap_mark || -- (skb->ip_summed != CHECKSUM_PARTIAL && -+ (uh->check && skb->ip_summed != CHECKSUM_PARTIAL && - NAPI_GRO_CB(skb)->csum_cnt == 0 && - !NAPI_GRO_CB(skb)->csum_valid) || - !udp_sk(sk)->gro_receive) -diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c -index 8d3f66c310dbd..7426e33686d13 100644 ---- a/net/ipv6/calipso.c -+++ b/net/ipv6/calipso.c -@@ -83,6 +83,9 @@ struct calipso_map_cache_entry { - - static struct calipso_map_cache_bkt *calipso_cache; - -+static void calipso_cache_invalidate(void); -+static void calipso_doi_putdef(struct calipso_doi *doi_def); -+ - /* Label Mapping Cache Functions - */ - -@@ -444,15 +447,10 @@ static int calipso_doi_remove(u32 doi, struct netlbl_audit *audit_info) - ret_val = -ENOENT; - goto doi_remove_return; - } -- if (!refcount_dec_and_test(&doi_def->refcount)) { -- spin_unlock(&calipso_doi_list_lock); -- ret_val = -EBUSY; -- goto doi_remove_return; -- } - list_del_rcu(&doi_def->list); - spin_unlock(&calipso_doi_list_lock); - -- call_rcu(&doi_def->rcu, calipso_doi_free_rcu); -+ calipso_doi_putdef(doi_def); - ret_val = 0; - - doi_remove_return: -@@ -508,10 +506,8 @@ static void calipso_doi_putdef(struct calipso_doi *doi_def) - - if (!refcount_dec_and_test(&doi_def->refcount)) - return; -- spin_lock(&calipso_doi_list_lock); -- list_del_rcu(&doi_def->list); -- spin_unlock(&calipso_doi_list_lock); - -+ calipso_cache_invalidate(); - call_rcu(&doi_def->rcu, calipso_doi_free_rcu); - } - -diff --git a/net/mpls/mpls_gso.c b/net/mpls/mpls_gso.c -index b1690149b6fa0..1482259de9b5d 100644 ---- a/net/mpls/mpls_gso.c -+++ b/net/mpls/mpls_gso.c -@@ -14,6 +14,7 @@ - #include - #include - #include -+#include - - static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, - netdev_features_t features) -@@ -27,6 +28,8 @@ static struct sk_buff *mpls_gso_segment(struct sk_buff *skb, - - skb_reset_network_header(skb); - mpls_hlen = skb_inner_network_header(skb) - skb_network_header(skb); -+ if (unlikely(!mpls_hlen || mpls_hlen % MPLS_HLEN)) -+ goto out; - if (unlikely(!pskb_may_pull(skb, mpls_hlen))) - goto out; - -diff --git a/net/netfilter/nf_nat_proto.c b/net/netfilter/nf_nat_proto.c -index e87b6bd6b3cdb..4731d21fc3ad8 100644 ---- a/net/netfilter/nf_nat_proto.c -+++ b/net/netfilter/nf_nat_proto.c -@@ -646,8 +646,8 @@ nf_nat_ipv4_fn(void *priv, struct sk_buff *skb, - } - - static unsigned int --nf_nat_ipv4_in(void *priv, struct sk_buff *skb, -- const struct nf_hook_state *state) -+nf_nat_ipv4_pre_routing(void *priv, struct sk_buff *skb, -+ const struct nf_hook_state *state) - { - unsigned int ret; - __be32 daddr = ip_hdr(skb)->daddr; -@@ -659,6 +659,23 @@ nf_nat_ipv4_in(void *priv, struct sk_buff *skb, - return ret; - } - -+static unsigned int -+nf_nat_ipv4_local_in(void *priv, struct sk_buff *skb, -+ const struct nf_hook_state *state) -+{ -+ __be32 saddr = ip_hdr(skb)->saddr; -+ struct sock *sk = skb->sk; -+ unsigned int ret; -+ -+ ret = nf_nat_ipv4_fn(priv, skb, state); -+ -+ if (ret == NF_ACCEPT && sk && saddr != ip_hdr(skb)->saddr && -+ !inet_sk_transparent(sk)) -+ skb_orphan(skb); /* TCP edemux obtained wrong socket */ -+ -+ return ret; -+} -+ - static unsigned int - nf_nat_ipv4_out(void *priv, struct sk_buff *skb, - const struct nf_hook_state *state) -@@ -736,7 +753,7 @@ nf_nat_ipv4_local_fn(void *priv, struct sk_buff *skb, - static const struct nf_hook_ops nf_nat_ipv4_ops[] = { - /* Before packet filtering, change destination */ - { -- .hook = nf_nat_ipv4_in, -+ .hook = nf_nat_ipv4_pre_routing, - .pf = NFPROTO_IPV4, - .hooknum = NF_INET_PRE_ROUTING, - .priority = NF_IP_PRI_NAT_DST, -@@ -757,7 +774,7 @@ static const struct nf_hook_ops nf_nat_ipv4_ops[] = { - }, - /* After packet filtering, change source */ - { -- .hook = nf_nat_ipv4_fn, -+ .hook = nf_nat_ipv4_local_in, - .pf = NFPROTO_IPV4, - .hooknum = NF_INET_LOCAL_IN, - .priority = NF_IP_PRI_NAT_SRC, -diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c -index d1ef2d7930739..8b60fc04c67c2 100644 ---- a/net/netfilter/x_tables.c -+++ b/net/netfilter/x_tables.c -@@ -330,6 +330,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp) - const struct xt_match *m; - int have_rev = 0; - -+ mutex_lock(&xt[af].mutex); - list_for_each_entry(m, &xt[af].match, list) { - if (strcmp(m->name, name) == 0) { - if (m->revision > *bestp) -@@ -338,6 +339,7 @@ static int match_revfn(u8 af, const char *name, u8 revision, int *bestp) - have_rev = 1; - } - } -+ mutex_unlock(&xt[af].mutex); - - if (af != NFPROTO_UNSPEC && !have_rev) - return match_revfn(NFPROTO_UNSPEC, name, revision, bestp); -@@ -350,6 +352,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp) - const struct xt_target *t; - int have_rev = 0; - -+ mutex_lock(&xt[af].mutex); - list_for_each_entry(t, &xt[af].target, list) { - if (strcmp(t->name, name) == 0) { - if (t->revision > *bestp) -@@ -358,6 +361,7 @@ static int target_revfn(u8 af, const char *name, u8 revision, int *bestp) - have_rev = 1; - } - } -+ mutex_unlock(&xt[af].mutex); - - if (af != NFPROTO_UNSPEC && !have_rev) - return target_revfn(NFPROTO_UNSPEC, name, revision, bestp); -@@ -371,12 +375,10 @@ int xt_find_revision(u8 af, const char *name, u8 revision, int target, - { - int have_rev, best = -1; - -- mutex_lock(&xt[af].mutex); - if (target == 1) - have_rev = target_revfn(af, name, revision, &best); - else - have_rev = match_revfn(af, name, revision, &best); -- mutex_unlock(&xt[af].mutex); - - /* Nothing at all? Return 0 to try loading module. */ - if (best == -1) { -diff --git a/net/netlabel/netlabel_cipso_v4.c b/net/netlabel/netlabel_cipso_v4.c -index 0f16080b87cb9..4cb43a2c07d14 100644 ---- a/net/netlabel/netlabel_cipso_v4.c -+++ b/net/netlabel/netlabel_cipso_v4.c -@@ -575,6 +575,7 @@ list_start: - - break; - } -+ cipso_v4_doi_putdef(doi_def); - rcu_read_unlock(); - - genlmsg_end(ans_skb, data); -@@ -583,12 +584,14 @@ list_start: - list_retry: - /* XXX - this limit is a guesstimate */ - if (nlsze_mult < 4) { -+ cipso_v4_doi_putdef(doi_def); - rcu_read_unlock(); - kfree_skb(ans_skb); - nlsze_mult *= 2; - goto list_start; - } - list_failure_lock: -+ cipso_v4_doi_putdef(doi_def); - rcu_read_unlock(); - list_failure: - kfree_skb(ans_skb); -diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c -index ef602976bb2c8..6e023e93d3186 100644 ---- a/net/qrtr/qrtr.c -+++ b/net/qrtr/qrtr.c -@@ -791,8 +791,10 @@ static int qrtr_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) - plen = (len + 3) & ~3; - skb = sock_alloc_send_skb(sk, plen + QRTR_HDR_MAX_SIZE, - msg->msg_flags & MSG_DONTWAIT, &rc); -- if (!skb) -+ if (!skb) { -+ rc = -ENOMEM; - goto out_node; -+ } - - skb_reserve(skb, QRTR_HDR_MAX_SIZE); - -diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c -index b65a405f607b2..3b1b5ee521379 100644 ---- a/net/sched/sch_api.c -+++ b/net/sched/sch_api.c -@@ -2157,7 +2157,7 @@ static int tc_dump_tclass_qdisc(struct Qdisc *q, struct sk_buff *skb, - - static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb, - struct tcmsg *tcm, struct netlink_callback *cb, -- int *t_p, int s_t) -+ int *t_p, int s_t, bool recur) - { - struct Qdisc *q; - int b; -@@ -2168,7 +2168,7 @@ static int tc_dump_tclass_root(struct Qdisc *root, struct sk_buff *skb, - if (tc_dump_tclass_qdisc(root, skb, tcm, cb, t_p, s_t) < 0) - return -1; - -- if (!qdisc_dev(root)) -+ if (!qdisc_dev(root) || !recur) - return 0; - - if (tcm->tcm_parent) { -@@ -2203,13 +2203,13 @@ static int tc_dump_tclass(struct sk_buff *skb, struct netlink_callback *cb) - s_t = cb->args[0]; - t = 0; - -- if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t) < 0) -+ if (tc_dump_tclass_root(dev->qdisc, skb, tcm, cb, &t, s_t, true) < 0) - goto done; - - dev_queue = dev_ingress_queue(dev); - if (dev_queue && - tc_dump_tclass_root(dev_queue->qdisc_sleeping, skb, tcm, cb, -- &t, s_t) < 0) -+ &t, s_t, false) < 0) - goto done; - - done: -diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c -index 7afbf15bcbd9a..4beb6d2957c33 100644 ---- a/net/sunrpc/sched.c -+++ b/net/sunrpc/sched.c -@@ -990,8 +990,11 @@ void rpc_execute(struct rpc_task *task) - - rpc_set_active(task); - rpc_make_runnable(rpciod_workqueue, task); -- if (!is_async) -+ if (!is_async) { -+ unsigned int pflags = memalloc_nofs_save(); - __rpc_execute(task); -+ memalloc_nofs_restore(pflags); -+ } - } - - static void rpc_async_schedule(struct work_struct *work) -diff --git a/samples/bpf/xdpsock_user.c b/samples/bpf/xdpsock_user.c -index 79d1005ff2ee3..3b604c1eb3c3b 100644 ---- a/samples/bpf/xdpsock_user.c -+++ b/samples/bpf/xdpsock_user.c -@@ -783,5 +783,7 @@ int main(int argc, char **argv) - else - l2fwd_all(); - -+ munmap(bufs, NUM_FRAMES * opt_xsk_frame_size); -+ - return 0; - } -diff --git a/security/commoncap.c b/security/commoncap.c -index ed89a6dd4f83d..28a6939bcc4e5 100644 ---- a/security/commoncap.c -+++ b/security/commoncap.c -@@ -500,8 +500,7 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size) - __u32 magic, nsmagic; - struct inode *inode = d_backing_inode(dentry); - struct user_namespace *task_ns = current_user_ns(), -- *fs_ns = inode->i_sb->s_user_ns, -- *ancestor; -+ *fs_ns = inode->i_sb->s_user_ns; - kuid_t rootid; - size_t newsize; - -@@ -524,15 +523,6 @@ int cap_convert_nscap(struct dentry *dentry, void **ivalue, size_t size) - if (nsrootid == -1) - return -EINVAL; - -- /* -- * Do not allow allow adding a v3 filesystem capability xattr -- * if the rootid field is ambiguous. -- */ -- for (ancestor = task_ns->parent; ancestor; ancestor = ancestor->parent) { -- if (from_kuid(ancestor, rootid) == 0) -- return -EINVAL; -- } -- - newsize = sizeof(struct vfs_ns_cap_data); - nscap = kmalloc(newsize, GFP_ATOMIC); - if (!nscap) -diff --git a/sound/pci/hda/hda_bind.c b/sound/pci/hda/hda_bind.c -index 6a85645663759..17a25e453f60c 100644 ---- a/sound/pci/hda/hda_bind.c -+++ b/sound/pci/hda/hda_bind.c -@@ -47,6 +47,10 @@ static void hda_codec_unsol_event(struct hdac_device *dev, unsigned int ev) - if (codec->bus->shutdown) - return; - -+ /* ignore unsol events during system suspend/resume */ -+ if (codec->core.dev.power.power_state.event != PM_EVENT_ON) -+ return; -+ - if (codec->patch_ops.unsol_event) - codec->patch_ops.unsol_event(codec, ev); - } -diff --git a/sound/pci/hda/hda_controller.c b/sound/pci/hda/hda_controller.c -index 5e6081750bd9b..6a159c6c2f546 100644 ---- a/sound/pci/hda/hda_controller.c -+++ b/sound/pci/hda/hda_controller.c -@@ -613,13 +613,6 @@ static int azx_pcm_open(struct snd_pcm_substream *substream) - 20, - 178000000); - -- /* by some reason, the playback stream stalls on PulseAudio with -- * tsched=1 when a capture stream triggers. Until we figure out the -- * real cause, disable tsched mode by telling the PCM info flag. -- */ -- if (chip->driver_caps & AZX_DCAPS_AMD_WORKAROUND) -- runtime->hw.info |= SNDRV_PCM_INFO_BATCH; -- - if (chip->align_buffer_size) - /* constrain buffer sizes to be multiple of 128 - bytes. This is more efficient in terms of memory -diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c -index 7f9f6bbca5489..febd16c9efd7a 100644 ---- a/sound/pci/hda/hda_intel.c -+++ b/sound/pci/hda/hda_intel.c -@@ -1025,6 +1025,8 @@ static int azx_prepare(struct device *dev) - chip = card->private_data; - chip->pm_prepared = 1; - -+ flush_work(&azx_bus(chip)->unsol_work); -+ - /* HDA controller always requires different WAKEEN for runtime suspend - * and system suspend, so don't use direct-complete here. - */ -diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c -index d7b2aae6d4289..9412bdda85c82 100644 ---- a/sound/pci/hda/patch_ca0132.c -+++ b/sound/pci/hda/patch_ca0132.c -@@ -1185,6 +1185,7 @@ static const struct snd_pci_quirk ca0132_quirks[] = { - SND_PCI_QUIRK(0x1102, 0x0013, "Recon3D", QUIRK_R3D), - SND_PCI_QUIRK(0x1102, 0x0018, "Recon3D", QUIRK_R3D), - SND_PCI_QUIRK(0x1102, 0x0051, "Sound Blaster AE-5", QUIRK_AE5), -+ SND_PCI_QUIRK(0x1102, 0x0191, "Sound Blaster AE-5 Plus", QUIRK_AE5), - SND_PCI_QUIRK(0x1102, 0x0081, "Sound Blaster AE-7", QUIRK_AE7), - {} - }; -diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c -index df4771b9eff24..ce38b5d4670da 100644 ---- a/sound/pci/hda/patch_hdmi.c -+++ b/sound/pci/hda/patch_hdmi.c -@@ -2382,6 +2382,18 @@ static void generic_hdmi_free(struct hda_codec *codec) - } - - #ifdef CONFIG_PM -+static int generic_hdmi_suspend(struct hda_codec *codec) -+{ -+ struct hdmi_spec *spec = codec->spec; -+ int pin_idx; -+ -+ for (pin_idx = 0; pin_idx < spec->num_pins; pin_idx++) { -+ struct hdmi_spec_per_pin *per_pin = get_pin(spec, pin_idx); -+ cancel_delayed_work_sync(&per_pin->work); -+ } -+ return 0; -+} -+ - static int generic_hdmi_resume(struct hda_codec *codec) - { - struct hdmi_spec *spec = codec->spec; -@@ -2405,6 +2417,7 @@ static const struct hda_codec_ops generic_hdmi_patch_ops = { - .build_controls = generic_hdmi_build_controls, - .unsol_event = hdmi_unsol_event, - #ifdef CONFIG_PM -+ .suspend = generic_hdmi_suspend, - .resume = generic_hdmi_resume, - #endif - }; -diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c -index a7f31766d14df..9fb03c646a88f 100644 ---- a/sound/usb/quirks.c -+++ b/sound/usb/quirks.c -@@ -1452,6 +1452,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) - case USB_ID(0x1901, 0x0191): /* GE B850V3 CP2114 audio interface */ - case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ - case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ -+ case USB_ID(0x413c, 0xa506): /* Dell AE515 sound bar */ - return true; - } - -@@ -1604,6 +1605,14 @@ void snd_usb_ctl_msg_quirk(struct usb_device *dev, unsigned int pipe, - && (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) - msleep(20); - -+ /* -+ * Plantronics headsets (C320, C320-M, etc) need a delay to avoid -+ * random microhpone failures. -+ */ -+ if (USB_ID_VENDOR(chip->usb_id) == 0x047f && -+ (requesttype & USB_TYPE_MASK) == USB_TYPE_CLASS) -+ msleep(20); -+ - /* Zoom R16/24, many Logitech(at least H650e/H570e/BCC950), - * Jabra 550a, Kingston HyperX needs a tiny delay here, - * otherwise requests like get/set frequency return -diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c -index 8593d3c200c61..0116b0c06e976 100644 ---- a/tools/perf/util/trace-event-read.c -+++ b/tools/perf/util/trace-event-read.c -@@ -361,6 +361,7 @@ static int read_saved_cmdline(struct tep_handle *pevent) - pr_debug("error reading saved cmdlines\n"); - goto out; - } -+ buf[ret] = '\0'; - - parse_saved_cmdline(pevent, buf, size); - ret = 0; -diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -index 0f98724120deb..b4e9a1d8c6cdb 100644 ---- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -@@ -446,10 +446,8 @@ int _geneve_get_tunnel(struct __sk_buff *skb) - } - - ret = bpf_skb_get_tunnel_opt(skb, &gopt, sizeof(gopt)); -- if (ret < 0) { -- ERROR(ret); -- return TC_ACT_SHOT; -- } -+ if (ret < 0) -+ gopt.opt_class = 0; - - bpf_trace_printk(fmt, sizeof(fmt), - key.tunnel_id, key.remote_ipv4, gopt.opt_class); -diff --git a/tools/testing/selftests/bpf/verifier/array_access.c b/tools/testing/selftests/bpf/verifier/array_access.c -index f3c33e128709b..bcc87906c4c19 100644 ---- a/tools/testing/selftests/bpf/verifier/array_access.c -+++ b/tools/testing/selftests/bpf/verifier/array_access.c -@@ -250,12 +250,13 @@ - BPF_MOV64_IMM(BPF_REG_5, 0), - BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, - BPF_FUNC_csum_diff), -+ BPF_ALU64_IMM(BPF_AND, BPF_REG_0, 0xffff), - BPF_EXIT_INSN(), - }, - .prog_type = BPF_PROG_TYPE_SCHED_CLS, - .fixup_map_array_ro = { 3 }, - .result = ACCEPT, -- .retval = -29, -+ .retval = 65507, - }, - { - "invalid write map access into a read-only array 1", -diff --git a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh -index 197e769c2ed16..f8cda822c1cec 100755 ---- a/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh -+++ b/tools/testing/selftests/net/forwarding/mirror_gre_bridge_1d_vlan.sh -@@ -86,11 +86,20 @@ test_ip6gretap() - - test_gretap_stp() - { -+ # Sometimes after mirror installation, the neighbor's state is not valid. -+ # The reason is that there is no SW datapath activity related to the -+ # neighbor for the remote GRE address. Therefore whether the corresponding -+ # neighbor will be valid is a matter of luck, and the test is thus racy. -+ # Set the neighbor's state to permanent, so it would be always valid. -+ ip neigh replace 192.0.2.130 lladdr $(mac_get $h3) \ -+ nud permanent dev br2 - full_test_span_gre_stp gt4 $swp3.555 "mirror to gretap" - } - - test_ip6gretap_stp() - { -+ ip neigh replace 2001:db8:2::2 lladdr $(mac_get $h3) \ -+ nud permanent dev br2 - full_test_span_gre_stp gt6 $swp3.555 "mirror to ip6gretap" - } - -diff --git a/virt/kvm/arm/arm.c b/virt/kvm/arm/arm.c -index 986fbc3cf667b..2e7d2b3f29079 100644 ---- a/virt/kvm/arm/arm.c -+++ b/virt/kvm/arm/arm.c -@@ -373,11 +373,17 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu) - cpu_data = this_cpu_ptr(&kvm_host_data); - - /* -+ * We guarantee that both TLBs and I-cache are private to each -+ * vcpu. If detecting that a vcpu from the same VM has -+ * previously run on the same physical CPU, call into the -+ * hypervisor code to nuke the relevant contexts. -+ * -+ * We might get preempted before the vCPU actually runs, but - * We might get preempted before the vCPU actually runs, but - * over-invalidation doesn't affect correctness. - */ - if (*last_ran != vcpu->vcpu_id) { -- kvm_call_hyp(__kvm_tlb_flush_local_vmid, vcpu); -+ kvm_call_hyp(__kvm_flush_cpu_context, vcpu); - *last_ran = vcpu->vcpu_id; - } - -diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c -index 03a586ab6d27b..c6ba672f07ccf 100644 ---- a/virt/kvm/arm/mmu.c -+++ b/virt/kvm/arm/mmu.c -@@ -2307,8 +2307,7 @@ int kvm_arch_prepare_memory_region(struct kvm *kvm, - * Prevent userspace from creating a memory region outside of the IPA - * space addressable by the KVM guest IPA space. - */ -- if (memslot->base_gfn + memslot->npages >= -- (kvm_phys_size(kvm) >> PAGE_SHIFT)) -+ if ((memslot->base_gfn + memslot->npages) > (kvm_phys_size(kvm) >> PAGE_SHIFT)) - return -EFAULT; - - down_read(¤t->mm->mmap_sem); diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.106-107.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.106-107.patch deleted file mode 100644 index bcae52edc9..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.106-107.patch +++ /dev/null @@ -1,3430 +0,0 @@ -diff --git a/Makefile b/Makefile -index a333b378f1f71..43159b21a83f4 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 106 -+SUBLEVEL = 107 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm64/include/asm/kvm_hyp.h b/arch/arm64/include/asm/kvm_hyp.h -index 97f21cc666579..7f7fdb16bb968 100644 ---- a/arch/arm64/include/asm/kvm_hyp.h -+++ b/arch/arm64/include/asm/kvm_hyp.h -@@ -71,6 +71,9 @@ void __sysreg32_restore_state(struct kvm_vcpu *vcpu); - - void __debug_switch_to_guest(struct kvm_vcpu *vcpu); - void __debug_switch_to_host(struct kvm_vcpu *vcpu); -+void __debug_save_host_buffers_nvhe(struct kvm_vcpu *vcpu); -+void __debug_restore_host_buffers_nvhe(struct kvm_vcpu *vcpu); -+ - - void __fpsimd_save_state(struct user_fpsimd_state *fp_regs); - void __fpsimd_restore_state(struct user_fpsimd_state *fp_regs); -diff --git a/arch/arm64/kvm/hyp/debug-sr.c b/arch/arm64/kvm/hyp/debug-sr.c -index 0fc9872a14671..aead8a5fbe919 100644 ---- a/arch/arm64/kvm/hyp/debug-sr.c -+++ b/arch/arm64/kvm/hyp/debug-sr.c -@@ -168,6 +168,21 @@ static void __hyp_text __debug_restore_state(struct kvm_vcpu *vcpu, - write_sysreg(ctxt->sys_regs[MDCCINT_EL1], mdccint_el1); - } - -+void __hyp_text __debug_save_host_buffers_nvhe(struct kvm_vcpu *vcpu) -+{ -+ /* -+ * Non-VHE: Disable and flush SPE data generation -+ * VHE: The vcpu can run, but it can't hide. -+ */ -+ __debug_save_spe_nvhe(&vcpu->arch.host_debug_state.pmscr_el1); -+ -+} -+ -+void __hyp_text __debug_restore_host_buffers_nvhe(struct kvm_vcpu *vcpu) -+{ -+ __debug_restore_spe_nvhe(vcpu->arch.host_debug_state.pmscr_el1); -+} -+ - void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu) - { - struct kvm_cpu_context *host_ctxt; -@@ -175,13 +190,6 @@ void __hyp_text __debug_switch_to_guest(struct kvm_vcpu *vcpu) - struct kvm_guest_debug_arch *host_dbg; - struct kvm_guest_debug_arch *guest_dbg; - -- /* -- * Non-VHE: Disable and flush SPE data generation -- * VHE: The vcpu can run, but it can't hide. -- */ -- if (!has_vhe()) -- __debug_save_spe_nvhe(&vcpu->arch.host_debug_state.pmscr_el1); -- - if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)) - return; - -@@ -201,8 +209,6 @@ void __hyp_text __debug_switch_to_host(struct kvm_vcpu *vcpu) - struct kvm_guest_debug_arch *host_dbg; - struct kvm_guest_debug_arch *guest_dbg; - -- if (!has_vhe()) -- __debug_restore_spe_nvhe(vcpu->arch.host_debug_state.pmscr_el1); - - if (!(vcpu->arch.flags & KVM_ARM64_DEBUG_DIRTY)) - return; -diff --git a/arch/arm64/kvm/hyp/switch.c b/arch/arm64/kvm/hyp/switch.c -index 84964983198e2..14607fac7ca38 100644 ---- a/arch/arm64/kvm/hyp/switch.c -+++ b/arch/arm64/kvm/hyp/switch.c -@@ -682,6 +682,15 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) - - __sysreg_save_state_nvhe(host_ctxt); - -+ /* -+ * We must flush and disable the SPE buffer for nVHE, as -+ * the translation regime(EL1&0) is going to be loaded with -+ * that of the guest. And we must do this before we change the -+ * translation regime to EL2 (via MDCR_EL2_EPB == 0) and -+ * before we load guest Stage1. -+ */ -+ __debug_save_host_buffers_nvhe(vcpu); -+ - __activate_vm(kern_hyp_va(vcpu->kvm)); - __activate_traps(vcpu); - -@@ -720,11 +729,13 @@ int __hyp_text __kvm_vcpu_run_nvhe(struct kvm_vcpu *vcpu) - if (vcpu->arch.flags & KVM_ARM64_FP_ENABLED) - __fpsimd_save_fpexc32(vcpu); - -+ __debug_switch_to_host(vcpu); -+ - /* - * This must come after restoring the host sysregs, since a non-VHE - * system may enable SPE here and make use of the TTBRs. - */ -- __debug_switch_to_host(vcpu); -+ __debug_restore_host_buffers_nvhe(vcpu); - - if (pmu_switch_needed) - __pmu_switch_to_host(host_ctxt); -diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S -index 9afeb58c910eb..dd954d8db629b 100644 ---- a/arch/x86/crypto/aesni-intel_asm.S -+++ b/arch/x86/crypto/aesni-intel_asm.S -@@ -319,7 +319,7 @@ _initial_blocks_\@: - - # Main loop - Encrypt/Decrypt remaining blocks - -- cmp $0, %r13 -+ test %r13, %r13 - je _zero_cipher_left_\@ - sub $64, %r13 - je _four_cipher_left_\@ -@@ -438,7 +438,7 @@ _multiple_of_16_bytes_\@: - - mov PBlockLen(%arg2), %r12 - -- cmp $0, %r12 -+ test %r12, %r12 - je _partial_done\@ - - GHASH_MUL %xmm8, %xmm13, %xmm9, %xmm10, %xmm11, %xmm5, %xmm6 -@@ -475,7 +475,7 @@ _T_8_\@: - add $8, %r10 - sub $8, %r11 - psrldq $8, %xmm0 -- cmp $0, %r11 -+ test %r11, %r11 - je _return_T_done_\@ - _T_4_\@: - movd %xmm0, %eax -@@ -483,7 +483,7 @@ _T_4_\@: - add $4, %r10 - sub $4, %r11 - psrldq $4, %xmm0 -- cmp $0, %r11 -+ test %r11, %r11 - je _return_T_done_\@ - _T_123_\@: - movd %xmm0, %eax -@@ -620,7 +620,7 @@ _get_AAD_blocks\@: - - /* read the last <16B of AAD */ - _get_AAD_rest\@: -- cmp $0, %r11 -+ test %r11, %r11 - je _get_AAD_done\@ - - READ_PARTIAL_BLOCK %r10, %r11, \TMP1, \TMP7 -@@ -641,7 +641,7 @@ _get_AAD_done\@: - .macro PARTIAL_BLOCK CYPH_PLAIN_OUT PLAIN_CYPH_IN PLAIN_CYPH_LEN DATA_OFFSET \ - AAD_HASH operation - mov PBlockLen(%arg2), %r13 -- cmp $0, %r13 -+ test %r13, %r13 - je _partial_block_done_\@ # Leave Macro if no partial blocks - # Read in input data without over reading - cmp $16, \PLAIN_CYPH_LEN -@@ -693,7 +693,7 @@ _no_extra_mask_1_\@: - PSHUFB_XMM %xmm2, %xmm3 - pxor %xmm3, \AAD_HASH - -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_incomplete_1_\@ - - # GHASH computation for the last <16 Byte block -@@ -728,7 +728,7 @@ _no_extra_mask_2_\@: - PSHUFB_XMM %xmm2, %xmm9 - pxor %xmm9, \AAD_HASH - -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_incomplete_2_\@ - - # GHASH computation for the last <16 Byte block -@@ -748,7 +748,7 @@ _encode_done_\@: - PSHUFB_XMM %xmm2, %xmm9 - .endif - # output encrypted Bytes -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_fill_\@ - mov %r13, %r12 - mov $16, %r13 -@@ -1946,7 +1946,7 @@ ENTRY(aesni_set_key) - ENDPROC(aesni_set_key) - - /* -- * void aesni_enc(struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) -+ * void aesni_enc(const void *ctx, u8 *dst, const u8 *src) - */ - ENTRY(aesni_enc) - FRAME_BEGIN -@@ -2137,7 +2137,7 @@ _aesni_enc4: - ENDPROC(_aesni_enc4) - - /* -- * void aesni_dec (struct crypto_aes_ctx *ctx, u8 *dst, const u8 *src) -+ * void aesni_dec (const void *ctx, u8 *dst, const u8 *src) - */ - ENTRY(aesni_dec) - FRAME_BEGIN -@@ -2726,25 +2726,18 @@ ENDPROC(aesni_ctr_enc) - pxor CTR, IV; - - /* -- * void aesni_xts_crypt8(struct crypto_aes_ctx *ctx, const u8 *dst, u8 *src, -- * bool enc, u8 *iv) -+ * void aesni_xts_encrypt(const struct crypto_aes_ctx *ctx, u8 *dst, -+ * const u8 *src, unsigned int len, le128 *iv) - */ --ENTRY(aesni_xts_crypt8) -+ENTRY(aesni_xts_encrypt) - FRAME_BEGIN -- cmpb $0, %cl -- movl $0, %ecx -- movl $240, %r10d -- leaq _aesni_enc4, %r11 -- leaq _aesni_dec4, %rax -- cmovel %r10d, %ecx -- cmoveq %rax, %r11 - - movdqa .Lgf128mul_x_ble_mask, GF128MUL_MASK - movups (IVP), IV - - mov 480(KEYP), KLEN -- addq %rcx, KEYP - -+.Lxts_enc_loop4: - movdqa IV, STATE1 - movdqu 0x00(INP), INC - pxor INC, STATE1 -@@ -2768,71 +2761,103 @@ ENTRY(aesni_xts_crypt8) - pxor INC, STATE4 - movdqu IV, 0x30(OUTP) - -- CALL_NOSPEC %r11 -+ call _aesni_enc4 - - movdqu 0x00(OUTP), INC - pxor INC, STATE1 - movdqu STATE1, 0x00(OUTP) - -- _aesni_gf128mul_x_ble() -- movdqa IV, STATE1 -- movdqu 0x40(INP), INC -- pxor INC, STATE1 -- movdqu IV, 0x40(OUTP) -- - movdqu 0x10(OUTP), INC - pxor INC, STATE2 - movdqu STATE2, 0x10(OUTP) - -- _aesni_gf128mul_x_ble() -- movdqa IV, STATE2 -- movdqu 0x50(INP), INC -- pxor INC, STATE2 -- movdqu IV, 0x50(OUTP) -- - movdqu 0x20(OUTP), INC - pxor INC, STATE3 - movdqu STATE3, 0x20(OUTP) - -- _aesni_gf128mul_x_ble() -- movdqa IV, STATE3 -- movdqu 0x60(INP), INC -- pxor INC, STATE3 -- movdqu IV, 0x60(OUTP) -- - movdqu 0x30(OUTP), INC - pxor INC, STATE4 - movdqu STATE4, 0x30(OUTP) - - _aesni_gf128mul_x_ble() -- movdqa IV, STATE4 -- movdqu 0x70(INP), INC -- pxor INC, STATE4 -- movdqu IV, 0x70(OUTP) - -- _aesni_gf128mul_x_ble() -+ add $64, INP -+ add $64, OUTP -+ sub $64, LEN -+ ja .Lxts_enc_loop4 -+ - movups IV, (IVP) - -- CALL_NOSPEC %r11 -+ FRAME_END -+ ret -+ENDPROC(aesni_xts_encrypt) -+ -+/* -+ * void aesni_xts_decrypt(const struct crypto_aes_ctx *ctx, u8 *dst, -+ * const u8 *src, unsigned int len, le128 *iv) -+ */ -+ENTRY(aesni_xts_decrypt) -+ FRAME_BEGIN -+ -+ movdqa .Lgf128mul_x_ble_mask, GF128MUL_MASK -+ movups (IVP), IV -+ -+ mov 480(KEYP), KLEN -+ add $240, KEYP - -- movdqu 0x40(OUTP), INC -+.Lxts_dec_loop4: -+ movdqa IV, STATE1 -+ movdqu 0x00(INP), INC - pxor INC, STATE1 -- movdqu STATE1, 0x40(OUTP) -+ movdqu IV, 0x00(OUTP) - -- movdqu 0x50(OUTP), INC -+ _aesni_gf128mul_x_ble() -+ movdqa IV, STATE2 -+ movdqu 0x10(INP), INC -+ pxor INC, STATE2 -+ movdqu IV, 0x10(OUTP) -+ -+ _aesni_gf128mul_x_ble() -+ movdqa IV, STATE3 -+ movdqu 0x20(INP), INC -+ pxor INC, STATE3 -+ movdqu IV, 0x20(OUTP) -+ -+ _aesni_gf128mul_x_ble() -+ movdqa IV, STATE4 -+ movdqu 0x30(INP), INC -+ pxor INC, STATE4 -+ movdqu IV, 0x30(OUTP) -+ -+ call _aesni_dec4 -+ -+ movdqu 0x00(OUTP), INC -+ pxor INC, STATE1 -+ movdqu STATE1, 0x00(OUTP) -+ -+ movdqu 0x10(OUTP), INC - pxor INC, STATE2 -- movdqu STATE2, 0x50(OUTP) -+ movdqu STATE2, 0x10(OUTP) - -- movdqu 0x60(OUTP), INC -+ movdqu 0x20(OUTP), INC - pxor INC, STATE3 -- movdqu STATE3, 0x60(OUTP) -+ movdqu STATE3, 0x20(OUTP) - -- movdqu 0x70(OUTP), INC -+ movdqu 0x30(OUTP), INC - pxor INC, STATE4 -- movdqu STATE4, 0x70(OUTP) -+ movdqu STATE4, 0x30(OUTP) -+ -+ _aesni_gf128mul_x_ble() -+ -+ add $64, INP -+ add $64, OUTP -+ sub $64, LEN -+ ja .Lxts_dec_loop4 -+ -+ movups IV, (IVP) - - FRAME_END - ret --ENDPROC(aesni_xts_crypt8) -+ENDPROC(aesni_xts_decrypt) - - #endif -diff --git a/arch/x86/crypto/aesni-intel_avx-x86_64.S b/arch/x86/crypto/aesni-intel_avx-x86_64.S -index 91c039ab56999..4e4d34956170b 100644 ---- a/arch/x86/crypto/aesni-intel_avx-x86_64.S -+++ b/arch/x86/crypto/aesni-intel_avx-x86_64.S -@@ -370,7 +370,7 @@ _initial_num_blocks_is_0\@: - - - _initial_blocks_encrypted\@: -- cmp $0, %r13 -+ test %r13, %r13 - je _zero_cipher_left\@ - - sub $128, %r13 -@@ -529,7 +529,7 @@ _multiple_of_16_bytes\@: - vmovdqu HashKey(arg2), %xmm13 - - mov PBlockLen(arg2), %r12 -- cmp $0, %r12 -+ test %r12, %r12 - je _partial_done\@ - - #GHASH computation for the last <16 Byte block -@@ -574,7 +574,7 @@ _T_8\@: - add $8, %r10 - sub $8, %r11 - vpsrldq $8, %xmm9, %xmm9 -- cmp $0, %r11 -+ test %r11, %r11 - je _return_T_done\@ - _T_4\@: - vmovd %xmm9, %eax -@@ -582,7 +582,7 @@ _T_4\@: - add $4, %r10 - sub $4, %r11 - vpsrldq $4, %xmm9, %xmm9 -- cmp $0, %r11 -+ test %r11, %r11 - je _return_T_done\@ - _T_123\@: - vmovd %xmm9, %eax -@@ -626,7 +626,7 @@ _get_AAD_blocks\@: - cmp $16, %r11 - jge _get_AAD_blocks\@ - vmovdqu \T8, \T7 -- cmp $0, %r11 -+ test %r11, %r11 - je _get_AAD_done\@ - - vpxor \T7, \T7, \T7 -@@ -645,7 +645,7 @@ _get_AAD_rest8\@: - vpxor \T1, \T7, \T7 - jmp _get_AAD_rest8\@ - _get_AAD_rest4\@: -- cmp $0, %r11 -+ test %r11, %r11 - jle _get_AAD_rest0\@ - mov (%r10), %eax - movq %rax, \T1 -@@ -750,7 +750,7 @@ _done_read_partial_block_\@: - .macro PARTIAL_BLOCK GHASH_MUL CYPH_PLAIN_OUT PLAIN_CYPH_IN PLAIN_CYPH_LEN DATA_OFFSET \ - AAD_HASH ENC_DEC - mov PBlockLen(arg2), %r13 -- cmp $0, %r13 -+ test %r13, %r13 - je _partial_block_done_\@ # Leave Macro if no partial blocks - # Read in input data without over reading - cmp $16, \PLAIN_CYPH_LEN -@@ -802,7 +802,7 @@ _no_extra_mask_1_\@: - vpshufb %xmm2, %xmm3, %xmm3 - vpxor %xmm3, \AAD_HASH, \AAD_HASH - -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_incomplete_1_\@ - - # GHASH computation for the last <16 Byte block -@@ -837,7 +837,7 @@ _no_extra_mask_2_\@: - vpshufb %xmm2, %xmm9, %xmm9 - vpxor %xmm9, \AAD_HASH, \AAD_HASH - -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_incomplete_2_\@ - - # GHASH computation for the last <16 Byte block -@@ -857,7 +857,7 @@ _encode_done_\@: - vpshufb %xmm2, %xmm9, %xmm9 - .endif - # output encrypted Bytes -- cmp $0, %r10 -+ test %r10, %r10 - jl _partial_fill_\@ - mov %r13, %r12 - mov $16, %r13 -diff --git a/arch/x86/crypto/aesni-intel_glue.c b/arch/x86/crypto/aesni-intel_glue.c -index 88ad272aa2b46..18cfb76daa232 100644 ---- a/arch/x86/crypto/aesni-intel_glue.c -+++ b/arch/x86/crypto/aesni-intel_glue.c -@@ -83,10 +83,8 @@ struct gcm_context_data { - - asmlinkage int aesni_set_key(struct crypto_aes_ctx *ctx, const u8 *in_key, - unsigned int key_len); --asmlinkage void aesni_enc(struct crypto_aes_ctx *ctx, u8 *out, -- const u8 *in); --asmlinkage void aesni_dec(struct crypto_aes_ctx *ctx, u8 *out, -- const u8 *in); -+asmlinkage void aesni_enc(const void *ctx, u8 *out, const u8 *in); -+asmlinkage void aesni_dec(const void *ctx, u8 *out, const u8 *in); - asmlinkage void aesni_ecb_enc(struct crypto_aes_ctx *ctx, u8 *out, - const u8 *in, unsigned int len); - asmlinkage void aesni_ecb_dec(struct crypto_aes_ctx *ctx, u8 *out, -@@ -99,6 +97,12 @@ asmlinkage void aesni_cbc_dec(struct crypto_aes_ctx *ctx, u8 *out, - #define AVX_GEN2_OPTSIZE 640 - #define AVX_GEN4_OPTSIZE 4096 - -+asmlinkage void aesni_xts_encrypt(const struct crypto_aes_ctx *ctx, u8 *out, -+ const u8 *in, unsigned int len, u8 *iv); -+ -+asmlinkage void aesni_xts_decrypt(const struct crypto_aes_ctx *ctx, u8 *out, -+ const u8 *in, unsigned int len, u8 *iv); -+ - #ifdef CONFIG_X86_64 - - static void (*aesni_ctr_enc_tfm)(struct crypto_aes_ctx *ctx, u8 *out, -@@ -106,9 +110,6 @@ static void (*aesni_ctr_enc_tfm)(struct crypto_aes_ctx *ctx, u8 *out, - asmlinkage void aesni_ctr_enc(struct crypto_aes_ctx *ctx, u8 *out, - const u8 *in, unsigned int len, u8 *iv); - --asmlinkage void aesni_xts_crypt8(struct crypto_aes_ctx *ctx, u8 *out, -- const u8 *in, bool enc, u8 *iv); -- - /* asmlinkage void aesni_gcm_enc() - * void *ctx, AES Key schedule. Starts on a 16 byte boundary. - * struct gcm_context_data. May be uninitialized. -@@ -550,29 +551,24 @@ static int xts_aesni_setkey(struct crypto_skcipher *tfm, const u8 *key, - } - - --static void aesni_xts_tweak(void *ctx, u8 *out, const u8 *in) --{ -- aesni_enc(ctx, out, in); --} -- --static void aesni_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void aesni_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, GLUE_FUNC_CAST(aesni_enc)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, aesni_enc); - } - --static void aesni_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void aesni_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, GLUE_FUNC_CAST(aesni_dec)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, aesni_dec); - } - --static void aesni_xts_enc8(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void aesni_xts_enc32(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- aesni_xts_crypt8(ctx, (u8 *)dst, (const u8 *)src, true, (u8 *)iv); -+ aesni_xts_encrypt(ctx, dst, src, 32 * AES_BLOCK_SIZE, (u8 *)iv); - } - --static void aesni_xts_dec8(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void aesni_xts_dec32(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- aesni_xts_crypt8(ctx, (u8 *)dst, (const u8 *)src, false, (u8 *)iv); -+ aesni_xts_decrypt(ctx, dst, src, 32 * AES_BLOCK_SIZE, (u8 *)iv); - } - - static const struct common_glue_ctx aesni_enc_xts = { -@@ -580,11 +576,11 @@ static const struct common_glue_ctx aesni_enc_xts = { - .fpu_blocks_limit = 1, - - .funcs = { { -- .num_blocks = 8, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(aesni_xts_enc8) } -+ .num_blocks = 32, -+ .fn_u = { .xts = aesni_xts_enc32 } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(aesni_xts_enc) } -+ .fn_u = { .xts = aesni_xts_enc } - } } - }; - -@@ -593,11 +589,11 @@ static const struct common_glue_ctx aesni_dec_xts = { - .fpu_blocks_limit = 1, - - .funcs = { { -- .num_blocks = 8, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(aesni_xts_dec8) } -+ .num_blocks = 32, -+ .fn_u = { .xts = aesni_xts_dec32 } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(aesni_xts_dec) } -+ .fn_u = { .xts = aesni_xts_dec } - } } - }; - -@@ -606,8 +602,7 @@ static int xts_encrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct aesni_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&aesni_enc_xts, req, -- XTS_TWEAK_CAST(aesni_xts_tweak), -+ return glue_xts_req_128bit(&aesni_enc_xts, req, aesni_enc, - aes_ctx(ctx->raw_tweak_ctx), - aes_ctx(ctx->raw_crypt_ctx), - false); -@@ -618,8 +613,7 @@ static int xts_decrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct aesni_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&aesni_dec_xts, req, -- XTS_TWEAK_CAST(aesni_xts_tweak), -+ return glue_xts_req_128bit(&aesni_dec_xts, req, aesni_enc, - aes_ctx(ctx->raw_tweak_ctx), - aes_ctx(ctx->raw_crypt_ctx), - true); -diff --git a/arch/x86/crypto/camellia_aesni_avx2_glue.c b/arch/x86/crypto/camellia_aesni_avx2_glue.c -index a4f00128ea552..a8cc2c83fe1bb 100644 ---- a/arch/x86/crypto/camellia_aesni_avx2_glue.c -+++ b/arch/x86/crypto/camellia_aesni_avx2_glue.c -@@ -19,20 +19,17 @@ - #define CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS 32 - - /* 32-way AVX2/AES-NI parallel cipher functions */ --asmlinkage void camellia_ecb_enc_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void camellia_ecb_dec_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_ecb_enc_32way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void camellia_ecb_dec_32way(const void *ctx, u8 *dst, const u8 *src); - --asmlinkage void camellia_cbc_dec_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void camellia_ctr_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void camellia_cbc_dec_32way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void camellia_ctr_32way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - --asmlinkage void camellia_xts_enc_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); --asmlinkage void camellia_xts_dec_32way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void camellia_xts_enc_32way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+asmlinkage void camellia_xts_dec_32way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - - static const struct common_glue_ctx camellia_enc = { - .num_funcs = 4, -@@ -40,16 +37,16 @@ static const struct common_glue_ctx camellia_enc = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_enc_32way) } -+ .fn_u = { .ecb = camellia_ecb_enc_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_enc_16way) } -+ .fn_u = { .ecb = camellia_ecb_enc_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk_2way) } -+ .fn_u = { .ecb = camellia_enc_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk) } -+ .fn_u = { .ecb = camellia_enc_blk } - } } - }; - -@@ -59,16 +56,16 @@ static const struct common_glue_ctx camellia_ctr = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_ctr_32way) } -+ .fn_u = { .ctr = camellia_ctr_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_ctr_16way) } -+ .fn_u = { .ctr = camellia_ctr_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way) } -+ .fn_u = { .ctr = camellia_crypt_ctr_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr) } -+ .fn_u = { .ctr = camellia_crypt_ctr } - } } - }; - -@@ -78,13 +75,13 @@ static const struct common_glue_ctx camellia_enc_xts = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_enc_32way) } -+ .fn_u = { .xts = camellia_xts_enc_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_enc_16way) } -+ .fn_u = { .xts = camellia_xts_enc_16way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_enc) } -+ .fn_u = { .xts = camellia_xts_enc } - } } - }; - -@@ -94,16 +91,16 @@ static const struct common_glue_ctx camellia_dec = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_dec_32way) } -+ .fn_u = { .ecb = camellia_ecb_dec_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_dec_16way) } -+ .fn_u = { .ecb = camellia_ecb_dec_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk_2way) } -+ .fn_u = { .ecb = camellia_dec_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .ecb = camellia_dec_blk } - } } - }; - -@@ -113,16 +110,16 @@ static const struct common_glue_ctx camellia_dec_cbc = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_cbc_dec_32way) } -+ .fn_u = { .cbc = camellia_cbc_dec_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_cbc_dec_16way) } -+ .fn_u = { .cbc = camellia_cbc_dec_16way } - }, { - .num_blocks = 2, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way) } -+ .fn_u = { .cbc = camellia_decrypt_cbc_2way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .cbc = camellia_dec_blk } - } } - }; - -@@ -132,13 +129,13 @@ static const struct common_glue_ctx camellia_dec_xts = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_AVX2_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_dec_32way) } -+ .fn_u = { .xts = camellia_xts_dec_32way } - }, { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_dec_16way) } -+ .fn_u = { .xts = camellia_xts_dec_16way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_dec) } -+ .fn_u = { .xts = camellia_xts_dec } - } } - }; - -@@ -161,8 +158,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(camellia_enc_blk), -- req); -+ return glue_cbc_encrypt_req_128bit(camellia_enc_blk, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -180,8 +176,7 @@ static int xts_encrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct camellia_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&camellia_enc_xts, req, -- XTS_TWEAK_CAST(camellia_enc_blk), -+ return glue_xts_req_128bit(&camellia_enc_xts, req, camellia_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, false); - } - -@@ -190,8 +185,7 @@ static int xts_decrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct camellia_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&camellia_dec_xts, req, -- XTS_TWEAK_CAST(camellia_enc_blk), -+ return glue_xts_req_128bit(&camellia_dec_xts, req, camellia_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, true); - } - -diff --git a/arch/x86/crypto/camellia_aesni_avx_glue.c b/arch/x86/crypto/camellia_aesni_avx_glue.c -index f28d282779b87..31a82a79f4ac9 100644 ---- a/arch/x86/crypto/camellia_aesni_avx_glue.c -+++ b/arch/x86/crypto/camellia_aesni_avx_glue.c -@@ -18,41 +18,36 @@ - #define CAMELLIA_AESNI_PARALLEL_BLOCKS 16 - - /* 16-way parallel cipher functions (avx/aes-ni) */ --asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src); - EXPORT_SYMBOL_GPL(camellia_ecb_enc_16way); - --asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src); - EXPORT_SYMBOL_GPL(camellia_ecb_dec_16way); - --asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src); - EXPORT_SYMBOL_GPL(camellia_cbc_dec_16way); - --asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void camellia_ctr_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - EXPORT_SYMBOL_GPL(camellia_ctr_16way); - --asmlinkage void camellia_xts_enc_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void camellia_xts_enc_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - EXPORT_SYMBOL_GPL(camellia_xts_enc_16way); - --asmlinkage void camellia_xts_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void camellia_xts_dec_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - EXPORT_SYMBOL_GPL(camellia_xts_dec_16way); - --void camellia_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void camellia_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(camellia_enc_blk)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, camellia_enc_blk); - } - EXPORT_SYMBOL_GPL(camellia_xts_enc); - --void camellia_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void camellia_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(camellia_dec_blk)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, camellia_dec_blk); - } - EXPORT_SYMBOL_GPL(camellia_xts_dec); - -@@ -62,13 +57,13 @@ static const struct common_glue_ctx camellia_enc = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_enc_16way) } -+ .fn_u = { .ecb = camellia_ecb_enc_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk_2way) } -+ .fn_u = { .ecb = camellia_enc_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk) } -+ .fn_u = { .ecb = camellia_enc_blk } - } } - }; - -@@ -78,13 +73,13 @@ static const struct common_glue_ctx camellia_ctr = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_ctr_16way) } -+ .fn_u = { .ctr = camellia_ctr_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way) } -+ .fn_u = { .ctr = camellia_crypt_ctr_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr) } -+ .fn_u = { .ctr = camellia_crypt_ctr } - } } - }; - -@@ -94,10 +89,10 @@ static const struct common_glue_ctx camellia_enc_xts = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_enc_16way) } -+ .fn_u = { .xts = camellia_xts_enc_16way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_enc) } -+ .fn_u = { .xts = camellia_xts_enc } - } } - }; - -@@ -107,13 +102,13 @@ static const struct common_glue_ctx camellia_dec = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_ecb_dec_16way) } -+ .fn_u = { .ecb = camellia_ecb_dec_16way } - }, { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk_2way) } -+ .fn_u = { .ecb = camellia_dec_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .ecb = camellia_dec_blk } - } } - }; - -@@ -123,13 +118,13 @@ static const struct common_glue_ctx camellia_dec_cbc = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_cbc_dec_16way) } -+ .fn_u = { .cbc = camellia_cbc_dec_16way } - }, { - .num_blocks = 2, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way) } -+ .fn_u = { .cbc = camellia_decrypt_cbc_2way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .cbc = camellia_dec_blk } - } } - }; - -@@ -139,10 +134,10 @@ static const struct common_glue_ctx camellia_dec_xts = { - - .funcs = { { - .num_blocks = CAMELLIA_AESNI_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_dec_16way) } -+ .fn_u = { .xts = camellia_xts_dec_16way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(camellia_xts_dec) } -+ .fn_u = { .xts = camellia_xts_dec } - } } - }; - -@@ -165,8 +160,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(camellia_enc_blk), -- req); -+ return glue_cbc_encrypt_req_128bit(camellia_enc_blk, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -206,8 +200,7 @@ static int xts_encrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct camellia_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&camellia_enc_xts, req, -- XTS_TWEAK_CAST(camellia_enc_blk), -+ return glue_xts_req_128bit(&camellia_enc_xts, req, camellia_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, false); - } - -@@ -216,8 +209,7 @@ static int xts_decrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct camellia_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&camellia_dec_xts, req, -- XTS_TWEAK_CAST(camellia_enc_blk), -+ return glue_xts_req_128bit(&camellia_dec_xts, req, camellia_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, true); - } - -diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c -index 7c62db56ffe1b..5f3ed5af68d70 100644 ---- a/arch/x86/crypto/camellia_glue.c -+++ b/arch/x86/crypto/camellia_glue.c -@@ -18,19 +18,17 @@ - #include - - /* regular block cipher functions */ --asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, bool xor); -+asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src, -+ bool xor); - EXPORT_SYMBOL_GPL(__camellia_enc_blk); --asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src); - EXPORT_SYMBOL_GPL(camellia_dec_blk); - - /* 2-way parallel cipher functions */ --asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, bool xor); -+asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src, -+ bool xor); - EXPORT_SYMBOL_GPL(__camellia_enc_blk_2way); --asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src); - EXPORT_SYMBOL_GPL(camellia_dec_blk_2way); - - static void camellia_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) -@@ -1267,8 +1265,10 @@ static int camellia_setkey_skcipher(struct crypto_skcipher *tfm, const u8 *key, - return camellia_setkey(&tfm->base, key, key_len); - } - --void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src) -+void camellia_decrypt_cbc_2way(const void *ctx, u8 *d, const u8 *s) - { -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - u128 iv = *src; - - camellia_dec_blk_2way(ctx, (u8 *)dst, (u8 *)src); -@@ -1277,9 +1277,11 @@ void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src) - } - EXPORT_SYMBOL_GPL(camellia_decrypt_cbc_2way); - --void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void camellia_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblk; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - if (dst != src) - *dst = *src; -@@ -1291,9 +1293,11 @@ void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) - } - EXPORT_SYMBOL_GPL(camellia_crypt_ctr); - --void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void camellia_crypt_ctr_2way(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblks[2]; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - if (dst != src) { - dst[0] = src[0]; -@@ -1315,10 +1319,10 @@ static const struct common_glue_ctx camellia_enc = { - - .funcs = { { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk_2way) } -+ .fn_u = { .ecb = camellia_enc_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_enc_blk) } -+ .fn_u = { .ecb = camellia_enc_blk } - } } - }; - -@@ -1328,10 +1332,10 @@ static const struct common_glue_ctx camellia_ctr = { - - .funcs = { { - .num_blocks = 2, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr_2way) } -+ .fn_u = { .ctr = camellia_crypt_ctr_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(camellia_crypt_ctr) } -+ .fn_u = { .ctr = camellia_crypt_ctr } - } } - }; - -@@ -1341,10 +1345,10 @@ static const struct common_glue_ctx camellia_dec = { - - .funcs = { { - .num_blocks = 2, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk_2way) } -+ .fn_u = { .ecb = camellia_dec_blk_2way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .ecb = camellia_dec_blk } - } } - }; - -@@ -1354,10 +1358,10 @@ static const struct common_glue_ctx camellia_dec_cbc = { - - .funcs = { { - .num_blocks = 2, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_decrypt_cbc_2way) } -+ .fn_u = { .cbc = camellia_decrypt_cbc_2way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(camellia_dec_blk) } -+ .fn_u = { .cbc = camellia_dec_blk } - } } - }; - -@@ -1373,8 +1377,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(camellia_enc_blk), -- req); -+ return glue_cbc_encrypt_req_128bit(camellia_enc_blk, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -diff --git a/arch/x86/crypto/cast6_avx_glue.c b/arch/x86/crypto/cast6_avx_glue.c -index a8a38fffb4a98..da5297475f9ec 100644 ---- a/arch/x86/crypto/cast6_avx_glue.c -+++ b/arch/x86/crypto/cast6_avx_glue.c -@@ -20,20 +20,17 @@ - - #define CAST6_PARALLEL_BLOCKS 8 - --asmlinkage void cast6_ecb_enc_8way(struct cast6_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void cast6_ecb_dec_8way(struct cast6_ctx *ctx, u8 *dst, -- const u8 *src); -- --asmlinkage void cast6_cbc_dec_8way(struct cast6_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void cast6_ctr_8way(struct cast6_ctx *ctx, u8 *dst, const u8 *src, -+asmlinkage void cast6_ecb_enc_8way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void cast6_ecb_dec_8way(const void *ctx, u8 *dst, const u8 *src); -+ -+asmlinkage void cast6_cbc_dec_8way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void cast6_ctr_8way(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); - --asmlinkage void cast6_xts_enc_8way(struct cast6_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); --asmlinkage void cast6_xts_dec_8way(struct cast6_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void cast6_xts_enc_8way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+asmlinkage void cast6_xts_dec_8way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - - static int cast6_setkey_skcipher(struct crypto_skcipher *tfm, - const u8 *key, unsigned int keylen) -@@ -41,21 +38,21 @@ static int cast6_setkey_skcipher(struct crypto_skcipher *tfm, - return cast6_setkey(&tfm->base, key, keylen); - } - --static void cast6_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void cast6_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(__cast6_encrypt)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, __cast6_encrypt); - } - --static void cast6_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void cast6_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(__cast6_decrypt)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, __cast6_decrypt); - } - --static void cast6_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void cast6_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblk; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - le128_to_be128(&ctrblk, iv); - le128_inc(iv); -@@ -70,10 +67,10 @@ static const struct common_glue_ctx cast6_enc = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_ecb_enc_8way) } -+ .fn_u = { .ecb = cast6_ecb_enc_8way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_encrypt) } -+ .fn_u = { .ecb = __cast6_encrypt } - } } - }; - -@@ -83,10 +80,10 @@ static const struct common_glue_ctx cast6_ctr = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_ctr_8way) } -+ .fn_u = { .ctr = cast6_ctr_8way } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(cast6_crypt_ctr) } -+ .fn_u = { .ctr = cast6_crypt_ctr } - } } - }; - -@@ -96,10 +93,10 @@ static const struct common_glue_ctx cast6_enc_xts = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(cast6_xts_enc_8way) } -+ .fn_u = { .xts = cast6_xts_enc_8way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(cast6_xts_enc) } -+ .fn_u = { .xts = cast6_xts_enc } - } } - }; - -@@ -109,10 +106,10 @@ static const struct common_glue_ctx cast6_dec = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(cast6_ecb_dec_8way) } -+ .fn_u = { .ecb = cast6_ecb_dec_8way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__cast6_decrypt) } -+ .fn_u = { .ecb = __cast6_decrypt } - } } - }; - -@@ -122,10 +119,10 @@ static const struct common_glue_ctx cast6_dec_cbc = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(cast6_cbc_dec_8way) } -+ .fn_u = { .cbc = cast6_cbc_dec_8way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__cast6_decrypt) } -+ .fn_u = { .cbc = __cast6_decrypt } - } } - }; - -@@ -135,10 +132,10 @@ static const struct common_glue_ctx cast6_dec_xts = { - - .funcs = { { - .num_blocks = CAST6_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(cast6_xts_dec_8way) } -+ .fn_u = { .xts = cast6_xts_dec_8way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(cast6_xts_dec) } -+ .fn_u = { .xts = cast6_xts_dec } - } } - }; - -@@ -154,8 +151,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(__cast6_encrypt), -- req); -+ return glue_cbc_encrypt_req_128bit(__cast6_encrypt, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -199,8 +195,7 @@ static int xts_encrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct cast6_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&cast6_enc_xts, req, -- XTS_TWEAK_CAST(__cast6_encrypt), -+ return glue_xts_req_128bit(&cast6_enc_xts, req, __cast6_encrypt, - &ctx->tweak_ctx, &ctx->crypt_ctx, false); - } - -@@ -209,8 +204,7 @@ static int xts_decrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct cast6_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&cast6_dec_xts, req, -- XTS_TWEAK_CAST(__cast6_encrypt), -+ return glue_xts_req_128bit(&cast6_dec_xts, req, __cast6_encrypt, - &ctx->tweak_ctx, &ctx->crypt_ctx, true); - } - -diff --git a/arch/x86/crypto/glue_helper.c b/arch/x86/crypto/glue_helper.c -index d15b99397480b..d3d91a0abf88f 100644 ---- a/arch/x86/crypto/glue_helper.c -+++ b/arch/x86/crypto/glue_helper.c -@@ -134,7 +134,8 @@ int glue_cbc_decrypt_req_128bit(const struct common_glue_ctx *gctx, - src -= num_blocks - 1; - dst -= num_blocks - 1; - -- gctx->funcs[i].fn_u.cbc(ctx, dst, src); -+ gctx->funcs[i].fn_u.cbc(ctx, (u8 *)dst, -+ (const u8 *)src); - - nbytes -= func_bytes; - if (nbytes < bsize) -@@ -188,7 +189,9 @@ int glue_ctr_req_128bit(const struct common_glue_ctx *gctx, - - /* Process multi-block batch */ - do { -- gctx->funcs[i].fn_u.ctr(ctx, dst, src, &ctrblk); -+ gctx->funcs[i].fn_u.ctr(ctx, (u8 *)dst, -+ (const u8 *)src, -+ &ctrblk); - src += num_blocks; - dst += num_blocks; - nbytes -= func_bytes; -@@ -210,7 +213,8 @@ int glue_ctr_req_128bit(const struct common_glue_ctx *gctx, - - be128_to_le128(&ctrblk, (be128 *)walk.iv); - memcpy(&tmp, walk.src.virt.addr, nbytes); -- gctx->funcs[gctx->num_funcs - 1].fn_u.ctr(ctx, &tmp, &tmp, -+ gctx->funcs[gctx->num_funcs - 1].fn_u.ctr(ctx, (u8 *)&tmp, -+ (const u8 *)&tmp, - &ctrblk); - memcpy(walk.dst.virt.addr, &tmp, nbytes); - le128_to_be128((be128 *)walk.iv, &ctrblk); -@@ -240,7 +244,8 @@ static unsigned int __glue_xts_req_128bit(const struct common_glue_ctx *gctx, - - if (nbytes >= func_bytes) { - do { -- gctx->funcs[i].fn_u.xts(ctx, dst, src, -+ gctx->funcs[i].fn_u.xts(ctx, (u8 *)dst, -+ (const u8 *)src, - walk->iv); - - src += num_blocks; -@@ -354,8 +359,8 @@ out: - } - EXPORT_SYMBOL_GPL(glue_xts_req_128bit); - --void glue_xts_crypt_128bit_one(void *ctx, u128 *dst, const u128 *src, le128 *iv, -- common_glue_func_t fn) -+void glue_xts_crypt_128bit_one(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv, common_glue_func_t fn) - { - le128 ivblk = *iv; - -@@ -363,13 +368,13 @@ void glue_xts_crypt_128bit_one(void *ctx, u128 *dst, const u128 *src, le128 *iv, - gf128mul_x_ble(iv, &ivblk); - - /* CC <- T xor C */ -- u128_xor(dst, src, (u128 *)&ivblk); -+ u128_xor((u128 *)dst, (const u128 *)src, (u128 *)&ivblk); - - /* PP <- D(Key2,CC) */ -- fn(ctx, (u8 *)dst, (u8 *)dst); -+ fn(ctx, dst, dst); - - /* P <- T xor PP */ -- u128_xor(dst, dst, (u128 *)&ivblk); -+ u128_xor((u128 *)dst, (u128 *)dst, (u128 *)&ivblk); - } - EXPORT_SYMBOL_GPL(glue_xts_crypt_128bit_one); - -diff --git a/arch/x86/crypto/serpent_avx2_glue.c b/arch/x86/crypto/serpent_avx2_glue.c -index 13fd8d3d2da00..f973ace44ad35 100644 ---- a/arch/x86/crypto/serpent_avx2_glue.c -+++ b/arch/x86/crypto/serpent_avx2_glue.c -@@ -19,18 +19,16 @@ - #define SERPENT_AVX2_PARALLEL_BLOCKS 16 - - /* 16-way AVX2 parallel cipher functions */ --asmlinkage void serpent_ecb_enc_16way(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void serpent_ecb_dec_16way(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void serpent_cbc_dec_16way(void *ctx, u128 *dst, const u128 *src); -+asmlinkage void serpent_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void serpent_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void serpent_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src); - --asmlinkage void serpent_ctr_16way(void *ctx, u128 *dst, const u128 *src, -+asmlinkage void serpent_ctr_16way(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); --asmlinkage void serpent_xts_enc_16way(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); --asmlinkage void serpent_xts_dec_16way(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void serpent_xts_enc_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+asmlinkage void serpent_xts_dec_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - - static int serpent_setkey_skcipher(struct crypto_skcipher *tfm, - const u8 *key, unsigned int keylen) -@@ -44,13 +42,13 @@ static const struct common_glue_ctx serpent_enc = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_enc_16way) } -+ .fn_u = { .ecb = serpent_ecb_enc_16way } - }, { - .num_blocks = 8, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_enc_8way_avx) } -+ .fn_u = { .ecb = serpent_ecb_enc_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) } -+ .fn_u = { .ecb = __serpent_encrypt } - } } - }; - -@@ -60,13 +58,13 @@ static const struct common_glue_ctx serpent_ctr = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_ctr_16way) } -+ .fn_u = { .ctr = serpent_ctr_16way } - }, { - .num_blocks = 8, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_ctr_8way_avx) } -+ .fn_u = { .ctr = serpent_ctr_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(__serpent_crypt_ctr) } -+ .fn_u = { .ctr = __serpent_crypt_ctr } - } } - }; - -@@ -76,13 +74,13 @@ static const struct common_glue_ctx serpent_enc_xts = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_enc_16way) } -+ .fn_u = { .xts = serpent_xts_enc_16way } - }, { - .num_blocks = 8, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_enc_8way_avx) } -+ .fn_u = { .xts = serpent_xts_enc_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_enc) } -+ .fn_u = { .xts = serpent_xts_enc } - } } - }; - -@@ -92,13 +90,13 @@ static const struct common_glue_ctx serpent_dec = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_dec_16way) } -+ .fn_u = { .ecb = serpent_ecb_dec_16way } - }, { - .num_blocks = 8, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_dec_8way_avx) } -+ .fn_u = { .ecb = serpent_ecb_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .ecb = __serpent_decrypt } - } } - }; - -@@ -108,13 +106,13 @@ static const struct common_glue_ctx serpent_dec_cbc = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_cbc_dec_16way) } -+ .fn_u = { .cbc = serpent_cbc_dec_16way } - }, { - .num_blocks = 8, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_cbc_dec_8way_avx) } -+ .fn_u = { .cbc = serpent_cbc_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .cbc = __serpent_decrypt } - } } - }; - -@@ -124,13 +122,13 @@ static const struct common_glue_ctx serpent_dec_xts = { - - .funcs = { { - .num_blocks = 16, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_dec_16way) } -+ .fn_u = { .xts = serpent_xts_dec_16way } - }, { - .num_blocks = 8, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_dec_8way_avx) } -+ .fn_u = { .xts = serpent_xts_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_dec) } -+ .fn_u = { .xts = serpent_xts_dec } - } } - }; - -@@ -146,8 +144,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(__serpent_encrypt), -- req); -+ return glue_cbc_encrypt_req_128bit(__serpent_encrypt, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -166,8 +163,8 @@ static int xts_encrypt(struct skcipher_request *req) - struct serpent_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - - return glue_xts_req_128bit(&serpent_enc_xts, req, -- XTS_TWEAK_CAST(__serpent_encrypt), -- &ctx->tweak_ctx, &ctx->crypt_ctx, false); -+ __serpent_encrypt, &ctx->tweak_ctx, -+ &ctx->crypt_ctx, false); - } - - static int xts_decrypt(struct skcipher_request *req) -@@ -176,8 +173,8 @@ static int xts_decrypt(struct skcipher_request *req) - struct serpent_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - - return glue_xts_req_128bit(&serpent_dec_xts, req, -- XTS_TWEAK_CAST(__serpent_encrypt), -- &ctx->tweak_ctx, &ctx->crypt_ctx, true); -+ __serpent_encrypt, &ctx->tweak_ctx, -+ &ctx->crypt_ctx, true); - } - - static struct skcipher_alg serpent_algs[] = { -diff --git a/arch/x86/crypto/serpent_avx_glue.c b/arch/x86/crypto/serpent_avx_glue.c -index 7d3dca38a5a2e..7806d1cbe8541 100644 ---- a/arch/x86/crypto/serpent_avx_glue.c -+++ b/arch/x86/crypto/serpent_avx_glue.c -@@ -20,33 +20,35 @@ - #include - - /* 8-way parallel cipher functions */ --asmlinkage void serpent_ecb_enc_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_ecb_enc_8way_avx(const void *ctx, u8 *dst, - const u8 *src); - EXPORT_SYMBOL_GPL(serpent_ecb_enc_8way_avx); - --asmlinkage void serpent_ecb_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_ecb_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src); - EXPORT_SYMBOL_GPL(serpent_ecb_dec_8way_avx); - --asmlinkage void serpent_cbc_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_cbc_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src); - EXPORT_SYMBOL_GPL(serpent_cbc_dec_8way_avx); - --asmlinkage void serpent_ctr_8way_avx(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void serpent_ctr_8way_avx(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - EXPORT_SYMBOL_GPL(serpent_ctr_8way_avx); - --asmlinkage void serpent_xts_enc_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_xts_enc_8way_avx(const void *ctx, u8 *dst, - const u8 *src, le128 *iv); - EXPORT_SYMBOL_GPL(serpent_xts_enc_8way_avx); - --asmlinkage void serpent_xts_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_xts_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src, le128 *iv); - EXPORT_SYMBOL_GPL(serpent_xts_dec_8way_avx); - --void __serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void __serpent_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblk; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - le128_to_be128(&ctrblk, iv); - le128_inc(iv); -@@ -56,17 +58,15 @@ void __serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) - } - EXPORT_SYMBOL_GPL(__serpent_crypt_ctr); - --void serpent_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void serpent_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(__serpent_encrypt)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, __serpent_encrypt); - } - EXPORT_SYMBOL_GPL(serpent_xts_enc); - --void serpent_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void serpent_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(__serpent_decrypt)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, __serpent_decrypt); - } - EXPORT_SYMBOL_GPL(serpent_xts_dec); - -@@ -102,10 +102,10 @@ static const struct common_glue_ctx serpent_enc = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_enc_8way_avx) } -+ .fn_u = { .ecb = serpent_ecb_enc_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) } -+ .fn_u = { .ecb = __serpent_encrypt } - } } - }; - -@@ -115,10 +115,10 @@ static const struct common_glue_ctx serpent_ctr = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_ctr_8way_avx) } -+ .fn_u = { .ctr = serpent_ctr_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(__serpent_crypt_ctr) } -+ .fn_u = { .ctr = __serpent_crypt_ctr } - } } - }; - -@@ -128,10 +128,10 @@ static const struct common_glue_ctx serpent_enc_xts = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_enc_8way_avx) } -+ .fn_u = { .xts = serpent_xts_enc_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_enc) } -+ .fn_u = { .xts = serpent_xts_enc } - } } - }; - -@@ -141,10 +141,10 @@ static const struct common_glue_ctx serpent_dec = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_ecb_dec_8way_avx) } -+ .fn_u = { .ecb = serpent_ecb_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .ecb = __serpent_decrypt } - } } - }; - -@@ -154,10 +154,10 @@ static const struct common_glue_ctx serpent_dec_cbc = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_cbc_dec_8way_avx) } -+ .fn_u = { .cbc = serpent_cbc_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .cbc = __serpent_decrypt } - } } - }; - -@@ -167,10 +167,10 @@ static const struct common_glue_ctx serpent_dec_xts = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_dec_8way_avx) } -+ .fn_u = { .xts = serpent_xts_dec_8way_avx } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(serpent_xts_dec) } -+ .fn_u = { .xts = serpent_xts_dec } - } } - }; - -@@ -186,8 +186,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(__serpent_encrypt), -- req); -+ return glue_cbc_encrypt_req_128bit(__serpent_encrypt, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -206,8 +205,8 @@ static int xts_encrypt(struct skcipher_request *req) - struct serpent_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - - return glue_xts_req_128bit(&serpent_enc_xts, req, -- XTS_TWEAK_CAST(__serpent_encrypt), -- &ctx->tweak_ctx, &ctx->crypt_ctx, false); -+ __serpent_encrypt, &ctx->tweak_ctx, -+ &ctx->crypt_ctx, false); - } - - static int xts_decrypt(struct skcipher_request *req) -@@ -216,8 +215,8 @@ static int xts_decrypt(struct skcipher_request *req) - struct serpent_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - - return glue_xts_req_128bit(&serpent_dec_xts, req, -- XTS_TWEAK_CAST(__serpent_encrypt), -- &ctx->tweak_ctx, &ctx->crypt_ctx, true); -+ __serpent_encrypt, &ctx->tweak_ctx, -+ &ctx->crypt_ctx, true); - } - - static struct skcipher_alg serpent_algs[] = { -diff --git a/arch/x86/crypto/serpent_sse2_glue.c b/arch/x86/crypto/serpent_sse2_glue.c -index 5fdf1931d0690..4fed8d26b91a4 100644 ---- a/arch/x86/crypto/serpent_sse2_glue.c -+++ b/arch/x86/crypto/serpent_sse2_glue.c -@@ -31,9 +31,11 @@ static int serpent_setkey_skcipher(struct crypto_skcipher *tfm, - return __serpent_setkey(crypto_skcipher_ctx(tfm), key, keylen); - } - --static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) -+static void serpent_decrypt_cbc_xway(const void *ctx, u8 *d, const u8 *s) - { - u128 ivs[SERPENT_PARALLEL_BLOCKS - 1]; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - unsigned int j; - - for (j = 0; j < SERPENT_PARALLEL_BLOCKS - 1; j++) -@@ -45,9 +47,11 @@ static void serpent_decrypt_cbc_xway(void *ctx, u128 *dst, const u128 *src) - u128_xor(dst + (j + 1), dst + (j + 1), ivs + j); - } - --static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void serpent_crypt_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblk; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - le128_to_be128(&ctrblk, iv); - le128_inc(iv); -@@ -56,10 +60,12 @@ static void serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) - u128_xor(dst, src, (u128 *)&ctrblk); - } - --static void serpent_crypt_ctr_xway(void *ctx, u128 *dst, const u128 *src, -+static void serpent_crypt_ctr_xway(const void *ctx, u8 *d, const u8 *s, - le128 *iv) - { - be128 ctrblks[SERPENT_PARALLEL_BLOCKS]; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - unsigned int i; - - for (i = 0; i < SERPENT_PARALLEL_BLOCKS; i++) { -@@ -79,10 +85,10 @@ static const struct common_glue_ctx serpent_enc = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_enc_blk_xway) } -+ .fn_u = { .ecb = serpent_enc_blk_xway } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_encrypt) } -+ .fn_u = { .ecb = __serpent_encrypt } - } } - }; - -@@ -92,10 +98,10 @@ static const struct common_glue_ctx serpent_ctr = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr_xway) } -+ .fn_u = { .ctr = serpent_crypt_ctr_xway } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(serpent_crypt_ctr) } -+ .fn_u = { .ctr = serpent_crypt_ctr } - } } - }; - -@@ -105,10 +111,10 @@ static const struct common_glue_ctx serpent_dec = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(serpent_dec_blk_xway) } -+ .fn_u = { .ecb = serpent_dec_blk_xway } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .ecb = __serpent_decrypt } - } } - }; - -@@ -118,10 +124,10 @@ static const struct common_glue_ctx serpent_dec_cbc = { - - .funcs = { { - .num_blocks = SERPENT_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(serpent_decrypt_cbc_xway) } -+ .fn_u = { .cbc = serpent_decrypt_cbc_xway } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(__serpent_decrypt) } -+ .fn_u = { .cbc = __serpent_decrypt } - } } - }; - -@@ -137,7 +143,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(__serpent_encrypt), -+ return glue_cbc_encrypt_req_128bit(__serpent_encrypt, - req); - } - -diff --git a/arch/x86/crypto/twofish_avx_glue.c b/arch/x86/crypto/twofish_avx_glue.c -index d561c821788b7..3b36e97ec7abb 100644 ---- a/arch/x86/crypto/twofish_avx_glue.c -+++ b/arch/x86/crypto/twofish_avx_glue.c -@@ -22,20 +22,17 @@ - #define TWOFISH_PARALLEL_BLOCKS 8 - - /* 8-way parallel cipher functions */ --asmlinkage void twofish_ecb_enc_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void twofish_ecb_dec_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void twofish_ecb_enc_8way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void twofish_ecb_dec_8way(const void *ctx, u8 *dst, const u8 *src); - --asmlinkage void twofish_cbc_dec_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void twofish_ctr_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void twofish_cbc_dec_8way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void twofish_ctr_8way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - --asmlinkage void twofish_xts_enc_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); --asmlinkage void twofish_xts_dec_8way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void twofish_xts_enc_8way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+asmlinkage void twofish_xts_dec_8way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - - static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, - const u8 *key, unsigned int keylen) -@@ -43,22 +40,19 @@ static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, - return twofish_setkey(&tfm->base, key, keylen); - } - --static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src) - { - __twofish_enc_blk_3way(ctx, dst, src, false); - } - --static void twofish_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void twofish_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(twofish_enc_blk)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, twofish_enc_blk); - } - --static void twofish_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+static void twofish_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv) - { -- glue_xts_crypt_128bit_one(ctx, dst, src, iv, -- GLUE_FUNC_CAST(twofish_dec_blk)); -+ glue_xts_crypt_128bit_one(ctx, dst, src, iv, twofish_dec_blk); - } - - struct twofish_xts_ctx { -@@ -93,13 +87,13 @@ static const struct common_glue_ctx twofish_enc = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_ecb_enc_8way) } -+ .fn_u = { .ecb = twofish_ecb_enc_8way } - }, { - .num_blocks = 3, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) } -+ .fn_u = { .ecb = twofish_enc_blk_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) } -+ .fn_u = { .ecb = twofish_enc_blk } - } } - }; - -@@ -109,13 +103,13 @@ static const struct common_glue_ctx twofish_ctr = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_ctr_8way) } -+ .fn_u = { .ctr = twofish_ctr_8way } - }, { - .num_blocks = 3, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr_3way) } -+ .fn_u = { .ctr = twofish_enc_blk_ctr_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ctr = GLUE_CTR_FUNC_CAST(twofish_enc_blk_ctr) } -+ .fn_u = { .ctr = twofish_enc_blk_ctr } - } } - }; - -@@ -125,10 +119,10 @@ static const struct common_glue_ctx twofish_enc_xts = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(twofish_xts_enc_8way) } -+ .fn_u = { .xts = twofish_xts_enc_8way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(twofish_xts_enc) } -+ .fn_u = { .xts = twofish_xts_enc } - } } - }; - -@@ -138,13 +132,13 @@ static const struct common_glue_ctx twofish_dec = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_ecb_dec_8way) } -+ .fn_u = { .ecb = twofish_ecb_dec_8way } - }, { - .num_blocks = 3, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) } -+ .fn_u = { .ecb = twofish_dec_blk_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) } -+ .fn_u = { .ecb = twofish_dec_blk } - } } - }; - -@@ -154,13 +148,13 @@ static const struct common_glue_ctx twofish_dec_cbc = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_cbc_dec_8way) } -+ .fn_u = { .cbc = twofish_cbc_dec_8way } - }, { - .num_blocks = 3, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) } -+ .fn_u = { .cbc = twofish_dec_blk_cbc_3way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) } -+ .fn_u = { .cbc = twofish_dec_blk } - } } - }; - -@@ -170,10 +164,10 @@ static const struct common_glue_ctx twofish_dec_xts = { - - .funcs = { { - .num_blocks = TWOFISH_PARALLEL_BLOCKS, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(twofish_xts_dec_8way) } -+ .fn_u = { .xts = twofish_xts_dec_8way } - }, { - .num_blocks = 1, -- .fn_u = { .xts = GLUE_XTS_FUNC_CAST(twofish_xts_dec) } -+ .fn_u = { .xts = twofish_xts_dec } - } } - }; - -@@ -189,8 +183,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(twofish_enc_blk), -- req); -+ return glue_cbc_encrypt_req_128bit(twofish_enc_blk, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -@@ -208,8 +201,7 @@ static int xts_encrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct twofish_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&twofish_enc_xts, req, -- XTS_TWEAK_CAST(twofish_enc_blk), -+ return glue_xts_req_128bit(&twofish_enc_xts, req, twofish_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, false); - } - -@@ -218,8 +210,7 @@ static int xts_decrypt(struct skcipher_request *req) - struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); - struct twofish_xts_ctx *ctx = crypto_skcipher_ctx(tfm); - -- return glue_xts_req_128bit(&twofish_dec_xts, req, -- XTS_TWEAK_CAST(twofish_enc_blk), -+ return glue_xts_req_128bit(&twofish_dec_xts, req, twofish_enc_blk, - &ctx->tweak_ctx, &ctx->crypt_ctx, true); - } - -diff --git a/arch/x86/crypto/twofish_glue_3way.c b/arch/x86/crypto/twofish_glue_3way.c -index 1dc9e29f221e8..768af6075479c 100644 ---- a/arch/x86/crypto/twofish_glue_3way.c -+++ b/arch/x86/crypto/twofish_glue_3way.c -@@ -25,21 +25,22 @@ static int twofish_setkey_skcipher(struct crypto_skcipher *tfm, - return twofish_setkey(&tfm->base, key, keylen); - } - --static inline void twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src) - { - __twofish_enc_blk_3way(ctx, dst, src, false); - } - --static inline void twofish_enc_blk_xor_3way(struct twofish_ctx *ctx, u8 *dst, -+static inline void twofish_enc_blk_xor_3way(const void *ctx, u8 *dst, - const u8 *src) - { - __twofish_enc_blk_3way(ctx, dst, src, true); - } - --void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src) -+void twofish_dec_blk_cbc_3way(const void *ctx, u8 *d, const u8 *s) - { - u128 ivs[2]; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - ivs[0] = src[0]; - ivs[1] = src[1]; -@@ -51,9 +52,11 @@ void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src) - } - EXPORT_SYMBOL_GPL(twofish_dec_blk_cbc_3way); - --void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) -+void twofish_enc_blk_ctr(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblk; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - if (dst != src) - *dst = *src; -@@ -66,10 +69,11 @@ void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, le128 *iv) - } - EXPORT_SYMBOL_GPL(twofish_enc_blk_ctr); - --void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, -- le128 *iv) -+void twofish_enc_blk_ctr_3way(const void *ctx, u8 *d, const u8 *s, le128 *iv) - { - be128 ctrblks[3]; -+ u128 *dst = (u128 *)d; -+ const u128 *src = (const u128 *)s; - - if (dst != src) { - dst[0] = src[0]; -@@ -94,10 +98,10 @@ static const struct common_glue_ctx twofish_enc = { - - .funcs = { { - .num_blocks = 3, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_3way) } -+ .fn_u = { .ecb = twofish_enc_blk_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk) } -+ .fn_u = { .ecb = twofish_enc_blk } - } } - }; - -@@ -107,10 +111,10 @@ static const struct common_glue_ctx twofish_ctr = { - - .funcs = { { - .num_blocks = 3, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr_3way) } -+ .fn_u = { .ctr = twofish_enc_blk_ctr_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_enc_blk_ctr) } -+ .fn_u = { .ctr = twofish_enc_blk_ctr } - } } - }; - -@@ -120,10 +124,10 @@ static const struct common_glue_ctx twofish_dec = { - - .funcs = { { - .num_blocks = 3, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk_3way) } -+ .fn_u = { .ecb = twofish_dec_blk_3way } - }, { - .num_blocks = 1, -- .fn_u = { .ecb = GLUE_FUNC_CAST(twofish_dec_blk) } -+ .fn_u = { .ecb = twofish_dec_blk } - } } - }; - -@@ -133,10 +137,10 @@ static const struct common_glue_ctx twofish_dec_cbc = { - - .funcs = { { - .num_blocks = 3, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk_cbc_3way) } -+ .fn_u = { .cbc = twofish_dec_blk_cbc_3way } - }, { - .num_blocks = 1, -- .fn_u = { .cbc = GLUE_CBC_FUNC_CAST(twofish_dec_blk) } -+ .fn_u = { .cbc = twofish_dec_blk } - } } - }; - -@@ -152,8 +156,7 @@ static int ecb_decrypt(struct skcipher_request *req) - - static int cbc_encrypt(struct skcipher_request *req) - { -- return glue_cbc_encrypt_req_128bit(GLUE_FUNC_CAST(twofish_enc_blk), -- req); -+ return glue_cbc_encrypt_req_128bit(twofish_enc_blk, req); - } - - static int cbc_decrypt(struct skcipher_request *req) -diff --git a/arch/x86/include/asm/crypto/camellia.h b/arch/x86/include/asm/crypto/camellia.h -index a5d86fc0593f2..f1592619dd651 100644 ---- a/arch/x86/include/asm/crypto/camellia.h -+++ b/arch/x86/include/asm/crypto/camellia.h -@@ -32,65 +32,60 @@ extern int xts_camellia_setkey(struct crypto_skcipher *tfm, const u8 *key, - unsigned int keylen); - - /* regular block cipher functions */ --asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, bool xor); --asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src, -+ bool xor); -+asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src); - - /* 2-way parallel cipher functions */ --asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, bool xor); --asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src, -+ bool xor); -+asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src); - - /* 16-way parallel cipher functions (avx/aes-ni) */ --asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); -- --asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -- --asmlinkage void camellia_xts_enc_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); --asmlinkage void camellia_xts_dec_16way(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -- --static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src) -+asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src); -+ -+asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void camellia_ctr_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+ -+asmlinkage void camellia_xts_enc_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+asmlinkage void camellia_xts_dec_16way(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+ -+static inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src) - { - __camellia_enc_blk(ctx, dst, src, false); - } - --static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src) - { - __camellia_enc_blk(ctx, dst, src, true); - } - --static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, -+static inline void camellia_enc_blk_2way(const void *ctx, u8 *dst, - const u8 *src) - { - __camellia_enc_blk_2way(ctx, dst, src, false); - } - --static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst, -+static inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst, - const u8 *src) - { - __camellia_enc_blk_2way(ctx, dst, src, true); - } - - /* glue helpers */ --extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src); --extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, -+extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src); -+extern void camellia_crypt_ctr(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); --extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, -+extern void camellia_crypt_ctr_2way(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); - --extern void camellia_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv); --extern void camellia_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv); -+extern void camellia_xts_enc(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); -+extern void camellia_xts_dec(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - - #endif /* ASM_X86_CAMELLIA_H */ -diff --git a/arch/x86/include/asm/crypto/glue_helper.h b/arch/x86/include/asm/crypto/glue_helper.h -index 8d4a8e1226ee3..777c0f63418c8 100644 ---- a/arch/x86/include/asm/crypto/glue_helper.h -+++ b/arch/x86/include/asm/crypto/glue_helper.h -@@ -11,18 +11,13 @@ - #include - #include - --typedef void (*common_glue_func_t)(void *ctx, u8 *dst, const u8 *src); --typedef void (*common_glue_cbc_func_t)(void *ctx, u128 *dst, const u128 *src); --typedef void (*common_glue_ctr_func_t)(void *ctx, u128 *dst, const u128 *src, -+typedef void (*common_glue_func_t)(const void *ctx, u8 *dst, const u8 *src); -+typedef void (*common_glue_cbc_func_t)(const void *ctx, u8 *dst, const u8 *src); -+typedef void (*common_glue_ctr_func_t)(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); --typedef void (*common_glue_xts_func_t)(void *ctx, u128 *dst, const u128 *src, -+typedef void (*common_glue_xts_func_t)(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); - --#define GLUE_FUNC_CAST(fn) ((common_glue_func_t)(fn)) --#define GLUE_CBC_FUNC_CAST(fn) ((common_glue_cbc_func_t)(fn)) --#define GLUE_CTR_FUNC_CAST(fn) ((common_glue_ctr_func_t)(fn)) --#define GLUE_XTS_FUNC_CAST(fn) ((common_glue_xts_func_t)(fn)) -- - struct common_glue_func_entry { - unsigned int num_blocks; /* number of blocks that @fn will process */ - union { -@@ -116,7 +111,8 @@ extern int glue_xts_req_128bit(const struct common_glue_ctx *gctx, - common_glue_func_t tweak_fn, void *tweak_ctx, - void *crypt_ctx, bool decrypt); - --extern void glue_xts_crypt_128bit_one(void *ctx, u128 *dst, const u128 *src, -- le128 *iv, common_glue_func_t fn); -+extern void glue_xts_crypt_128bit_one(const void *ctx, u8 *dst, -+ const u8 *src, le128 *iv, -+ common_glue_func_t fn); - - #endif /* _CRYPTO_GLUE_HELPER_H */ -diff --git a/arch/x86/include/asm/crypto/serpent-avx.h b/arch/x86/include/asm/crypto/serpent-avx.h -index db7c9cc322342..251c2c89d7cfe 100644 ---- a/arch/x86/include/asm/crypto/serpent-avx.h -+++ b/arch/x86/include/asm/crypto/serpent-avx.h -@@ -15,26 +15,26 @@ struct serpent_xts_ctx { - struct serpent_ctx crypt_ctx; - }; - --asmlinkage void serpent_ecb_enc_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_ecb_enc_8way_avx(const void *ctx, u8 *dst, - const u8 *src); --asmlinkage void serpent_ecb_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_ecb_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src); - --asmlinkage void serpent_cbc_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_cbc_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src); --asmlinkage void serpent_ctr_8way_avx(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src, le128 *iv); -+asmlinkage void serpent_ctr_8way_avx(const void *ctx, u8 *dst, const u8 *src, -+ le128 *iv); - --asmlinkage void serpent_xts_enc_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_xts_enc_8way_avx(const void *ctx, u8 *dst, - const u8 *src, le128 *iv); --asmlinkage void serpent_xts_dec_8way_avx(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_xts_dec_8way_avx(const void *ctx, u8 *dst, - const u8 *src, le128 *iv); - --extern void __serpent_crypt_ctr(void *ctx, u128 *dst, const u128 *src, -+extern void __serpent_crypt_ctr(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); - --extern void serpent_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv); --extern void serpent_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv); -+extern void serpent_xts_enc(const void *ctx, u8 *dst, const u8 *src, le128 *iv); -+extern void serpent_xts_dec(const void *ctx, u8 *dst, const u8 *src, le128 *iv); - - extern int xts_serpent_setkey(struct crypto_skcipher *tfm, const u8 *key, - unsigned int keylen); -diff --git a/arch/x86/include/asm/crypto/serpent-sse2.h b/arch/x86/include/asm/crypto/serpent-sse2.h -index 1a345e8a7496c..860ca248914b1 100644 ---- a/arch/x86/include/asm/crypto/serpent-sse2.h -+++ b/arch/x86/include/asm/crypto/serpent-sse2.h -@@ -9,25 +9,23 @@ - - #define SERPENT_PARALLEL_BLOCKS 4 - --asmlinkage void __serpent_enc_blk_4way(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void __serpent_enc_blk_4way(const struct serpent_ctx *ctx, u8 *dst, - const u8 *src, bool xor); --asmlinkage void serpent_dec_blk_4way(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_dec_blk_4way(const struct serpent_ctx *ctx, u8 *dst, - const u8 *src); - --static inline void serpent_enc_blk_xway(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_enc_blk_xway(const void *ctx, u8 *dst, const u8 *src) - { - __serpent_enc_blk_4way(ctx, dst, src, false); - } - --static inline void serpent_enc_blk_xway_xor(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_enc_blk_xway_xor(const struct serpent_ctx *ctx, -+ u8 *dst, const u8 *src) - { - __serpent_enc_blk_4way(ctx, dst, src, true); - } - --static inline void serpent_dec_blk_xway(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_dec_blk_xway(const void *ctx, u8 *dst, const u8 *src) - { - serpent_dec_blk_4way(ctx, dst, src); - } -@@ -36,25 +34,23 @@ static inline void serpent_dec_blk_xway(struct serpent_ctx *ctx, u8 *dst, - - #define SERPENT_PARALLEL_BLOCKS 8 - --asmlinkage void __serpent_enc_blk_8way(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void __serpent_enc_blk_8way(const struct serpent_ctx *ctx, u8 *dst, - const u8 *src, bool xor); --asmlinkage void serpent_dec_blk_8way(struct serpent_ctx *ctx, u8 *dst, -+asmlinkage void serpent_dec_blk_8way(const struct serpent_ctx *ctx, u8 *dst, - const u8 *src); - --static inline void serpent_enc_blk_xway(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_enc_blk_xway(const void *ctx, u8 *dst, const u8 *src) - { - __serpent_enc_blk_8way(ctx, dst, src, false); - } - --static inline void serpent_enc_blk_xway_xor(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_enc_blk_xway_xor(const struct serpent_ctx *ctx, -+ u8 *dst, const u8 *src) - { - __serpent_enc_blk_8way(ctx, dst, src, true); - } - --static inline void serpent_dec_blk_xway(struct serpent_ctx *ctx, u8 *dst, -- const u8 *src) -+static inline void serpent_dec_blk_xway(const void *ctx, u8 *dst, const u8 *src) - { - serpent_dec_blk_8way(ctx, dst, src); - } -diff --git a/arch/x86/include/asm/crypto/twofish.h b/arch/x86/include/asm/crypto/twofish.h -index f618bf272b900..2c377a8042e17 100644 ---- a/arch/x86/include/asm/crypto/twofish.h -+++ b/arch/x86/include/asm/crypto/twofish.h -@@ -7,22 +7,19 @@ - #include - - /* regular block cipher functions from twofish_x86_64 module */ --asmlinkage void twofish_enc_blk(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); --asmlinkage void twofish_dec_blk(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void twofish_enc_blk(const void *ctx, u8 *dst, const u8 *src); -+asmlinkage void twofish_dec_blk(const void *ctx, u8 *dst, const u8 *src); - - /* 3-way parallel cipher functions */ --asmlinkage void __twofish_enc_blk_3way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src, bool xor); --asmlinkage void twofish_dec_blk_3way(struct twofish_ctx *ctx, u8 *dst, -- const u8 *src); -+asmlinkage void __twofish_enc_blk_3way(const void *ctx, u8 *dst, const u8 *src, -+ bool xor); -+asmlinkage void twofish_dec_blk_3way(const void *ctx, u8 *dst, const u8 *src); - - /* helpers from twofish_x86_64-3way module */ --extern void twofish_dec_blk_cbc_3way(void *ctx, u128 *dst, const u128 *src); --extern void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src, -+extern void twofish_dec_blk_cbc_3way(const void *ctx, u8 *dst, const u8 *src); -+extern void twofish_enc_blk_ctr(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); --extern void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src, -+extern void twofish_enc_blk_ctr_3way(const void *ctx, u8 *dst, const u8 *src, - le128 *iv); - - #endif /* ASM_X86_TWOFISH_H */ -diff --git a/crypto/cast6_generic.c b/crypto/cast6_generic.c -index a8248f8e2777e..85328522c5ca1 100644 ---- a/crypto/cast6_generic.c -+++ b/crypto/cast6_generic.c -@@ -154,7 +154,7 @@ int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) - EXPORT_SYMBOL_GPL(cast6_setkey); - - /*forward quad round*/ --static inline void Q(u32 *block, u8 *Kr, u32 *Km) -+static inline void Q(u32 *block, const u8 *Kr, const u32 *Km) - { - u32 I; - block[2] ^= F1(block[3], Kr[0], Km[0]); -@@ -164,7 +164,7 @@ static inline void Q(u32 *block, u8 *Kr, u32 *Km) - } - - /*reverse quad round*/ --static inline void QBAR(u32 *block, u8 *Kr, u32 *Km) -+static inline void QBAR(u32 *block, const u8 *Kr, const u32 *Km) - { - u32 I; - block[3] ^= F1(block[0], Kr[3], Km[3]); -@@ -173,13 +173,14 @@ static inline void QBAR(u32 *block, u8 *Kr, u32 *Km) - block[2] ^= F1(block[3], Kr[0], Km[0]); - } - --void __cast6_encrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) -+void __cast6_encrypt(const void *ctx, u8 *outbuf, const u8 *inbuf) - { -+ const struct cast6_ctx *c = ctx; - const __be32 *src = (const __be32 *)inbuf; - __be32 *dst = (__be32 *)outbuf; - u32 block[4]; -- u32 *Km; -- u8 *Kr; -+ const u32 *Km; -+ const u8 *Kr; - - block[0] = be32_to_cpu(src[0]); - block[1] = be32_to_cpu(src[1]); -@@ -211,13 +212,14 @@ static void cast6_encrypt(struct crypto_tfm *tfm, u8 *outbuf, const u8 *inbuf) - __cast6_encrypt(crypto_tfm_ctx(tfm), outbuf, inbuf); - } - --void __cast6_decrypt(struct cast6_ctx *c, u8 *outbuf, const u8 *inbuf) -+void __cast6_decrypt(const void *ctx, u8 *outbuf, const u8 *inbuf) - { -+ const struct cast6_ctx *c = ctx; - const __be32 *src = (const __be32 *)inbuf; - __be32 *dst = (__be32 *)outbuf; - u32 block[4]; -- u32 *Km; -- u8 *Kr; -+ const u32 *Km; -+ const u8 *Kr; - - block[0] = be32_to_cpu(src[0]); - block[1] = be32_to_cpu(src[1]); -diff --git a/crypto/serpent_generic.c b/crypto/serpent_generic.c -index 56fa665a4f010..492c1d0bfe068 100644 ---- a/crypto/serpent_generic.c -+++ b/crypto/serpent_generic.c -@@ -449,8 +449,9 @@ int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) - } - EXPORT_SYMBOL_GPL(serpent_setkey); - --void __serpent_encrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src) -+void __serpent_encrypt(const void *c, u8 *dst, const u8 *src) - { -+ const struct serpent_ctx *ctx = c; - const u32 *k = ctx->expkey; - const __le32 *s = (const __le32 *)src; - __le32 *d = (__le32 *)dst; -@@ -514,8 +515,9 @@ static void serpent_encrypt(struct crypto_tfm *tfm, u8 *dst, const u8 *src) - __serpent_encrypt(ctx, dst, src); - } - --void __serpent_decrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src) -+void __serpent_decrypt(const void *c, u8 *dst, const u8 *src) - { -+ const struct serpent_ctx *ctx = c; - const u32 *k = ctx->expkey; - const __le32 *s = (const __le32 *)src; - __le32 *d = (__le32 *)dst; -diff --git a/drivers/gpu/drm/i915/gvt/display.c b/drivers/gpu/drm/i915/gvt/display.c -index 59aa5e64acb04..21a562c2b1f50 100644 ---- a/drivers/gpu/drm/i915/gvt/display.c -+++ b/drivers/gpu/drm/i915/gvt/display.c -@@ -172,21 +172,176 @@ static void emulate_monitor_status_change(struct intel_vgpu *vgpu) - int pipe; - - if (IS_BROXTON(dev_priv)) { -+ enum transcoder trans; -+ enum port port; -+ -+ /* Clear PIPE, DDI, PHY, HPD before setting new */ - vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= ~(BXT_DE_PORT_HP_DDIA | - BXT_DE_PORT_HP_DDIB | - BXT_DE_PORT_HP_DDIC); - -+ for_each_pipe(dev_priv, pipe) { -+ vgpu_vreg_t(vgpu, PIPECONF(pipe)) &= -+ ~(PIPECONF_ENABLE | I965_PIPECONF_ACTIVE); -+ vgpu_vreg_t(vgpu, DSPCNTR(pipe)) &= ~DISPLAY_PLANE_ENABLE; -+ vgpu_vreg_t(vgpu, SPRCTL(pipe)) &= ~SPRITE_ENABLE; -+ vgpu_vreg_t(vgpu, CURCNTR(pipe)) &= ~MCURSOR_MODE; -+ vgpu_vreg_t(vgpu, CURCNTR(pipe)) |= MCURSOR_MODE_DISABLE; -+ } -+ -+ for (trans = TRANSCODER_A; trans <= TRANSCODER_EDP; trans++) { -+ vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(trans)) &= -+ ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK | -+ TRANS_DDI_PORT_MASK | TRANS_DDI_FUNC_ENABLE); -+ } -+ vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) &= -+ ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK | -+ TRANS_DDI_PORT_MASK); -+ -+ for (port = PORT_A; port <= PORT_C; port++) { -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(port)) &= -+ ~BXT_PHY_LANE_ENABLED; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(port)) |= -+ (BXT_PHY_CMNLANE_POWERDOWN_ACK | -+ BXT_PHY_LANE_POWERDOWN_ACK); -+ -+ vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(port)) &= -+ ~(PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE | -+ PORT_PLL_REF_SEL | PORT_PLL_LOCK | -+ PORT_PLL_ENABLE); -+ -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(port)) &= -+ ~(DDI_INIT_DISPLAY_DETECTED | -+ DDI_BUF_CTL_ENABLE); -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(port)) |= DDI_BUF_IS_IDLE; -+ } -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~(PORTA_HOTPLUG_ENABLE | PORTA_HOTPLUG_STATUS_MASK); -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~(PORTB_HOTPLUG_ENABLE | PORTB_HOTPLUG_STATUS_MASK); -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~(PORTC_HOTPLUG_ENABLE | PORTC_HOTPLUG_STATUS_MASK); -+ /* No hpd_invert set in vgpu vbt, need to clear invert mask */ -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= ~BXT_DDI_HPD_INVERT_MASK; -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= ~BXT_DE_PORT_HOTPLUG_MASK; -+ -+ vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) &= ~(BIT(0) | BIT(1)); -+ vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) &= -+ ~PHY_POWER_GOOD; -+ vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) &= -+ ~PHY_POWER_GOOD; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) &= ~BIT(30); -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY1)) &= ~BIT(30); -+ -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) &= ~SFUSE_STRAP_DDIB_DETECTED; -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) &= ~SFUSE_STRAP_DDIC_DETECTED; -+ -+ /* -+ * Only 1 PIPE enabled in current vGPU display and PIPE_A is -+ * tied to TRANSCODER_A in HW, so it's safe to assume PIPE_A, -+ * TRANSCODER_A can be enabled. PORT_x depends on the input of -+ * setup_virtual_dp_monitor. -+ */ -+ vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= PIPECONF_ENABLE; -+ vgpu_vreg_t(vgpu, PIPECONF(PIPE_A)) |= I965_PIPECONF_ACTIVE; -+ -+ /* -+ * Golden M/N are calculated based on: -+ * 24 bpp, 4 lanes, 154000 pixel clk (from virtual EDID), -+ * DP link clk 1620 MHz and non-constant_n. -+ * TODO: calculate DP link symbol clk and stream clk m/n. -+ */ -+ vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) = 63 << TU_SIZE_SHIFT; -+ vgpu_vreg_t(vgpu, PIPE_DATA_M1(TRANSCODER_A)) |= 0x5b425e; -+ vgpu_vreg_t(vgpu, PIPE_DATA_N1(TRANSCODER_A)) = 0x800000; -+ vgpu_vreg_t(vgpu, PIPE_LINK_M1(TRANSCODER_A)) = 0x3cd6e; -+ vgpu_vreg_t(vgpu, PIPE_LINK_N1(TRANSCODER_A)) = 0x80000; -+ -+ /* Enable per-DDI/PORT vreg */ - if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) { -+ vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(1); -+ vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY1)) |= -+ PHY_POWER_GOOD; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY1)) |= -+ BIT(30); -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) |= -+ BXT_PHY_LANE_ENABLED; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_A)) &= -+ ~(BXT_PHY_CMNLANE_POWERDOWN_ACK | -+ BXT_PHY_LANE_POWERDOWN_ACK); -+ vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_A)) |= -+ (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE | -+ PORT_PLL_REF_SEL | PORT_PLL_LOCK | -+ PORT_PLL_ENABLE); -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) |= -+ (DDI_BUF_CTL_ENABLE | DDI_INIT_DISPLAY_DETECTED); -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_A)) &= -+ ~DDI_BUF_IS_IDLE; -+ vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_EDP)) |= -+ (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | -+ TRANS_DDI_FUNC_ENABLE); -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTA_HOTPLUG_ENABLE; - vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= - BXT_DE_PORT_HP_DDIA; - } - - if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) { -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIB_DETECTED; -+ vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(0); -+ vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) |= -+ PHY_POWER_GOOD; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) |= -+ BIT(30); -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) |= -+ BXT_PHY_LANE_ENABLED; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_B)) &= -+ ~(BXT_PHY_CMNLANE_POWERDOWN_ACK | -+ BXT_PHY_LANE_POWERDOWN_ACK); -+ vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_B)) |= -+ (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE | -+ PORT_PLL_REF_SEL | PORT_PLL_LOCK | -+ PORT_PLL_ENABLE); -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) |= -+ DDI_BUF_CTL_ENABLE; -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_B)) &= -+ ~DDI_BUF_IS_IDLE; -+ vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |= -+ (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | -+ (PORT_B << TRANS_DDI_PORT_SHIFT) | -+ TRANS_DDI_FUNC_ENABLE); -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTB_HOTPLUG_ENABLE; - vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= - BXT_DE_PORT_HP_DDIB; - } - - if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) { -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) |= SFUSE_STRAP_DDIC_DETECTED; -+ vgpu_vreg_t(vgpu, BXT_P_CR_GT_DISP_PWRON) |= BIT(0); -+ vgpu_vreg_t(vgpu, BXT_PORT_CL1CM_DW0(DPIO_PHY0)) |= -+ PHY_POWER_GOOD; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL_FAMILY(DPIO_PHY0)) |= -+ BIT(30); -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) |= -+ BXT_PHY_LANE_ENABLED; -+ vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) &= -+ ~(BXT_PHY_CMNLANE_POWERDOWN_ACK | -+ BXT_PHY_LANE_POWERDOWN_ACK); -+ vgpu_vreg_t(vgpu, BXT_PORT_PLL_ENABLE(PORT_C)) |= -+ (PORT_PLL_POWER_STATE | PORT_PLL_POWER_ENABLE | -+ PORT_PLL_REF_SEL | PORT_PLL_LOCK | -+ PORT_PLL_ENABLE); -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) |= -+ DDI_BUF_CTL_ENABLE; -+ vgpu_vreg_t(vgpu, DDI_BUF_CTL(PORT_C)) &= -+ ~DDI_BUF_IS_IDLE; -+ vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |= -+ (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | -+ (PORT_B << TRANS_DDI_PORT_SHIFT) | -+ TRANS_DDI_FUNC_ENABLE); -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTC_HOTPLUG_ENABLE; - vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= - BXT_DE_PORT_HP_DDIC; - } -@@ -511,6 +666,63 @@ void intel_vgpu_emulate_hotplug(struct intel_vgpu *vgpu, bool connected) - vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= - PORTD_HOTPLUG_STATUS_MASK; - intel_vgpu_trigger_virtual_event(vgpu, DP_D_HOTPLUG); -+ } else if (IS_BROXTON(dev_priv)) { -+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_A)) { -+ if (connected) { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= -+ BXT_DE_PORT_HP_DDIA; -+ } else { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= -+ ~BXT_DE_PORT_HP_DDIA; -+ } -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |= -+ BXT_DE_PORT_HP_DDIA; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~PORTA_HOTPLUG_STATUS_MASK; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTA_HOTPLUG_LONG_DETECT; -+ intel_vgpu_trigger_virtual_event(vgpu, DP_A_HOTPLUG); -+ } -+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_B)) { -+ if (connected) { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= -+ BXT_DE_PORT_HP_DDIB; -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) |= -+ SFUSE_STRAP_DDIB_DETECTED; -+ } else { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= -+ ~BXT_DE_PORT_HP_DDIB; -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) &= -+ ~SFUSE_STRAP_DDIB_DETECTED; -+ } -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |= -+ BXT_DE_PORT_HP_DDIB; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~PORTB_HOTPLUG_STATUS_MASK; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTB_HOTPLUG_LONG_DETECT; -+ intel_vgpu_trigger_virtual_event(vgpu, DP_B_HOTPLUG); -+ } -+ if (intel_vgpu_has_monitor_on_port(vgpu, PORT_C)) { -+ if (connected) { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) |= -+ BXT_DE_PORT_HP_DDIC; -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) |= -+ SFUSE_STRAP_DDIC_DETECTED; -+ } else { -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_ISR) &= -+ ~BXT_DE_PORT_HP_DDIC; -+ vgpu_vreg_t(vgpu, SFUSE_STRAP) &= -+ ~SFUSE_STRAP_DDIC_DETECTED; -+ } -+ vgpu_vreg_t(vgpu, GEN8_DE_PORT_IIR) |= -+ BXT_DE_PORT_HP_DDIC; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) &= -+ ~PORTC_HOTPLUG_STATUS_MASK; -+ vgpu_vreg_t(vgpu, PCH_PORT_HOTPLUG) |= -+ PORTC_HOTPLUG_LONG_DETECT; -+ intel_vgpu_trigger_virtual_event(vgpu, DP_C_HOTPLUG); -+ } - } - } - -diff --git a/drivers/gpu/drm/i915/gvt/handlers.c b/drivers/gpu/drm/i915/gvt/handlers.c -index 689b07bc91c47..245c20d36f1b2 100644 ---- a/drivers/gpu/drm/i915/gvt/handlers.c -+++ b/drivers/gpu/drm/i915/gvt/handlers.c -@@ -1632,6 +1632,34 @@ static int edp_psr_imr_iir_write(struct intel_vgpu *vgpu, - return 0; - } - -+/** -+ * FixMe: -+ * If guest fills non-priv batch buffer on ApolloLake/Broxton as Mesa i965 did: -+ * 717e7539124d (i965: Use a WC map and memcpy for the batch instead of pwrite.) -+ * Due to the missing flush of bb filled by VM vCPU, host GPU hangs on executing -+ * these MI_BATCH_BUFFER. -+ * Temporarily workaround this by setting SNOOP bit for PAT3 used by PPGTT -+ * PML4 PTE: PAT(0) PCD(1) PWT(1). -+ * The performance is still expected to be low, will need further improvement. -+ */ -+static int bxt_ppat_low_write(struct intel_vgpu *vgpu, unsigned int offset, -+ void *p_data, unsigned int bytes) -+{ -+ u64 pat = -+ GEN8_PPAT(0, CHV_PPAT_SNOOP) | -+ GEN8_PPAT(1, 0) | -+ GEN8_PPAT(2, 0) | -+ GEN8_PPAT(3, CHV_PPAT_SNOOP) | -+ GEN8_PPAT(4, CHV_PPAT_SNOOP) | -+ GEN8_PPAT(5, CHV_PPAT_SNOOP) | -+ GEN8_PPAT(6, CHV_PPAT_SNOOP) | -+ GEN8_PPAT(7, CHV_PPAT_SNOOP); -+ -+ vgpu_vreg(vgpu, offset) = lower_32_bits(pat); -+ -+ return 0; -+} -+ - static int mmio_read_from_hw(struct intel_vgpu *vgpu, - unsigned int offset, void *p_data, unsigned int bytes) - { -@@ -2778,7 +2806,7 @@ static int init_broadwell_mmio_info(struct intel_gvt *gvt) - - MMIO_DH(GEN6_PCODE_MAILBOX, D_BDW_PLUS, NULL, mailbox_write); - -- MMIO_D(GEN8_PRIVATE_PAT_LO, D_BDW_PLUS); -+ MMIO_D(GEN8_PRIVATE_PAT_LO, D_BDW_PLUS & ~D_BXT); - MMIO_D(GEN8_PRIVATE_PAT_HI, D_BDW_PLUS); - - MMIO_D(GAMTARBMODE, D_BDW_PLUS); -@@ -3104,7 +3132,7 @@ static int init_skl_mmio_info(struct intel_gvt *gvt) - NULL, NULL); - - MMIO_D(GAMT_CHKN_BIT_REG, D_KBL | D_CFL); -- MMIO_D(GEN9_CTX_PREEMPT_REG, D_SKL_PLUS); -+ MMIO_D(GEN9_CTX_PREEMPT_REG, D_SKL_PLUS & ~D_BXT); - - return 0; - } -@@ -3278,9 +3306,17 @@ static int init_bxt_mmio_info(struct intel_gvt *gvt) - MMIO_D(GEN8_PUSHBUS_SHIFT, D_BXT); - MMIO_D(GEN6_GFXPAUSE, D_BXT); - MMIO_DFH(GEN8_L3SQCREG1, D_BXT, F_CMD_ACCESS, NULL, NULL); -+ MMIO_DFH(GEN8_L3CNTLREG, D_BXT, F_CMD_ACCESS, NULL, NULL); -+ MMIO_DFH(_MMIO(0x20D8), D_BXT, F_CMD_ACCESS, NULL, NULL); -+ MMIO_F(HSW_CS_GPR(0), 0x40, F_CMD_ACCESS, 0, 0, D_BXT, NULL, NULL); -+ MMIO_F(_MMIO(0x12600), 0x40, F_CMD_ACCESS, 0, 0, D_BXT, NULL, NULL); -+ MMIO_F(BCS_GPR(0), 0x40, F_CMD_ACCESS, 0, 0, D_BXT, NULL, NULL); -+ MMIO_F(_MMIO(0x1a600), 0x40, F_CMD_ACCESS, 0, 0, D_BXT, NULL, NULL); - - MMIO_DFH(GEN9_CTX_PREEMPT_REG, D_BXT, F_CMD_ACCESS, NULL, NULL); - -+ MMIO_DH(GEN8_PRIVATE_PAT_LO, D_BXT, NULL, bxt_ppat_low_write); -+ - return 0; - } - -diff --git a/drivers/gpu/drm/i915/gvt/mmio.c b/drivers/gpu/drm/i915/gvt/mmio.c -index a55178884d67a..e0e7adc545a5b 100644 ---- a/drivers/gpu/drm/i915/gvt/mmio.c -+++ b/drivers/gpu/drm/i915/gvt/mmio.c -@@ -271,6 +271,11 @@ void intel_vgpu_reset_mmio(struct intel_vgpu *vgpu, bool dmlr) - vgpu_vreg_t(vgpu, BXT_PHY_CTL(PORT_C)) |= - BXT_PHY_CMNLANE_POWERDOWN_ACK | - BXT_PHY_LANE_POWERDOWN_ACK; -+ vgpu_vreg_t(vgpu, SKL_FUSE_STATUS) |= -+ SKL_FUSE_DOWNLOAD_STATUS | -+ SKL_FUSE_PG_DIST_STATUS(SKL_PG0) | -+ SKL_FUSE_PG_DIST_STATUS(SKL_PG1) | -+ SKL_FUSE_PG_DIST_STATUS(SKL_PG2); - } - } else { - #define GVT_GEN8_MMIO_RESET_OFFSET (0x44200) -diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c -index 32e57635709ad..4deb7fec5eb52 100644 ---- a/drivers/gpu/drm/i915/gvt/vgpu.c -+++ b/drivers/gpu/drm/i915/gvt/vgpu.c -@@ -432,8 +432,9 @@ static struct intel_vgpu *__intel_gvt_create_vgpu(struct intel_gvt *gvt, - if (ret) - goto out_clean_sched_policy; - -- /*TODO: add more platforms support */ -- if (IS_SKYLAKE(gvt->dev_priv) || IS_KABYLAKE(gvt->dev_priv)) -+ if (IS_BROADWELL(gvt->dev_priv) || IS_BROXTON(gvt->dev_priv)) -+ ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_B); -+ else - ret = intel_gvt_hypervisor_set_edid(vgpu, PORT_D); - if (ret) - goto out_clean_sched_policy; -diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c -index 0b1223f360d97..f35757b63ea78 100644 ---- a/drivers/net/dsa/b53/b53_common.c -+++ b/drivers/net/dsa/b53/b53_common.c -@@ -514,6 +514,19 @@ void b53_imp_vlan_setup(struct dsa_switch *ds, int cpu_port) - } - EXPORT_SYMBOL(b53_imp_vlan_setup); - -+static void b53_port_set_learning(struct b53_device *dev, int port, -+ bool learning) -+{ -+ u16 reg; -+ -+ b53_read16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, ®); -+ if (learning) -+ reg &= ~BIT(port); -+ else -+ reg |= BIT(port); -+ b53_write16(dev, B53_CTRL_PAGE, B53_DIS_LEARNING, reg); -+} -+ - int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) - { - struct b53_device *dev = ds->priv; -@@ -527,6 +540,7 @@ int b53_enable_port(struct dsa_switch *ds, int port, struct phy_device *phy) - cpu_port = ds->ports[port].cpu_dp->index; - - b53_br_egress_floods(ds, port, true, true); -+ b53_port_set_learning(dev, port, false); - - if (dev->ops->irq_enable) - ret = dev->ops->irq_enable(dev, port); -@@ -645,6 +659,7 @@ static void b53_enable_cpu_port(struct b53_device *dev, int port) - b53_brcm_hdr_setup(dev->ds, port); - - b53_br_egress_floods(dev->ds, port, true, true); -+ b53_port_set_learning(dev, port, false); - } - - static void b53_enable_mib(struct b53_device *dev) -@@ -1704,6 +1719,8 @@ int b53_br_join(struct dsa_switch *ds, int port, struct net_device *br) - b53_write16(dev, B53_PVLAN_PAGE, B53_PVLAN_PORT_MASK(port), pvlan); - dev->ports[port].vlan_ctl_mask = pvlan; - -+ b53_port_set_learning(dev, port, true); -+ - return 0; - } - EXPORT_SYMBOL(b53_br_join); -@@ -1751,6 +1768,7 @@ void b53_br_leave(struct dsa_switch *ds, int port, struct net_device *br) - vl->untag |= BIT(port) | BIT(cpu_port); - b53_set_vlan_entry(dev, pvid, vl); - } -+ b53_port_set_learning(dev, port, false); - } - EXPORT_SYMBOL(b53_br_leave); - -diff --git a/drivers/net/dsa/b53/b53_regs.h b/drivers/net/dsa/b53/b53_regs.h -index c90985c294a2e..b2c539a421545 100644 ---- a/drivers/net/dsa/b53/b53_regs.h -+++ b/drivers/net/dsa/b53/b53_regs.h -@@ -115,6 +115,7 @@ - #define B53_UC_FLOOD_MASK 0x32 - #define B53_MC_FLOOD_MASK 0x34 - #define B53_IPMC_FLOOD_MASK 0x36 -+#define B53_DIS_LEARNING 0x3c - - /* - * Override Ports 0-7 State on devices with xMII interfaces (8 bit) -diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c -index 6dd29bad1609f..ca425c15953b1 100644 ---- a/drivers/net/dsa/bcm_sf2.c -+++ b/drivers/net/dsa/bcm_sf2.c -@@ -172,11 +172,6 @@ static int bcm_sf2_port_setup(struct dsa_switch *ds, int port, - reg &= ~P_TXQ_PSM_VDD(port); - core_writel(priv, reg, CORE_MEM_PSM_VDD_CTRL); - -- /* Enable learning */ -- reg = core_readl(priv, CORE_DIS_LEARN); -- reg &= ~BIT(port); -- core_writel(priv, reg, CORE_DIS_LEARN); -- - /* Enable Broadcom tags for that port if requested */ - if (priv->brcm_tag_mask & BIT(port)) - b53_brcm_hdr_setup(ds, port); -diff --git a/fs/btrfs/block-group.c b/fs/btrfs/block-group.c -index 08ca9441270d2..a352c1704042d 100644 ---- a/fs/btrfs/block-group.c -+++ b/fs/btrfs/block-group.c -@@ -2048,8 +2048,17 @@ static u64 update_block_group_flags(struct btrfs_fs_info *fs_info, u64 flags) - return flags; - } - --int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache) -- -+/* -+ * Mark one block group RO, can be called several times for the same block -+ * group. -+ * -+ * @cache: the destination block group -+ * @do_chunk_alloc: whether need to do chunk pre-allocation, this is to -+ * ensure we still have some free space after marking this -+ * block group RO. -+ */ -+int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache, -+ bool do_chunk_alloc) - { - struct btrfs_fs_info *fs_info = cache->fs_info; - struct btrfs_trans_handle *trans; -@@ -2079,25 +2088,29 @@ again: - goto again; - } - -- /* -- * if we are changing raid levels, try to allocate a corresponding -- * block group with the new raid level. -- */ -- alloc_flags = update_block_group_flags(fs_info, cache->flags); -- if (alloc_flags != cache->flags) { -- ret = btrfs_chunk_alloc(trans, alloc_flags, CHUNK_ALLOC_FORCE); -+ if (do_chunk_alloc) { - /* -- * ENOSPC is allowed here, we may have enough space -- * already allocated at the new raid level to -- * carry on -+ * If we are changing raid levels, try to allocate a -+ * corresponding block group with the new raid level. - */ -- if (ret == -ENOSPC) -- ret = 0; -- if (ret < 0) -- goto out; -+ alloc_flags = update_block_group_flags(fs_info, cache->flags); -+ if (alloc_flags != cache->flags) { -+ ret = btrfs_chunk_alloc(trans, alloc_flags, -+ CHUNK_ALLOC_FORCE); -+ /* -+ * ENOSPC is allowed here, we may have enough space -+ * already allocated at the new raid level to carry on -+ */ -+ if (ret == -ENOSPC) -+ ret = 0; -+ if (ret < 0) -+ goto out; -+ } - } - -- ret = inc_block_group_ro(cache, 0); -+ ret = inc_block_group_ro(cache, !do_chunk_alloc); -+ if (!do_chunk_alloc) -+ goto unlock_out; - if (!ret) - goto out; - alloc_flags = btrfs_get_alloc_profile(fs_info, cache->space_info->flags); -@@ -2112,6 +2125,7 @@ out: - check_system_chunk(trans, alloc_flags); - mutex_unlock(&fs_info->chunk_mutex); - } -+unlock_out: - mutex_unlock(&fs_info->ro_block_group_mutex); - - btrfs_end_transaction(trans); -diff --git a/fs/btrfs/block-group.h b/fs/btrfs/block-group.h -index c391800388dda..0758e6d52acba 100644 ---- a/fs/btrfs/block-group.h -+++ b/fs/btrfs/block-group.h -@@ -205,7 +205,8 @@ int btrfs_read_block_groups(struct btrfs_fs_info *info); - int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 bytes_used, - u64 type, u64 chunk_offset, u64 size); - void btrfs_create_pending_block_groups(struct btrfs_trans_handle *trans); --int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache); -+int btrfs_inc_block_group_ro(struct btrfs_block_group_cache *cache, -+ bool do_chunk_alloc); - void btrfs_dec_block_group_ro(struct btrfs_block_group_cache *cache); - int btrfs_start_dirty_block_groups(struct btrfs_trans_handle *trans); - int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans); -diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c -index 05b3e27b21d44..68b5d7c4aa491 100644 ---- a/fs/btrfs/relocation.c -+++ b/fs/btrfs/relocation.c -@@ -4428,7 +4428,7 @@ int btrfs_relocate_block_group(struct btrfs_fs_info *fs_info, u64 group_start) - rc->extent_root = extent_root; - rc->block_group = bg; - -- ret = btrfs_inc_block_group_ro(rc->block_group); -+ ret = btrfs_inc_block_group_ro(rc->block_group, true); - if (ret) { - err = ret; - goto out; -diff --git a/fs/btrfs/scrub.c b/fs/btrfs/scrub.c -index 93d7cb56e44b2..e5db948daa123 100644 ---- a/fs/btrfs/scrub.c -+++ b/fs/btrfs/scrub.c -@@ -3560,7 +3560,26 @@ int scrub_enumerate_chunks(struct scrub_ctx *sctx, - * -> btrfs_scrub_pause() - */ - scrub_pause_on(fs_info); -- ret = btrfs_inc_block_group_ro(cache); -+ -+ /* -+ * Don't do chunk preallocation for scrub. -+ * -+ * This is especially important for SYSTEM bgs, or we can hit -+ * -EFBIG from btrfs_finish_chunk_alloc() like: -+ * 1. The only SYSTEM bg is marked RO. -+ * Since SYSTEM bg is small, that's pretty common. -+ * 2. New SYSTEM bg will be allocated -+ * Due to regular version will allocate new chunk. -+ * 3. New SYSTEM bg is empty and will get cleaned up -+ * Before cleanup really happens, it's marked RO again. -+ * 4. Empty SYSTEM bg get scrubbed -+ * We go back to 2. -+ * -+ * This can easily boost the amount of SYSTEM chunks if cleaner -+ * thread can't be triggered fast enough, and use up all space -+ * of btrfs_super_block::sys_chunk_array -+ */ -+ ret = btrfs_inc_block_group_ro(cache, false); - if (!ret && sctx->is_dev_replace) { - /* - * If we are doing a device replace wait for any tasks -diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h -index e3688312e9f1b..43bacf0a6bd31 100644 ---- a/fs/fuse/fuse_i.h -+++ b/fs/fuse/fuse_i.h -@@ -791,6 +791,7 @@ static inline u64 fuse_get_attr_version(struct fuse_conn *fc) - - static inline void fuse_make_bad(struct inode *inode) - { -+ remove_inode_hash(inode); - set_bit(FUSE_I_BAD, &get_fuse_inode(inode)->state); - } - -diff --git a/include/crypto/cast6.h b/include/crypto/cast6.h -index c71f6ef47f0f4..4c8d0c72f78d4 100644 ---- a/include/crypto/cast6.h -+++ b/include/crypto/cast6.h -@@ -19,7 +19,7 @@ int __cast6_setkey(struct cast6_ctx *ctx, const u8 *key, - unsigned int keylen, u32 *flags); - int cast6_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); - --void __cast6_encrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); --void __cast6_decrypt(struct cast6_ctx *ctx, u8 *dst, const u8 *src); -+void __cast6_encrypt(const void *ctx, u8 *dst, const u8 *src); -+void __cast6_decrypt(const void *ctx, u8 *dst, const u8 *src); - - #endif -diff --git a/include/crypto/serpent.h b/include/crypto/serpent.h -index 7dd780c5d0589..75c7eaa208535 100644 ---- a/include/crypto/serpent.h -+++ b/include/crypto/serpent.h -@@ -22,7 +22,7 @@ int __serpent_setkey(struct serpent_ctx *ctx, const u8 *key, - unsigned int keylen); - int serpent_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); - --void __serpent_encrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src); --void __serpent_decrypt(struct serpent_ctx *ctx, u8 *dst, const u8 *src); -+void __serpent_encrypt(const void *ctx, u8 *dst, const u8 *src); -+void __serpent_decrypt(const void *ctx, u8 *dst, const u8 *src); - - #endif -diff --git a/include/crypto/xts.h b/include/crypto/xts.h -index 75fd96ff976b7..15ae7fdc04789 100644 ---- a/include/crypto/xts.h -+++ b/include/crypto/xts.h -@@ -8,8 +8,6 @@ - - #define XTS_BLOCK_SIZE 16 - --#define XTS_TWEAK_CAST(x) ((void (*)(void *, u8*, const u8*))(x)) -- - static inline int xts_check_key(struct crypto_tfm *tfm, - const u8 *key, unsigned int keylen) - { -diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c -index e6a43c0fdee88..ab2a4b7dfca57 100644 ---- a/kernel/bpf/verifier.c -+++ b/kernel/bpf/verifier.c -@@ -4268,10 +4268,14 @@ static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, - { - bool mask_to_left = (opcode == BPF_ADD && off_is_neg) || - (opcode == BPF_SUB && !off_is_neg); -- u32 off; -+ u32 off, max; - - switch (ptr_reg->type) { - case PTR_TO_STACK: -+ /* Offset 0 is out-of-bounds, but acceptable start for the -+ * left direction, see BPF_REG_FP. -+ */ -+ max = MAX_BPF_STACK + mask_to_left; - /* Indirect variable offset stack access is prohibited in - * unprivileged mode so it's not handled here. - */ -@@ -4279,16 +4283,17 @@ static int retrieve_ptr_limit(const struct bpf_reg_state *ptr_reg, - if (mask_to_left) - *ptr_limit = MAX_BPF_STACK + off; - else -- *ptr_limit = -off; -- return 0; -+ *ptr_limit = -off - 1; -+ return *ptr_limit >= max ? -ERANGE : 0; - case PTR_TO_MAP_VALUE: -+ max = ptr_reg->map_ptr->value_size; - if (mask_to_left) { - *ptr_limit = ptr_reg->umax_value + ptr_reg->off; - } else { - off = ptr_reg->smin_value + ptr_reg->off; -- *ptr_limit = ptr_reg->map_ptr->value_size - off; -+ *ptr_limit = ptr_reg->map_ptr->value_size - off - 1; - } -- return 0; -+ return *ptr_limit >= max ? -ERANGE : 0; - default: - return -EINVAL; - } -@@ -4341,6 +4346,7 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, - u32 alu_state, alu_limit; - struct bpf_reg_state tmp; - bool ret; -+ int err; - - if (can_skip_alu_sanitation(env, insn)) - return 0; -@@ -4356,10 +4362,13 @@ static int sanitize_ptr_alu(struct bpf_verifier_env *env, - alu_state |= ptr_is_dst_reg ? - BPF_ALU_SANITIZE_SRC : BPF_ALU_SANITIZE_DST; - -- if (retrieve_ptr_limit(ptr_reg, &alu_limit, opcode, off_is_neg)) -- return 0; -- if (update_alu_sanitation_state(aux, alu_state, alu_limit)) -- return -EACCES; -+ err = retrieve_ptr_limit(ptr_reg, &alu_limit, opcode, off_is_neg); -+ if (err < 0) -+ return err; -+ -+ err = update_alu_sanitation_state(aux, alu_state, alu_limit); -+ if (err < 0) -+ return err; - do_sim: - /* Simulate and find potential out-of-bounds access under - * speculative execution from truncation as a result of -@@ -4467,7 +4476,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, - case BPF_ADD: - ret = sanitize_ptr_alu(env, insn, ptr_reg, dst_reg, smin_val < 0); - if (ret < 0) { -- verbose(env, "R%d tried to add from different maps or paths\n", dst); -+ verbose(env, "R%d tried to add from different maps, paths, or prohibited types\n", dst); - return ret; - } - /* We can take a fixed offset as long as it doesn't overflow -@@ -4522,7 +4531,7 @@ static int adjust_ptr_min_max_vals(struct bpf_verifier_env *env, - case BPF_SUB: - ret = sanitize_ptr_alu(env, insn, ptr_reg, dst_reg, smin_val < 0); - if (ret < 0) { -- verbose(env, "R%d tried to sub from different maps or paths\n", dst); -+ verbose(env, "R%d tried to sub from different maps, paths, or prohibited types\n", dst); - return ret; - } - if (dst_reg == off_reg) { -@@ -9077,7 +9086,7 @@ static int fixup_bpf_calls(struct bpf_verifier_env *env) - off_reg = issrc ? insn->src_reg : insn->dst_reg; - if (isneg) - *patch++ = BPF_ALU64_IMM(BPF_MUL, off_reg, -1); -- *patch++ = BPF_MOV32_IMM(BPF_REG_AX, aux->alu_limit - 1); -+ *patch++ = BPF_MOV32_IMM(BPF_REG_AX, aux->alu_limit); - *patch++ = BPF_ALU64_REG(BPF_SUB, BPF_REG_AX, off_reg); - *patch++ = BPF_ALU64_REG(BPF_OR, BPF_REG_AX, off_reg); - *patch++ = BPF_ALU64_IMM(BPF_NEG, BPF_REG_AX, 0); -diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c -index d6619edd53e5a..edc505e07125b 100644 ---- a/net/dsa/tag_mtk.c -+++ b/net/dsa/tag_mtk.c -@@ -13,6 +13,7 @@ - #define MTK_HDR_LEN 4 - #define MTK_HDR_XMIT_UNTAGGED 0 - #define MTK_HDR_XMIT_TAGGED_TPID_8100 1 -+#define MTK_HDR_XMIT_TAGGED_TPID_88A8 2 - #define MTK_HDR_RECV_SOURCE_PORT_MASK GENMASK(2, 0) - #define MTK_HDR_XMIT_DP_BIT_MASK GENMASK(5, 0) - #define MTK_HDR_XMIT_SA_DIS BIT(6) -@@ -21,8 +22,8 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, - struct net_device *dev) - { - struct dsa_port *dp = dsa_slave_to_port(dev); -+ u8 xmit_tpid; - u8 *mtk_tag; -- bool is_vlan_skb = true; - unsigned char *dest = eth_hdr(skb)->h_dest; - bool is_multicast_skb = is_multicast_ether_addr(dest) && - !is_broadcast_ether_addr(dest); -@@ -33,13 +34,20 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, - * the both special and VLAN tag at the same time and then look up VLAN - * table with VID. - */ -- if (!skb_vlan_tagged(skb)) { -+ switch (skb->protocol) { -+ case htons(ETH_P_8021Q): -+ xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_8100; -+ break; -+ case htons(ETH_P_8021AD): -+ xmit_tpid = MTK_HDR_XMIT_TAGGED_TPID_88A8; -+ break; -+ default: - if (skb_cow_head(skb, MTK_HDR_LEN) < 0) - return NULL; - -+ xmit_tpid = MTK_HDR_XMIT_UNTAGGED; - skb_push(skb, MTK_HDR_LEN); - memmove(skb->data, skb->data + MTK_HDR_LEN, 2 * ETH_ALEN); -- is_vlan_skb = false; - } - - mtk_tag = skb->data + 2 * ETH_ALEN; -@@ -47,8 +55,7 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, - /* Mark tag attribute on special tag insertion to notify hardware - * whether that's a combined special tag with 802.1Q header. - */ -- mtk_tag[0] = is_vlan_skb ? MTK_HDR_XMIT_TAGGED_TPID_8100 : -- MTK_HDR_XMIT_UNTAGGED; -+ mtk_tag[0] = xmit_tpid; - mtk_tag[1] = (1 << dp->index) & MTK_HDR_XMIT_DP_BIT_MASK; - - /* Disable SA learning for multicast frames */ -@@ -56,7 +63,7 @@ static struct sk_buff *mtk_tag_xmit(struct sk_buff *skb, - mtk_tag[1] |= MTK_HDR_XMIT_SA_DIS; - - /* Tag control information is kept for 802.1Q */ -- if (!is_vlan_skb) { -+ if (xmit_tpid == MTK_HDR_XMIT_UNTAGGED) { - mtk_tag[2] = 0; - mtk_tag[3] = 0; - } -diff --git a/tools/testing/selftests/bpf/verifier/bounds_deduction.c b/tools/testing/selftests/bpf/verifier/bounds_deduction.c -index 1fd07a4f27ac2..c162498a64fc6 100644 ---- a/tools/testing/selftests/bpf/verifier/bounds_deduction.c -+++ b/tools/testing/selftests/bpf/verifier/bounds_deduction.c -@@ -6,8 +6,9 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types", - .errstr = "R0 tried to subtract pointer from scalar", -+ .result = REJECT, - }, - { - "check deducing bounds from const, 2", -@@ -20,6 +21,8 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0), - BPF_EXIT_INSN(), - }, -+ .errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types", -+ .result_unpriv = REJECT, - .result = ACCEPT, - .retval = 1, - }, -@@ -31,8 +34,9 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types", - .errstr = "R0 tried to subtract pointer from scalar", -+ .result = REJECT, - }, - { - "check deducing bounds from const, 4", -@@ -45,6 +49,8 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_1, BPF_REG_0), - BPF_EXIT_INSN(), - }, -+ .errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types", -+ .result_unpriv = REJECT, - .result = ACCEPT, - }, - { -@@ -55,8 +61,9 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types", - .errstr = "R0 tried to subtract pointer from scalar", -+ .result = REJECT, - }, - { - "check deducing bounds from const, 6", -@@ -67,8 +74,9 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types", - .errstr = "R0 tried to subtract pointer from scalar", -+ .result = REJECT, - }, - { - "check deducing bounds from const, 7", -@@ -80,8 +88,9 @@ - offsetof(struct __sk_buff, mark)), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R1 tried to sub from different maps, paths, or prohibited types", - .errstr = "dereference of modified ctx ptr", -+ .result = REJECT, - .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, - }, - { -@@ -94,8 +103,9 @@ - offsetof(struct __sk_buff, mark)), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types", - .errstr = "dereference of modified ctx ptr", -+ .result = REJECT, - .flags = F_NEEDS_EFFICIENT_UNALIGNED_ACCESS, - }, - { -@@ -106,8 +116,9 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, -+ .errstr_unpriv = "R0 tried to sub from different maps, paths, or prohibited types", - .errstr = "R0 tried to subtract pointer from scalar", -+ .result = REJECT, - }, - { - "check deducing bounds from const, 10", -@@ -119,6 +130,6 @@ - BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), - BPF_EXIT_INSN(), - }, -- .result = REJECT, - .errstr = "math between ctx pointer and register with unbounded min value is not allowed", -+ .result = REJECT, - }, -diff --git a/tools/testing/selftests/bpf/verifier/unpriv.c b/tools/testing/selftests/bpf/verifier/unpriv.c -index 91bb77c24a2ef..0d621c841db14 100644 ---- a/tools/testing/selftests/bpf/verifier/unpriv.c -+++ b/tools/testing/selftests/bpf/verifier/unpriv.c -@@ -495,7 +495,7 @@ - .result = ACCEPT, - }, - { -- "unpriv: adding of fp", -+ "unpriv: adding of fp, reg", - .insns = { - BPF_MOV64_IMM(BPF_REG_0, 0), - BPF_MOV64_IMM(BPF_REG_1, 0), -@@ -503,6 +503,19 @@ - BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8), - BPF_EXIT_INSN(), - }, -+ .errstr_unpriv = "R1 tried to add from different maps, paths, or prohibited types", -+ .result_unpriv = REJECT, -+ .result = ACCEPT, -+}, -+{ -+ "unpriv: adding of fp, imm", -+ .insns = { -+ BPF_MOV64_IMM(BPF_REG_0, 0), -+ BPF_MOV64_REG(BPF_REG_1, BPF_REG_10), -+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_1, 0), -+ BPF_STX_MEM(BPF_DW, BPF_REG_1, BPF_REG_0, -8), -+ BPF_EXIT_INSN(), -+ }, - .errstr_unpriv = "R1 stack pointer arithmetic goes out of range", - .result_unpriv = REJECT, - .result = ACCEPT, -diff --git a/tools/testing/selftests/bpf/verifier/value_ptr_arith.c b/tools/testing/selftests/bpf/verifier/value_ptr_arith.c -index a53d99cebd9ff..00b59d5d7a7f0 100644 ---- a/tools/testing/selftests/bpf/verifier/value_ptr_arith.c -+++ b/tools/testing/selftests/bpf/verifier/value_ptr_arith.c -@@ -169,7 +169,7 @@ - .fixup_map_array_48b = { 1 }, - .result = ACCEPT, - .result_unpriv = REJECT, -- .errstr_unpriv = "R2 tried to add from different maps or paths", -+ .errstr_unpriv = "R2 tried to add from different maps, paths, or prohibited types", - .retval = 0, - }, - { -@@ -516,6 +516,27 @@ - .result = ACCEPT, - .retval = 0xabcdef12, - }, -+{ -+ "map access: value_ptr += N, value_ptr -= N known scalar", -+ .insns = { -+ BPF_ST_MEM(BPF_DW, BPF_REG_10, -8, 0), -+ BPF_MOV64_REG(BPF_REG_2, BPF_REG_10), -+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_2, -8), -+ BPF_LD_MAP_FD(BPF_REG_1, 0), -+ BPF_RAW_INSN(BPF_JMP | BPF_CALL, 0, 0, 0, BPF_FUNC_map_lookup_elem), -+ BPF_JMP_IMM(BPF_JEQ, BPF_REG_0, 0, 6), -+ BPF_MOV32_IMM(BPF_REG_1, 0x12345678), -+ BPF_STX_MEM(BPF_W, BPF_REG_0, BPF_REG_1, 0), -+ BPF_ALU64_IMM(BPF_ADD, BPF_REG_0, 2), -+ BPF_MOV64_IMM(BPF_REG_1, 2), -+ BPF_ALU64_REG(BPF_SUB, BPF_REG_0, BPF_REG_1), -+ BPF_LDX_MEM(BPF_W, BPF_REG_0, BPF_REG_0, 0), -+ BPF_EXIT_INSN(), -+ }, -+ .fixup_map_array_48b = { 3 }, -+ .result = ACCEPT, -+ .retval = 0x12345678, -+}, - { - "map access: unknown scalar += value_ptr, 1", - .insns = { diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.107-108.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.107-108.patch deleted file mode 100644 index 36837ecbf0..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.107-108.patch +++ /dev/null @@ -1,1941 +0,0 @@ -diff --git a/Makefile b/Makefile -index 43159b21a83f4..b0abe257221a7 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 107 -+SUBLEVEL = 108 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -@@ -1177,15 +1177,17 @@ endef - define filechk_version.h - if [ $(SUBLEVEL) -gt 255 ]; then \ - echo \#define LINUX_VERSION_CODE $(shell \ -- expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + 255); \ -+ expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + 255); \ - else \ - echo \#define LINUX_VERSION_CODE $(shell \ -- expr $(VERSION) \* 65536 + 0$(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ -+ expr $(VERSION) \* 65536 + $(PATCHLEVEL) \* 256 + $(SUBLEVEL)); \ - fi; \ - echo '#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + \ - ((c) > 255 ? 255 : (c)))' - endef - -+$(version_h): PATCHLEVEL := $(if $(PATCHLEVEL), $(PATCHLEVEL), 0) -+$(version_h): SUBLEVEL := $(if $(SUBLEVEL), $(SUBLEVEL), 0) - $(version_h): FORCE - $(call filechk,version.h) - $(Q)rm -f $(old_version_h) -diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S -index a874b753397ec..b62d74a2c73a5 100644 ---- a/arch/arm/kernel/entry-armv.S -+++ b/arch/arm/kernel/entry-armv.S -@@ -252,31 +252,10 @@ __und_svc: - #else - svc_entry - #endif -- @ -- @ call emulation code, which returns using r9 if it has emulated -- @ the instruction, or the more conventional lr if we are to treat -- @ this as a real undefined instruction -- @ -- @ r0 - instruction -- @ --#ifndef CONFIG_THUMB2_KERNEL -- ldr r0, [r4, #-4] --#else -- mov r1, #2 -- ldrh r0, [r4, #-2] @ Thumb instruction at LR - 2 -- cmp r0, #0xe800 @ 32-bit instruction if xx >= 0 -- blo __und_svc_fault -- ldrh r9, [r4] @ bottom 16 bits -- add r4, r4, #2 -- str r4, [sp, #S_PC] -- orr r0, r9, r0, lsl #16 --#endif -- badr r9, __und_svc_finish -- mov r2, r4 -- bl call_fpe - - mov r1, #4 @ PC correction to apply --__und_svc_fault: -+ THUMB( tst r5, #PSR_T_BIT ) @ exception taken in Thumb mode? -+ THUMB( movne r1, #2 ) @ if so, fix up PC correction - mov r0, sp @ struct pt_regs *regs - bl __und_fault - -diff --git a/arch/arm/vfp/entry.S b/arch/arm/vfp/entry.S -index 0186cf9da890b..27b0a1f27fbdf 100644 ---- a/arch/arm/vfp/entry.S -+++ b/arch/arm/vfp/entry.S -@@ -37,20 +37,3 @@ ENDPROC(vfp_null_entry) - .align 2 - .LCvfp: - .word vfp_vector -- --@ This code is called if the VFP does not exist. It needs to flag the --@ failure to the VFP initialisation code. -- -- __INIT --ENTRY(vfp_testing_entry) -- dec_preempt_count_ti r10, r4 -- ldr r0, VFP_arch_address -- str r0, [r0] @ set to non-zero value -- ret r9 @ we have handled the fault --ENDPROC(vfp_testing_entry) -- -- .align 2 --VFP_arch_address: -- .word VFP_arch -- -- __FINIT -diff --git a/arch/arm/vfp/vfphw.S b/arch/arm/vfp/vfphw.S -index b2e560290860e..b530db8f2c6c8 100644 ---- a/arch/arm/vfp/vfphw.S -+++ b/arch/arm/vfp/vfphw.S -@@ -78,11 +78,6 @@ - ENTRY(vfp_support_entry) - DBGSTR3 "instr %08x pc %08x state %p", r0, r2, r10 - -- ldr r3, [sp, #S_PSR] @ Neither lazy restore nor FP exceptions -- and r3, r3, #MODE_MASK @ are supported in kernel mode -- teq r3, #USR_MODE -- bne vfp_kmode_exception @ Returns through lr -- - VFPFMRX r1, FPEXC @ Is the VFP enabled? - DBGSTR1 "fpexc %08x", r1 - tst r1, #FPEXC_EN -diff --git a/arch/arm/vfp/vfpmodule.c b/arch/arm/vfp/vfpmodule.c -index 8c9e7f9f0277d..2cb355c1b5b71 100644 ---- a/arch/arm/vfp/vfpmodule.c -+++ b/arch/arm/vfp/vfpmodule.c -@@ -23,6 +23,7 @@ - #include - #include - #include -+#include - #include - - #include "vfpinstr.h" -@@ -31,7 +32,6 @@ - /* - * Our undef handlers (in entry.S) - */ --asmlinkage void vfp_testing_entry(void); - asmlinkage void vfp_support_entry(void); - asmlinkage void vfp_null_entry(void); - -@@ -42,7 +42,7 @@ asmlinkage void (*vfp_vector)(void) = vfp_null_entry; - * Used in startup: set to non-zero if VFP checks fail - * After startup, holds VFP architecture - */ --unsigned int VFP_arch; -+static unsigned int __initdata VFP_arch; - - /* - * The pointer to the vfpstate structure of the thread which currently -@@ -436,7 +436,7 @@ static void vfp_enable(void *unused) - * present on all CPUs within a SMP complex. Needs to be called prior to - * vfp_init(). - */ --void vfp_disable(void) -+void __init vfp_disable(void) - { - if (VFP_arch) { - pr_debug("%s: should be called prior to vfp_init\n", __func__); -@@ -642,7 +642,9 @@ static int vfp_starting_cpu(unsigned int unused) - return 0; - } - --void vfp_kmode_exception(void) -+#ifdef CONFIG_KERNEL_MODE_NEON -+ -+static int vfp_kmode_exception(struct pt_regs *regs, unsigned int instr) - { - /* - * If we reach this point, a floating point exception has been raised -@@ -660,9 +662,51 @@ void vfp_kmode_exception(void) - pr_crit("BUG: unsupported FP instruction in kernel mode\n"); - else - pr_crit("BUG: FP instruction issued in kernel mode with FP unit disabled\n"); -+ pr_crit("FPEXC == 0x%08x\n", fmrx(FPEXC)); -+ return 1; - } - --#ifdef CONFIG_KERNEL_MODE_NEON -+static struct undef_hook vfp_kmode_exception_hook[] = {{ -+ .instr_mask = 0xfe000000, -+ .instr_val = 0xf2000000, -+ .cpsr_mask = MODE_MASK | PSR_T_BIT, -+ .cpsr_val = SVC_MODE, -+ .fn = vfp_kmode_exception, -+}, { -+ .instr_mask = 0xff100000, -+ .instr_val = 0xf4000000, -+ .cpsr_mask = MODE_MASK | PSR_T_BIT, -+ .cpsr_val = SVC_MODE, -+ .fn = vfp_kmode_exception, -+}, { -+ .instr_mask = 0xef000000, -+ .instr_val = 0xef000000, -+ .cpsr_mask = MODE_MASK | PSR_T_BIT, -+ .cpsr_val = SVC_MODE | PSR_T_BIT, -+ .fn = vfp_kmode_exception, -+}, { -+ .instr_mask = 0xff100000, -+ .instr_val = 0xf9000000, -+ .cpsr_mask = MODE_MASK | PSR_T_BIT, -+ .cpsr_val = SVC_MODE | PSR_T_BIT, -+ .fn = vfp_kmode_exception, -+}, { -+ .instr_mask = 0x0c000e00, -+ .instr_val = 0x0c000a00, -+ .cpsr_mask = MODE_MASK, -+ .cpsr_val = SVC_MODE, -+ .fn = vfp_kmode_exception, -+}}; -+ -+static int __init vfp_kmode_exception_hook_init(void) -+{ -+ int i; -+ -+ for (i = 0; i < ARRAY_SIZE(vfp_kmode_exception_hook); i++) -+ register_undef_hook(&vfp_kmode_exception_hook[i]); -+ return 0; -+} -+subsys_initcall(vfp_kmode_exception_hook_init); - - /* - * Kernel-side NEON support functions -@@ -708,6 +752,21 @@ EXPORT_SYMBOL(kernel_neon_end); - - #endif /* CONFIG_KERNEL_MODE_NEON */ - -+static int __init vfp_detect(struct pt_regs *regs, unsigned int instr) -+{ -+ VFP_arch = UINT_MAX; /* mark as not present */ -+ regs->ARM_pc += 4; -+ return 0; -+} -+ -+static struct undef_hook vfp_detect_hook __initdata = { -+ .instr_mask = 0x0c000e00, -+ .instr_val = 0x0c000a00, -+ .cpsr_mask = MODE_MASK, -+ .cpsr_val = SVC_MODE, -+ .fn = vfp_detect, -+}; -+ - /* - * VFP support code initialisation. - */ -@@ -728,10 +787,11 @@ static int __init vfp_init(void) - * The handler is already setup to just log calls, so - * we just need to read the VFPSID register. - */ -- vfp_vector = vfp_testing_entry; -+ register_undef_hook(&vfp_detect_hook); - barrier(); - vfpsid = fmrx(FPSID); - barrier(); -+ unregister_undef_hook(&vfp_detect_hook); - vfp_vector = vfp_null_entry; - - pr_info("VFP support v0.3: "); -diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig -index a0fa4be94a68e..6b23a0cb2b353 100644 ---- a/arch/riscv/Kconfig -+++ b/arch/riscv/Kconfig -@@ -58,7 +58,6 @@ config RISCV - select EDAC_SUPPORT - select ARCH_HAS_GIGANTIC_PAGE - select ARCH_WANT_HUGE_PMD_SHARE if 64BIT -- select SPARSEMEM_STATIC if 32BIT - select ARCH_WANT_DEFAULT_TOPDOWN_MMAP_LAYOUT if MMU - select HAVE_ARCH_MMAP_RND_BITS - select HAVE_COPY_THREAD_TLS -@@ -102,7 +101,8 @@ config ARCH_FLATMEM_ENABLE - config ARCH_SPARSEMEM_ENABLE - def_bool y - depends on MMU -- select SPARSEMEM_VMEMMAP_ENABLE -+ select SPARSEMEM_STATIC if 32BIT && SPARSMEM -+ select SPARSEMEM_VMEMMAP_ENABLE if 64BIT - - config ARCH_SELECT_MEMORY_MODEL - def_bool ARCH_SPARSEMEM_ENABLE -diff --git a/arch/s390/kernel/vtime.c b/arch/s390/kernel/vtime.c -index 3e72f955bff7f..6e60cc2443b2e 100644 ---- a/arch/s390/kernel/vtime.c -+++ b/arch/s390/kernel/vtime.c -@@ -217,7 +217,7 @@ void vtime_flush(struct task_struct *tsk) - avg_steal = S390_lowcore.avg_steal_timer / 2; - if ((s64) steal > 0) { - S390_lowcore.steal_timer = 0; -- account_steal_time(steal); -+ account_steal_time(cputime_to_nsecs(steal)); - avg_steal += steal; - } - S390_lowcore.avg_steal_timer = avg_steal; -diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c -index eb8bd0eeace7d..5965d341350ca 100644 ---- a/arch/x86/events/intel/ds.c -+++ b/arch/x86/events/intel/ds.c -@@ -1890,7 +1890,7 @@ static void intel_pmu_drain_pebs_nhm(struct pt_regs *iregs) - */ - if (!pebs_status && cpuc->pebs_enabled && - !(cpuc->pebs_enabled & (cpuc->pebs_enabled-1))) -- pebs_status = cpuc->pebs_enabled; -+ pebs_status = p->status = cpuc->pebs_enabled; - - bit = find_first_bit((unsigned long *)&pebs_status, - x86_pmu.max_pebs_events); -diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h -index a07dfdf7759ec..537c0dd4c3d4a 100644 ---- a/arch/x86/include/asm/processor.h -+++ b/arch/x86/include/asm/processor.h -@@ -506,15 +506,6 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset, - *size = fpu_kernel_xstate_size; - } - --/* -- * Thread-synchronous status. -- * -- * This is different from the flags in that nobody else -- * ever touches our thread-synchronous status, so we don't -- * have to worry about atomic accesses. -- */ --#define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/ -- - /* - * Set IOPL bits in EFLAGS from given mask - */ -diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h -index f9453536f9bbc..a4de7aa7500fb 100644 ---- a/arch/x86/include/asm/thread_info.h -+++ b/arch/x86/include/asm/thread_info.h -@@ -221,10 +221,31 @@ static inline int arch_within_stack_frames(const void * const stack, - - #endif - -+/* -+ * Thread-synchronous status. -+ * -+ * This is different from the flags in that nobody else -+ * ever touches our thread-synchronous status, so we don't -+ * have to worry about atomic accesses. -+ */ -+#define TS_COMPAT 0x0002 /* 32bit syscall active (64BIT)*/ -+ -+#ifndef __ASSEMBLY__ - #ifdef CONFIG_COMPAT - #define TS_I386_REGS_POKED 0x0004 /* regs poked by 32-bit ptracer */ -+#define TS_COMPAT_RESTART 0x0008 -+ -+#define arch_set_restart_data arch_set_restart_data -+ -+static inline void arch_set_restart_data(struct restart_block *restart) -+{ -+ struct thread_info *ti = current_thread_info(); -+ if (ti->status & TS_COMPAT) -+ ti->status |= TS_COMPAT_RESTART; -+ else -+ ti->status &= ~TS_COMPAT_RESTART; -+} - #endif --#ifndef __ASSEMBLY__ - - #ifdef CONFIG_X86_32 - #define in_ia32_syscall() true -diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c -index 3dca7b8642e9c..7fafa859e9f25 100644 ---- a/arch/x86/kernel/apic/apic.c -+++ b/arch/x86/kernel/apic/apic.c -@@ -2354,6 +2354,11 @@ static int cpuid_to_apicid[] = { - [0 ... NR_CPUS - 1] = -1, - }; - -+bool arch_match_cpu_phys_id(int cpu, u64 phys_id) -+{ -+ return phys_id == cpuid_to_apicid[cpu]; -+} -+ - #ifdef CONFIG_SMP - /** - * apic_id_is_primary_thread - Check whether APIC ID belongs to a primary thread -diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c -index 4b6301946f455..0edcf69659eee 100644 ---- a/arch/x86/kernel/apic/io_apic.c -+++ b/arch/x86/kernel/apic/io_apic.c -@@ -1046,6 +1046,16 @@ static int mp_map_pin_to_irq(u32 gsi, int idx, int ioapic, int pin, - if (idx >= 0 && test_bit(mp_irqs[idx].srcbus, mp_bus_not_pci)) { - irq = mp_irqs[idx].srcbusirq; - legacy = mp_is_legacy_irq(irq); -+ /* -+ * IRQ2 is unusable for historical reasons on systems which -+ * have a legacy PIC. See the comment vs. IRQ2 further down. -+ * -+ * If this gets removed at some point then the related code -+ * in lapic_assign_system_vectors() needs to be adjusted as -+ * well. -+ */ -+ if (legacy && irq == PIC_CASCADE_IR) -+ return -EINVAL; - } - - mutex_lock(&ioapic_mutex); -diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c -index 8eb7193e158dd..2fdbf5ef8c39c 100644 ---- a/arch/x86/kernel/signal.c -+++ b/arch/x86/kernel/signal.c -@@ -770,30 +770,8 @@ handle_signal(struct ksignal *ksig, struct pt_regs *regs) - - static inline unsigned long get_nr_restart_syscall(const struct pt_regs *regs) - { -- /* -- * This function is fundamentally broken as currently -- * implemented. -- * -- * The idea is that we want to trigger a call to the -- * restart_block() syscall and that we want in_ia32_syscall(), -- * in_x32_syscall(), etc. to match whatever they were in the -- * syscall being restarted. We assume that the syscall -- * instruction at (regs->ip - 2) matches whatever syscall -- * instruction we used to enter in the first place. -- * -- * The problem is that we can get here when ptrace pokes -- * syscall-like values into regs even if we're not in a syscall -- * at all. -- * -- * For now, we maintain historical behavior and guess based on -- * stored state. We could do better by saving the actual -- * syscall arch in restart_block or (with caveats on x32) by -- * checking if regs->ip points to 'int $0x80'. The current -- * behavior is incorrect if a tracer has a different bitness -- * than the tracee. -- */ - #ifdef CONFIG_IA32_EMULATION -- if (current_thread_info()->status & (TS_COMPAT|TS_I386_REGS_POKED)) -+ if (current_thread_info()->status & TS_COMPAT_RESTART) - return __NR_ia32_restart_syscall; - #endif - #ifdef CONFIG_X86_X32_ABI -diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c -index 8e3d0228b05bb..137a7ba053d78 100644 ---- a/drivers/base/power/runtime.c -+++ b/drivers/base/power/runtime.c -@@ -325,22 +325,22 @@ static void rpm_put_suppliers(struct device *dev) - static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - __releases(&dev->power.lock) __acquires(&dev->power.lock) - { -- bool use_links = dev->power.links_count > 0; -- bool get = false; - int retval, idx; -- bool put; -+ bool use_links = dev->power.links_count > 0; - - if (dev->power.irq_safe) { - spin_unlock(&dev->power.lock); -- } else if (!use_links) { -- spin_unlock_irq(&dev->power.lock); - } else { -- get = dev->power.runtime_status == RPM_RESUMING; -- - spin_unlock_irq(&dev->power.lock); - -- /* Resume suppliers if necessary. */ -- if (get) { -+ /* -+ * Resume suppliers if necessary. -+ * -+ * The device's runtime PM status cannot change until this -+ * routine returns, so it is safe to read the status outside of -+ * the lock. -+ */ -+ if (use_links && dev->power.runtime_status == RPM_RESUMING) { - idx = device_links_read_lock(); - - retval = rpm_get_suppliers(dev); -@@ -355,36 +355,24 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - - if (dev->power.irq_safe) { - spin_lock(&dev->power.lock); -- return retval; -- } -- -- spin_lock_irq(&dev->power.lock); -- -- if (!use_links) -- return retval; -- -- /* -- * If the device is suspending and the callback has returned success, -- * drop the usage counters of the suppliers that have been reference -- * counted on its resume. -- * -- * Do that if the resume fails too. -- */ -- put = dev->power.runtime_status == RPM_SUSPENDING && !retval; -- if (put) -- __update_runtime_status(dev, RPM_SUSPENDED); -- else -- put = get && retval; -- -- if (put) { -- spin_unlock_irq(&dev->power.lock); -- -- idx = device_links_read_lock(); -+ } else { -+ /* -+ * If the device is suspending and the callback has returned -+ * success, drop the usage counters of the suppliers that have -+ * been reference counted on its resume. -+ * -+ * Do that if resume fails too. -+ */ -+ if (use_links -+ && ((dev->power.runtime_status == RPM_SUSPENDING && !retval) -+ || (dev->power.runtime_status == RPM_RESUMING && retval))) { -+ idx = device_links_read_lock(); - --fail: -- rpm_put_suppliers(dev); -+ fail: -+ rpm_put_suppliers(dev); - -- device_links_read_unlock(idx); -+ device_links_read_unlock(idx); -+ } - - spin_lock_irq(&dev->power.lock); - } -diff --git a/drivers/counter/stm32-timer-cnt.c b/drivers/counter/stm32-timer-cnt.c -index 644ba18a72ad5..75e08a98d09be 100644 ---- a/drivers/counter/stm32-timer-cnt.c -+++ b/drivers/counter/stm32-timer-cnt.c -@@ -25,6 +25,7 @@ struct stm32_timer_cnt { - struct regmap *regmap; - struct clk *clk; - u32 ceiling; -+ u32 max_arr; - }; - - /** -@@ -35,13 +36,14 @@ struct stm32_timer_cnt { - * @STM32_COUNT_ENCODER_MODE_3: counts on both TI1FP1 and TI2FP2 edges - */ - enum stm32_count_function { -- STM32_COUNT_SLAVE_MODE_DISABLED = -1, -+ STM32_COUNT_SLAVE_MODE_DISABLED, - STM32_COUNT_ENCODER_MODE_1, - STM32_COUNT_ENCODER_MODE_2, - STM32_COUNT_ENCODER_MODE_3, - }; - - static enum counter_count_function stm32_count_functions[] = { -+ [STM32_COUNT_SLAVE_MODE_DISABLED] = COUNTER_COUNT_FUNCTION_INCREASE, - [STM32_COUNT_ENCODER_MODE_1] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_A, - [STM32_COUNT_ENCODER_MODE_2] = COUNTER_COUNT_FUNCTION_QUADRATURE_X2_B, - [STM32_COUNT_ENCODER_MODE_3] = COUNTER_COUNT_FUNCTION_QUADRATURE_X4, -@@ -88,6 +90,9 @@ static int stm32_count_function_get(struct counter_device *counter, - regmap_read(priv->regmap, TIM_SMCR, &smcr); - - switch (smcr & TIM_SMCR_SMS) { -+ case 0: -+ *function = STM32_COUNT_SLAVE_MODE_DISABLED; -+ return 0; - case 1: - *function = STM32_COUNT_ENCODER_MODE_1; - return 0; -@@ -97,9 +102,9 @@ static int stm32_count_function_get(struct counter_device *counter, - case 3: - *function = STM32_COUNT_ENCODER_MODE_3; - return 0; -+ default: -+ return -EINVAL; - } -- -- return -EINVAL; - } - - static int stm32_count_function_set(struct counter_device *counter, -@@ -110,6 +115,9 @@ static int stm32_count_function_set(struct counter_device *counter, - u32 cr1, sms; - - switch (function) { -+ case STM32_COUNT_SLAVE_MODE_DISABLED: -+ sms = 0; -+ break; - case STM32_COUNT_ENCODER_MODE_1: - sms = 1; - break; -@@ -120,8 +128,7 @@ static int stm32_count_function_set(struct counter_device *counter, - sms = 3; - break; - default: -- sms = 0; -- break; -+ return -EINVAL; - } - - /* Store enable status */ -@@ -183,6 +190,9 @@ static ssize_t stm32_count_ceiling_write(struct counter_device *counter, - if (ret) - return ret; - -+ if (ceiling > priv->max_arr) -+ return -ERANGE; -+ - /* TIMx_ARR register shouldn't be buffered (ARPE=0) */ - regmap_update_bits(priv->regmap, TIM_CR1, TIM_CR1_ARPE, 0); - regmap_write(priv->regmap, TIM_ARR, ceiling); -@@ -269,31 +279,36 @@ static int stm32_action_get(struct counter_device *counter, - size_t function; - int err; - -- /* Default action mode (e.g. STM32_COUNT_SLAVE_MODE_DISABLED) */ -- *action = STM32_SYNAPSE_ACTION_NONE; -- - err = stm32_count_function_get(counter, count, &function); - if (err) -- return 0; -+ return err; - - switch (function) { -+ case STM32_COUNT_SLAVE_MODE_DISABLED: -+ /* counts on internal clock when CEN=1 */ -+ *action = STM32_SYNAPSE_ACTION_NONE; -+ return 0; - case STM32_COUNT_ENCODER_MODE_1: - /* counts up/down on TI1FP1 edge depending on TI2FP2 level */ - if (synapse->signal->id == count->synapses[0].signal->id) - *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; -- break; -+ else -+ *action = STM32_SYNAPSE_ACTION_NONE; -+ return 0; - case STM32_COUNT_ENCODER_MODE_2: - /* counts up/down on TI2FP2 edge depending on TI1FP1 level */ - if (synapse->signal->id == count->synapses[1].signal->id) - *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; -- break; -+ else -+ *action = STM32_SYNAPSE_ACTION_NONE; -+ return 0; - case STM32_COUNT_ENCODER_MODE_3: - /* counts up/down on both TI1FP1 and TI2FP2 edges */ - *action = STM32_SYNAPSE_ACTION_BOTH_EDGES; -- break; -+ return 0; -+ default: -+ return -EINVAL; - } -- -- return 0; - } - - static const struct counter_ops stm32_timer_cnt_ops = { -@@ -355,6 +370,7 @@ static int stm32_timer_cnt_probe(struct platform_device *pdev) - priv->regmap = ddata->regmap; - priv->clk = ddata->clk; - priv->ceiling = ddata->max_arr; -+ priv->max_arr = ddata->max_arr; - - priv->counter.name = dev_name(dev); - priv->counter.parent = dev; -diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c -index b299e22b7532a..3a2b607369151 100644 ---- a/drivers/firmware/efi/efi.c -+++ b/drivers/firmware/efi/efi.c -@@ -1006,7 +1006,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) - } - - /* first try to find a slot in an existing linked list entry */ -- for (prsv = efi_memreserve_root->next; prsv; prsv = rsv->next) { -+ for (prsv = efi_memreserve_root->next; prsv; ) { - rsv = memremap(prsv, sizeof(*rsv), MEMREMAP_WB); - index = atomic_fetch_add_unless(&rsv->count, 1, rsv->size); - if (index < rsv->size) { -@@ -1016,6 +1016,7 @@ int __ref efi_mem_reserve_persistent(phys_addr_t addr, u64 size) - memunmap(rsv); - return efi_mem_reserve_iomem(addr, size); - } -+ prsv = rsv->next; - memunmap(rsv); - } - -diff --git a/drivers/iio/adc/Kconfig b/drivers/iio/adc/Kconfig -index f0af3a42f53cf..cb57880842991 100644 ---- a/drivers/iio/adc/Kconfig -+++ b/drivers/iio/adc/Kconfig -@@ -784,6 +784,7 @@ config STM32_ADC_CORE - depends on ARCH_STM32 || COMPILE_TEST - depends on OF - depends on REGULATOR -+ depends on HAS_IOMEM - select IIO_BUFFER - select MFD_STM32_TIMERS - select IIO_STM32_TIMER_TRIGGER -diff --git a/drivers/iio/adc/ad7949.c b/drivers/iio/adc/ad7949.c -index 6b51bfcad0d04..325cd7d18b918 100644 ---- a/drivers/iio/adc/ad7949.c -+++ b/drivers/iio/adc/ad7949.c -@@ -91,7 +91,7 @@ static int ad7949_spi_read_channel(struct ad7949_adc_chip *ad7949_adc, int *val, - int ret; - int i; - int bits_per_word = ad7949_adc->resolution; -- int mask = GENMASK(ad7949_adc->resolution, 0); -+ int mask = GENMASK(ad7949_adc->resolution - 1, 0); - struct spi_message msg; - struct spi_transfer tx[] = { - { -diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c -index 203ad59da3364..71c455a27097b 100644 ---- a/drivers/iio/adc/qcom-spmi-vadc.c -+++ b/drivers/iio/adc/qcom-spmi-vadc.c -@@ -598,7 +598,7 @@ static const struct vadc_channels vadc_chans[] = { - VADC_CHAN_NO_SCALE(P_MUX16_1_3, 1) - - VADC_CHAN_NO_SCALE(LR_MUX1_BAT_THERM, 0) -- VADC_CHAN_NO_SCALE(LR_MUX2_BAT_ID, 0) -+ VADC_CHAN_VOLT(LR_MUX2_BAT_ID, 0, SCALE_DEFAULT) - VADC_CHAN_NO_SCALE(LR_MUX3_XO_THERM, 0) - VADC_CHAN_NO_SCALE(LR_MUX4_AMUX_THM1, 0) - VADC_CHAN_NO_SCALE(LR_MUX5_AMUX_THM2, 0) -diff --git a/drivers/iio/gyro/mpu3050-core.c b/drivers/iio/gyro/mpu3050-core.c -index 80154bca18b61..7046bca1d7eba 100644 ---- a/drivers/iio/gyro/mpu3050-core.c -+++ b/drivers/iio/gyro/mpu3050-core.c -@@ -550,6 +550,8 @@ static irqreturn_t mpu3050_trigger_handler(int irq, void *p) - MPU3050_FIFO_R, - &fifo_values[offset], - toread); -+ if (ret) -+ goto out_trigger_unlock; - - dev_dbg(mpu3050->dev, - "%04x %04x %04x %04x %04x\n", -diff --git a/drivers/iio/humidity/hid-sensor-humidity.c b/drivers/iio/humidity/hid-sensor-humidity.c -index c99b54b0568df..969e16f5eeb64 100644 ---- a/drivers/iio/humidity/hid-sensor-humidity.c -+++ b/drivers/iio/humidity/hid-sensor-humidity.c -@@ -17,7 +17,10 @@ - struct hid_humidity_state { - struct hid_sensor_common common_attributes; - struct hid_sensor_hub_attribute_info humidity_attr; -- s32 humidity_data; -+ struct { -+ s32 humidity_data; -+ u64 timestamp __aligned(8); -+ } scan; - int scale_pre_decml; - int scale_post_decml; - int scale_precision; -@@ -127,9 +130,8 @@ static int humidity_proc_event(struct hid_sensor_hub_device *hsdev, - struct hid_humidity_state *humid_st = iio_priv(indio_dev); - - if (atomic_read(&humid_st->common_attributes.data_ready)) -- iio_push_to_buffers_with_timestamp(indio_dev, -- &humid_st->humidity_data, -- iio_get_time_ns(indio_dev)); -+ iio_push_to_buffers_with_timestamp(indio_dev, &humid_st->scan, -+ iio_get_time_ns(indio_dev)); - - return 0; - } -@@ -144,7 +146,7 @@ static int humidity_capture_sample(struct hid_sensor_hub_device *hsdev, - - switch (usage_id) { - case HID_USAGE_SENSOR_ATMOSPHERIC_HUMIDITY: -- humid_st->humidity_data = *(s32 *)raw_data; -+ humid_st->scan.humidity_data = *(s32 *)raw_data; - - return 0; - default: -diff --git a/drivers/iio/imu/adis16400.c b/drivers/iio/imu/adis16400.c -index 0575ff706bd43..59e33302042c5 100644 ---- a/drivers/iio/imu/adis16400.c -+++ b/drivers/iio/imu/adis16400.c -@@ -464,8 +464,7 @@ static int adis16400_initial_setup(struct iio_dev *indio_dev) - if (ret) - goto err_ret; - -- ret = sscanf(indio_dev->name, "adis%u\n", &device_id); -- if (ret != 1) { -+ if (sscanf(indio_dev->name, "adis%u\n", &device_id) != 1) { - ret = -EINVAL; - goto err_ret; - } -diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c -index 7e1030af9ba31..70da928e0d168 100644 ---- a/drivers/iio/light/hid-sensor-prox.c -+++ b/drivers/iio/light/hid-sensor-prox.c -@@ -25,6 +25,9 @@ struct prox_state { - struct hid_sensor_common common_attributes; - struct hid_sensor_hub_attribute_info prox_attr; - u32 human_presence; -+ int scale_pre_decml; -+ int scale_post_decml; -+ int scale_precision; - }; - - /* Channel definitions */ -@@ -95,8 +98,9 @@ static int prox_read_raw(struct iio_dev *indio_dev, - ret_type = IIO_VAL_INT; - break; - case IIO_CHAN_INFO_SCALE: -- *val = prox_state->prox_attr.units; -- ret_type = IIO_VAL_INT; -+ *val = prox_state->scale_pre_decml; -+ *val2 = prox_state->scale_post_decml; -+ ret_type = prox_state->scale_precision; - break; - case IIO_CHAN_INFO_OFFSET: - *val = hid_sensor_convert_exponent( -@@ -236,6 +240,11 @@ static int prox_parse_report(struct platform_device *pdev, - HID_USAGE_SENSOR_HUMAN_PRESENCE, - &st->common_attributes.sensitivity); - -+ st->scale_precision = hid_sensor_format_scale( -+ hsdev->usage, -+ &st->prox_attr, -+ &st->scale_pre_decml, &st->scale_post_decml); -+ - return ret; - } - -diff --git a/drivers/iio/temperature/hid-sensor-temperature.c b/drivers/iio/temperature/hid-sensor-temperature.c -index eda55b9c1e9b1..500b5cc4351a2 100644 ---- a/drivers/iio/temperature/hid-sensor-temperature.c -+++ b/drivers/iio/temperature/hid-sensor-temperature.c -@@ -17,7 +17,10 @@ - struct temperature_state { - struct hid_sensor_common common_attributes; - struct hid_sensor_hub_attribute_info temperature_attr; -- s32 temperature_data; -+ struct { -+ s32 temperature_data; -+ u64 timestamp __aligned(8); -+ } scan; - int scale_pre_decml; - int scale_post_decml; - int scale_precision; -@@ -34,7 +37,7 @@ static const struct iio_chan_spec temperature_channels[] = { - BIT(IIO_CHAN_INFO_SAMP_FREQ) | - BIT(IIO_CHAN_INFO_HYSTERESIS), - }, -- IIO_CHAN_SOFT_TIMESTAMP(3), -+ IIO_CHAN_SOFT_TIMESTAMP(1), - }; - - /* Adjust channel real bits based on report descriptor */ -@@ -125,9 +128,8 @@ static int temperature_proc_event(struct hid_sensor_hub_device *hsdev, - struct temperature_state *temp_st = iio_priv(indio_dev); - - if (atomic_read(&temp_st->common_attributes.data_ready)) -- iio_push_to_buffers_with_timestamp(indio_dev, -- &temp_st->temperature_data, -- iio_get_time_ns(indio_dev)); -+ iio_push_to_buffers_with_timestamp(indio_dev, &temp_st->scan, -+ iio_get_time_ns(indio_dev)); - - return 0; - } -@@ -142,7 +144,7 @@ static int temperature_capture_sample(struct hid_sensor_hub_device *hsdev, - - switch (usage_id) { - case HID_USAGE_SENSOR_DATA_ENVIRONMENTAL_TEMPERATURE: -- temp_st->temperature_data = *(s32 *)raw_data; -+ temp_st->scan.temperature_data = *(s32 *)raw_data; - return 0; - default: - return -EINVAL; -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index e4e24e7bf4628..308f3a28e12a2 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -1743,30 +1743,18 @@ static void nvme_config_discard(struct gendisk *disk, struct nvme_ns *ns) - blk_queue_max_write_zeroes_sectors(queue, UINT_MAX); - } - --static void nvme_config_write_zeroes(struct gendisk *disk, struct nvme_ns *ns) -+/* -+ * Even though NVMe spec explicitly states that MDTS is not applicable to the -+ * write-zeroes, we are cautious and limit the size to the controllers -+ * max_hw_sectors value, which is based on the MDTS field and possibly other -+ * limiting factors. -+ */ -+static void nvme_config_write_zeroes(struct request_queue *q, -+ struct nvme_ctrl *ctrl) - { -- u64 max_blocks; -- -- if (!(ns->ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) || -- (ns->ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES)) -- return; -- /* -- * Even though NVMe spec explicitly states that MDTS is not -- * applicable to the write-zeroes:- "The restriction does not apply to -- * commands that do not transfer data between the host and the -- * controller (e.g., Write Uncorrectable ro Write Zeroes command).". -- * In order to be more cautious use controller's max_hw_sectors value -- * to configure the maximum sectors for the write-zeroes which is -- * configured based on the controller's MDTS field in the -- * nvme_init_identify() if available. -- */ -- if (ns->ctrl->max_hw_sectors == UINT_MAX) -- max_blocks = (u64)USHRT_MAX + 1; -- else -- max_blocks = ns->ctrl->max_hw_sectors + 1; -- -- blk_queue_max_write_zeroes_sectors(disk->queue, -- nvme_lba_to_sect(ns, max_blocks)); -+ if ((ctrl->oncs & NVME_CTRL_ONCS_WRITE_ZEROES) && -+ !(ctrl->quirks & NVME_QUIRK_DISABLE_WRITE_ZEROES)) -+ blk_queue_max_write_zeroes_sectors(q, ctrl->max_hw_sectors); - } - - static int nvme_report_ns_ids(struct nvme_ctrl *ctrl, unsigned int nsid, -@@ -1853,7 +1841,7 @@ static void nvme_update_disk_info(struct gendisk *disk, - set_capacity(disk, capacity); - - nvme_config_discard(disk, ns); -- nvme_config_write_zeroes(disk, ns); -+ nvme_config_write_zeroes(disk->queue, ns->ctrl); - - if (id->nsattr & (1 << 0)) - set_disk_ro(disk, true); -diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c -index da60300104322..b8c0f75bfb7ba 100644 ---- a/drivers/nvme/host/rdma.c -+++ b/drivers/nvme/host/rdma.c -@@ -666,8 +666,11 @@ static int nvme_rdma_alloc_io_queues(struct nvme_rdma_ctrl *ctrl) - return ret; - - ctrl->ctrl.queue_count = nr_io_queues + 1; -- if (ctrl->ctrl.queue_count < 2) -- return 0; -+ if (ctrl->ctrl.queue_count < 2) { -+ dev_err(ctrl->ctrl.device, -+ "unable to set any I/O queues\n"); -+ return -ENOMEM; -+ } - - dev_info(ctrl->ctrl.device, - "creating %d I/O queues.\n", nr_io_queues); -diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c -index 77a3c488ec120..ac3503ea54c46 100644 ---- a/drivers/nvme/host/tcp.c -+++ b/drivers/nvme/host/tcp.c -@@ -512,6 +512,13 @@ static int nvme_tcp_setup_h2c_data_pdu(struct nvme_tcp_request *req, - req->pdu_len = le32_to_cpu(pdu->r2t_length); - req->pdu_sent = 0; - -+ if (unlikely(!req->pdu_len)) { -+ dev_err(queue->ctrl->ctrl.device, -+ "req %d r2t len is %u, probably a bug...\n", -+ rq->tag, req->pdu_len); -+ return -EPROTO; -+ } -+ - if (unlikely(req->data_sent + req->pdu_len > req->data_len)) { - dev_err(queue->ctrl->ctrl.device, - "req %d r2t len %u exceeded data len %u (%zu sent)\n", -@@ -1643,8 +1650,11 @@ static int nvme_tcp_alloc_io_queues(struct nvme_ctrl *ctrl) - return ret; - - ctrl->queue_count = nr_io_queues + 1; -- if (ctrl->queue_count < 2) -- return 0; -+ if (ctrl->queue_count < 2) { -+ dev_err(ctrl->device, -+ "unable to set any I/O queues\n"); -+ return -ENOMEM; -+ } - - dev_info(ctrl->device, - "creating %d I/O queues.\n", nr_io_queues); -diff --git a/drivers/nvme/target/core.c b/drivers/nvme/target/core.c -index cca5a00c098a8..ee81d94fe810c 100644 ---- a/drivers/nvme/target/core.c -+++ b/drivers/nvme/target/core.c -@@ -1031,9 +1031,20 @@ static void nvmet_start_ctrl(struct nvmet_ctrl *ctrl) - { - lockdep_assert_held(&ctrl->lock); - -- if (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES || -- nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES || -- nvmet_cc_mps(ctrl->cc) != 0 || -+ /* -+ * Only I/O controllers should verify iosqes,iocqes. -+ * Strictly speaking, the spec says a discovery controller -+ * should verify iosqes,iocqes are zeroed, however that -+ * would break backwards compatibility, so don't enforce it. -+ */ -+ if (ctrl->subsys->type != NVME_NQN_DISC && -+ (nvmet_cc_iosqes(ctrl->cc) != NVME_NVM_IOSQES || -+ nvmet_cc_iocqes(ctrl->cc) != NVME_NVM_IOCQES)) { -+ ctrl->csts = NVME_CSTS_CFS; -+ return; -+ } -+ -+ if (nvmet_cc_mps(ctrl->cc) != 0 || - nvmet_cc_ams(ctrl->cc) != 0 || - nvmet_cc_css(ctrl->cc) != 0) { - ctrl->csts = NVME_CSTS_CFS; -diff --git a/drivers/pci/hotplug/rpadlpar_sysfs.c b/drivers/pci/hotplug/rpadlpar_sysfs.c -index cdbfa5df3a51f..dbfa0b55d31a5 100644 ---- a/drivers/pci/hotplug/rpadlpar_sysfs.c -+++ b/drivers/pci/hotplug/rpadlpar_sysfs.c -@@ -34,12 +34,11 @@ static ssize_t add_slot_store(struct kobject *kobj, struct kobj_attribute *attr, - if (nbytes >= MAX_DRC_NAME_LEN) - return 0; - -- memcpy(drc_name, buf, nbytes); -+ strscpy(drc_name, buf, nbytes + 1); - - end = strchr(drc_name, '\n'); -- if (!end) -- end = &drc_name[nbytes]; -- *end = '\0'; -+ if (end) -+ *end = '\0'; - - rc = dlpar_add_slot(drc_name); - if (rc) -@@ -65,12 +64,11 @@ static ssize_t remove_slot_store(struct kobject *kobj, - if (nbytes >= MAX_DRC_NAME_LEN) - return 0; - -- memcpy(drc_name, buf, nbytes); -+ strscpy(drc_name, buf, nbytes + 1); - - end = strchr(drc_name, '\n'); -- if (!end) -- end = &drc_name[nbytes]; -- *end = '\0'; -+ if (end) -+ *end = '\0'; - - rc = dlpar_remove_slot(drc_name); - if (rc) -diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c -index 8d34be60d3798..3c9248d2435e1 100644 ---- a/drivers/scsi/lpfc/lpfc_debugfs.c -+++ b/drivers/scsi/lpfc/lpfc_debugfs.c -@@ -2217,7 +2217,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, - memset(dstbuf, 0, 33); - size = (nbytes < 32) ? nbytes : 32; - if (copy_from_user(dstbuf, buf, size)) -- return 0; -+ return -EFAULT; - - if (dent == phba->debug_InjErrLBA) { - if ((buf[0] == 'o') && (buf[1] == 'f') && (buf[2] == 'f')) -@@ -2225,7 +2225,7 @@ lpfc_debugfs_dif_err_write(struct file *file, const char __user *buf, - } - - if ((tmp == 0) && (kstrtoull(dstbuf, 0, &tmp))) -- return 0; -+ return -EINVAL; - - if (dent == phba->debug_writeGuard) - phba->lpfc_injerr_wgrd_cnt = (uint32_t)tmp; -diff --git a/drivers/scsi/myrs.c b/drivers/scsi/myrs.c -index eb0dd566330ab..cfc3f8b4174ab 100644 ---- a/drivers/scsi/myrs.c -+++ b/drivers/scsi/myrs.c -@@ -2274,12 +2274,12 @@ static void myrs_cleanup(struct myrs_hba *cs) - if (cs->mmio_base) { - cs->disable_intr(cs); - iounmap(cs->mmio_base); -+ cs->mmio_base = NULL; - } - if (cs->irq) - free_irq(cs->irq, cs); - if (cs->io_addr) - release_region(cs->io_addr, 0x80); -- iounmap(cs->mmio_base); - pci_set_drvdata(pdev, NULL); - pci_disable_device(pdev); - scsi_host_put(cs->host); -diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c -index ed46fd74a292a..24dad1d78d1ea 100644 ---- a/drivers/usb/gadget/composite.c -+++ b/drivers/usb/gadget/composite.c -@@ -1091,7 +1091,7 @@ static void collect_langs(struct usb_gadget_strings **sp, __le16 *buf) - while (*sp) { - s = *sp; - language = cpu_to_le16(s->language); -- for (tmp = buf; *tmp && tmp < &buf[126]; tmp++) { -+ for (tmp = buf; *tmp && tmp < &buf[USB_MAX_STRING_LEN]; tmp++) { - if (*tmp == language) - goto repeat; - } -@@ -1166,7 +1166,7 @@ static int get_string(struct usb_composite_dev *cdev, - collect_langs(sp, s->wData); - } - -- for (len = 0; len <= 126 && s->wData[len]; len++) -+ for (len = 0; len <= USB_MAX_STRING_LEN && s->wData[len]; len++) - continue; - if (!len) - return -EINVAL; -diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c -index 5b8b2ca4376cb..3d4710cc34bc1 100644 ---- a/drivers/usb/gadget/configfs.c -+++ b/drivers/usb/gadget/configfs.c -@@ -109,21 +109,27 @@ struct gadget_config_name { - struct list_head list; - }; - -+#define USB_MAX_STRING_WITH_NULL_LEN (USB_MAX_STRING_LEN+1) -+ - static int usb_string_copy(const char *s, char **s_copy) - { - int ret; - char *str; - char *copy = *s_copy; - ret = strlen(s); -- if (ret > 126) -+ if (ret > USB_MAX_STRING_LEN) - return -EOVERFLOW; - -- str = kstrdup(s, GFP_KERNEL); -- if (!str) -- return -ENOMEM; -+ if (copy) { -+ str = copy; -+ } else { -+ str = kmalloc(USB_MAX_STRING_WITH_NULL_LEN, GFP_KERNEL); -+ if (!str) -+ return -ENOMEM; -+ } -+ strcpy(str, s); - if (str[ret - 1] == '\n') - str[ret - 1] = '\0'; -- kfree(copy); - *s_copy = str; - return 0; - } -diff --git a/drivers/usb/gadget/usbstring.c b/drivers/usb/gadget/usbstring.c -index 7c24d1ce10889..33f77e59aa6fb 100644 ---- a/drivers/usb/gadget/usbstring.c -+++ b/drivers/usb/gadget/usbstring.c -@@ -55,9 +55,9 @@ usb_gadget_get_string (const struct usb_gadget_strings *table, int id, u8 *buf) - return -EINVAL; - - /* string descriptors have length, tag, then UTF16-LE text */ -- len = min ((size_t) 126, strlen (s->s)); -+ len = min((size_t)USB_MAX_STRING_LEN, strlen(s->s)); - len = utf8s_to_utf16s(s->s, len, UTF16_LITTLE_ENDIAN, -- (wchar_t *) &buf[2], 126); -+ (wchar_t *) &buf[2], USB_MAX_STRING_LEN); - if (len < 0) - return -EINVAL; - buf [0] = (len + 1) * 2; -diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c -index 96cb0409dd893..737b765d0f6ea 100644 ---- a/drivers/usb/storage/transport.c -+++ b/drivers/usb/storage/transport.c -@@ -651,6 +651,13 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) - need_auto_sense = 1; - } - -+ /* Some devices (Kindle) require another command after SYNC CACHE */ -+ if ((us->fflags & US_FL_SENSE_AFTER_SYNC) && -+ srb->cmnd[0] == SYNCHRONIZE_CACHE) { -+ usb_stor_dbg(us, "-- sense after SYNC CACHE\n"); -+ need_auto_sense = 1; -+ } -+ - /* - * If we have a failure, we're going to do a REQUEST_SENSE - * automatically. Note that we differentiate between a command -diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h -index 88275842219ef..861153d294b67 100644 ---- a/drivers/usb/storage/unusual_devs.h -+++ b/drivers/usb/storage/unusual_devs.h -@@ -2211,6 +2211,18 @@ UNUSUAL_DEV( 0x1908, 0x3335, 0x0200, 0x0200, - USB_SC_DEVICE, USB_PR_DEVICE, NULL, - US_FL_NO_READ_DISC_INFO ), - -+/* -+ * Reported by Matthias Schwarzott -+ * The Amazon Kindle treats SYNCHRONIZE CACHE as an indication that -+ * the host may be finished with it, and automatically ejects its -+ * emulated media unless it receives another command within one second. -+ */ -+UNUSUAL_DEV( 0x1949, 0x0004, 0x0000, 0x9999, -+ "Amazon", -+ "Kindle", -+ USB_SC_DEVICE, USB_PR_DEVICE, NULL, -+ US_FL_SENSE_AFTER_SYNC ), -+ - /* - * Reported by Oliver Neukum - * This device morphes spontaneously into another device if the access -diff --git a/drivers/usb/typec/tcpm/tcpm.c b/drivers/usb/typec/tcpm/tcpm.c -index 5bb84cb4876a9..c595da1761247 100644 ---- a/drivers/usb/typec/tcpm/tcpm.c -+++ b/drivers/usb/typec/tcpm/tcpm.c -@@ -739,6 +739,7 @@ static int tcpm_set_current_limit(struct tcpm_port *port, u32 max_ma, u32 mv) - - port->supply_voltage = mv; - port->current_limit = max_ma; -+ power_supply_changed(port->psy); - - if (port->tcpc->set_current_limit) - ret = port->tcpc->set_current_limit(port->tcpc, max_ma, mv); -@@ -2138,6 +2139,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, - - port->pps_data.supported = false; - port->usb_type = POWER_SUPPLY_USB_TYPE_PD; -+ power_supply_changed(port->psy); - - /* - * Select the source PDO providing the most power which has a -@@ -2162,6 +2164,7 @@ static int tcpm_pd_select_pdo(struct tcpm_port *port, int *sink_pdo, - port->pps_data.supported = true; - port->usb_type = - POWER_SUPPLY_USB_TYPE_PD_PPS; -+ power_supply_changed(port->psy); - } - continue; - default: -@@ -2319,6 +2322,7 @@ static unsigned int tcpm_pd_select_pps_apdo(struct tcpm_port *port) - port->pps_data.out_volt)); - port->pps_data.op_curr = min(port->pps_data.max_curr, - port->pps_data.op_curr); -+ power_supply_changed(port->psy); - } - - return src_pdo; -@@ -2554,6 +2558,7 @@ static int tcpm_set_charge(struct tcpm_port *port, bool charge) - return ret; - } - port->vbus_charge = charge; -+ power_supply_changed(port->psy); - return 0; - } - -@@ -4665,7 +4670,7 @@ static int tcpm_psy_set_prop(struct power_supply *psy, - ret = -EINVAL; - break; - } -- -+ power_supply_changed(port->psy); - return ret; - } - -@@ -4816,6 +4821,7 @@ struct tcpm_port *tcpm_register_port(struct device *dev, struct tcpc_dev *tcpc) - err = devm_tcpm_psy_register(port); - if (err) - goto out_role_sw_put; -+ power_supply_changed(port->psy); - - port->typec_port = typec_register_port(port->dev, &port->typec_caps); - if (IS_ERR(port->typec_port)) { -diff --git a/drivers/usb/usbip/vudc_sysfs.c b/drivers/usb/usbip/vudc_sysfs.c -index a3ec39fc61778..7383a543c6d12 100644 ---- a/drivers/usb/usbip/vudc_sysfs.c -+++ b/drivers/usb/usbip/vudc_sysfs.c -@@ -174,7 +174,7 @@ static ssize_t usbip_sockfd_store(struct device *dev, - - udc->ud.tcp_socket = socket; - udc->ud.tcp_rx = tcp_rx; -- udc->ud.tcp_rx = tcp_tx; -+ udc->ud.tcp_tx = tcp_tx; - udc->ud.status = SDEV_ST_USED; - - spin_unlock_irq(&udc->ud.lock); -diff --git a/drivers/vfio/Kconfig b/drivers/vfio/Kconfig -index fd17db9b432f4..9dc95024afaeb 100644 ---- a/drivers/vfio/Kconfig -+++ b/drivers/vfio/Kconfig -@@ -21,7 +21,7 @@ config VFIO_VIRQFD - - menuconfig VFIO - tristate "VFIO Non-Privileged userspace driver framework" -- depends on IOMMU_API -+ select IOMMU_API - select VFIO_IOMMU_TYPE1 if (X86 || S390 || ARM || ARM64) - help - VFIO provides a framework for secure userspace device drivers. -diff --git a/fs/afs/dir.c b/fs/afs/dir.c -index 3c486340b2208..e7494cd49ce7b 100644 ---- a/fs/afs/dir.c -+++ b/fs/afs/dir.c -@@ -69,7 +69,6 @@ const struct inode_operations afs_dir_inode_operations = { - .permission = afs_permission, - .getattr = afs_getattr, - .setattr = afs_setattr, -- .listxattr = afs_listxattr, - }; - - const struct address_space_operations afs_dir_aops = { -diff --git a/fs/afs/file.c b/fs/afs/file.c -index dd3c55c9101c4..5d0b472e984ba 100644 ---- a/fs/afs/file.c -+++ b/fs/afs/file.c -@@ -42,7 +42,6 @@ const struct inode_operations afs_file_inode_operations = { - .getattr = afs_getattr, - .setattr = afs_setattr, - .permission = afs_permission, -- .listxattr = afs_listxattr, - }; - - const struct address_space_operations afs_fs_aops = { -diff --git a/fs/afs/inode.c b/fs/afs/inode.c -index a74e8e209454b..4f58b28a1edd2 100644 ---- a/fs/afs/inode.c -+++ b/fs/afs/inode.c -@@ -27,7 +27,6 @@ - - static const struct inode_operations afs_symlink_inode_operations = { - .get_link = page_get_link, -- .listxattr = afs_listxattr, - }; - - static noinline void dump_vnode(struct afs_vnode *vnode, struct afs_vnode *parent_vnode) -diff --git a/fs/afs/internal.h b/fs/afs/internal.h -index 7fe88d918b238..c3ad582f9fd0e 100644 ---- a/fs/afs/internal.h -+++ b/fs/afs/internal.h -@@ -1354,7 +1354,6 @@ extern int afs_launder_page(struct page *); - * xattr.c - */ - extern const struct xattr_handler *afs_xattr_handlers[]; --extern ssize_t afs_listxattr(struct dentry *, char *, size_t); - - /* - * yfsclient.c -diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c -index 79bc5f1338edf..f105f061e89bb 100644 ---- a/fs/afs/mntpt.c -+++ b/fs/afs/mntpt.c -@@ -32,7 +32,6 @@ const struct inode_operations afs_mntpt_inode_operations = { - .lookup = afs_mntpt_lookup, - .readlink = page_readlink, - .getattr = afs_getattr, -- .listxattr = afs_listxattr, - }; - - const struct inode_operations afs_autocell_inode_operations = { -diff --git a/fs/afs/xattr.c b/fs/afs/xattr.c -index 5552d034090af..13292d4ca860c 100644 ---- a/fs/afs/xattr.c -+++ b/fs/afs/xattr.c -@@ -11,29 +11,6 @@ - #include - #include "internal.h" - --static const char afs_xattr_list[] = -- "afs.acl\0" -- "afs.cell\0" -- "afs.fid\0" -- "afs.volume\0" -- "afs.yfs.acl\0" -- "afs.yfs.acl_inherited\0" -- "afs.yfs.acl_num_cleaned\0" -- "afs.yfs.vol_acl"; -- --/* -- * Retrieve a list of the supported xattrs. -- */ --ssize_t afs_listxattr(struct dentry *dentry, char *buffer, size_t size) --{ -- if (size == 0) -- return sizeof(afs_xattr_list); -- if (size < sizeof(afs_xattr_list)) -- return -ERANGE; -- memcpy(buffer, afs_xattr_list, sizeof(afs_xattr_list)); -- return sizeof(afs_xattr_list); --} -- - /* - * Get a file's ACL. - */ -diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c -index 1af73367087df..35741901f4e0b 100644 ---- a/fs/btrfs/ctree.c -+++ b/fs/btrfs/ctree.c -@@ -1406,7 +1406,9 @@ get_old_root(struct btrfs_root *root, u64 time_seq) - "failed to read tree block %llu from get_old_root", - logical); - } else { -+ btrfs_tree_read_lock(old); - eb = btrfs_clone_extent_buffer(old); -+ btrfs_tree_read_unlock(old); - free_extent_buffer(old); - } - } else if (old_root) { -diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c -index 67b49b94c9cd6..b36a4d144bec0 100644 ---- a/fs/btrfs/inode.c -+++ b/fs/btrfs/inode.c -@@ -9628,7 +9628,7 @@ int __init btrfs_init_cachep(void) - - btrfs_free_space_bitmap_cachep = kmem_cache_create("btrfs_free_space_bitmap", - PAGE_SIZE, PAGE_SIZE, -- SLAB_RED_ZONE, NULL); -+ SLAB_MEM_SPREAD, NULL); - if (!btrfs_free_space_bitmap_cachep) - goto fail; - -diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c -index eab7940bfebef..e99ecfafffac3 100644 ---- a/fs/cifs/transport.c -+++ b/fs/cifs/transport.c -@@ -1134,9 +1134,12 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, - /* - * Compounding is never used during session establish. - */ -- if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) -+ if ((ses->status == CifsNew) || (optype & CIFS_NEG_OP)) { -+ mutex_lock(&server->srv_mutex); - smb311_update_preauth_hash(ses, rqst[0].rq_iov, - rqst[0].rq_nvec); -+ mutex_unlock(&server->srv_mutex); -+ } - - for (i = 0; i < num_rqst; i++) { - rc = wait_for_response(server, midQ[i]); -@@ -1204,7 +1207,9 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, - .iov_base = resp_iov[0].iov_base, - .iov_len = resp_iov[0].iov_len - }; -+ mutex_lock(&server->srv_mutex); - smb311_update_preauth_hash(ses, &iov, 1); -+ mutex_unlock(&server->srv_mutex); - } - - out: -diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c -index 539d95bd364d4..efce97b938b7a 100644 ---- a/fs/ext4/inode.c -+++ b/fs/ext4/inode.c -@@ -5267,7 +5267,7 @@ static int ext4_do_update_inode(handle_t *handle, - struct ext4_inode_info *ei = EXT4_I(inode); - struct buffer_head *bh = iloc->bh; - struct super_block *sb = inode->i_sb; -- int err = 0, rc, block; -+ int err = 0, block; - int need_datasync = 0, set_large_file = 0; - uid_t i_uid; - gid_t i_gid; -@@ -5379,9 +5379,9 @@ static int ext4_do_update_inode(handle_t *handle, - bh->b_data); - - BUFFER_TRACE(bh, "call ext4_handle_dirty_metadata"); -- rc = ext4_handle_dirty_metadata(handle, NULL, bh); -- if (!err) -- err = rc; -+ err = ext4_handle_dirty_metadata(handle, NULL, bh); -+ if (err) -+ goto out_brelse; - ext4_clear_inode_state(inode, EXT4_STATE_NEW); - if (set_large_file) { - BUFFER_TRACE(EXT4_SB(sb)->s_sbh, "get write access"); -diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c -index 7f22487d502b5..e992a9f156714 100644 ---- a/fs/ext4/namei.c -+++ b/fs/ext4/namei.c -@@ -3547,6 +3547,31 @@ static int ext4_setent(handle_t *handle, struct ext4_renament *ent, - return 0; - } - -+static void ext4_resetent(handle_t *handle, struct ext4_renament *ent, -+ unsigned ino, unsigned file_type) -+{ -+ struct ext4_renament old = *ent; -+ int retval = 0; -+ -+ /* -+ * old->de could have moved from under us during make indexed dir, -+ * so the old->de may no longer valid and need to find it again -+ * before reset old inode info. -+ */ -+ old.bh = ext4_find_entry(old.dir, &old.dentry->d_name, &old.de, NULL); -+ if (IS_ERR(old.bh)) -+ retval = PTR_ERR(old.bh); -+ if (!old.bh) -+ retval = -ENOENT; -+ if (retval) { -+ ext4_std_error(old.dir->i_sb, retval); -+ return; -+ } -+ -+ ext4_setent(handle, &old, ino, file_type); -+ brelse(old.bh); -+} -+ - static int ext4_find_delete_entry(handle_t *handle, struct inode *dir, - const struct qstr *d_name) - { -@@ -3843,8 +3868,8 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, - end_rename: - if (whiteout) { - if (retval) { -- ext4_setent(handle, &old, -- old.inode->i_ino, old_file_type); -+ ext4_resetent(handle, &old, -+ old.inode->i_ino, old_file_type); - drop_nlink(whiteout); - } - unlock_new_inode(whiteout); -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 894a61010ae99..5451f10800065 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -2415,7 +2415,7 @@ retry_inode: - * external inode if possible. - */ - if (ext4_has_feature_ea_inode(inode->i_sb) && -- !i.in_inode) { -+ i.value_len && !i.in_inode) { - i.in_inode = 1; - goto retry_inode; - } -diff --git a/fs/nfsd/filecache.c b/fs/nfsd/filecache.c -index 51c08ae79063c..662937472e9bd 100644 ---- a/fs/nfsd/filecache.c -+++ b/fs/nfsd/filecache.c -@@ -751,6 +751,8 @@ nfsd_file_find_locked(struct inode *inode, unsigned int may_flags, - continue; - if (!nfsd_match_cred(nf->nf_cred, current_cred())) - continue; -+ if (!test_bit(NFSD_FILE_HASHED, &nf->nf_flags)) -+ continue; - if (nfsd_file_get(nf) != NULL) - return nf; - } -diff --git a/fs/select.c b/fs/select.c -index 53a0c149f5283..e51796063cb6e 100644 ---- a/fs/select.c -+++ b/fs/select.c -@@ -1037,10 +1037,9 @@ static long do_restart_poll(struct restart_block *restart_block) - - ret = do_sys_poll(ufds, nfds, to); - -- if (ret == -ERESTARTNOHAND) { -- restart_block->fn = do_restart_poll; -- ret = -ERESTART_RESTARTBLOCK; -- } -+ if (ret == -ERESTARTNOHAND) -+ ret = set_restart_fn(restart_block, do_restart_poll); -+ - return ret; - } - -@@ -1062,7 +1061,6 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, - struct restart_block *restart_block; - - restart_block = ¤t->restart_block; -- restart_block->fn = do_restart_poll; - restart_block->poll.ufds = ufds; - restart_block->poll.nfds = nfds; - -@@ -1073,7 +1071,7 @@ SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, - } else - restart_block->poll.has_timeout = 0; - -- ret = -ERESTART_RESTARTBLOCK; -+ ret = set_restart_fn(restart_block, do_restart_poll); - } - return ret; - } -diff --git a/include/linux/efi.h b/include/linux/efi.h -index 13ed2c6b13f8b..c82ef0eba4f84 100644 ---- a/include/linux/efi.h -+++ b/include/linux/efi.h -@@ -63,8 +63,10 @@ typedef void *efi_handle_t; - */ - typedef guid_t efi_guid_t __aligned(__alignof__(u32)); - --#define EFI_GUID(a,b,c,d0,d1,d2,d3,d4,d5,d6,d7) \ -- GUID_INIT(a, b, c, d0, d1, d2, d3, d4, d5, d6, d7) -+#define EFI_GUID(a, b, c, d...) (efi_guid_t){ { \ -+ (a) & 0xff, ((a) >> 8) & 0xff, ((a) >> 16) & 0xff, ((a) >> 24) & 0xff, \ -+ (b) & 0xff, ((b) >> 8) & 0xff, \ -+ (c) & 0xff, ((c) >> 8) & 0xff, d } } - - /* - * Generic EFI table header -diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h -index e93e249a4e9bf..f3040b0b4b235 100644 ---- a/include/linux/thread_info.h -+++ b/include/linux/thread_info.h -@@ -11,6 +11,7 @@ - #include - #include - #include -+#include - - #ifdef CONFIG_THREAD_INFO_IN_TASK - /* -@@ -39,6 +40,18 @@ enum { - - #ifdef __KERNEL__ - -+#ifndef arch_set_restart_data -+#define arch_set_restart_data(restart) do { } while (0) -+#endif -+ -+static inline long set_restart_fn(struct restart_block *restart, -+ long (*fn)(struct restart_block *)) -+{ -+ restart->fn = fn; -+ arch_set_restart_data(restart); -+ return -ERESTART_RESTARTBLOCK; -+} -+ - #ifndef THREAD_ALIGN - #define THREAD_ALIGN THREAD_SIZE - #endif -diff --git a/include/linux/usb_usual.h b/include/linux/usb_usual.h -index a7f7ebdd3069e..0a958c7948324 100644 ---- a/include/linux/usb_usual.h -+++ b/include/linux/usb_usual.h -@@ -86,6 +86,8 @@ - /* lies about caching, so always sync */ \ - US_FLAG(NO_SAME, 0x40000000) \ - /* Cannot handle WRITE_SAME */ \ -+ US_FLAG(SENSE_AFTER_SYNC, 0x80000000) \ -+ /* Do REQUEST_SENSE after SYNCHRONIZE_CACHE */ \ - - #define US_FLAG(name, value) US_FL_##name = value , - enum { US_DO_ALL_FLAGS }; -diff --git a/include/uapi/linux/usb/ch9.h b/include/uapi/linux/usb/ch9.h -index 2b623f36af6bc..5633c804683e2 100644 ---- a/include/uapi/linux/usb/ch9.h -+++ b/include/uapi/linux/usb/ch9.h -@@ -364,6 +364,9 @@ struct usb_config_descriptor { - - /*-------------------------------------------------------------------------*/ - -+/* USB String descriptors can contain at most 126 characters. */ -+#define USB_MAX_STRING_LEN 126 -+ - /* USB_DT_STRING: String descriptor */ - struct usb_string_descriptor { - __u8 bLength; -diff --git a/kernel/futex.c b/kernel/futex.c -index 042c2707e9131..36a2a923f7ccf 100644 ---- a/kernel/futex.c -+++ b/kernel/futex.c -@@ -2865,14 +2865,13 @@ retry: - goto out; - - restart = ¤t->restart_block; -- restart->fn = futex_wait_restart; - restart->futex.uaddr = uaddr; - restart->futex.val = val; - restart->futex.time = *abs_time; - restart->futex.bitset = bitset; - restart->futex.flags = flags | FLAGS_HAS_TIMEOUT; - -- ret = -ERESTART_RESTARTBLOCK; -+ ret = set_restart_fn(restart, futex_wait_restart); - - out: - if (to) { -diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c -index 3b1d0a4725a49..918fe05933862 100644 ---- a/kernel/irq/manage.c -+++ b/kernel/irq/manage.c -@@ -1026,11 +1026,15 @@ irq_forced_thread_fn(struct irq_desc *desc, struct irqaction *action) - irqreturn_t ret; - - local_bh_disable(); -+ if (!IS_ENABLED(CONFIG_PREEMPT_RT)) -+ local_irq_disable(); - ret = action->thread_fn(action->irq, action->dev_id); - if (ret == IRQ_HANDLED) - atomic_inc(&desc->threads_handled); - - irq_finalize_oneshot(desc, action); -+ if (!IS_ENABLED(CONFIG_PREEMPT_RT)) -+ local_irq_enable(); - local_bh_enable(); - return ret; - } -diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c -index b97401f6bc232..0e96c38204a84 100644 ---- a/kernel/time/alarmtimer.c -+++ b/kernel/time/alarmtimer.c -@@ -838,9 +838,9 @@ static int alarm_timer_nsleep(const clockid_t which_clock, int flags, - if (flags == TIMER_ABSTIME) - return -ERESTARTNOHAND; - -- restart->fn = alarm_timer_nsleep_restart; - restart->nanosleep.clockid = type; - restart->nanosleep.expires = exp; -+ set_restart_fn(restart, alarm_timer_nsleep_restart); - return ret; - } - -diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c -index 299a4c5b6cf8d..1f3e3a17f67e0 100644 ---- a/kernel/time/hrtimer.c -+++ b/kernel/time/hrtimer.c -@@ -1953,9 +1953,9 @@ long hrtimer_nanosleep(const struct timespec64 *rqtp, - } - - restart = ¤t->restart_block; -- restart->fn = hrtimer_nanosleep_restart; - restart->nanosleep.clockid = t.timer.base->clockid; - restart->nanosleep.expires = hrtimer_get_expires_tv64(&t.timer); -+ set_restart_fn(restart, hrtimer_nanosleep_restart); - out: - destroy_hrtimer_on_stack(&t.timer); - return ret; -diff --git a/kernel/time/posix-cpu-timers.c b/kernel/time/posix-cpu-timers.c -index 42d512fcfda2e..eacb0ca301932 100644 ---- a/kernel/time/posix-cpu-timers.c -+++ b/kernel/time/posix-cpu-timers.c -@@ -1335,8 +1335,8 @@ static int posix_cpu_nsleep(const clockid_t which_clock, int flags, - if (flags & TIMER_ABSTIME) - return -ERESTARTNOHAND; - -- restart_block->fn = posix_cpu_nsleep_restart; - restart_block->nanosleep.clockid = which_clock; -+ set_restart_fn(restart_block, posix_cpu_nsleep_restart); - } - return error; - } -diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c -index 6e023e93d3186..0d4f12dbd2443 100644 ---- a/net/qrtr/qrtr.c -+++ b/net/qrtr/qrtr.c -@@ -264,7 +264,7 @@ int qrtr_endpoint_post(struct qrtr_endpoint *ep, const void *data, size_t len) - if (len == 0 || len & 3) - return -EINVAL; - -- skb = netdev_alloc_skb(NULL, len); -+ skb = __netdev_alloc_skb(NULL, len, GFP_ATOMIC | __GFP_NOWARN); - if (!skb) - return -ENOMEM; - -diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c -index f0dcb6d14bbb1..1741f114e8ff7 100644 ---- a/net/sunrpc/svc.c -+++ b/net/sunrpc/svc.c -@@ -1417,7 +1417,7 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv) - - sendit: - if (svc_authorise(rqstp)) -- goto close; -+ goto close_xprt; - return 1; /* Caller can now send it */ - - release_dropit: -@@ -1429,6 +1429,8 @@ release_dropit: - return 0; - - close: -+ svc_authorise(rqstp); -+close_xprt: - if (rqstp->rq_xprt && test_bit(XPT_TEMP, &rqstp->rq_xprt->xpt_flags)) - svc_close_xprt(rqstp->rq_xprt); - dprintk("svc: svc_process close\n"); -@@ -1437,7 +1439,7 @@ release_dropit: - err_short_len: - svc_printk(rqstp, "short len %zd, dropping request\n", - argv->iov_len); -- goto close; -+ goto close_xprt; - - err_bad_rpc: - serv->sv_stats->rpcbadfmt++; -diff --git a/net/sunrpc/svc_xprt.c b/net/sunrpc/svc_xprt.c -index fe4cd0b4c4127..f911153339a96 100644 ---- a/net/sunrpc/svc_xprt.c -+++ b/net/sunrpc/svc_xprt.c -@@ -1072,7 +1072,7 @@ static int svc_close_list(struct svc_serv *serv, struct list_head *xprt_list, st - struct svc_xprt *xprt; - int ret = 0; - -- spin_lock(&serv->sv_lock); -+ spin_lock_bh(&serv->sv_lock); - list_for_each_entry(xprt, xprt_list, xpt_list) { - if (xprt->xpt_net != net) - continue; -@@ -1080,7 +1080,7 @@ static int svc_close_list(struct svc_serv *serv, struct list_head *xprt_list, st - set_bit(XPT_CLOSE, &xprt->xpt_flags); - svc_xprt_enqueue(xprt); - } -- spin_unlock(&serv->sv_lock); -+ spin_unlock_bh(&serv->sv_lock); - return ret; - } - -diff --git a/net/sunrpc/xprtrdma/svc_rdma_backchannel.c b/net/sunrpc/xprtrdma/svc_rdma_backchannel.c -index 68d2dcf0a1be1..0ff5c5971dddc 100644 ---- a/net/sunrpc/xprtrdma/svc_rdma_backchannel.c -+++ b/net/sunrpc/xprtrdma/svc_rdma_backchannel.c -@@ -285,9 +285,9 @@ xprt_setup_rdma_bc(struct xprt_create *args) - xprt->timeout = &xprt_rdma_bc_timeout; - xprt_set_bound(xprt); - xprt_set_connected(xprt); -- xprt->bind_timeout = RPCRDMA_BIND_TO; -- xprt->reestablish_timeout = RPCRDMA_INIT_REEST_TO; -- xprt->idle_timeout = RPCRDMA_IDLE_DISC_TO; -+ xprt->bind_timeout = 0; -+ xprt->reestablish_timeout = 0; -+ xprt->idle_timeout = 0; - - xprt->prot = XPRT_TRANSPORT_BC_RDMA; - xprt->ops = &xprt_rdma_bc_procs; -diff --git a/sound/firewire/dice/dice-stream.c b/sound/firewire/dice/dice-stream.c -index f6a8627ae5a2b..0aa3c56cf3907 100644 ---- a/sound/firewire/dice/dice-stream.c -+++ b/sound/firewire/dice/dice-stream.c -@@ -489,11 +489,10 @@ void snd_dice_stream_stop_duplex(struct snd_dice *dice) - struct reg_params tx_params, rx_params; - - if (dice->substreams_counter == 0) { -- if (get_register_params(dice, &tx_params, &rx_params) >= 0) { -- amdtp_domain_stop(&dice->domain); -+ if (get_register_params(dice, &tx_params, &rx_params) >= 0) - finish_session(dice, &tx_params, &rx_params); -- } - -+ amdtp_domain_stop(&dice->domain); - release_resources(dice); - } - } -diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c -index 3caea6d58c9aa..efceeae09045f 100644 ---- a/sound/pci/hda/hda_generic.c -+++ b/sound/pci/hda/hda_generic.c -@@ -4017,7 +4017,7 @@ int snd_hda_gen_add_micmute_led(struct hda_codec *codec, - - spec->micmute_led.led_mode = MICMUTE_LED_FOLLOW_MUTE; - spec->micmute_led.capture = 0; -- spec->micmute_led.led_value = 0; -+ spec->micmute_led.led_value = -1; - spec->micmute_led.old_hook = spec->cap_sync_hook; - spec->micmute_led.update = hook; - spec->cap_sync_hook = update_micmute_led; -diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c -index 1283796316b62..73580e8208ed1 100644 ---- a/sound/pci/hda/patch_realtek.c -+++ b/sound/pci/hda/patch_realtek.c -@@ -8102,7 +8102,9 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { - SND_PCI_QUIRK(0x1b35, 0x1237, "CZC L101", ALC269_FIXUP_CZC_L101), - SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */ - SND_PCI_QUIRK(0x1d72, 0x1602, "RedmiBook", ALC255_FIXUP_XIAOMI_HEADSET_MIC), -+ SND_PCI_QUIRK(0x1d72, 0x1701, "XiaomiNotebook Pro", ALC298_FIXUP_DELL1_MIC_NO_PRESENCE), - SND_PCI_QUIRK(0x1d72, 0x1901, "RedmiBook 14", ALC256_FIXUP_ASUS_HEADSET_MIC), -+ SND_PCI_QUIRK(0x1d72, 0x1947, "RedmiBook Air", ALC255_FIXUP_XIAOMI_HEADSET_MIC), - SND_PCI_QUIRK(0x10ec, 0x118c, "Medion EE4254 MD62100", ALC256_FIXUP_MEDION_HEADSET_NO_PRESENCE), - SND_PCI_QUIRK(0x1c06, 0x2013, "Lemote A1802", ALC269_FIXUP_LEMOTE_A1802), - SND_PCI_QUIRK(0x1c06, 0x2015, "Lemote A190X", ALC269_FIXUP_LEMOTE_A190X), -diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c -index 217e8ce9a4ba4..eca5fc559d694 100644 ---- a/sound/soc/codecs/ak4458.c -+++ b/sound/soc/codecs/ak4458.c -@@ -707,6 +707,7 @@ static const struct of_device_id ak4458_of_match[] = { - { .compatible = "asahi-kasei,ak4497", .data = &ak4497_drvdata}, - { }, - }; -+MODULE_DEVICE_TABLE(of, ak4458_of_match); - - static struct i2c_driver ak4458_i2c_driver = { - .driver = { -diff --git a/sound/soc/codecs/ak5558.c b/sound/soc/codecs/ak5558.c -index 8179512129d35..5eb4168bb9d93 100644 ---- a/sound/soc/codecs/ak5558.c -+++ b/sound/soc/codecs/ak5558.c -@@ -389,6 +389,7 @@ static const struct of_device_id ak5558_i2c_dt_ids[] = { - { .compatible = "asahi-kasei,ak5558"}, - { } - }; -+MODULE_DEVICE_TABLE(of, ak5558_i2c_dt_ids); - - static struct i2c_driver ak5558_i2c_driver = { - .driver = { -diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c -index a4ebd6ddaba10..ed18bc69e0954 100644 ---- a/sound/soc/fsl/fsl_ssi.c -+++ b/sound/soc/fsl/fsl_ssi.c -@@ -873,6 +873,7 @@ static int fsl_ssi_hw_free(struct snd_pcm_substream *substream, - static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt) - { - u32 strcr = 0, scr = 0, stcr, srcr, mask; -+ unsigned int slots; - - ssi->dai_fmt = fmt; - -@@ -904,10 +905,11 @@ static int _fsl_ssi_set_dai_fmt(struct fsl_ssi *ssi, unsigned int fmt) - return -EINVAL; - } - -+ slots = ssi->slots ? : 2; - regmap_update_bits(ssi->regs, REG_SSI_STCCR, -- SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); -+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots)); - regmap_update_bits(ssi->regs, REG_SSI_SRCCR, -- SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(2)); -+ SSI_SxCCR_DC_MASK, SSI_SxCCR_DC(slots)); - - /* Data on rising edge of bclk, frame low, 1clk before data */ - strcr |= SSI_STCR_TFSI | SSI_STCR_TSCKP | SSI_STCR_TEFS; -diff --git a/sound/soc/generic/simple-card-utils.c b/sound/soc/generic/simple-card-utils.c -index edad6721251f4..9b794775df537 100644 ---- a/sound/soc/generic/simple-card-utils.c -+++ b/sound/soc/generic/simple-card-utils.c -@@ -172,15 +172,16 @@ int asoc_simple_parse_clk(struct device *dev, - * or device's module clock. - */ - clk = devm_get_clk_from_child(dev, node, NULL); -- if (IS_ERR(clk)) -- clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); -- - if (!IS_ERR(clk)) { -- simple_dai->clk = clk; - simple_dai->sysclk = clk_get_rate(clk); -- } else if (!of_property_read_u32(node, "system-clock-frequency", -- &val)) { -+ -+ simple_dai->clk = clk; -+ } else if (!of_property_read_u32(node, "system-clock-frequency", &val)) { - simple_dai->sysclk = val; -+ } else { -+ clk = devm_get_clk_from_child(dev, dlc->of_node, NULL); -+ if (!IS_ERR(clk)) -+ simple_dai->sysclk = clk_get_rate(clk); - } - - if (of_property_read_bool(node, "system-clock-direction-out")) -diff --git a/sound/soc/sof/intel/hda-dsp.c b/sound/soc/sof/intel/hda-dsp.c -index fb55a3c5afd0d..94b093b370e2f 100644 ---- a/sound/soc/sof/intel/hda-dsp.c -+++ b/sound/soc/sof/intel/hda-dsp.c -@@ -179,7 +179,7 @@ int hda_dsp_core_power_down(struct snd_sof_dev *sdev, unsigned int core_mask) - - return snd_sof_dsp_read_poll_timeout(sdev, HDA_DSP_BAR, - HDA_DSP_REG_ADSPCS, adspcs, -- !(adspcs & HDA_DSP_ADSPCS_SPA_MASK(core_mask)), -+ !(adspcs & HDA_DSP_ADSPCS_CPA_MASK(core_mask)), - HDA_DSP_REG_POLL_INTERVAL_US, - HDA_DSP_PD_TIMEOUT * USEC_PER_MSEC); - } -diff --git a/sound/soc/sof/intel/hda.c b/sound/soc/sof/intel/hda.c -index 3c4b604412f0e..a10166741865c 100644 ---- a/sound/soc/sof/intel/hda.c -+++ b/sound/soc/sof/intel/hda.c -@@ -672,6 +672,7 @@ free_streams: - /* dsp_unmap: not currently used */ - iounmap(sdev->bar[HDA_DSP_BAR]); - hdac_bus_unmap: -+ platform_device_unregister(hdev->dmic_dev); - iounmap(bus->remap_addr); - err: - return ret; diff --git a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.108-109.patch b/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.108-109.patch deleted file mode 100644 index 6569291cc9..0000000000 --- a/patch/kernel/archive/odroidxu4-5.4/0002-patch-5.4.108-109.patch +++ /dev/null @@ -1,3135 +0,0 @@ -diff --git a/Makefile b/Makefile -index b0abe257221a7..e037662c369ba 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,7 +1,7 @@ - # SPDX-License-Identifier: GPL-2.0 - VERSION = 5 - PATCHLEVEL = 4 --SUBLEVEL = 108 -+SUBLEVEL = 109 - EXTRAVERSION = - NAME = Kleptomaniac Octopus - -diff --git a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi -index 7788d5db65c25..ae6d07dc02832 100644 ---- a/arch/arm/boot/dts/at91-sama5d27_som1.dtsi -+++ b/arch/arm/boot/dts/at91-sama5d27_som1.dtsi -@@ -44,8 +44,8 @@ - pinctrl-0 = <&pinctrl_macb0_default>; - phy-mode = "rmii"; - -- ethernet-phy@0 { -- reg = <0x0>; -+ ethernet-phy@7 { -+ reg = <0x7>; - interrupt-parent = <&pioA>; - interrupts = ; - pinctrl-names = "default"; -diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi -index 337919366dc85..ec141c9852893 100644 ---- a/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi -+++ b/arch/arm64/boot/dts/freescale/fsl-ls1012a.dtsi -@@ -177,6 +177,7 @@ - ranges = <0x0 0x00 0x1700000 0x100000>; - reg = <0x00 0x1700000 0x0 0x100000>; - interrupts = ; -+ dma-coherent; - - sec_jr0: jr@10000 { - compatible = "fsl,sec-v5.4-job-ring", -diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi -index c084c7a4b6a6f..b611d835dc25a 100644 ---- a/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi -+++ b/arch/arm64/boot/dts/freescale/fsl-ls1043a.dtsi -@@ -241,6 +241,7 @@ - ranges = <0x0 0x00 0x1700000 0x100000>; - reg = <0x00 0x1700000 0x0 0x100000>; - interrupts = <0 75 0x4>; -+ dma-coherent; - - sec_jr0: jr@10000 { - compatible = "fsl,sec-v5.4-job-ring", -diff --git a/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi b/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi -index 04d4b1b11a00a..ca087918c250a 100644 ---- a/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi -+++ b/arch/arm64/boot/dts/freescale/fsl-ls1046a.dtsi -@@ -244,6 +244,7 @@ - ranges = <0x0 0x00 0x1700000 0x100000>; - reg = <0x00 0x1700000 0x0 0x100000>; - interrupts = ; -+ dma-coherent; - - sec_jr0: jr@10000 { - compatible = "fsl,sec-v5.4-job-ring", -diff --git a/arch/arm64/kernel/crash_dump.c b/arch/arm64/kernel/crash_dump.c -index e6e284265f19d..58303a9ec32c4 100644 ---- a/arch/arm64/kernel/crash_dump.c -+++ b/arch/arm64/kernel/crash_dump.c -@@ -64,5 +64,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf, - ssize_t elfcorehdr_read(char *buf, size_t count, u64 *ppos) - { - memcpy(buf, phys_to_virt((phys_addr_t)*ppos), count); -+ *ppos += count; -+ - return count; - } -diff --git a/arch/ia64/include/asm/syscall.h b/arch/ia64/include/asm/syscall.h -index 6c6f16e409a87..0d23c00493018 100644 ---- a/arch/ia64/include/asm/syscall.h -+++ b/arch/ia64/include/asm/syscall.h -@@ -32,7 +32,7 @@ static inline void syscall_rollback(struct task_struct *task, - static inline long syscall_get_error(struct task_struct *task, - struct pt_regs *regs) - { -- return regs->r10 == -1 ? regs->r8:0; -+ return regs->r10 == -1 ? -regs->r8:0; - } - - static inline long syscall_get_return_value(struct task_struct *task, -diff --git a/arch/ia64/kernel/ptrace.c b/arch/ia64/kernel/ptrace.c -index bf9c24d9ce84e..54e12b0ecebdf 100644 ---- a/arch/ia64/kernel/ptrace.c -+++ b/arch/ia64/kernel/ptrace.c -@@ -2147,27 +2147,39 @@ static void syscall_get_set_args_cb(struct unw_frame_info *info, void *data) - { - struct syscall_get_set_args *args = data; - struct pt_regs *pt = args->regs; -- unsigned long *krbs, cfm, ndirty; -+ unsigned long *krbs, cfm, ndirty, nlocals, nouts; - int i, count; - - if (unw_unwind_to_user(info) < 0) - return; - -+ /* -+ * We get here via a few paths: -+ * - break instruction: cfm is shared with caller. -+ * syscall args are in out= regs, locals are non-empty. -+ * - epsinstruction: cfm is set by br.call -+ * locals don't exist. -+ * -+ * For both cases argguments are reachable in cfm.sof - cfm.sol. -+ * CFM: [ ... | sor: 17..14 | sol : 13..7 | sof : 6..0 ] -+ */ - cfm = pt->cr_ifs; -+ nlocals = (cfm >> 7) & 0x7f; /* aka sol */ -+ nouts = (cfm & 0x7f) - nlocals; /* aka sof - sol */ - krbs = (unsigned long *)info->task + IA64_RBS_OFFSET/8; - ndirty = ia64_rse_num_regs(krbs, krbs + (pt->loadrs >> 19)); - - count = 0; - if (in_syscall(pt)) -- count = min_t(int, args->n, cfm & 0x7f); -+ count = min_t(int, args->n, nouts); - -+ /* Iterate over outs. */ - for (i = 0; i < count; i++) { -+ int j = ndirty + nlocals + i + args->i; - if (args->rw) -- *ia64_rse_skip_regs(krbs, ndirty + i + args->i) = -- args->args[i]; -+ *ia64_rse_skip_regs(krbs, j) = args->args[i]; - else -- args->args[i] = *ia64_rse_skip_regs(krbs, -- ndirty + i + args->i); -+ args->args[i] = *ia64_rse_skip_regs(krbs, j); - } - - if (!args->rw) { -diff --git a/arch/powerpc/include/asm/dcr-native.h b/arch/powerpc/include/asm/dcr-native.h -index 7141ccea8c94e..a92059964579b 100644 ---- a/arch/powerpc/include/asm/dcr-native.h -+++ b/arch/powerpc/include/asm/dcr-native.h -@@ -53,8 +53,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val) - #define mfdcr(rn) \ - ({unsigned int rval; \ - if (__builtin_constant_p(rn) && rn < 1024) \ -- asm volatile("mfdcr %0," __stringify(rn) \ -- : "=r" (rval)); \ -+ asm volatile("mfdcr %0, %1" : "=r" (rval) \ -+ : "n" (rn)); \ - else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR))) \ - rval = mfdcrx(rn); \ - else \ -@@ -64,8 +64,8 @@ static inline void mtdcrx(unsigned int reg, unsigned int val) - #define mtdcr(rn, v) \ - do { \ - if (__builtin_constant_p(rn) && rn < 1024) \ -- asm volatile("mtdcr " __stringify(rn) ",%0" \ -- : : "r" (v)); \ -+ asm volatile("mtdcr %0, %1" \ -+ : : "n" (rn), "r" (v)); \ - else if (likely(cpu_has_feature(CPU_FTR_INDEXED_DCR))) \ - mtdcrx(rn, v); \ - else \ -diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c -index 27778b65a965e..f2b22c496fb97 100644 ---- a/arch/sparc/kernel/traps_64.c -+++ b/arch/sparc/kernel/traps_64.c -@@ -275,14 +275,13 @@ bool is_no_fault_exception(struct pt_regs *regs) - asi = (regs->tstate >> 24); /* saved %asi */ - else - asi = (insn >> 5); /* immediate asi */ -- if ((asi & 0xf2) == ASI_PNF) { -- if (insn & 0x1000000) { /* op3[5:4]=3 */ -- handle_ldf_stq(insn, regs); -- return true; -- } else if (insn & 0x200000) { /* op3[2], stores */ -+ if ((asi & 0xf6) == ASI_PNF) { -+ if (insn & 0x200000) /* op3[2], stores */ - return false; -- } -- handle_ld_nf(insn, regs); -+ if (insn & 0x1000000) /* op3[5:4]=3 (fp) */ -+ handle_ldf_stq(insn, regs); -+ else -+ handle_ld_nf(insn, regs); - return true; - } - } -diff --git a/arch/x86/mm/mem_encrypt.c b/arch/x86/mm/mem_encrypt.c -index dfa01bcdc3694..7b558939b89c1 100644 ---- a/arch/x86/mm/mem_encrypt.c -+++ b/arch/x86/mm/mem_encrypt.c -@@ -229,7 +229,7 @@ static void __init __set_clr_pte_enc(pte_t *kpte, int level, bool enc) - if (pgprot_val(old_prot) == pgprot_val(new_prot)) - return; - -- pa = pfn << page_level_shift(level); -+ pa = pfn << PAGE_SHIFT; - size = page_level_size(level); - - /* -diff --git a/block/blk-merge.c b/block/blk-merge.c -index 86c4c1ef87429..03959bfe961cf 100644 ---- a/block/blk-merge.c -+++ b/block/blk-merge.c -@@ -370,6 +370,14 @@ unsigned int blk_recalc_rq_segments(struct request *rq) - switch (bio_op(rq->bio)) { - case REQ_OP_DISCARD: - case REQ_OP_SECURE_ERASE: -+ if (queue_max_discard_segments(rq->q) > 1) { -+ struct bio *bio = rq->bio; -+ -+ for_each_bio(bio) -+ nr_phys_segs++; -+ return nr_phys_segs; -+ } -+ return 1; - case REQ_OP_WRITE_ZEROES: - return 0; - case REQ_OP_WRITE_SAME: -diff --git a/block/genhd.c b/block/genhd.c -index 604f0a2cbc9a0..2f6f341a8fbb7 100644 ---- a/block/genhd.c -+++ b/block/genhd.c -@@ -637,10 +637,8 @@ static void register_disk(struct device *parent, struct gendisk *disk, - disk->part0.holder_dir = kobject_create_and_add("holders", &ddev->kobj); - disk->slave_dir = kobject_create_and_add("slaves", &ddev->kobj); - -- if (disk->flags & GENHD_FL_HIDDEN) { -- dev_set_uevent_suppress(ddev, 0); -+ if (disk->flags & GENHD_FL_HIDDEN) - return; -- } - - /* No minors to use for partitions */ - if (!disk_part_scan_enabled(disk)) -diff --git a/drivers/acpi/internal.h b/drivers/acpi/internal.h -index 1db2e1bb72ba6..159c422601bc4 100644 ---- a/drivers/acpi/internal.h -+++ b/drivers/acpi/internal.h -@@ -9,6 +9,8 @@ - #ifndef _ACPI_INTERNAL_H_ - #define _ACPI_INTERNAL_H_ - -+#include -+ - #define PREFIX "ACPI: " - - int early_acpi_osi_init(void); -@@ -96,9 +98,11 @@ void acpi_scan_table_handler(u32 event, void *table, void *context); - - extern struct list_head acpi_bus_id_list; - -+#define ACPI_MAX_DEVICE_INSTANCES 4096 -+ - struct acpi_device_bus_id { - const char *bus_id; -- unsigned int instance_no; -+ struct ida instance_ida; - struct list_head node; - }; - -diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c -index 8887a72712d4b..dbb5919f23e2d 100644 ---- a/drivers/acpi/scan.c -+++ b/drivers/acpi/scan.c -@@ -483,9 +483,8 @@ static void acpi_device_del(struct acpi_device *device) - list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) - if (!strcmp(acpi_device_bus_id->bus_id, - acpi_device_hid(device))) { -- if (acpi_device_bus_id->instance_no > 0) -- acpi_device_bus_id->instance_no--; -- else { -+ ida_simple_remove(&acpi_device_bus_id->instance_ida, device->pnp.instance_no); -+ if (ida_is_empty(&acpi_device_bus_id->instance_ida)) { - list_del(&acpi_device_bus_id->node); - kfree_const(acpi_device_bus_id->bus_id); - kfree(acpi_device_bus_id); -@@ -624,12 +623,38 @@ void acpi_bus_put_acpi_device(struct acpi_device *adev) - put_device(&adev->dev); - } - -+static struct acpi_device_bus_id *acpi_device_bus_id_match(const char *dev_id) -+{ -+ struct acpi_device_bus_id *acpi_device_bus_id; -+ -+ /* Find suitable bus_id and instance number in acpi_bus_id_list. */ -+ list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { -+ if (!strcmp(acpi_device_bus_id->bus_id, dev_id)) -+ return acpi_device_bus_id; -+ } -+ return NULL; -+} -+ -+static int acpi_device_set_name(struct acpi_device *device, -+ struct acpi_device_bus_id *acpi_device_bus_id) -+{ -+ struct ida *instance_ida = &acpi_device_bus_id->instance_ida; -+ int result; -+ -+ result = ida_simple_get(instance_ida, 0, ACPI_MAX_DEVICE_INSTANCES, GFP_KERNEL); -+ if (result < 0) -+ return result; -+ -+ device->pnp.instance_no = result; -+ dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, result); -+ return 0; -+} -+ - int acpi_device_add(struct acpi_device *device, - void (*release)(struct device *)) - { -+ struct acpi_device_bus_id *acpi_device_bus_id; - int result; -- struct acpi_device_bus_id *acpi_device_bus_id, *new_bus_id; -- int found = 0; - - if (device->handle) { - acpi_status status; -@@ -655,41 +680,38 @@ int acpi_device_add(struct acpi_device *device, - INIT_LIST_HEAD(&device->del_list); - mutex_init(&device->physical_node_lock); - -- new_bus_id = kzalloc(sizeof(struct acpi_device_bus_id), GFP_KERNEL); -- if (!new_bus_id) { -- pr_err(PREFIX "Memory allocation error\n"); -- result = -ENOMEM; -- goto err_detach; -- } -- - mutex_lock(&acpi_device_lock); -- /* -- * Find suitable bus_id and instance number in acpi_bus_id_list -- * If failed, create one and link it into acpi_bus_id_list -- */ -- list_for_each_entry(acpi_device_bus_id, &acpi_bus_id_list, node) { -- if (!strcmp(acpi_device_bus_id->bus_id, -- acpi_device_hid(device))) { -- acpi_device_bus_id->instance_no++; -- found = 1; -- kfree(new_bus_id); -- break; -+ -+ acpi_device_bus_id = acpi_device_bus_id_match(acpi_device_hid(device)); -+ if (acpi_device_bus_id) { -+ result = acpi_device_set_name(device, acpi_device_bus_id); -+ if (result) -+ goto err_unlock; -+ } else { -+ acpi_device_bus_id = kzalloc(sizeof(*acpi_device_bus_id), -+ GFP_KERNEL); -+ if (!acpi_device_bus_id) { -+ result = -ENOMEM; -+ goto err_unlock; - } -- } -- if (!found) { -- acpi_device_bus_id = new_bus_id; - acpi_device_bus_id->bus_id = - kstrdup_const(acpi_device_hid(device), GFP_KERNEL); - if (!acpi_device_bus_id->bus_id) { -- pr_err(PREFIX "Memory allocation error for bus id\n"); -+ kfree(acpi_device_bus_id); - result = -ENOMEM; -- goto err_free_new_bus_id; -+ goto err_unlock; -+ } -+ -+ ida_init(&acpi_device_bus_id->instance_ida); -+ -+ result = acpi_device_set_name(device, acpi_device_bus_id); -+ if (result) { -+ kfree(acpi_device_bus_id); -+ goto err_unlock; - } - -- acpi_device_bus_id->instance_no = 0; - list_add_tail(&acpi_device_bus_id->node, &acpi_bus_id_list); - } -- dev_set_name(&device->dev, "%s:%02x", acpi_device_bus_id->bus_id, acpi_device_bus_id->instance_no); - - if (device->parent) - list_add_tail(&device->node, &device->parent->children); -@@ -721,13 +743,9 @@ int acpi_device_add(struct acpi_device *device, - list_del(&device->node); - list_del(&device->wakeup_list); - -- err_free_new_bus_id: -- if (!found) -- kfree(new_bus_id); -- -+ err_unlock: - mutex_unlock(&acpi_device_lock); - -- err_detach: - acpi_detach_data(device->handle, acpi_scan_drop_device); - return result; - } -diff --git a/drivers/acpi/video_detect.c b/drivers/acpi/video_detect.c -index 301ffe5b8feb0..e7978d983b263 100644 ---- a/drivers/acpi/video_detect.c -+++ b/drivers/acpi/video_detect.c -@@ -150,6 +150,7 @@ static const struct dmi_system_id video_detect_dmi_table[] = { - }, - }, - { -+ .callback = video_detect_force_vendor, - .ident = "Sony VPCEH3U1E", - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "Sony Corporation"), -diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c -index bedaebd5a4956..de52428b8833d 100644 ---- a/drivers/atm/eni.c -+++ b/drivers/atm/eni.c -@@ -2281,7 +2281,8 @@ out: - return rc; - - err_eni_release: -- eni_do_release(dev); -+ dev->phy = NULL; -+ iounmap(ENI_DEV(dev)->ioaddr); - err_unregister: - atm_dev_deregister(dev); - err_free_consistent: -diff --git a/drivers/atm/idt77105.c b/drivers/atm/idt77105.c -index 63871859e6e8e..52c2878b755db 100644 ---- a/drivers/atm/idt77105.c -+++ b/drivers/atm/idt77105.c -@@ -262,7 +262,7 @@ static int idt77105_start(struct atm_dev *dev) - { - unsigned long flags; - -- if (!(dev->dev_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL))) -+ if (!(dev->phy_data = kmalloc(sizeof(struct idt77105_priv),GFP_KERNEL))) - return -ENOMEM; - PRIV(dev)->dev = dev; - spin_lock_irqsave(&idt77105_priv_lock, flags); -@@ -337,7 +337,7 @@ static int idt77105_stop(struct atm_dev *dev) - else - idt77105_all = walk->next; - dev->phy = NULL; -- dev->dev_data = NULL; -+ dev->phy_data = NULL; - kfree(walk); - break; - } -diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c -index 645a6bc1df888..c6b38112bcf4f 100644 ---- a/drivers/atm/lanai.c -+++ b/drivers/atm/lanai.c -@@ -2234,6 +2234,7 @@ static int lanai_dev_open(struct atm_dev *atmdev) - conf1_write(lanai); - #endif - iounmap(lanai->base); -+ lanai->base = NULL; - error_pci: - pci_disable_device(lanai->pci); - error: -@@ -2246,6 +2247,8 @@ static int lanai_dev_open(struct atm_dev *atmdev) - static void lanai_dev_close(struct atm_dev *atmdev) - { - struct lanai_dev *lanai = (struct lanai_dev *) atmdev->dev_data; -+ if (lanai->base==NULL) -+ return; - printk(KERN_INFO DEV_LABEL "(itf %d): shutting down interface\n", - lanai->number); - lanai_timed_poll_stop(lanai); -@@ -2555,7 +2558,7 @@ static int lanai_init_one(struct pci_dev *pci, - struct atm_dev *atmdev; - int result; - -- lanai = kmalloc(sizeof(*lanai), GFP_KERNEL); -+ lanai = kzalloc(sizeof(*lanai), GFP_KERNEL); - if (lanai == NULL) { - printk(KERN_ERR DEV_LABEL - ": couldn't allocate dev_data structure!\n"); -diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c -index 7850758b5bb82..239852d855589 100644 ---- a/drivers/atm/uPD98402.c -+++ b/drivers/atm/uPD98402.c -@@ -211,7 +211,7 @@ static void uPD98402_int(struct atm_dev *dev) - static int uPD98402_start(struct atm_dev *dev) - { - DPRINTK("phy_start\n"); -- if (!(dev->dev_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL))) -+ if (!(dev->phy_data = kmalloc(sizeof(struct uPD98402_priv),GFP_KERNEL))) - return -ENOMEM; - spin_lock_init(&PRIV(dev)->lock); - memset(&PRIV(dev)->sonet_stats,0,sizeof(struct k_sonet_stats)); -diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c -index 137a7ba053d78..e0c4ef06ca917 100644 ---- a/drivers/base/power/runtime.c -+++ b/drivers/base/power/runtime.c -@@ -305,7 +305,7 @@ static int rpm_get_suppliers(struct device *dev) - return 0; - } - --static void rpm_put_suppliers(struct device *dev) -+static void __rpm_put_suppliers(struct device *dev, bool try_to_suspend) - { - struct device_link *link; - -@@ -313,10 +313,30 @@ static void rpm_put_suppliers(struct device *dev) - device_links_read_lock_held()) { - - while (refcount_dec_not_one(&link->rpm_active)) -- pm_runtime_put(link->supplier); -+ pm_runtime_put_noidle(link->supplier); -+ -+ if (try_to_suspend) -+ pm_request_idle(link->supplier); - } - } - -+static void rpm_put_suppliers(struct device *dev) -+{ -+ __rpm_put_suppliers(dev, true); -+} -+ -+static void rpm_suspend_suppliers(struct device *dev) -+{ -+ struct device_link *link; -+ int idx = device_links_read_lock(); -+ -+ list_for_each_entry_rcu(link, &dev->links.suppliers, c_node, -+ device_links_read_lock_held()) -+ pm_request_idle(link->supplier); -+ -+ device_links_read_unlock(idx); -+} -+ - /** - * __rpm_callback - Run a given runtime PM callback for a given device. - * @cb: Runtime PM callback to run. -@@ -344,8 +364,10 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - idx = device_links_read_lock(); - - retval = rpm_get_suppliers(dev); -- if (retval) -+ if (retval) { -+ rpm_put_suppliers(dev); - goto fail; -+ } - - device_links_read_unlock(idx); - } -@@ -368,9 +390,9 @@ static int __rpm_callback(int (*cb)(struct device *), struct device *dev) - || (dev->power.runtime_status == RPM_RESUMING && retval))) { - idx = device_links_read_lock(); - -- fail: -- rpm_put_suppliers(dev); -+ __rpm_put_suppliers(dev, false); - -+fail: - device_links_read_unlock(idx); - } - -@@ -644,8 +666,11 @@ static int rpm_suspend(struct device *dev, int rpmflags) - goto out; - } - -+ if (dev->power.irq_safe) -+ goto out; -+ - /* Maybe the parent is now able to suspend. */ -- if (parent && !parent->power.ignore_children && !dev->power.irq_safe) { -+ if (parent && !parent->power.ignore_children) { - spin_unlock(&dev->power.lock); - - spin_lock(&parent->power.lock); -@@ -654,6 +679,14 @@ static int rpm_suspend(struct device *dev, int rpmflags) - - spin_lock(&dev->power.lock); - } -+ /* Maybe the suppliers are now able to suspend. */ -+ if (dev->power.links_count > 0) { -+ spin_unlock_irq(&dev->power.lock); -+ -+ rpm_suspend_suppliers(dev); -+ -+ spin_lock_irq(&dev->power.lock); -+ } - - out: - trace_rpm_return_int_rcuidle(dev, _THIS_IP_, retval); -diff --git a/drivers/block/xen-blkback/blkback.c b/drivers/block/xen-blkback/blkback.c -index 208f3eea3641f..d98cfd3b64ff0 100644 ---- a/drivers/block/xen-blkback/blkback.c -+++ b/drivers/block/xen-blkback/blkback.c -@@ -944,7 +944,7 @@ next: - out: - for (i = last_map; i < num; i++) { - /* Don't zap current batch's valid persistent grants. */ -- if(i >= last_map + segs_to_map) -+ if(i >= map_until) - pages[i]->persistent_gnt = NULL; - pages[i]->handle = BLKBACK_INVALID_HANDLE; - } -diff --git a/drivers/bus/omap_l3_noc.c b/drivers/bus/omap_l3_noc.c -index b040447575adc..dcfb32ee5cb60 100644 ---- a/drivers/bus/omap_l3_noc.c -+++ b/drivers/bus/omap_l3_noc.c -@@ -285,7 +285,7 @@ static int omap_l3_probe(struct platform_device *pdev) - */ - l3->debug_irq = platform_get_irq(pdev, 0); - ret = devm_request_irq(l3->dev, l3->debug_irq, l3_interrupt_handler, -- 0x0, "l3-dbg-irq", l3); -+ IRQF_NO_THREAD, "l3-dbg-irq", l3); - if (ret) { - dev_err(l3->dev, "request_irq failed for %d\n", - l3->debug_irq); -@@ -294,7 +294,7 @@ static int omap_l3_probe(struct platform_device *pdev) - - l3->app_irq = platform_get_irq(pdev, 1); - ret = devm_request_irq(l3->dev, l3->app_irq, l3_interrupt_handler, -- 0x0, "l3-app-irq", l3); -+ IRQF_NO_THREAD, "l3-app-irq", l3); - if (ret) - dev_err(l3->dev, "request_irq failed for %d\n", l3->app_irq); - -diff --git a/drivers/cpufreq/cpufreq-dt-platdev.c b/drivers/cpufreq/cpufreq-dt-platdev.c -index bca8d1f47fd2c..1200842c3da42 100644 ---- a/drivers/cpufreq/cpufreq-dt-platdev.c -+++ b/drivers/cpufreq/cpufreq-dt-platdev.c -@@ -103,6 +103,8 @@ static const struct of_device_id whitelist[] __initconst = { - static const struct of_device_id blacklist[] __initconst = { - { .compatible = "allwinner,sun50i-h6", }, - -+ { .compatible = "arm,vexpress", }, -+ - { .compatible = "calxeda,highbank", }, - { .compatible = "calxeda,ecx-2000", }, - -diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c -index b2e186047014f..66dcab6ab26dd 100644 ---- a/drivers/gpio/gpiolib-acpi.c -+++ b/drivers/gpio/gpiolib-acpi.c -@@ -174,7 +174,7 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio, - int ret, value; - - ret = request_threaded_irq(event->irq, NULL, event->handler, -- event->irqflags, "ACPI:Event", event); -+ event->irqflags | IRQF_ONESHOT, "ACPI:Event", event); - if (ret) { - dev_err(acpi_gpio->chip->parent, - "Failed to setup interrupt handler for %d\n", -diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig -index e67c194c2acad..649f17dfcf459 100644 ---- a/drivers/gpu/drm/Kconfig -+++ b/drivers/gpu/drm/Kconfig -@@ -206,6 +206,7 @@ source "drivers/gpu/drm/arm/Kconfig" - config DRM_RADEON - tristate "ATI Radeon" - depends on DRM && PCI && MMU -+ depends on AGP || !AGP - select FW_LOADER - select DRM_KMS_HELPER - select DRM_TTM -diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c -index eaa5e7b7c19d6..fd94a17fb2c6d 100644 ---- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c -+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c -@@ -146,7 +146,7 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev, - size = mode_cmd->pitches[0] * height; - aligned_size = ALIGN(size, PAGE_SIZE); - ret = amdgpu_gem_object_create(adev, aligned_size, 0, domain, flags, -- ttm_bo_type_kernel, NULL, &gobj); -+ ttm_bo_type_device, NULL, &gobj); - if (ret) { - pr_err("failed to allocate framebuffer (%d)\n", aligned_size); - return -ENOMEM; -diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -index f63cbbee7b337..11a4c4029a902 100644 ---- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c -@@ -257,7 +257,7 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = { - .num_banks = 8, - .num_chans = 4, - .vmm_page_size_bytes = 4096, -- .dram_clock_change_latency_us = 11.72, -+ .dram_clock_change_latency_us = 23.84, - .return_bus_width_bytes = 64, - .dispclk_dppclk_vco_speed_mhz = 3600, - .xfc_bus_transport_time_us = 4, -diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c -index 8d9d86c76a4e9..896d6f95a9604 100644 ---- a/drivers/gpu/drm/msm/msm_drv.c -+++ b/drivers/gpu/drm/msm/msm_drv.c -@@ -1326,6 +1326,10 @@ static int msm_pdev_remove(struct platform_device *pdev) - static void msm_pdev_shutdown(struct platform_device *pdev) - { - struct drm_device *drm = platform_get_drvdata(pdev); -+ struct msm_drm_private *priv = drm ? drm->dev_private : NULL; -+ -+ if (!priv || !priv->kms) -+ return; - - drm_atomic_helper_shutdown(drm); - } -diff --git a/drivers/infiniband/hw/cxgb4/cm.c b/drivers/infiniband/hw/cxgb4/cm.c -index 30e08bcc9afb5..3c78f8c32d12b 100644 ---- a/drivers/infiniband/hw/cxgb4/cm.c -+++ b/drivers/infiniband/hw/cxgb4/cm.c -@@ -3610,13 +3610,13 @@ int c4iw_destroy_listen(struct iw_cm_id *cm_id) - ep->com.local_addr.ss_family == AF_INET) { - err = cxgb4_remove_server_filter( - ep->com.dev->rdev.lldi.ports[0], ep->stid, -- ep->com.dev->rdev.lldi.rxq_ids[0], 0); -+ ep->com.dev->rdev.lldi.rxq_ids[0], false); - } else { - struct sockaddr_in6 *sin6; - c4iw_init_wr_wait(ep->com.wr_waitp); - err = cxgb4_remove_server( - ep->com.dev->rdev.lldi.ports[0], ep->stid, -- ep->com.dev->rdev.lldi.rxq_ids[0], 0); -+ ep->com.dev->rdev.lldi.rxq_ids[0], true); - if (err) - goto done; - err = c4iw_wait_for_reply(&ep->com.dev->rdev, ep->com.wr_waitp, -diff --git a/drivers/irqchip/irq-ingenic-tcu.c b/drivers/irqchip/irq-ingenic-tcu.c -index 6d05cefe9d795..02a82723a57ab 100644 ---- a/drivers/irqchip/irq-ingenic-tcu.c -+++ b/drivers/irqchip/irq-ingenic-tcu.c -@@ -179,4 +179,5 @@ err_free_tcu: - } - IRQCHIP_DECLARE(jz4740_tcu_irq, "ingenic,jz4740-tcu", ingenic_tcu_irq_init); - IRQCHIP_DECLARE(jz4725b_tcu_irq, "ingenic,jz4725b-tcu", ingenic_tcu_irq_init); -+IRQCHIP_DECLARE(jz4760_tcu_irq, "ingenic,jz4760-tcu", ingenic_tcu_irq_init); - IRQCHIP_DECLARE(jz4770_tcu_irq, "ingenic,jz4770-tcu", ingenic_tcu_irq_init); -diff --git a/drivers/irqchip/irq-ingenic.c b/drivers/irqchip/irq-ingenic.c -index dda512dfe2c17..31bc11f15bfa4 100644 ---- a/drivers/irqchip/irq-ingenic.c -+++ b/drivers/irqchip/irq-ingenic.c -@@ -168,6 +168,7 @@ static int __init intc_2chip_of_init(struct device_node *node, - { - return ingenic_intc_of_init(node, 2); - } -+IRQCHIP_DECLARE(jz4760_intc, "ingenic,jz4760-intc", intc_2chip_of_init); - IRQCHIP_DECLARE(jz4770_intc, "ingenic,jz4770-intc", intc_2chip_of_init); - IRQCHIP_DECLARE(jz4775_intc, "ingenic,jz4775-intc", intc_2chip_of_init); - IRQCHIP_DECLARE(jz4780_intc, "ingenic,jz4780-intc", intc_2chip_of_init); -diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c -index 1c5133f71af39..3f15d8dc2b71f 100644 ---- a/drivers/md/dm-ioctl.c -+++ b/drivers/md/dm-ioctl.c -@@ -529,7 +529,7 @@ static int list_devices(struct file *filp, struct dm_ioctl *param, size_t param_ - * Grab our output buffer. - */ - nl = orig_nl = get_result_buffer(param, param_size, &len); -- if (len < needed) { -+ if (len < needed || len < sizeof(nl->dev)) { - param->flags |= DM_BUFFER_FULL_FLAG; - goto out; - } -diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c -index 2aeb922e2365c..711f101447e3e 100644 ---- a/drivers/md/dm-verity-target.c -+++ b/drivers/md/dm-verity-target.c -@@ -33,7 +33,7 @@ - #define DM_VERITY_OPT_IGN_ZEROES "ignore_zero_blocks" - #define DM_VERITY_OPT_AT_MOST_ONCE "check_at_most_once" - --#define DM_VERITY_OPTS_MAX (2 + DM_VERITY_OPTS_FEC + \ -+#define DM_VERITY_OPTS_MAX (3 + DM_VERITY_OPTS_FEC + \ - DM_VERITY_ROOT_HASH_VERIFICATION_OPTS) - - static unsigned dm_verity_prefetch_cluster = DM_VERITY_DEFAULT_PREFETCH_SIZE; -diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c -index 3486bf33474d9..e3d943c65419b 100644 ---- a/drivers/misc/habanalabs/device.c -+++ b/drivers/misc/habanalabs/device.c -@@ -108,6 +108,8 @@ static int hl_device_release_ctrl(struct inode *inode, struct file *filp) - list_del(&hpriv->dev_node); - mutex_unlock(&hdev->fpriv_list_lock); - -+ put_pid(hpriv->taskpid); -+ - kfree(hpriv); - - return 0; -diff --git a/drivers/net/can/c_can/c_can.c b/drivers/net/can/c_can/c_can.c -index 8e9f5620c9a21..f14e739ba3f45 100644 ---- a/drivers/net/can/c_can/c_can.c -+++ b/drivers/net/can/c_can/c_can.c -@@ -212,18 +212,6 @@ static const struct can_bittiming_const c_can_bittiming_const = { - .brp_inc = 1, - }; - --static inline void c_can_pm_runtime_enable(const struct c_can_priv *priv) --{ -- if (priv->device) -- pm_runtime_enable(priv->device); --} -- --static inline void c_can_pm_runtime_disable(const struct c_can_priv *priv) --{ -- if (priv->device) -- pm_runtime_disable(priv->device); --} -- - static inline void c_can_pm_runtime_get_sync(const struct c_can_priv *priv) - { - if (priv->device) -@@ -1334,7 +1322,6 @@ static const struct net_device_ops c_can_netdev_ops = { - - int register_c_can_dev(struct net_device *dev) - { -- struct c_can_priv *priv = netdev_priv(dev); - int err; - - /* Deactivate pins to prevent DRA7 DCAN IP from being -@@ -1344,28 +1331,19 @@ int register_c_can_dev(struct net_device *dev) - */ - pinctrl_pm_select_sleep_state(dev->dev.parent); - -- c_can_pm_runtime_enable(priv); -- - dev->flags |= IFF_ECHO; /* we support local echo */ - dev->netdev_ops = &c_can_netdev_ops; - - err = register_candev(dev); -- if (err) -- c_can_pm_runtime_disable(priv); -- else -+ if (!err) - devm_can_led_init(dev); -- - return err; - } - EXPORT_SYMBOL_GPL(register_c_can_dev); - - void unregister_c_can_dev(struct net_device *dev) - { -- struct c_can_priv *priv = netdev_priv(dev); -- - unregister_candev(dev); -- -- c_can_pm_runtime_disable(priv); - } - EXPORT_SYMBOL_GPL(unregister_c_can_dev); - -diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c -index 406b4847e5dc3..7efb60b508762 100644 ---- a/drivers/net/can/c_can/c_can_pci.c -+++ b/drivers/net/can/c_can/c_can_pci.c -@@ -239,12 +239,13 @@ static void c_can_pci_remove(struct pci_dev *pdev) - { - struct net_device *dev = pci_get_drvdata(pdev); - struct c_can_priv *priv = netdev_priv(dev); -+ void __iomem *addr = priv->base; - - unregister_c_can_dev(dev); - - free_c_can_dev(dev); - -- pci_iounmap(pdev, priv->base); -+ pci_iounmap(pdev, addr); - pci_disable_msi(pdev); - pci_clear_master(pdev); - pci_release_regions(pdev); -diff --git a/drivers/net/can/c_can/c_can_platform.c b/drivers/net/can/c_can/c_can_platform.c -index b5145a7f874c2..f2b0408ce87d1 100644 ---- a/drivers/net/can/c_can/c_can_platform.c -+++ b/drivers/net/can/c_can/c_can_platform.c -@@ -29,6 +29,7 @@ - #include - #include - #include -+#include - #include - #include - #include -@@ -385,6 +386,7 @@ static int c_can_plat_probe(struct platform_device *pdev) - platform_set_drvdata(pdev, dev); - SET_NETDEV_DEV(dev, &pdev->dev); - -+ pm_runtime_enable(priv->device); - ret = register_c_can_dev(dev); - if (ret) { - dev_err(&pdev->dev, "registering %s failed (err=%d)\n", -@@ -397,6 +399,7 @@ static int c_can_plat_probe(struct platform_device *pdev) - return 0; - - exit_free_device: -+ pm_runtime_disable(priv->device); - free_c_can_dev(dev); - exit: - dev_err(&pdev->dev, "probe failed\n"); -@@ -407,9 +410,10 @@ exit: - static int c_can_plat_remove(struct platform_device *pdev) - { - struct net_device *dev = platform_get_drvdata(pdev); -+ struct c_can_priv *priv = netdev_priv(dev); - - unregister_c_can_dev(dev); -- -+ pm_runtime_disable(priv->device); - free_c_can_dev(dev); - - return 0; -diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c -index 2ae9feb99a07d..1e0c1a05df82d 100644 ---- a/drivers/net/can/dev.c -+++ b/drivers/net/can/dev.c -@@ -1226,6 +1226,7 @@ static void can_dellink(struct net_device *dev, struct list_head *head) - - static struct rtnl_link_ops can_link_ops __read_mostly = { - .kind = "can", -+ .netns_refund = true, - .maxtype = IFLA_CAN_MAX, - .policy = can_policy, - .setup = can_setup, -diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c -index b6d00dfa8b8f6..7ec15cb356c01 100644 ---- a/drivers/net/can/flexcan.c -+++ b/drivers/net/can/flexcan.c -@@ -544,9 +544,15 @@ static int flexcan_chip_disable(struct flexcan_priv *priv) - static int flexcan_chip_freeze(struct flexcan_priv *priv) - { - struct flexcan_regs __iomem *regs = priv->regs; -- unsigned int timeout = 1000 * 1000 * 10 / priv->can.bittiming.bitrate; -+ unsigned int timeout; -+ u32 bitrate = priv->can.bittiming.bitrate; - u32 reg; - -+ if (bitrate) -+ timeout = 1000 * 1000 * 10 / bitrate; -+ else -+ timeout = FLEXCAN_TIMEOUT_US / 10; -+ - reg = priv->read(®s->mcr); - reg |= FLEXCAN_MCR_FRZ | FLEXCAN_MCR_HALT; - priv->write(reg, ®s->mcr); -diff --git a/drivers/net/can/kvaser_pciefd.c b/drivers/net/can/kvaser_pciefd.c -index 72acd1ba162d2..e7a26ec9bdc11 100644 ---- a/drivers/net/can/kvaser_pciefd.c -+++ b/drivers/net/can/kvaser_pciefd.c -@@ -57,6 +57,7 @@ MODULE_DESCRIPTION("CAN driver for Kvaser CAN/PCIe devices"); - #define KVASER_PCIEFD_KCAN_STAT_REG 0x418 - #define KVASER_PCIEFD_KCAN_MODE_REG 0x41c - #define KVASER_PCIEFD_KCAN_BTRN_REG 0x420 -+#define KVASER_PCIEFD_KCAN_BUS_LOAD_REG 0x424 - #define KVASER_PCIEFD_KCAN_BTRD_REG 0x428 - #define KVASER_PCIEFD_KCAN_PWM_REG 0x430 - /* Loopback control register */ -@@ -947,6 +948,9 @@ static int kvaser_pciefd_setup_can_ctrls(struct kvaser_pciefd *pcie) - timer_setup(&can->bec_poll_timer, kvaser_pciefd_bec_poll_timer, - 0); - -+ /* Disable Bus load reporting */ -+ iowrite32(0, can->reg_base + KVASER_PCIEFD_KCAN_BUS_LOAD_REG); -+ - tx_npackets = ioread32(can->reg_base + - KVASER_PCIEFD_KCAN_TX_NPACKETS_REG); - if (((tx_npackets >> KVASER_PCIEFD_KCAN_TX_NPACKETS_MAX_SHIFT) & -diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c -index 8a842545e3f69..b2224113987c7 100644 ---- a/drivers/net/can/m_can/m_can.c -+++ b/drivers/net/can/m_can/m_can.c -@@ -501,9 +501,6 @@ static int m_can_do_rx_poll(struct net_device *dev, int quota) - } - - while ((rxfs & RXFS_FFL_MASK) && (quota > 0)) { -- if (rxfs & RXFS_RFL) -- netdev_warn(dev, "Rx FIFO 0 Message Lost\n"); -- - m_can_read_fifo(dev, rxfs); - - quota--; -@@ -842,7 +839,7 @@ static int m_can_rx_peripheral(struct net_device *dev) - { - struct m_can_classdev *cdev = netdev_priv(dev); - -- m_can_rx_handler(dev, 1); -+ m_can_rx_handler(dev, M_CAN_NAPI_WEIGHT); - - m_can_enable_all_interrupts(cdev); - -diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c -index f35757b63ea78..e78b683f73052 100644 ---- a/drivers/net/dsa/b53/b53_common.c -+++ b/drivers/net/dsa/b53/b53_common.c -@@ -996,13 +996,6 @@ static int b53_setup(struct dsa_switch *ds) - b53_disable_port(ds, port); - } - -- /* Let DSA handle the case were multiple bridges span the same switch -- * device and different VLAN awareness settings are requested, which -- * would be breaking filtering semantics for any of the other bridge -- * devices. (not hardware supported) -- */ -- ds->vlan_filtering_is_global = true; -- - return ret; - } - -@@ -2418,6 +2411,13 @@ struct b53_device *b53_switch_alloc(struct device *base, - dev->priv = priv; - dev->ops = ops; - ds->ops = &b53_switch_ops; -+ /* Let DSA handle the case were multiple bridges span the same switch -+ * device and different VLAN awareness settings are requested, which -+ * would be breaking filtering semantics for any of the other bridge -+ * devices. (not hardware supported) -+ */ -+ ds->vlan_filtering_is_global = true; -+ - mutex_init(&dev->reg_mutex); - mutex_init(&dev->stats_mutex); - -diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c -index ca425c15953b1..0ee1c0a7b165b 100644 ---- a/drivers/net/dsa/bcm_sf2.c -+++ b/drivers/net/dsa/bcm_sf2.c -@@ -479,8 +479,10 @@ static u32 bcm_sf2_sw_get_phy_flags(struct dsa_switch *ds, int port) - * in bits 15:8 and the patch level in bits 7:0 which is exactly what - * the REG_PHY_REVISION register layout is. - */ -- -- return priv->hw_params.gphy_rev; -+ if (priv->int_phy_mask & BIT(port)) -+ return priv->hw_params.gphy_rev; -+ else -+ return 0; - } - - static void bcm_sf2_sw_validate(struct dsa_switch *ds, int port, -diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c -index 0928bec79fe4b..4b958681d66e7 100644 ---- a/drivers/net/ethernet/davicom/dm9000.c -+++ b/drivers/net/ethernet/davicom/dm9000.c -@@ -1512,7 +1512,7 @@ dm9000_probe(struct platform_device *pdev) - goto out; - } - -- db->irq_wake = platform_get_irq(pdev, 1); -+ db->irq_wake = platform_get_irq_optional(pdev, 1); - if (db->irq_wake >= 0) { - dev_dbg(db->dev, "wakeup irq %d\n", db->irq_wake); - -diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c -index 1aea22d2540fb..4050f81f788c3 100644 ---- a/drivers/net/ethernet/faraday/ftgmac100.c -+++ b/drivers/net/ethernet/faraday/ftgmac100.c -@@ -1307,6 +1307,7 @@ static int ftgmac100_poll(struct napi_struct *napi, int budget) - */ - if (unlikely(priv->need_mac_restart)) { - ftgmac100_start_hw(priv); -+ priv->need_mac_restart = false; - - /* Re-enable "bad" interrupts */ - iowrite32(FTGMAC100_INT_BAD, -diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c -index 945643c026155..49fad118988bc 100644 ---- a/drivers/net/ethernet/freescale/fec_ptp.c -+++ b/drivers/net/ethernet/freescale/fec_ptp.c -@@ -382,9 +382,16 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts) - u64 ns; - unsigned long flags; - -+ mutex_lock(&adapter->ptp_clk_mutex); -+ /* Check the ptp clock */ -+ if (!adapter->ptp_clk_on) { -+ mutex_unlock(&adapter->ptp_clk_mutex); -+ return -EINVAL; -+ } - spin_lock_irqsave(&adapter->tmreg_lock, flags); - ns = timecounter_read(&adapter->tc); - spin_unlock_irqrestore(&adapter->tmreg_lock, flags); -+ mutex_unlock(&adapter->ptp_clk_mutex); - - *ts = ns_to_timespec64(ns); - -diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c -index 5cb58ab1eec97..a8959a092344f 100644 ---- a/drivers/net/ethernet/freescale/gianfar.c -+++ b/drivers/net/ethernet/freescale/gianfar.c -@@ -2388,6 +2388,10 @@ static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus, - if (lstatus & BD_LFLAG(RXBD_LAST)) - size -= skb->len; - -+ WARN(size < 0, "gianfar: rx fragment size underflow"); -+ if (size < 0) -+ return false; -+ - skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, - rxb->page_offset + RXBUF_ALIGNMENT, - size, GFAR_RXB_TRUESIZE); -@@ -2550,6 +2554,17 @@ static int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue, - if (lstatus & BD_LFLAG(RXBD_EMPTY)) - break; - -+ /* lost RXBD_LAST descriptor due to overrun */ -+ if (skb && -+ (lstatus & BD_LFLAG(RXBD_FIRST))) { -+ /* discard faulty buffer */ -+ dev_kfree_skb(skb); -+ skb = NULL; -+ rx_queue->stats.rx_dropped++; -+ -+ /* can continue normally */ -+ } -+ - /* order rx buffer descriptor reads */ - rmb(); - -diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c -index 6d5d53cfc7ab4..7516f68230900 100644 ---- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c -+++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c -@@ -1677,8 +1677,10 @@ static int hns_nic_clear_all_rx_fetch(struct net_device *ndev) - for (j = 0; j < fetch_num; j++) { - /* alloc one skb and init */ - skb = hns_assemble_skb(ndev); -- if (!skb) -+ if (!skb) { -+ ret = -ENOMEM; - goto out; -+ } - rd = &tx_ring_data(priv, skb->queue_mapping); - hns_nic_net_xmit_hw(ndev, skb, rd); - -diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c -index 2c1bab377b2a5..1fd4406173a87 100644 ---- a/drivers/net/ethernet/intel/e1000e/82571.c -+++ b/drivers/net/ethernet/intel/e1000e/82571.c -@@ -899,6 +899,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active) - } else { - data &= ~IGP02E1000_PM_D0_LPLU; - ret_val = e1e_wphy(hw, IGP02E1000_PHY_POWER_MGMT, data); -+ if (ret_val) -+ return ret_val; - /* LPLU and SmartSpeed are mutually exclusive. LPLU is used - * during Dx states where the power conservation is most - * important. During driver activity we should enable -diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c -index 4cb05a31e66df..c2feedfd321dc 100644 ---- a/drivers/net/ethernet/intel/e1000e/netdev.c -+++ b/drivers/net/ethernet/intel/e1000e/netdev.c -@@ -5953,15 +5953,19 @@ static void e1000_reset_task(struct work_struct *work) - struct e1000_adapter *adapter; - adapter = container_of(work, struct e1000_adapter, reset_task); - -+ rtnl_lock(); - /* don't run the task if already down */ -- if (test_bit(__E1000_DOWN, &adapter->state)) -+ if (test_bit(__E1000_DOWN, &adapter->state)) { -+ rtnl_unlock(); - return; -+ } - - if (!(adapter->flags & FLAG_RESTART_NOW)) { - e1000e_dump(adapter); - e_err("Reset adapter unexpectedly\n"); - } - e1000e_reinit_locked(adapter); -+ rtnl_unlock(); - } - - /** -diff --git a/drivers/net/ethernet/intel/iavf/iavf_main.c b/drivers/net/ethernet/intel/iavf/iavf_main.c -index 56e6bec9af797..cffc8c1044f20 100644 ---- a/drivers/net/ethernet/intel/iavf/iavf_main.c -+++ b/drivers/net/ethernet/intel/iavf/iavf_main.c -@@ -1786,7 +1786,8 @@ static int iavf_init_get_resources(struct iavf_adapter *adapter) - goto err_alloc; - } - -- if (iavf_process_config(adapter)) -+ err = iavf_process_config(adapter); -+ if (err) - goto err_alloc; - adapter->current_op = VIRTCHNL_OP_UNKNOWN; - -diff --git a/drivers/net/ethernet/intel/igc/igc_ethtool.c b/drivers/net/ethernet/intel/igc/igc_ethtool.c -index 0365bf2b480e3..cbcb8611ab50d 100644 ---- a/drivers/net/ethernet/intel/igc/igc_ethtool.c -+++ b/drivers/net/ethernet/intel/igc/igc_ethtool.c -@@ -1690,6 +1690,9 @@ static int igc_get_link_ksettings(struct net_device *netdev, - Autoneg); - } - -+ /* Set pause flow control settings */ -+ ethtool_link_ksettings_add_link_mode(cmd, supported, Pause); -+ - switch (hw->fc.requested_mode) { - case igc_fc_full: - ethtool_link_ksettings_add_link_mode(cmd, advertising, Pause); -@@ -1704,9 +1707,7 @@ static int igc_get_link_ksettings(struct net_device *netdev, - Asym_Pause); - break; - default: -- ethtool_link_ksettings_add_link_mode(cmd, advertising, Pause); -- ethtool_link_ksettings_add_link_mode(cmd, advertising, -- Asym_Pause); -+ break; - } - - status = pm_runtime_suspended(&adapter->pdev->dev) ? -diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -index f605540644035..1b8e70585c44a 100644 ---- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c -@@ -9595,8 +9595,10 @@ static int ixgbe_configure_clsu32(struct ixgbe_adapter *adapter, - ixgbe_atr_compute_perfect_hash_82599(&input->filter, mask); - err = ixgbe_fdir_write_perfect_filter_82599(hw, &input->filter, - input->sw_idx, queue); -- if (!err) -- ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); -+ if (err) -+ goto err_out_w_lock; -+ -+ ixgbe_update_ethtool_fdir_entry(adapter, input, input->sw_idx); - spin_unlock(&adapter->fdir_perfect_lock); - - if ((uhtid != 0x800) && (adapter->jump_tables[uhtid])) -diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c -index e581091c09c4e..02b4620f7368a 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c -+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c -@@ -1980,8 +1980,10 @@ static void rvu_unregister_interrupts(struct rvu *rvu) - INTR_MASK(rvu->hw->total_pfs) & ~1ULL); - - for (irq = 0; irq < rvu->num_vec; irq++) { -- if (rvu->irq_allocated[irq]) -+ if (rvu->irq_allocated[irq]) { - free_irq(pci_irq_vector(rvu->pdev, irq), rvu); -+ rvu->irq_allocated[irq] = false; -+ } - } - - pci_free_irq_vectors(rvu->pdev); -diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c -index 15f70273e29c7..d82a519a0cd9a 100644 ---- a/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c -+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu_npc.c -@@ -1967,10 +1967,10 @@ int rvu_mbox_handler_npc_mcam_free_counter(struct rvu *rvu, - index = find_next_bit(mcam->bmap, mcam->bmap_entries, entry); - if (index >= mcam->bmap_entries) - break; -+ entry = index + 1; - if (mcam->entry2cntr_map[index] != req->cntr) - continue; - -- entry = index + 1; - npc_unmap_mcam_entry_and_cntr(rvu, mcam, blkaddr, - index, req->cntr); - } -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c -index 951ea26d96bc3..6d27f69cc7fc9 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_tun_geneve.c -@@ -227,6 +227,10 @@ static int mlx5e_tc_tun_parse_geneve_options(struct mlx5e_priv *priv, - option_key = (struct geneve_opt *)&enc_opts.key->data[0]; - option_mask = (struct geneve_opt *)&enc_opts.mask->data[0]; - -+ if (option_mask->opt_class == 0 && option_mask->type == 0 && -+ !memchr_inv(option_mask->opt_data, 0, option_mask->length * 4)) -+ return 0; -+ - if (option_key->length > max_tlv_option_data_len) { - NL_SET_ERR_MSG_MOD(extack, - "Matching on GENEVE options: unsupported option len"); -diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -index 01089c2283d7f..e09b4a96a1d5f 100644 ---- a/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_ethtool.c -@@ -1811,6 +1811,7 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, - { - struct mlx5e_priv *priv = netdev_priv(netdev); - struct mlx5_core_dev *mdev = priv->mdev; -+ int err; - - if (!MLX5_CAP_GEN(mdev, cqe_compression)) - return -EOPNOTSUPP; -@@ -1820,7 +1821,10 @@ static int set_pflag_rx_cqe_compress(struct net_device *netdev, - return -EINVAL; - } - -- mlx5e_modify_rx_cqe_compression_locked(priv, enable); -+ err = mlx5e_modify_rx_cqe_compression_locked(priv, enable); -+ if (err) -+ return err; -+ - priv->channels.params.rx_cqe_compress_def = enable; - - return 0; -diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c -index 5defd31d481c2..aa06fcb38f8b9 100644 ---- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c -+++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c -@@ -327,8 +327,14 @@ int nfp_compile_flow_metadata(struct nfp_app *app, - goto err_free_ctx_entry; - } - -+ /* Do net allocate a mask-id for pre_tun_rules. These flows are used to -+ * configure the pre_tun table and are never actually send to the -+ * firmware as an add-flow message. This causes the mask-id allocation -+ * on the firmware to get out of sync if allocated here. -+ */ - new_mask_id = 0; -- if (!nfp_check_mask_add(app, nfp_flow->mask_data, -+ if (!nfp_flow->pre_tun_rule.dev && -+ !nfp_check_mask_add(app, nfp_flow->mask_data, - nfp_flow->meta.mask_len, - &nfp_flow->meta.flags, &new_mask_id)) { - NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot allocate a new mask id"); -@@ -359,7 +365,8 @@ int nfp_compile_flow_metadata(struct nfp_app *app, - goto err_remove_mask; - } - -- if (!nfp_check_mask_remove(app, nfp_flow->mask_data, -+ if (!nfp_flow->pre_tun_rule.dev && -+ !nfp_check_mask_remove(app, nfp_flow->mask_data, - nfp_flow->meta.mask_len, - NULL, &new_mask_id)) { - NL_SET_ERR_MSG_MOD(extack, "invalid entry: cannot release mask id"); -@@ -374,8 +381,10 @@ int nfp_compile_flow_metadata(struct nfp_app *app, - return 0; - - err_remove_mask: -- nfp_check_mask_remove(app, nfp_flow->mask_data, nfp_flow->meta.mask_len, -- NULL, &new_mask_id); -+ if (!nfp_flow->pre_tun_rule.dev) -+ nfp_check_mask_remove(app, nfp_flow->mask_data, -+ nfp_flow->meta.mask_len, -+ NULL, &new_mask_id); - err_remove_rhash: - WARN_ON_ONCE(rhashtable_remove_fast(&priv->stats_ctx_table, - &ctx_entry->ht_node, -@@ -406,9 +415,10 @@ int nfp_modify_flow_metadata(struct nfp_app *app, - - __nfp_modify_flow_metadata(priv, nfp_flow); - -- nfp_check_mask_remove(app, nfp_flow->mask_data, -- nfp_flow->meta.mask_len, &nfp_flow->meta.flags, -- &new_mask_id); -+ if (!nfp_flow->pre_tun_rule.dev) -+ nfp_check_mask_remove(app, nfp_flow->mask_data, -+ nfp_flow->meta.mask_len, &nfp_flow->meta.flags, -+ &new_mask_id); - - /* Update flow payload with mask ids. */ - nfp_flow->unmasked_data[NFP_FL_MASK_ID_LOCATION] = new_mask_id; -diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c -index f34ae8c75bc5e..61a39d167c8bc 100644 ---- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c -+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c -@@ -1426,6 +1426,7 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter) - - if (fw_dump->tmpl_hdr == NULL || current_version > prev_version) { - vfree(fw_dump->tmpl_hdr); -+ fw_dump->tmpl_hdr = NULL; - - if (qlcnic_83xx_md_check_extended_dump_capability(adapter)) - extended = !qlcnic_83xx_extend_md_capab(adapter); -@@ -1444,6 +1445,8 @@ void qlcnic_83xx_get_minidump_template(struct qlcnic_adapter *adapter) - struct qlcnic_83xx_dump_template_hdr *hdr; - - hdr = fw_dump->tmpl_hdr; -+ if (!hdr) -+ return; - hdr->drv_cap_mask = 0x1f; - fw_dump->cap_mask = 0x1f; - dev_info(&pdev->dev, -diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c -index 8bd2912bf713c..33d7c2940ba9d 100644 ---- a/drivers/net/ethernet/socionext/netsec.c -+++ b/drivers/net/ethernet/socionext/netsec.c -@@ -1693,14 +1693,17 @@ static int netsec_netdev_init(struct net_device *ndev) - goto err1; - - /* set phy power down */ -- data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR) | -- BMCR_PDOWN; -- netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data); -+ data = netsec_phy_read(priv->mii_bus, priv->phy_addr, MII_BMCR); -+ netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, -+ data | BMCR_PDOWN); - - ret = netsec_reset_hardware(priv, true); - if (ret) - goto err2; - -+ /* Restore phy power state */ -+ netsec_phy_write(priv->mii_bus, priv->phy_addr, MII_BMCR, data); -+ - spin_lock_init(&priv->desc_ring[NETSEC_RING_TX].lock); - spin_lock_init(&priv->desc_ring[NETSEC_RING_RX].lock); - -diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c -index c4c9cbdeb601e..2f6258ca95155 100644 ---- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c -+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sun8i.c -@@ -1206,6 +1206,8 @@ static int sun8i_dwmac_probe(struct platform_device *pdev) - plat_dat->init = sun8i_dwmac_init; - plat_dat->exit = sun8i_dwmac_exit; - plat_dat->setup = sun8i_dwmac_setup; -+ plat_dat->tx_fifo_size = 4096; -+ plat_dat->rx_fifo_size = 16384; - - ret = sun8i_dwmac_init(pdev, plat_dat->bsp_priv); - if (ret) -diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c -index f5fd1f3c07cc5..2911740af7061 100644 ---- a/drivers/net/ethernet/sun/niu.c -+++ b/drivers/net/ethernet/sun/niu.c -@@ -3931,8 +3931,6 @@ static void niu_xmac_interrupt(struct niu *np) - mp->rx_mcasts += RXMAC_MC_FRM_CNT_COUNT; - if (val & XRXMAC_STATUS_RXBCAST_CNT_EXP) - mp->rx_bcasts += RXMAC_BC_FRM_CNT_COUNT; -- if (val & XRXMAC_STATUS_RXBCAST_CNT_EXP) -- mp->rx_bcasts += RXMAC_BC_FRM_CNT_COUNT; - if (val & XRXMAC_STATUS_RXHIST1_CNT_EXP) - mp->rx_hist_cnt1 += RXMAC_HIST_CNT1_COUNT; - if (val & XRXMAC_STATUS_RXHIST2_CNT_EXP) -diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c -index 0f8a924fc60c3..c6c1bb15557f4 100644 ---- a/drivers/net/ethernet/tehuti/tehuti.c -+++ b/drivers/net/ethernet/tehuti/tehuti.c -@@ -2052,6 +2052,7 @@ bdx_probe(struct pci_dev *pdev, const struct pci_device_id *ent) - /*bdx_hw_reset(priv); */ - if (bdx_read_mac(priv)) { - pr_err("load MAC address failed\n"); -+ err = -EFAULT; - goto err_out_iomap; - } - SET_NETDEV_DEV(ndev, &pdev->dev); -diff --git a/drivers/net/usb/cdc-phonet.c b/drivers/net/usb/cdc-phonet.c -index bcabd39d136ae..f778172356e68 100644 ---- a/drivers/net/usb/cdc-phonet.c -+++ b/drivers/net/usb/cdc-phonet.c -@@ -387,6 +387,8 @@ static int usbpn_probe(struct usb_interface *intf, const struct usb_device_id *i - - err = register_netdev(dev); - if (err) { -+ /* Set disconnected flag so that disconnect() returns early. */ -+ pnd->disconnected = 1; - usb_driver_release_interface(&usbpn_driver, data_intf); - goto out; - } -diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c -index 22f093797f417..f6d643ecaf39b 100644 ---- a/drivers/net/usb/r8152.c -+++ b/drivers/net/usb/r8152.c -@@ -2836,29 +2836,6 @@ static void __rtl_set_wol(struct r8152 *tp, u32 wolopts) - device_set_wakeup_enable(&tp->udev->dev, false); - } - --static void r8153_mac_clk_spd(struct r8152 *tp, bool enable) --{ -- /* MAC clock speed down */ -- if (enable) { -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, -- ALDPS_SPDWN_RATIO); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, -- EEE_SPDWN_RATIO); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, -- PKT_AVAIL_SPDWN_EN | SUSPEND_SPDWN_EN | -- U1U2_SPDWN_EN | L1_SPDWN_EN); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, -- PWRSAVE_SPDWN_EN | RXDV_SPDWN_EN | TX10MIDLE_EN | -- TP100_SPDWN_EN | TP500_SPDWN_EN | EEE_SPDWN_EN | -- TP1000_SPDWN_EN); -- } else { -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, 0); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, 0); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 0); -- ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, 0); -- } --} -- - static void r8153_u1u2en(struct r8152 *tp, bool enable) - { - u8 u1u2[8]; -@@ -3158,11 +3135,9 @@ static void rtl8153_runtime_enable(struct r8152 *tp, bool enable) - if (enable) { - r8153_u1u2en(tp, false); - r8153_u2p3en(tp, false); -- r8153_mac_clk_spd(tp, true); - rtl_runtime_suspend_enable(tp, true); - } else { - rtl_runtime_suspend_enable(tp, false); -- r8153_mac_clk_spd(tp, false); - - switch (tp->version) { - case RTL_VER_03: -@@ -3727,7 +3702,6 @@ static void r8153_first_init(struct r8152 *tp) - u32 ocp_data; - int i; - -- r8153_mac_clk_spd(tp, false); - rxdy_gated_en(tp, true); - r8153_teredo_off(tp); - -@@ -3789,8 +3763,6 @@ static void r8153_enter_oob(struct r8152 *tp) - u32 ocp_data; - int i; - -- r8153_mac_clk_spd(tp, true); -- - ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL); - ocp_data &= ~NOW_IS_OOB; - ocp_write_byte(tp, MCU_TYPE_PLA, PLA_OOB_CTRL, ocp_data); -@@ -4498,9 +4470,14 @@ static void r8153_init(struct r8152 *tp) - - ocp_write_word(tp, MCU_TYPE_USB, USB_CONNECT_TIMER, 0x0001); - -+ /* MAC clock speed down */ -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL, 0); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL2, 0); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL3, 0); -+ ocp_write_word(tp, MCU_TYPE_PLA, PLA_MAC_PWR_CTRL4, 0); -+ - r8153_power_cut_en(tp, false); - r8153_u1u2en(tp, true); -- r8153_mac_clk_spd(tp, false); - usb_enable_lpm(tp->udev); - - ocp_data = ocp_read_byte(tp, MCU_TYPE_PLA, PLA_CONFIG6); -@@ -5552,7 +5529,10 @@ static int rtl_ops_init(struct r8152 *tp) - ops->in_nway = rtl8153_in_nway; - ops->hw_phy_cfg = r8153_hw_phy_cfg; - ops->autosuspend_en = rtl8153_runtime_enable; -- tp->rx_buf_sz = 32 * 1024; -+ if (tp->udev->speed < USB_SPEED_SUPER) -+ tp->rx_buf_sz = 16 * 1024; -+ else -+ tp->rx_buf_sz = 32 * 1024; - tp->eee_en = true; - tp->eee_adv = MDIO_EEE_1000T | MDIO_EEE_100TX; - break; -diff --git a/drivers/net/veth.c b/drivers/net/veth.c -index 88cfd63f08a6a..44ad412f9a06f 100644 ---- a/drivers/net/veth.c -+++ b/drivers/net/veth.c -@@ -254,8 +254,7 @@ static netdev_tx_t veth_xmit(struct sk_buff *skb, struct net_device *dev) - if (rxq < rcv->real_num_rx_queues) { - rq = &rcv_priv->rq[rxq]; - rcv_xdp = rcu_access_pointer(rq->xdp_prog); -- if (rcv_xdp) -- skb_record_rx_queue(skb, rxq); -+ skb_record_rx_queue(skb, rxq); - } - - skb_tx_timestamp(skb); -diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c -index 4ad0a0c33d853..034eb6535ab7d 100644 ---- a/drivers/net/wan/fsl_ucc_hdlc.c -+++ b/drivers/net/wan/fsl_ucc_hdlc.c -@@ -204,14 +204,18 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) - priv->rx_skbuff = kcalloc(priv->rx_ring_size, - sizeof(*priv->rx_skbuff), - GFP_KERNEL); -- if (!priv->rx_skbuff) -+ if (!priv->rx_skbuff) { -+ ret = -ENOMEM; - goto free_ucc_pram; -+ } - - priv->tx_skbuff = kcalloc(priv->tx_ring_size, - sizeof(*priv->tx_skbuff), - GFP_KERNEL); -- if (!priv->tx_skbuff) -+ if (!priv->tx_skbuff) { -+ ret = -ENOMEM; - goto free_rx_skbuff; -+ } - - priv->skb_curtx = 0; - priv->skb_dirtytx = 0; -diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c -index 308f3a28e12a2..67ea531e8b34b 100644 ---- a/drivers/nvme/host/core.c -+++ b/drivers/nvme/host/core.c -@@ -312,6 +312,7 @@ bool nvme_cancel_request(struct request *req, void *data, bool reserved) - return true; - - nvme_req(req)->status = NVME_SC_HOST_ABORTED_CMD; -+ nvme_req(req)->flags |= NVME_REQ_CANCELLED; - blk_mq_complete_request(req); - return true; - } -diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c -index 65b3dc9cd693b..0d2c22cf12a08 100644 ---- a/drivers/nvme/host/fc.c -+++ b/drivers/nvme/host/fc.c -@@ -1608,7 +1608,7 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) - sizeof(op->rsp_iu), DMA_FROM_DEVICE); - - if (opstate == FCPOP_STATE_ABORTED) -- status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1); -+ status = cpu_to_le16(NVME_SC_HOST_ABORTED_CMD << 1); - else if (freq->status) { - status = cpu_to_le16(NVME_SC_HOST_PATH_ERROR << 1); - dev_info(ctrl->ctrl.device, -diff --git a/drivers/nvme/host/pci.c b/drivers/nvme/host/pci.c -index fc18738dcf8ff..3bee3724e9fa7 100644 ---- a/drivers/nvme/host/pci.c -+++ b/drivers/nvme/host/pci.c -@@ -3176,6 +3176,7 @@ static const struct pci_device_id nvme_id_table[] = { - .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, }, - { PCI_DEVICE(0x144d, 0xa822), /* Samsung PM1725a */ - .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY | -+ NVME_QUIRK_DISABLE_WRITE_ZEROES| - NVME_QUIRK_IGNORE_DEV_SUBNQN, }, - { PCI_DEVICE(0x1987, 0x5016), /* Phison E16 */ - .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, }, -diff --git a/drivers/platform/x86/intel-vbtn.c b/drivers/platform/x86/intel-vbtn.c -index d4fc2cbf78703..6aaceef3326c7 100644 ---- a/drivers/platform/x86/intel-vbtn.c -+++ b/drivers/platform/x86/intel-vbtn.c -@@ -46,8 +46,16 @@ static const struct key_entry intel_vbtn_keymap[] = { - }; - - static const struct key_entry intel_vbtn_switchmap[] = { -- { KE_SW, 0xCA, { .sw = { SW_DOCK, 1 } } }, /* Docked */ -- { KE_SW, 0xCB, { .sw = { SW_DOCK, 0 } } }, /* Undocked */ -+ /* -+ * SW_DOCK should only be reported for docking stations, but DSDTs using the -+ * intel-vbtn code, always seem to use this for 2-in-1s / convertibles and set -+ * SW_DOCK=1 when in laptop-mode (in tandem with setting SW_TABLET_MODE=0). -+ * This causes userspace to think the laptop is docked to a port-replicator -+ * and to disable suspend-on-lid-close, which is undesirable. -+ * Map the dock events to KEY_IGNORE to avoid this broken SW_DOCK reporting. -+ */ -+ { KE_IGNORE, 0xCA, { .sw = { SW_DOCK, 1 } } }, /* Docked */ -+ { KE_IGNORE, 0xCB, { .sw = { SW_DOCK, 0 } } }, /* Undocked */ - { KE_SW, 0xCC, { .sw = { SW_TABLET_MODE, 1 } } }, /* Tablet */ - { KE_SW, 0xCD, { .sw = { SW_TABLET_MODE, 0 } } }, /* Laptop */ - }; -diff --git a/drivers/regulator/qcom-rpmh-regulator.c b/drivers/regulator/qcom-rpmh-regulator.c -index 68d22acdb037a..2de7af13288e3 100644 ---- a/drivers/regulator/qcom-rpmh-regulator.c -+++ b/drivers/regulator/qcom-rpmh-regulator.c -@@ -726,8 +726,8 @@ static const struct rpmh_vreg_hw_data pmic5_ftsmps510 = { - static const struct rpmh_vreg_hw_data pmic5_hfsmps515 = { - .regulator_type = VRM, - .ops = &rpmh_regulator_vrm_ops, -- .voltage_range = REGULATOR_LINEAR_RANGE(2800000, 0, 4, 16000), -- .n_voltages = 5, -+ .voltage_range = REGULATOR_LINEAR_RANGE(320000, 0, 235, 16000), -+ .n_voltages = 236, - .pmic_mode_map = pmic_mode_map_pmic5_smps, - .of_map_mode = rpmh_regulator_pmic4_smps_of_map_mode, - }; -diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c -index 7532603aafb15..b6d42b2ce6fe4 100644 ---- a/drivers/scsi/mpt3sas/mpt3sas_base.c -+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c -@@ -7102,14 +7102,18 @@ mpt3sas_base_attach(struct MPT3SAS_ADAPTER *ioc) - ioc->pend_os_device_add_sz++; - ioc->pend_os_device_add = kzalloc(ioc->pend_os_device_add_sz, - GFP_KERNEL); -- if (!ioc->pend_os_device_add) -+ if (!ioc->pend_os_device_add) { -+ r = -ENOMEM; - goto out_free_resources; -+ } - - ioc->device_remove_in_progress_sz = ioc->pend_os_device_add_sz; - ioc->device_remove_in_progress = - kzalloc(ioc->device_remove_in_progress_sz, GFP_KERNEL); -- if (!ioc->device_remove_in_progress) -+ if (!ioc->device_remove_in_progress) { -+ r = -ENOMEM; - goto out_free_resources; -+ } - - ioc->fwfault_debug = mpt3sas_fwfault_debug; - -diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c -index fdd966fea7f6a..4498add3d4d66 100644 ---- a/drivers/scsi/qedi/qedi_main.c -+++ b/drivers/scsi/qedi/qedi_main.c -@@ -1605,6 +1605,7 @@ static int qedi_alloc_global_queues(struct qedi_ctx *qedi) - if (!qedi->global_queues[i]) { - QEDI_ERR(&qedi->dbg_ctx, - "Unable to allocation global queue %d.\n", i); -+ status = -ENOMEM; - goto mem_alloc_failure; - } - -diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c -index 412009e2b9488..8fd0a568303b5 100644 ---- a/drivers/scsi/qla2xxx/qla_target.c -+++ b/drivers/scsi/qla2xxx/qla_target.c -@@ -3216,8 +3216,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, - if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || - (cmd->sess && cmd->sess->deleted)) { - cmd->state = QLA_TGT_STATE_PROCESSED; -- res = 0; -- goto free; -+ return 0; - } - - ql_dbg_qp(ql_dbg_tgt, qpair, 0xe018, -@@ -3228,8 +3227,9 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, - - res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status, - &full_req_cnt); -- if (unlikely(res != 0)) -- goto free; -+ if (unlikely(res != 0)) { -+ return res; -+ } - - spin_lock_irqsave(qpair->qp_lock_ptr, flags); - -@@ -3249,8 +3249,7 @@ int qlt_xmit_response(struct qla_tgt_cmd *cmd, int xmit_type, - vha->flags.online, qla2x00_reset_active(vha), - cmd->reset_count, qpair->chip_reset); - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); -- res = 0; -- goto free; -+ return 0; - } - - /* Does F/W have an IOCBs for this request */ -@@ -3353,8 +3352,6 @@ out_unmap_unlock: - qlt_unmap_sg(vha, cmd); - spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); - --free: -- vha->hw->tgt.tgt_ops->free_cmd(cmd); - return res; - } - EXPORT_SYMBOL(qlt_xmit_response); -diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c -index 744cd93189da3..df8644da2c323 100644 ---- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c -+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c -@@ -623,7 +623,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) - { - struct qla_tgt_cmd *cmd = container_of(se_cmd, - struct qla_tgt_cmd, se_cmd); -- struct scsi_qla_host *vha = cmd->vha; - - if (cmd->aborted) { - /* Cmd can loop during Q-full. tcm_qla2xxx_aborted_task -@@ -636,7 +635,6 @@ static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd) - cmd->se_cmd.transport_state, - cmd->se_cmd.t_state, - cmd->se_cmd.se_cmd_flags); -- vha->hw->tgt.tgt_ops->free_cmd(cmd); - return 0; - } - -@@ -664,7 +662,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) - { - struct qla_tgt_cmd *cmd = container_of(se_cmd, - struct qla_tgt_cmd, se_cmd); -- struct scsi_qla_host *vha = cmd->vha; - int xmit_type = QLA_TGT_XMIT_STATUS; - - if (cmd->aborted) { -@@ -678,7 +675,6 @@ static int tcm_qla2xxx_queue_status(struct se_cmd *se_cmd) - cmd, kref_read(&cmd->se_cmd.cmd_kref), - cmd->se_cmd.transport_state, cmd->se_cmd.t_state, - cmd->se_cmd.se_cmd_flags); -- vha->hw->tgt.tgt_ops->free_cmd(cmd); - return 0; - } - cmd->bufflen = se_cmd->data_length; -diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c -index 7adecfd0c1e99..81d9c4ea0e8f3 100644 ---- a/fs/cifs/smb2pdu.c -+++ b/fs/cifs/smb2pdu.c -@@ -3743,8 +3743,7 @@ smb2_async_readv(struct cifs_readdata *rdata) - if (rdata->credits.value > 0) { - shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(rdata->bytes, - SMB2_MAX_BUFFER_SIZE)); -- shdr->CreditRequest = -- cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1); -+ shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8); - - rc = adjust_credits(server, &rdata->credits, rdata->bytes); - if (rc) -@@ -4038,8 +4037,7 @@ smb2_async_writev(struct cifs_writedata *wdata, - if (wdata->credits.value > 0) { - shdr->CreditCharge = cpu_to_le16(DIV_ROUND_UP(wdata->bytes, - SMB2_MAX_BUFFER_SIZE)); -- shdr->CreditRequest = -- cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 1); -+ shdr->CreditRequest = cpu_to_le16(le16_to_cpu(shdr->CreditCharge) + 8); - - rc = adjust_credits(server, &wdata->credits, wdata->bytes); - if (rc) -diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c -index e99ecfafffac3..61e7df4d9cb11 100644 ---- a/fs/cifs/transport.c -+++ b/fs/cifs/transport.c -@@ -1148,7 +1148,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, - } - if (rc != 0) { - for (; i < num_rqst; i++) { -- cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n", -+ cifs_server_dbg(FYI, "Cancelling wait for mid %llu cmd: %d\n", - midQ[i]->mid, le16_to_cpu(midQ[i]->command)); - send_cancel(server, &rqst[i], midQ[i]); - spin_lock(&GlobalMid_Lock); -diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c -index 5451f10800065..20e40cac819e4 100644 ---- a/fs/ext4/xattr.c -+++ b/fs/ext4/xattr.c -@@ -1476,6 +1476,9 @@ ext4_xattr_inode_cache_find(struct inode *inode, const void *value, - if (!ce) - return NULL; - -+ WARN_ON_ONCE(ext4_handle_valid(journal_current_handle()) && -+ !(current->flags & PF_MEMALLOC_NOFS)); -+ - ea_data = ext4_kvmalloc(value_len, GFP_NOFS); - if (!ea_data) { - mb_cache_entry_put(ea_inode_cache, ce); -@@ -2342,6 +2345,7 @@ ext4_xattr_set_handle(handle_t *handle, struct inode *inode, int name_index, - error = -ENOSPC; - goto cleanup; - } -+ WARN_ON_ONCE(!(current->flags & PF_MEMALLOC_NOFS)); - } - - error = ext4_reserve_inode_write(handle, inode, &is.iloc); -diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c -index cf3af2140c3d8..a2e9354b9d534 100644 ---- a/fs/hugetlbfs/inode.c -+++ b/fs/hugetlbfs/inode.c -@@ -440,7 +440,7 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart, - u32 hash; - - index = page->index; -- hash = hugetlb_fault_mutex_hash(h, mapping, index, 0); -+ hash = hugetlb_fault_mutex_hash(h, mapping, index); - mutex_lock(&hugetlb_fault_mutex_table[hash]); - - /* -@@ -644,7 +644,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, - addr = index * hpage_size; - - /* mutex taken here, fault path and hole punch */ -- hash = hugetlb_fault_mutex_hash(h, mapping, index, addr); -+ hash = hugetlb_fault_mutex_hash(h, mapping, index); - mutex_lock(&hugetlb_fault_mutex_table[hash]); - - /* See if already present in mapping to avoid alloc/free */ -diff --git a/fs/nfs/Kconfig b/fs/nfs/Kconfig -index e7dd07f478259..e84c187d942e8 100644 ---- a/fs/nfs/Kconfig -+++ b/fs/nfs/Kconfig -@@ -127,7 +127,7 @@ config PNFS_BLOCK - config PNFS_FLEXFILE_LAYOUT - tristate - depends on NFS_V4_1 && NFS_V3 -- default m -+ default NFS_V4 - - config NFS_V4_1_IMPLEMENTATION_ID_DOMAIN - string "NFSv4.1 Implementation ID Domain" -diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c -index 1f60ab2535eed..23d75cddbb2ee 100644 ---- a/fs/nfs/nfs3xdr.c -+++ b/fs/nfs/nfs3xdr.c -@@ -35,6 +35,7 @@ - */ - #define NFS3_fhandle_sz (1+16) - #define NFS3_fh_sz (NFS3_fhandle_sz) /* shorthand */ -+#define NFS3_post_op_fh_sz (1+NFS3_fh_sz) - #define NFS3_sattr_sz (15) - #define NFS3_filename_sz (1+(NFS3_MAXNAMLEN>>2)) - #define NFS3_path_sz (1+(NFS3_MAXPATHLEN>>2)) -@@ -72,7 +73,7 @@ - #define NFS3_readlinkres_sz (1+NFS3_post_op_attr_sz+1+1) - #define NFS3_readres_sz (1+NFS3_post_op_attr_sz+3+1) - #define NFS3_writeres_sz (1+NFS3_wcc_data_sz+4) --#define NFS3_createres_sz (1+NFS3_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) -+#define NFS3_createres_sz (1+NFS3_post_op_fh_sz+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) - #define NFS3_renameres_sz (1+(2 * NFS3_wcc_data_sz)) - #define NFS3_linkres_sz (1+NFS3_post_op_attr_sz+NFS3_wcc_data_sz) - #define NFS3_readdirres_sz (1+NFS3_post_op_attr_sz+2+1) -diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c -index b2119159dead2..304ab4cdaa8c1 100644 ---- a/fs/nfs/nfs4proc.c -+++ b/fs/nfs/nfs4proc.c -@@ -5754,6 +5754,9 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl - unsigned int npages = DIV_ROUND_UP(buflen, PAGE_SIZE); - int ret, i; - -+ /* You can't remove system.nfs4_acl: */ -+ if (buflen == 0) -+ return -EINVAL; - if (!nfs4_server_supports_acls(server)) - return -EOPNOTSUPP; - if (npages > ARRAY_SIZE(pages)) -diff --git a/fs/squashfs/export.c b/fs/squashfs/export.c -index eb02072d28dd6..723763746238d 100644 ---- a/fs/squashfs/export.c -+++ b/fs/squashfs/export.c -@@ -152,14 +152,18 @@ __le64 *squashfs_read_inode_lookup_table(struct super_block *sb, - start = le64_to_cpu(table[n]); - end = le64_to_cpu(table[n + 1]); - -- if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= end -+ || (end - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } - } - - start = le64_to_cpu(table[indexes - 1]); -- if (start >= lookup_table_start || (lookup_table_start - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= lookup_table_start || -+ (lookup_table_start - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } -diff --git a/fs/squashfs/id.c b/fs/squashfs/id.c -index 11581bf31af41..ea5387679723f 100644 ---- a/fs/squashfs/id.c -+++ b/fs/squashfs/id.c -@@ -97,14 +97,16 @@ __le64 *squashfs_read_id_index_table(struct super_block *sb, - start = le64_to_cpu(table[n]); - end = le64_to_cpu(table[n + 1]); - -- if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= end || (end - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } - } - - start = le64_to_cpu(table[indexes - 1]); -- if (start >= id_table_start || (id_table_start - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= id_table_start || (id_table_start - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } -diff --git a/fs/squashfs/squashfs_fs.h b/fs/squashfs/squashfs_fs.h -index 7187bd1a30ea5..236664d691419 100644 ---- a/fs/squashfs/squashfs_fs.h -+++ b/fs/squashfs/squashfs_fs.h -@@ -17,6 +17,7 @@ - - /* size of metadata (inode and directory) blocks */ - #define SQUASHFS_METADATA_SIZE 8192 -+#define SQUASHFS_BLOCK_OFFSET 2 - - /* default size of block device I/O */ - #ifdef CONFIG_SQUASHFS_4K_DEVBLK_SIZE -diff --git a/fs/squashfs/xattr_id.c b/fs/squashfs/xattr_id.c -index ead66670b41a5..087cab8c78f4e 100644 ---- a/fs/squashfs/xattr_id.c -+++ b/fs/squashfs/xattr_id.c -@@ -109,14 +109,16 @@ __le64 *squashfs_read_xattr_id_table(struct super_block *sb, u64 table_start, - start = le64_to_cpu(table[n]); - end = le64_to_cpu(table[n + 1]); - -- if (start >= end || (end - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= end || (end - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } - } - - start = le64_to_cpu(table[indexes - 1]); -- if (start >= table_start || (table_start - start) > SQUASHFS_METADATA_SIZE) { -+ if (start >= table_start || (table_start - start) > -+ (SQUASHFS_METADATA_SIZE + SQUASHFS_BLOCK_OFFSET)) { - kfree(table); - return ERR_PTR(-EINVAL); - } -diff --git a/include/acpi/acpi_bus.h b/include/acpi/acpi_bus.h -index defed629073bf..4d67a67964fa3 100644 ---- a/include/acpi/acpi_bus.h -+++ b/include/acpi/acpi_bus.h -@@ -232,6 +232,7 @@ struct acpi_pnp_type { - - struct acpi_device_pnp { - acpi_bus_id bus_id; /* Object name */ -+ int instance_no; /* Instance number of this object */ - struct acpi_pnp_type type; /* ID type */ - acpi_bus_address bus_address; /* _ADR */ - char *unique_id; /* _UID */ -diff --git a/include/linux/bpf.h b/include/linux/bpf.h -index 007147f643908..66590ae89c97c 100644 ---- a/include/linux/bpf.h -+++ b/include/linux/bpf.h -@@ -535,7 +535,7 @@ int bpf_prog_array_copy(struct bpf_prog_array *old_array, - struct bpf_prog *include_prog, - struct bpf_prog_array **new_array); - --#define __BPF_PROG_RUN_ARRAY(array, ctx, func, check_non_null) \ -+#define __BPF_PROG_RUN_ARRAY(array, ctx, func, check_non_null, set_cg_storage) \ - ({ \ - struct bpf_prog_array_item *_item; \ - struct bpf_prog *_prog; \ -@@ -548,7 +548,8 @@ int bpf_prog_array_copy(struct bpf_prog_array *old_array, - goto _out; \ - _item = &_array->items[0]; \ - while ((_prog = READ_ONCE(_item->prog))) { \ -- bpf_cgroup_storage_set(_item->cgroup_storage); \ -+ if (set_cg_storage) \ -+ bpf_cgroup_storage_set(_item->cgroup_storage); \ - _ret &= func(_prog, ctx); \ - _item++; \ - } \ -@@ -609,10 +610,10 @@ _out: \ - }) - - #define BPF_PROG_RUN_ARRAY(array, ctx, func) \ -- __BPF_PROG_RUN_ARRAY(array, ctx, func, false) -+ __BPF_PROG_RUN_ARRAY(array, ctx, func, false, true) - - #define BPF_PROG_RUN_ARRAY_CHECK(array, ctx, func) \ -- __BPF_PROG_RUN_ARRAY(array, ctx, func, true) -+ __BPF_PROG_RUN_ARRAY(array, ctx, func, true, false) - - #ifdef CONFIG_BPF_SYSCALL - DECLARE_PER_CPU(int, bpf_prog_active); -diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h -index 0e080ba5efbcc..fc717aeb2b3de 100644 ---- a/include/linux/hugetlb.h -+++ b/include/linux/hugetlb.h -@@ -106,7 +106,7 @@ void free_huge_page(struct page *page); - void hugetlb_fix_reserve_counts(struct inode *inode); - extern struct mutex *hugetlb_fault_mutex_table; - u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping, -- pgoff_t idx, unsigned long address); -+ pgoff_t idx); - - pte_t *huge_pmd_share(struct mm_struct *mm, unsigned long addr, pud_t *pud); - -diff --git a/include/linux/if_macvlan.h b/include/linux/if_macvlan.h -index a367ead4bf4bb..e11555989090c 100644 ---- a/include/linux/if_macvlan.h -+++ b/include/linux/if_macvlan.h -@@ -42,13 +42,14 @@ static inline void macvlan_count_rx(const struct macvlan_dev *vlan, - if (likely(success)) { - struct vlan_pcpu_stats *pcpu_stats; - -- pcpu_stats = this_cpu_ptr(vlan->pcpu_stats); -+ pcpu_stats = get_cpu_ptr(vlan->pcpu_stats); - u64_stats_update_begin(&pcpu_stats->syncp); - pcpu_stats->rx_packets++; - pcpu_stats->rx_bytes += len; - if (multicast) - pcpu_stats->rx_multicast++; - u64_stats_update_end(&pcpu_stats->syncp); -+ put_cpu_ptr(vlan->pcpu_stats); - } else { - this_cpu_inc(vlan->pcpu_stats->rx_errors); - } -diff --git a/include/linux/mm.h b/include/linux/mm.h -index c63e4b38b7fe0..703e0d72a05c7 100644 ---- a/include/linux/mm.h -+++ b/include/linux/mm.h -@@ -1226,13 +1226,26 @@ static inline bool cpupid_match_pid(struct task_struct *task, int cpupid) - #endif /* CONFIG_NUMA_BALANCING */ - - #ifdef CONFIG_KASAN_SW_TAGS -+ -+/* -+ * KASAN per-page tags are stored xor'ed with 0xff. This allows to avoid -+ * setting tags for all pages to native kernel tag value 0xff, as the default -+ * value 0x00 maps to 0xff. -+ */ -+ - static inline u8 page_kasan_tag(const struct page *page) - { -- return (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; -+ u8 tag; -+ -+ tag = (page->flags >> KASAN_TAG_PGSHIFT) & KASAN_TAG_MASK; -+ tag ^= 0xff; -+ -+ return tag; - } - - static inline void page_kasan_tag_set(struct page *page, u8 tag) - { -+ tag ^= 0xff; - page->flags &= ~(KASAN_TAG_MASK << KASAN_TAG_PGSHIFT); - page->flags |= (tag & KASAN_TAG_MASK) << KASAN_TAG_PGSHIFT; - } -diff --git a/include/linux/mutex.h b/include/linux/mutex.h -index aca8f36dfac9a..479bc96c3e63a 100644 ---- a/include/linux/mutex.h -+++ b/include/linux/mutex.h -@@ -171,7 +171,7 @@ extern void mutex_lock_io(struct mutex *lock); - # define mutex_lock_interruptible_nested(lock, subclass) mutex_lock_interruptible(lock) - # define mutex_lock_killable_nested(lock, subclass) mutex_lock_killable(lock) - # define mutex_lock_nest_lock(lock, nest_lock) mutex_lock(lock) --# define mutex_lock_io_nested(lock, subclass) mutex_lock(lock) -+# define mutex_lock_io_nested(lock, subclass) mutex_lock_io(lock) - #endif - - /* -diff --git a/include/linux/netfilter/x_tables.h b/include/linux/netfilter/x_tables.h -index f5c21b7d29748..04e7f5630509c 100644 ---- a/include/linux/netfilter/x_tables.h -+++ b/include/linux/netfilter/x_tables.h -@@ -227,7 +227,7 @@ struct xt_table { - unsigned int valid_hooks; - - /* Man behind the curtain... */ -- struct xt_table_info __rcu *private; -+ struct xt_table_info *private; - - /* Set this to THIS_MODULE if you are a module, otherwise NULL */ - struct module *me; -@@ -376,7 +376,7 @@ static inline unsigned int xt_write_recseq_begin(void) - * since addend is most likely 1 - */ - __this_cpu_add(xt_recseq.sequence, addend); -- smp_wmb(); -+ smp_mb(); - - return addend; - } -@@ -448,9 +448,6 @@ xt_get_per_cpu_counter(struct xt_counters *cnt, unsigned int cpu) - - struct nf_hook_ops *xt_hook_ops_alloc(const struct xt_table *, nf_hookfn *); - --struct xt_table_info --*xt_table_get_private_protected(const struct xt_table *table); -- - #ifdef CONFIG_COMPAT - #include - -diff --git a/include/linux/u64_stats_sync.h b/include/linux/u64_stats_sync.h -index a27604f99ed04..11096b561dab6 100644 ---- a/include/linux/u64_stats_sync.h -+++ b/include/linux/u64_stats_sync.h -@@ -69,12 +69,13 @@ struct u64_stats_sync { - }; - - -+#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) -+#define u64_stats_init(syncp) seqcount_init(&(syncp)->seq) -+#else - static inline void u64_stats_init(struct u64_stats_sync *syncp) - { --#if BITS_PER_LONG == 32 && defined(CONFIG_SMP) -- seqcount_init(&syncp->seq); --#endif - } -+#endif - - static inline void u64_stats_update_begin(struct u64_stats_sync *syncp) - { -diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h -index 6c8f8e5e33c3d..13792c0ef46e3 100644 ---- a/include/net/inet_connection_sock.h -+++ b/include/net/inet_connection_sock.h -@@ -287,7 +287,7 @@ static inline int inet_csk_reqsk_queue_is_full(const struct sock *sk) - return inet_csk_reqsk_queue_len(sk) >= sk->sk_max_ack_backlog; - } - --void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req); -+bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req); - void inet_csk_reqsk_queue_drop_and_put(struct sock *sk, struct request_sock *req); - - void inet_csk_destroy_sock(struct sock *sk); -diff --git a/include/net/nexthop.h b/include/net/nexthop.h -index 3bb618e5ecf72..18a5aca264767 100644 ---- a/include/net/nexthop.h -+++ b/include/net/nexthop.h -@@ -291,6 +291,7 @@ static inline struct fib_nh *fib_info_nh(struct fib_info *fi, int nhsel) - int fib6_check_nexthop(struct nexthop *nh, struct fib6_config *cfg, - struct netlink_ext_ack *extack); - -+/* Caller should either hold rcu_read_lock(), or RTNL. */ - static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) - { - struct nh_info *nhi; -@@ -311,6 +312,29 @@ static inline struct fib6_nh *nexthop_fib6_nh(struct nexthop *nh) - return NULL; - } - -+/* Variant of nexthop_fib6_nh(). -+ * Caller should either hold rcu_read_lock_bh(), or RTNL. -+ */ -+static inline struct fib6_nh *nexthop_fib6_nh_bh(struct nexthop *nh) -+{ -+ struct nh_info *nhi; -+ -+ if (nh->is_group) { -+ struct nh_group *nh_grp; -+ -+ nh_grp = rcu_dereference_bh_rtnl(nh->nh_grp); -+ nh = nexthop_mpath_select(nh_grp, 0); -+ if (!nh) -+ return NULL; -+ } -+ -+ nhi = rcu_dereference_bh_rtnl(nh->nh_info); -+ if (nhi->family == AF_INET6) -+ return &nhi->fib6_nh; -+ -+ return NULL; -+} -+ - static inline struct net_device *fib6_info_nh_dev(struct fib6_info *f6i) - { - struct fib6_nh *fib6_nh; -diff --git a/include/net/red.h b/include/net/red.h -index e21e7fd4fe077..8fe55b8b2fb81 100644 ---- a/include/net/red.h -+++ b/include/net/red.h -@@ -168,7 +168,8 @@ static inline void red_set_vars(struct red_vars *v) - v->qcount = -1; - } - --static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, u8 Scell_log) -+static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, -+ u8 Scell_log, u8 *stab) - { - if (fls(qth_min) + Wlog > 32) - return false; -@@ -178,6 +179,13 @@ static inline bool red_check_params(u32 qth_min, u32 qth_max, u8 Wlog, u8 Scell_ - return false; - if (qth_max < qth_min) - return false; -+ if (stab) { -+ int i; -+ -+ for (i = 0; i < RED_STAB_SIZE; i++) -+ if (stab[i] >= 32) -+ return false; -+ } - return true; - } - -diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h -index e2091bb2b3a8e..4da61c950e931 100644 ---- a/include/net/rtnetlink.h -+++ b/include/net/rtnetlink.h -@@ -33,6 +33,7 @@ static inline int rtnl_msg_family(const struct nlmsghdr *nlh) - * - * @list: Used internally - * @kind: Identifier -+ * @netns_refund: Physical device, move to init_net on netns exit - * @maxtype: Highest device specific netlink attribute number - * @policy: Netlink policy for device specific attribute validation - * @validate: Optional validation function for netlink/changelink parameters -@@ -64,6 +65,7 @@ struct rtnl_link_ops { - size_t priv_size; - void (*setup)(struct net_device *dev); - -+ bool netns_refund; - unsigned int maxtype; - const struct nla_policy *policy; - int (*validate)(struct nlattr *tb[], -diff --git a/kernel/gcov/clang.c b/kernel/gcov/clang.c -index c94b820a1b62c..8743150db2acc 100644 ---- a/kernel/gcov/clang.c -+++ b/kernel/gcov/clang.c -@@ -75,7 +75,9 @@ struct gcov_fn_info { - - u32 num_counters; - u64 *counters; -+#if CONFIG_CLANG_VERSION < 110000 - const char *function_name; -+#endif - }; - - static struct gcov_info *current_info; -@@ -105,6 +107,7 @@ void llvm_gcov_init(llvm_gcov_callback writeout, llvm_gcov_callback flush) - } - EXPORT_SYMBOL(llvm_gcov_init); - -+#if CONFIG_CLANG_VERSION < 110000 - void llvm_gcda_start_file(const char *orig_filename, const char version[4], - u32 checksum) - { -@@ -113,7 +116,17 @@ void llvm_gcda_start_file(const char *orig_filename, const char version[4], - current_info->checksum = checksum; - } - EXPORT_SYMBOL(llvm_gcda_start_file); -+#else -+void llvm_gcda_start_file(const char *orig_filename, u32 version, u32 checksum) -+{ -+ current_info->filename = orig_filename; -+ current_info->version = version; -+ current_info->checksum = checksum; -+} -+EXPORT_SYMBOL(llvm_gcda_start_file); -+#endif - -+#if CONFIG_CLANG_VERSION < 110000 - void llvm_gcda_emit_function(u32 ident, const char *function_name, - u32 func_checksum, u8 use_extra_checksum, u32 cfg_checksum) - { -@@ -133,6 +146,24 @@ void llvm_gcda_emit_function(u32 ident, const char *function_name, - list_add_tail(&info->head, ¤t_info->functions); - } - EXPORT_SYMBOL(llvm_gcda_emit_function); -+#else -+void llvm_gcda_emit_function(u32 ident, u32 func_checksum, -+ u8 use_extra_checksum, u32 cfg_checksum) -+{ -+ struct gcov_fn_info *info = kzalloc(sizeof(*info), GFP_KERNEL); -+ -+ if (!info) -+ return; -+ -+ INIT_LIST_HEAD(&info->head); -+ info->ident = ident; -+ info->checksum = func_checksum; -+ info->use_extra_checksum = use_extra_checksum; -+ info->cfg_checksum = cfg_checksum; -+ list_add_tail(&info->head, ¤t_info->functions); -+} -+EXPORT_SYMBOL(llvm_gcda_emit_function); -+#endif - - void llvm_gcda_emit_arcs(u32 num_counters, u64 *counters) - { -@@ -295,6 +326,7 @@ void gcov_info_add(struct gcov_info *dst, struct gcov_info *src) - } - } - -+#if CONFIG_CLANG_VERSION < 110000 - static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn) - { - size_t cv_size; /* counter values size */ -@@ -322,6 +354,28 @@ err_name: - kfree(fn_dup); - return NULL; - } -+#else -+static struct gcov_fn_info *gcov_fn_info_dup(struct gcov_fn_info *fn) -+{ -+ size_t cv_size; /* counter values size */ -+ struct gcov_fn_info *fn_dup = kmemdup(fn, sizeof(*fn), -+ GFP_KERNEL); -+ if (!fn_dup) -+ return NULL; -+ INIT_LIST_HEAD(&fn_dup->head); -+ -+ cv_size = fn->num_counters * sizeof(fn->counters[0]); -+ fn_dup->counters = vmalloc(cv_size); -+ if (!fn_dup->counters) { -+ kfree(fn_dup); -+ return NULL; -+ } -+ -+ memcpy(fn_dup->counters, fn->counters, cv_size); -+ -+ return fn_dup; -+} -+#endif - - /** - * gcov_info_dup - duplicate profiling data set -@@ -362,6 +416,7 @@ err: - * gcov_info_free - release memory for profiling data set duplicate - * @info: profiling data set duplicate to free - */ -+#if CONFIG_CLANG_VERSION < 110000 - void gcov_info_free(struct gcov_info *info) - { - struct gcov_fn_info *fn, *tmp; -@@ -375,6 +430,20 @@ void gcov_info_free(struct gcov_info *info) - kfree(info->filename); - kfree(info); - } -+#else -+void gcov_info_free(struct gcov_info *info) -+{ -+ struct gcov_fn_info *fn, *tmp; -+ -+ list_for_each_entry_safe(fn, tmp, &info->functions, head) { -+ vfree(fn->counters); -+ list_del(&fn->head); -+ kfree(fn); -+ } -+ kfree(info->filename); -+ kfree(info); -+} -+#endif - - #define ITER_STRIDE PAGE_SIZE - -diff --git a/kernel/power/energy_model.c b/kernel/power/energy_model.c -index 0a9326f5f4218..8dac32bd90894 100644 ---- a/kernel/power/energy_model.c -+++ b/kernel/power/energy_model.c -@@ -74,7 +74,7 @@ static int __init em_debug_init(void) - - return 0; - } --core_initcall(em_debug_init); -+fs_initcall(em_debug_init); - #else /* CONFIG_DEBUG_FS */ - static void em_debug_create_pd(struct em_perf_domain *pd, int cpu) {} - #endif -diff --git a/mm/hugetlb.c b/mm/hugetlb.c -index 4033b6ce01c40..5253c67acb1df 100644 ---- a/mm/hugetlb.c -+++ b/mm/hugetlb.c -@@ -4020,7 +4020,7 @@ retry: - * handling userfault. Reacquire after handling - * fault to make calling code simpler. - */ -- hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr); -+ hash = hugetlb_fault_mutex_hash(h, mapping, idx); - mutex_unlock(&hugetlb_fault_mutex_table[hash]); - ret = handle_userfault(&vmf, VM_UFFD_MISSING); - mutex_lock(&hugetlb_fault_mutex_table[hash]); -@@ -4148,7 +4148,7 @@ backout_unlocked: - - #ifdef CONFIG_SMP - u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping, -- pgoff_t idx, unsigned long address) -+ pgoff_t idx) - { - unsigned long key[2]; - u32 hash; -@@ -4156,7 +4156,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping, - key[0] = (unsigned long) mapping; - key[1] = idx; - -- hash = jhash2((u32 *)&key, sizeof(key)/sizeof(u32), 0); -+ hash = jhash2((u32 *)&key, sizeof(key)/(sizeof(u32)), 0); - - return hash & (num_fault_mutexes - 1); - } -@@ -4166,7 +4166,7 @@ u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping, - * return 0 and avoid the hashing overhead. - */ - u32 hugetlb_fault_mutex_hash(struct hstate *h, struct address_space *mapping, -- pgoff_t idx, unsigned long address) -+ pgoff_t idx) - { - return 0; - } -@@ -4210,7 +4210,7 @@ vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma, - * get spurious allocation failures if two CPUs race to instantiate - * the same page in the page cache. - */ -- hash = hugetlb_fault_mutex_hash(h, mapping, idx, haddr); -+ hash = hugetlb_fault_mutex_hash(h, mapping, idx); - mutex_lock(&hugetlb_fault_mutex_table[hash]); - - entry = huge_ptep_get(ptep); -diff --git a/mm/userfaultfd.c b/mm/userfaultfd.c -index c7ae74ce5ff3e..640ff2bd9a693 100644 ---- a/mm/userfaultfd.c -+++ b/mm/userfaultfd.c -@@ -269,7 +269,7 @@ retry: - */ - idx = linear_page_index(dst_vma, dst_addr); - mapping = dst_vma->vm_file->f_mapping; -- hash = hugetlb_fault_mutex_hash(h, mapping, idx, dst_addr); -+ hash = hugetlb_fault_mutex_hash(h, mapping, idx); - mutex_lock(&hugetlb_fault_mutex_table[hash]); - - err = -ENOMEM; -diff --git a/net/core/dev.c b/net/core/dev.c -index e732faade5dca..2ec21380f86d9 100644 ---- a/net/core/dev.c -+++ b/net/core/dev.c -@@ -10121,7 +10121,7 @@ static void __net_exit default_device_exit(struct net *net) - continue; - - /* Leave virtual devices for the generic cleanup */ -- if (dev->rtnl_link_ops) -+ if (dev->rtnl_link_ops && !dev->rtnl_link_ops->netns_refund) - continue; - - /* Push remaining network devices to init_net */ -diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c -index ac5c4f6cdefee..85a88425edc48 100644 ---- a/net/ipv4/inet_connection_sock.c -+++ b/net/ipv4/inet_connection_sock.c -@@ -700,12 +700,15 @@ static bool reqsk_queue_unlink(struct request_sock *req) - return found; - } - --void inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) -+bool inet_csk_reqsk_queue_drop(struct sock *sk, struct request_sock *req) - { -- if (reqsk_queue_unlink(req)) { -+ bool unlinked = reqsk_queue_unlink(req); -+ -+ if (unlinked) { - reqsk_queue_removed(&inet_csk(sk)->icsk_accept_queue, req); - reqsk_put(req); - } -+ return unlinked; - } - EXPORT_SYMBOL(inet_csk_reqsk_queue_drop); - -diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c -index 12d242fedffdc..f1f78a742b36a 100644 ---- a/net/ipv4/netfilter/arp_tables.c -+++ b/net/ipv4/netfilter/arp_tables.c -@@ -203,7 +203,7 @@ unsigned int arpt_do_table(struct sk_buff *skb, - - local_bh_disable(); - addend = xt_write_recseq_begin(); -- private = rcu_access_pointer(table->private); -+ private = READ_ONCE(table->private); /* Address dependency. */ - cpu = smp_processor_id(); - table_base = private->entries; - jumpstack = (struct arpt_entry **)private->jumpstack[cpu]; -@@ -649,7 +649,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) - { - unsigned int countersize; - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - - /* We need atomic snapshot of counters: rest doesn't change - * (other than comefrom, which userspace doesn't care -@@ -673,7 +673,7 @@ static int copy_entries_to_user(unsigned int total_size, - unsigned int off, num; - const struct arpt_entry *e; - struct xt_counters *counters; -- struct xt_table_info *private = xt_table_get_private_protected(table); -+ struct xt_table_info *private = table->private; - int ret = 0; - void *loc_cpu_entry; - -@@ -808,7 +808,7 @@ static int get_info(struct net *net, void __user *user, - t = xt_request_find_table_lock(net, NFPROTO_ARP, name); - if (!IS_ERR(t)) { - struct arpt_getinfo info; -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - #ifdef CONFIG_COMPAT - struct xt_table_info tmp; - -@@ -861,7 +861,7 @@ static int get_entries(struct net *net, struct arpt_get_entries __user *uptr, - - t = xt_find_table_lock(net, NFPROTO_ARP, get.name); - if (!IS_ERR(t)) { -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - - if (get.size == private->size) - ret = copy_entries_to_user(private->size, -@@ -1020,7 +1020,7 @@ static int do_add_counters(struct net *net, const void __user *user, - } - - local_bh_disable(); -- private = xt_table_get_private_protected(t); -+ private = t->private; - if (private->number != tmp.num_counters) { - ret = -EINVAL; - goto unlock_up_free; -@@ -1357,7 +1357,7 @@ static int compat_copy_entries_to_user(unsigned int total_size, - void __user *userptr) - { - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - void __user *pos; - unsigned int size; - int ret = 0; -@@ -1406,7 +1406,7 @@ static int compat_get_entries(struct net *net, - xt_compat_lock(NFPROTO_ARP); - t = xt_find_table_lock(net, NFPROTO_ARP, get.name); - if (!IS_ERR(t)) { -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - struct xt_table_info info; - - ret = compat_table_info(private, &info); -diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c -index cbbc8a7b82788..10b91ebdf2131 100644 ---- a/net/ipv4/netfilter/ip_tables.c -+++ b/net/ipv4/netfilter/ip_tables.c -@@ -258,7 +258,7 @@ ipt_do_table(struct sk_buff *skb, - WARN_ON(!(table->valid_hooks & (1 << hook))); - local_bh_disable(); - addend = xt_write_recseq_begin(); -- private = rcu_access_pointer(table->private); -+ private = READ_ONCE(table->private); /* Address dependency. */ - cpu = smp_processor_id(); - table_base = private->entries; - jumpstack = (struct ipt_entry **)private->jumpstack[cpu]; -@@ -791,7 +791,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) - { - unsigned int countersize; - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - - /* We need atomic snapshot of counters: rest doesn't change - (other than comefrom, which userspace doesn't care -@@ -815,7 +815,7 @@ copy_entries_to_user(unsigned int total_size, - unsigned int off, num; - const struct ipt_entry *e; - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - int ret = 0; - const void *loc_cpu_entry; - -@@ -965,7 +965,7 @@ static int get_info(struct net *net, void __user *user, - t = xt_request_find_table_lock(net, AF_INET, name); - if (!IS_ERR(t)) { - struct ipt_getinfo info; -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - #ifdef CONFIG_COMPAT - struct xt_table_info tmp; - -@@ -1019,7 +1019,7 @@ get_entries(struct net *net, struct ipt_get_entries __user *uptr, - - t = xt_find_table_lock(net, AF_INET, get.name); - if (!IS_ERR(t)) { -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - if (get.size == private->size) - ret = copy_entries_to_user(private->size, - t, uptr->entrytable); -@@ -1175,7 +1175,7 @@ do_add_counters(struct net *net, const void __user *user, - } - - local_bh_disable(); -- private = xt_table_get_private_protected(t); -+ private = t->private; - if (private->number != tmp.num_counters) { - ret = -EINVAL; - goto unlock_up_free; -@@ -1570,7 +1570,7 @@ compat_copy_entries_to_user(unsigned int total_size, struct xt_table *table, - void __user *userptr) - { - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - void __user *pos; - unsigned int size; - int ret = 0; -@@ -1616,7 +1616,7 @@ compat_get_entries(struct net *net, struct compat_ipt_get_entries __user *uptr, - xt_compat_lock(AF_INET); - t = xt_find_table_lock(net, AF_INET, get.name); - if (!IS_ERR(t)) { -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - struct xt_table_info info; - ret = compat_table_info(private, &info); - if (!ret && get.size == info.size) -diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c -index c802bc80c4006..194743bd3fc10 100644 ---- a/net/ipv4/tcp_minisocks.c -+++ b/net/ipv4/tcp_minisocks.c -@@ -796,8 +796,11 @@ embryonic_reset: - tcp_reset(sk); - } - if (!fastopen) { -- inet_csk_reqsk_queue_drop(sk, req); -- __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); -+ bool unlinked = inet_csk_reqsk_queue_drop(sk, req); -+ -+ if (unlinked) -+ __NET_INC_STATS(sock_net(sk), LINUX_MIB_EMBRYONICRSTS); -+ *req_stolen = !unlinked; - } - return NULL; - } -diff --git a/net/ipv6/ip6_fib.c b/net/ipv6/ip6_fib.c -index 906ac5e6d96cd..bb68290ad68d8 100644 ---- a/net/ipv6/ip6_fib.c -+++ b/net/ipv6/ip6_fib.c -@@ -2382,7 +2382,7 @@ static int ipv6_route_seq_show(struct seq_file *seq, void *v) - const struct net_device *dev; - - if (rt->nh) -- fib6_nh = nexthop_fib6_nh(rt->nh); -+ fib6_nh = nexthop_fib6_nh_bh(rt->nh); - - seq_printf(seq, "%pi6 %02x ", &rt->fib6_dst.addr, rt->fib6_dst.plen); - -diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c -index 01cdde25eb16d..c973ace208c51 100644 ---- a/net/ipv6/netfilter/ip6_tables.c -+++ b/net/ipv6/netfilter/ip6_tables.c -@@ -280,7 +280,7 @@ ip6t_do_table(struct sk_buff *skb, - - local_bh_disable(); - addend = xt_write_recseq_begin(); -- private = rcu_access_pointer(table->private); -+ private = READ_ONCE(table->private); /* Address dependency. */ - cpu = smp_processor_id(); - table_base = private->entries; - jumpstack = (struct ip6t_entry **)private->jumpstack[cpu]; -@@ -807,7 +807,7 @@ static struct xt_counters *alloc_counters(const struct xt_table *table) - { - unsigned int countersize; - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - - /* We need atomic snapshot of counters: rest doesn't change - (other than comefrom, which userspace doesn't care -@@ -831,7 +831,7 @@ copy_entries_to_user(unsigned int total_size, - unsigned int off, num; - const struct ip6t_entry *e; - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - int ret = 0; - const void *loc_cpu_entry; - -@@ -981,7 +981,7 @@ static int get_info(struct net *net, void __user *user, - t = xt_request_find_table_lock(net, AF_INET6, name); - if (!IS_ERR(t)) { - struct ip6t_getinfo info; -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - #ifdef CONFIG_COMPAT - struct xt_table_info tmp; - -@@ -1036,7 +1036,7 @@ get_entries(struct net *net, struct ip6t_get_entries __user *uptr, - - t = xt_find_table_lock(net, AF_INET6, get.name); - if (!IS_ERR(t)) { -- struct xt_table_info *private = xt_table_get_private_protected(t); -+ struct xt_table_info *private = t->private; - if (get.size == private->size) - ret = copy_entries_to_user(private->size, - t, uptr->entrytable); -@@ -1191,7 +1191,7 @@ do_add_counters(struct net *net, const void __user *user, unsigned int len, - } - - local_bh_disable(); -- private = xt_table_get_private_protected(t); -+ private = t->private; - if (private->number != tmp.num_counters) { - ret = -EINVAL; - goto unlock_up_free; -@@ -1579,7 +1579,7 @@ compat_copy_entries_to_user(unsigned int total_size, struct xt_table *table, - void __user *userptr) - { - struct xt_counters *counters; -- const struct xt_table_info *private = xt_table_get_private_protected(table); -+ const struct xt_table_info *private = table->private; - void __user *pos; - unsigned int size; - int ret = 0; -@@ -1625,7 +1625,7 @@ compat_get_entries(struct net *net, struct compat_ip6t_get_entries __user *uptr, - xt_compat_lock(AF_INET6); - t = xt_find_table_lock(net, AF_INET6, get.name); - if (!IS_ERR(t)) { -- const struct xt_table_info *private = xt_table_get_private_protected(t); -+ const struct xt_table_info *private = t->private; - struct xt_table_info info; - ret = compat_table_info(private, &info); - if (!ret && get.size == info.size) -diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c -index fa293feef935d..677928bf13d13 100644 ---- a/net/mac80211/cfg.c -+++ b/net/mac80211/cfg.c -@@ -2906,14 +2906,14 @@ static int ieee80211_set_bitrate_mask(struct wiphy *wiphy, - continue; - - for (j = 0; j < IEEE80211_HT_MCS_MASK_LEN; j++) { -- if (~sdata->rc_rateidx_mcs_mask[i][j]) { -+ if (sdata->rc_rateidx_mcs_mask[i][j] != 0xff) { - sdata->rc_has_mcs_mask[i] = true; - break; - } - } - - for (j = 0; j < NL80211_VHT_NSS_MAX; j++) { -- if (~sdata->rc_rateidx_vht_mcs_mask[i][j]) { -+ if (sdata->rc_rateidx_vht_mcs_mask[i][j] != 0xffff) { - sdata->rc_has_vht_mcs_mask[i] = true; - break; - } -diff --git a/net/mac80211/ibss.c b/net/mac80211/ibss.c -index 0a6ff01c68a96..0e26c83b6b412 100644 ---- a/net/mac80211/ibss.c -+++ b/net/mac80211/ibss.c -@@ -1868,6 +1868,8 @@ int ieee80211_ibss_leave(struct ieee80211_sub_if_data *sdata) - - /* remove beacon */ - kfree(sdata->u.ibss.ie); -+ sdata->u.ibss.ie = NULL; -+ sdata->u.ibss.ie_len = 0; - - /* on the next join, re-program HT parameters */ - memset(&ifibss->ht_capa, 0, sizeof(ifibss->ht_capa)); -diff --git a/net/netfilter/nf_conntrack_netlink.c b/net/netfilter/nf_conntrack_netlink.c -index b7f0d52e5f1b6..783af451a8325 100644 ---- a/net/netfilter/nf_conntrack_netlink.c -+++ b/net/netfilter/nf_conntrack_netlink.c -@@ -2680,6 +2680,7 @@ static int ctnetlink_exp_dump_mask(struct sk_buff *skb, - memset(&m, 0xFF, sizeof(m)); - memcpy(&m.src.u3, &mask->src.u3, sizeof(m.src.u3)); - m.src.u.all = mask->src.u.all; -+ m.src.l3num = tuple->src.l3num; - m.dst.protonum = tuple->dst.protonum; - - nest_parms = nla_nest_start(skb, CTA_EXPECT_MASK); -diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c -index 8b60fc04c67c2..5c35d64d1f342 100644 ---- a/net/netfilter/x_tables.c -+++ b/net/netfilter/x_tables.c -@@ -1351,14 +1351,6 @@ struct xt_counters *xt_counters_alloc(unsigned int counters) - } - EXPORT_SYMBOL(xt_counters_alloc); - --struct xt_table_info --*xt_table_get_private_protected(const struct xt_table *table) --{ -- return rcu_dereference_protected(table->private, -- mutex_is_locked(&xt[table->af].mutex)); --} --EXPORT_SYMBOL(xt_table_get_private_protected); -- - struct xt_table_info * - xt_replace_table(struct xt_table *table, - unsigned int num_counters, -@@ -1366,6 +1358,7 @@ xt_replace_table(struct xt_table *table, - int *error) - { - struct xt_table_info *private; -+ unsigned int cpu; - int ret; - - ret = xt_jumpstack_alloc(newinfo); -@@ -1375,20 +1368,47 @@ xt_replace_table(struct xt_table *table, - } - - /* Do the substitution. */ -- private = xt_table_get_private_protected(table); -+ local_bh_disable(); -+ private = table->private; - - /* Check inside lock: is the old number correct? */ - if (num_counters != private->number) { - pr_debug("num_counters != table->private->number (%u/%u)\n", - num_counters, private->number); -+ local_bh_enable(); - *error = -EAGAIN; - return NULL; - } - - newinfo->initial_entries = private->initial_entries; -+ /* -+ * Ensure contents of newinfo are visible before assigning to -+ * private. -+ */ -+ smp_wmb(); -+ table->private = newinfo; -+ -+ /* make sure all cpus see new ->private value */ -+ smp_mb(); - -- rcu_assign_pointer(table->private, newinfo); -- synchronize_rcu(); -+ /* -+ * Even though table entries have now been swapped, other CPU's -+ * may still be using the old entries... -+ */ -+ local_bh_enable(); -+ -+ /* ... so wait for even xt_recseq on all cpus */ -+ for_each_possible_cpu(cpu) { -+ seqcount_t *s = &per_cpu(xt_recseq, cpu); -+ u32 seq = raw_read_seqcount(s); -+ -+ if (seq & 1) { -+ do { -+ cond_resched(); -+ cpu_relax(); -+ } while (seq == raw_read_seqcount(s)); -+ } -+ } - - #ifdef CONFIG_AUDIT - if (audit_enabled) { -@@ -1429,12 +1449,12 @@ struct xt_table *xt_register_table(struct net *net, - } - - /* Simplifies replace_table code. */ -- rcu_assign_pointer(table->private, bootstrap); -+ table->private = bootstrap; - - if (!xt_replace_table(table, 0, newinfo, &ret)) - goto unlock; - -- private = xt_table_get_private_protected(table); -+ private = table->private; - pr_debug("table->private->number = %u\n", private->number); - - /* save number of initial entries */ -@@ -1457,8 +1477,7 @@ void *xt_unregister_table(struct xt_table *table) - struct xt_table_info *private; - - mutex_lock(&xt[table->af].mutex); -- private = xt_table_get_private_protected(table); -- RCU_INIT_POINTER(table->private, NULL); -+ private = table->private; - list_del(&table->list); - mutex_unlock(&xt[table->af].mutex); - kfree(table); -diff --git a/net/qrtr/qrtr.c b/net/qrtr/qrtr.c -index 0d4f12dbd2443..46273a8383615 100644 ---- a/net/qrtr/qrtr.c -+++ b/net/qrtr/qrtr.c -@@ -862,6 +862,11 @@ static int qrtr_recvmsg(struct socket *sock, struct msghdr *msg, - rc = copied; - - if (addr) { -+ /* There is an anonymous 2-byte hole after sq_family, -+ * make sure to clear it. -+ */ -+ memset(addr, 0, sizeof(*addr)); -+ - cb = (struct qrtr_cb *)skb->cb; - addr->sq_family = AF_QIPCRTR; - addr->sq_node = cb->src_node; -diff --git a/net/sched/sch_choke.c b/net/sched/sch_choke.c -index d856b395ee8eb..e54f6eabfa0c0 100644 ---- a/net/sched/sch_choke.c -+++ b/net/sched/sch_choke.c -@@ -351,6 +351,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt, - struct sk_buff **old = NULL; - unsigned int mask; - u32 max_P; -+ u8 *stab; - - if (opt == NULL) - return -EINVAL; -@@ -367,8 +368,8 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt, - max_P = tb[TCA_CHOKE_MAX_P] ? nla_get_u32(tb[TCA_CHOKE_MAX_P]) : 0; - - ctl = nla_data(tb[TCA_CHOKE_PARMS]); -- -- if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Scell_log)) -+ stab = nla_data(tb[TCA_CHOKE_STAB]); -+ if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Scell_log, stab)) - return -EINVAL; - - if (ctl->limit > CHOKE_MAX_QUEUE) -@@ -418,7 +419,7 @@ static int choke_change(struct Qdisc *sch, struct nlattr *opt, - - red_set_parms(&q->parms, ctl->qth_min, ctl->qth_max, ctl->Wlog, - ctl->Plog, ctl->Scell_log, -- nla_data(tb[TCA_CHOKE_STAB]), -+ stab, - max_P); - red_set_vars(&q->vars); - -diff --git a/net/sched/sch_gred.c b/net/sched/sch_gred.c -index e0bc77533acc3..f4132dc25ac05 100644 ---- a/net/sched/sch_gred.c -+++ b/net/sched/sch_gred.c -@@ -480,7 +480,7 @@ static inline int gred_change_vq(struct Qdisc *sch, int dp, - struct gred_sched *table = qdisc_priv(sch); - struct gred_sched_data *q = table->tab[dp]; - -- if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Scell_log)) { -+ if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Scell_log, stab)) { - NL_SET_ERR_MSG_MOD(extack, "invalid RED parameters"); - return -EINVAL; - } -diff --git a/net/sched/sch_red.c b/net/sched/sch_red.c -index 71e167e91a48d..7741f102be4a0 100644 ---- a/net/sched/sch_red.c -+++ b/net/sched/sch_red.c -@@ -197,6 +197,7 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt, - struct tc_red_qopt *ctl; - int err; - u32 max_P; -+ u8 *stab; - - if (opt == NULL) - return -EINVAL; -@@ -213,7 +214,9 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt, - max_P = tb[TCA_RED_MAX_P] ? nla_get_u32(tb[TCA_RED_MAX_P]) : 0; - - ctl = nla_data(tb[TCA_RED_PARMS]); -- if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, ctl->Scell_log)) -+ stab = nla_data(tb[TCA_RED_STAB]); -+ if (!red_check_params(ctl->qth_min, ctl->qth_max, ctl->Wlog, -+ ctl->Scell_log, stab)) - return -EINVAL; - - if (ctl->limit > 0) { -@@ -238,7 +241,7 @@ static int red_change(struct Qdisc *sch, struct nlattr *opt, - red_set_parms(&q->parms, - ctl->qth_min, ctl->qth_max, ctl->Wlog, - ctl->Plog, ctl->Scell_log, -- nla_data(tb[TCA_RED_STAB]), -+ stab, - max_P); - red_set_vars(&q->vars); - -diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c -index 6e13e137883c3..b92bafaf83f36 100644 ---- a/net/sched/sch_sfq.c -+++ b/net/sched/sch_sfq.c -@@ -647,7 +647,7 @@ static int sfq_change(struct Qdisc *sch, struct nlattr *opt) - } - - if (ctl_v1 && !red_check_params(ctl_v1->qth_min, ctl_v1->qth_max, -- ctl_v1->Wlog, ctl_v1->Scell_log)) -+ ctl_v1->Wlog, ctl_v1->Scell_log, NULL)) - return -EINVAL; - if (ctl_v1 && ctl_v1->qth_min) { - p = kmalloc(sizeof(*p), GFP_KERNEL); -diff --git a/security/integrity/iint.c b/security/integrity/iint.c -index e12c4900510f6..0b9cb639a0ed0 100644 ---- a/security/integrity/iint.c -+++ b/security/integrity/iint.c -@@ -98,6 +98,14 @@ struct integrity_iint_cache *integrity_inode_get(struct inode *inode) - struct rb_node *node, *parent = NULL; - struct integrity_iint_cache *iint, *test_iint; - -+ /* -+ * The integrity's "iint_cache" is initialized at security_init(), -+ * unless it is not included in the ordered list of LSMs enabled -+ * on the boot command line. -+ */ -+ if (!iint_cache) -+ panic("%s: lsm=integrity required.\n", __func__); -+ - iint = integrity_iint_find(inode); - if (iint) - return iint; -diff --git a/sound/hda/intel-nhlt.c b/sound/hda/intel-nhlt.c -index baeda6c9716a1..6ed80a4cba01a 100644 ---- a/sound/hda/intel-nhlt.c -+++ b/sound/hda/intel-nhlt.c -@@ -72,6 +72,11 @@ int intel_nhlt_get_dmic_geo(struct device *dev, struct nhlt_acpi_table *nhlt) - if (!nhlt) - return 0; - -+ if (nhlt->header.length <= sizeof(struct acpi_table_header)) { -+ dev_warn(dev, "Invalid DMIC description table\n"); -+ return 0; -+ } -+ - for (j = 0, epnt = nhlt->desc; j < nhlt->endpoint_count; j++, - epnt = (struct nhlt_endpoint *)((u8 *)epnt + epnt->length)) { - -diff --git a/tools/lib/bpf/Makefile b/tools/lib/bpf/Makefile -index 283caeaaffc30..9758bfa592321 100644 ---- a/tools/lib/bpf/Makefile -+++ b/tools/lib/bpf/Makefile -@@ -241,7 +241,7 @@ define do_install - if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ - $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ - fi; \ -- $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' -+ $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2' - endef - - install_lib: all_cmd -diff --git a/tools/lib/bpf/btf_dump.c b/tools/lib/bpf/btf_dump.c -index d9e386b8f47ed..b2fc452504501 100644 ---- a/tools/lib/bpf/btf_dump.c -+++ b/tools/lib/bpf/btf_dump.c -@@ -443,7 +443,7 @@ static int btf_dump_order_type(struct btf_dump *d, __u32 id, bool through_ptr) - return err; - - case BTF_KIND_ARRAY: -- return btf_dump_order_type(d, btf_array(t)->type, through_ptr); -+ return btf_dump_order_type(d, btf_array(t)->type, false); - - case BTF_KIND_STRUCT: - case BTF_KIND_UNION: { -diff --git a/tools/lib/bpf/netlink.c b/tools/lib/bpf/netlink.c -index 88416be2bf994..5ec8043c71bca 100644 ---- a/tools/lib/bpf/netlink.c -+++ b/tools/lib/bpf/netlink.c -@@ -37,7 +37,7 @@ int libbpf_netlink_open(__u32 *nl_pid) - memset(&sa, 0, sizeof(sa)); - sa.nl_family = AF_NETLINK; - -- sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); -+ sock = socket(AF_NETLINK, SOCK_RAW | SOCK_CLOEXEC, NETLINK_ROUTE); - if (sock < 0) - return -errno; - -diff --git a/tools/perf/util/auxtrace.c b/tools/perf/util/auxtrace.c -index 8470dfe9fe97b..61b8dc45428ff 100644 ---- a/tools/perf/util/auxtrace.c -+++ b/tools/perf/util/auxtrace.c -@@ -252,10 +252,6 @@ static int auxtrace_queues__queue_buffer(struct auxtrace_queues *queues, - queue->set = true; - queue->tid = buffer->tid; - queue->cpu = buffer->cpu; -- } else if (buffer->cpu != queue->cpu || buffer->tid != queue->tid) { -- pr_err("auxtrace queue conflict: cpu %d, tid %d vs cpu %d, tid %d\n", -- queue->cpu, queue->tid, buffer->cpu, buffer->tid); -- return -EINVAL; - } - - buffer->buffer_nr = queues->next_buffer_nr++; -diff --git a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -index b4e9a1d8c6cdb..141670ab4e670 100644 ---- a/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -+++ b/tools/testing/selftests/bpf/progs/test_tunnel_kern.c -@@ -508,10 +508,8 @@ int _ip6geneve_get_tunnel(struct __sk_buff *skb) - } - - ret = bpf_skb_get_tunnel_opt(skb, &gopt, sizeof(gopt)); -- if (ret < 0) { -- ERROR(ret); -- return TC_ACT_SHOT; -- } -+ if (ret < 0) -+ gopt.opt_class = 0; - - bpf_trace_printk(fmt, sizeof(fmt), - key.tunnel_id, key.remote_ipv4, gopt.opt_class); -diff --git a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh -index ce6bea9675c07..0ccb1dda099ae 100755 ---- a/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh -+++ b/tools/testing/selftests/net/forwarding/vxlan_bridge_1d.sh -@@ -658,7 +658,7 @@ test_ecn_decap() - # In accordance with INET_ECN_decapsulate() - __test_ecn_decap 00 00 0x00 - __test_ecn_decap 01 01 0x01 -- __test_ecn_decap 02 01 0x02 -+ __test_ecn_decap 02 01 0x01 - __test_ecn_decap 01 03 0x03 - __test_ecn_decap 02 03 0x03 - test_ecn_decap_error diff --git a/patch/kernel/archive/odroidxu4-5.4/patch-5.4.109-110.patch b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.109-110.patch new file mode 100644 index 0000000000..6f6dac89bb --- /dev/null +++ b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.109-110.patch @@ -0,0 +1,6003 @@ +diff --git a/Makefile b/Makefile +index e037662c369ba..b028b5ead5f7e 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 4 +-SUBLEVEL = 109 ++SUBLEVEL = 110 + EXTRAVERSION = + NAME = Kleptomaniac Octopus + +diff --git a/arch/powerpc/include/asm/cpu_has_feature.h b/arch/powerpc/include/asm/cpu_has_feature.h +index 7897d16e09904..727d4b3219379 100644 +--- a/arch/powerpc/include/asm/cpu_has_feature.h ++++ b/arch/powerpc/include/asm/cpu_has_feature.h +@@ -7,7 +7,7 @@ + #include + #include + +-static inline bool early_cpu_has_feature(unsigned long feature) ++static __always_inline bool early_cpu_has_feature(unsigned long feature) + { + return !!((CPU_FTRS_ALWAYS & feature) || + (CPU_FTRS_POSSIBLE & cur_cpu_spec->cpu_features & feature)); +@@ -46,7 +46,7 @@ static __always_inline bool cpu_has_feature(unsigned long feature) + return static_branch_likely(&cpu_feature_keys[i]); + } + #else +-static inline bool cpu_has_feature(unsigned long feature) ++static __always_inline bool cpu_has_feature(unsigned long feature) + { + return early_cpu_has_feature(feature); + } +diff --git a/arch/xtensa/kernel/coprocessor.S b/arch/xtensa/kernel/coprocessor.S +index 80828b95a51f0..d956f87fcb095 100644 +--- a/arch/xtensa/kernel/coprocessor.S ++++ b/arch/xtensa/kernel/coprocessor.S +@@ -108,37 +108,6 @@ + + .previous + +-/* +- * coprocessor_flush(struct thread_info*, index) +- * a2 a3 +- * +- * Save coprocessor registers for coprocessor 'index'. +- * The register values are saved to or loaded from the coprocessor area +- * inside the task_info structure. +- * +- * Note that this function doesn't update the coprocessor_owner information! +- * +- */ +- +-ENTRY(coprocessor_flush) +- +- /* reserve 4 bytes on stack to save a0 */ +- abi_entry(4) +- +- s32i a0, a1, 0 +- movi a0, .Lsave_cp_regs_jump_table +- addx8 a3, a3, a0 +- l32i a4, a3, 4 +- l32i a3, a3, 0 +- add a2, a2, a4 +- beqz a3, 1f +- callx0 a3 +-1: l32i a0, a1, 0 +- +- abi_ret(4) +- +-ENDPROC(coprocessor_flush) +- + /* + * Entry condition: + * +@@ -261,6 +230,39 @@ ENTRY(fast_coprocessor) + + ENDPROC(fast_coprocessor) + ++ .text ++ ++/* ++ * coprocessor_flush(struct thread_info*, index) ++ * a2 a3 ++ * ++ * Save coprocessor registers for coprocessor 'index'. ++ * The register values are saved to or loaded from the coprocessor area ++ * inside the task_info structure. ++ * ++ * Note that this function doesn't update the coprocessor_owner information! ++ * ++ */ ++ ++ENTRY(coprocessor_flush) ++ ++ /* reserve 4 bytes on stack to save a0 */ ++ abi_entry(4) ++ ++ s32i a0, a1, 0 ++ movi a0, .Lsave_cp_regs_jump_table ++ addx8 a3, a3, a0 ++ l32i a4, a3, 4 ++ l32i a3, a3, 0 ++ add a2, a2, a4 ++ beqz a3, 1f ++ callx0 a3 ++1: l32i a0, a1, 0 ++ ++ abi_ret(4) ++ ++ENDPROC(coprocessor_flush) ++ + .data + + ENTRY(coprocessor_owner) +diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c +index e0c4ef06ca917..94785083c018a 100644 +--- a/drivers/base/power/runtime.c ++++ b/drivers/base/power/runtime.c +@@ -1663,8 +1663,8 @@ void pm_runtime_get_suppliers(struct device *dev) + device_links_read_lock_held()) + if (link->flags & DL_FLAG_PM_RUNTIME) { + link->supplier_preactivated = true; +- refcount_inc(&link->rpm_active); + pm_runtime_get_sync(link->supplier); ++ refcount_inc(&link->rpm_active); + } + + device_links_read_unlock(idx); +@@ -1677,6 +1677,8 @@ void pm_runtime_get_suppliers(struct device *dev) + void pm_runtime_put_suppliers(struct device *dev) + { + struct device_link *link; ++ unsigned long flags; ++ bool put; + int idx; + + idx = device_links_read_lock(); +@@ -1685,7 +1687,11 @@ void pm_runtime_put_suppliers(struct device *dev) + device_links_read_lock_held()) + if (link->supplier_preactivated) { + link->supplier_preactivated = false; +- if (refcount_dec_not_one(&link->rpm_active)) ++ spin_lock_irqsave(&dev->power.lock, flags); ++ put = pm_runtime_status_suspended(dev) && ++ refcount_dec_not_one(&link->rpm_active); ++ spin_unlock_irqrestore(&dev->power.lock, flags); ++ if (put) + pm_runtime_put(link->supplier); + } + +diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c +index e055893fd5c39..5c9e156cd0862 100644 +--- a/drivers/extcon/extcon.c ++++ b/drivers/extcon/extcon.c +@@ -1241,6 +1241,7 @@ int extcon_dev_register(struct extcon_dev *edev) + sizeof(*edev->nh), GFP_KERNEL); + if (!edev->nh) { + ret = -ENOMEM; ++ device_unregister(&edev->dev); + goto err_dev; + } + +diff --git a/drivers/firewire/nosy.c b/drivers/firewire/nosy.c +index 0cc7466736773..9ee747a85ee49 100644 +--- a/drivers/firewire/nosy.c ++++ b/drivers/firewire/nosy.c +@@ -346,6 +346,7 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + struct client *client = file->private_data; + spinlock_t *client_list_lock = &client->lynx->client_list_lock; + struct nosy_stats stats; ++ int ret; + + switch (cmd) { + case NOSY_IOC_GET_STATS: +@@ -360,11 +361,15 @@ nosy_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + return 0; + + case NOSY_IOC_START: ++ ret = -EBUSY; + spin_lock_irq(client_list_lock); +- list_add_tail(&client->link, &client->lynx->client_list); ++ if (list_empty(&client->link)) { ++ list_add_tail(&client->link, &client->lynx->client_list); ++ ret = 0; ++ } + spin_unlock_irq(client_list_lock); + +- return 0; ++ return ret; + + case NOSY_IOC_STOP: + spin_lock_irq(client_list_lock); +diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +index 6335bd4ae374a..fb47ddc6f7f4e 100644 +--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c ++++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +@@ -2123,8 +2123,8 @@ int amdgpu_vm_bo_map(struct amdgpu_device *adev, + uint64_t eaddr; + + /* validate the parameters */ +- if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK || +- size == 0 || size & AMDGPU_GPU_PAGE_MASK) ++ if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || ++ size == 0 || size & ~PAGE_MASK) + return -EINVAL; + + /* make sure object fit at this offset */ +@@ -2188,8 +2188,8 @@ int amdgpu_vm_bo_replace_map(struct amdgpu_device *adev, + int r; + + /* validate the parameters */ +- if (saddr & AMDGPU_GPU_PAGE_MASK || offset & AMDGPU_GPU_PAGE_MASK || +- size == 0 || size & AMDGPU_GPU_PAGE_MASK) ++ if (saddr & ~PAGE_MASK || offset & ~PAGE_MASK || ++ size == 0 || size & ~PAGE_MASK) + return -EINVAL; + + /* make sure object fit at this offset */ +@@ -2333,7 +2333,7 @@ int amdgpu_vm_bo_clear_mappings(struct amdgpu_device *adev, + after->start = eaddr + 1; + after->last = tmp->last; + after->offset = tmp->offset; +- after->offset += after->start - tmp->start; ++ after->offset += (after->start - tmp->start) << PAGE_SHIFT; + after->flags = tmp->flags; + after->bo_va = tmp->bo_va; + list_add(&after->list, &tmp->bo_va->invalids); +diff --git a/drivers/net/can/Makefile b/drivers/net/can/Makefile +index 22164300122d5..a2b4463d84802 100644 +--- a/drivers/net/can/Makefile ++++ b/drivers/net/can/Makefile +@@ -7,12 +7,7 @@ obj-$(CONFIG_CAN_VCAN) += vcan.o + obj-$(CONFIG_CAN_VXCAN) += vxcan.o + obj-$(CONFIG_CAN_SLCAN) += slcan.o + +-obj-$(CONFIG_CAN_DEV) += can-dev.o +-can-dev-y += dev.o +-can-dev-y += rx-offload.o +- +-can-dev-$(CONFIG_CAN_LEDS) += led.o +- ++obj-y += dev/ + obj-y += rcar/ + obj-y += spi/ + obj-y += usb/ +diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c +deleted file mode 100644 +index 1e0c1a05df82d..0000000000000 +--- a/drivers/net/can/dev.c ++++ /dev/null +@@ -1,1310 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0-only +-/* Copyright (C) 2005 Marc Kleine-Budde, Pengutronix +- * Copyright (C) 2006 Andrey Volkov, Varma Electronics +- * Copyright (C) 2008-2009 Wolfgang Grandegger +- */ +- +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +-#include +- +-#define MOD_DESC "CAN device driver interface" +- +-MODULE_DESCRIPTION(MOD_DESC); +-MODULE_LICENSE("GPL v2"); +-MODULE_AUTHOR("Wolfgang Grandegger "); +- +-/* CAN DLC to real data length conversion helpers */ +- +-static const u8 dlc2len[] = {0, 1, 2, 3, 4, 5, 6, 7, +- 8, 12, 16, 20, 24, 32, 48, 64}; +- +-/* get data length from can_dlc with sanitized can_dlc */ +-u8 can_dlc2len(u8 can_dlc) +-{ +- return dlc2len[can_dlc & 0x0F]; +-} +-EXPORT_SYMBOL_GPL(can_dlc2len); +- +-static const u8 len2dlc[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, /* 0 - 8 */ +- 9, 9, 9, 9, /* 9 - 12 */ +- 10, 10, 10, 10, /* 13 - 16 */ +- 11, 11, 11, 11, /* 17 - 20 */ +- 12, 12, 12, 12, /* 21 - 24 */ +- 13, 13, 13, 13, 13, 13, 13, 13, /* 25 - 32 */ +- 14, 14, 14, 14, 14, 14, 14, 14, /* 33 - 40 */ +- 14, 14, 14, 14, 14, 14, 14, 14, /* 41 - 48 */ +- 15, 15, 15, 15, 15, 15, 15, 15, /* 49 - 56 */ +- 15, 15, 15, 15, 15, 15, 15, 15}; /* 57 - 64 */ +- +-/* map the sanitized data length to an appropriate data length code */ +-u8 can_len2dlc(u8 len) +-{ +- if (unlikely(len > 64)) +- return 0xF; +- +- return len2dlc[len]; +-} +-EXPORT_SYMBOL_GPL(can_len2dlc); +- +-#ifdef CONFIG_CAN_CALC_BITTIMING +-#define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */ +-#define CAN_CALC_SYNC_SEG 1 +- +-/* Bit-timing calculation derived from: +- * +- * Code based on LinCAN sources and H8S2638 project +- * Copyright 2004-2006 Pavel Pisa - DCE FELK CVUT cz +- * Copyright 2005 Stanislav Marek +- * email: pisa@cmp.felk.cvut.cz +- * +- * Calculates proper bit-timing parameters for a specified bit-rate +- * and sample-point, which can then be used to set the bit-timing +- * registers of the CAN controller. You can find more information +- * in the header file linux/can/netlink.h. +- */ +-static int +-can_update_sample_point(const struct can_bittiming_const *btc, +- unsigned int sample_point_nominal, unsigned int tseg, +- unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, +- unsigned int *sample_point_error_ptr) +-{ +- unsigned int sample_point_error, best_sample_point_error = UINT_MAX; +- unsigned int sample_point, best_sample_point = 0; +- unsigned int tseg1, tseg2; +- int i; +- +- for (i = 0; i <= 1; i++) { +- tseg2 = tseg + CAN_CALC_SYNC_SEG - +- (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / +- 1000 - i; +- tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max); +- tseg1 = tseg - tseg2; +- if (tseg1 > btc->tseg1_max) { +- tseg1 = btc->tseg1_max; +- tseg2 = tseg - tseg1; +- } +- +- sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / +- (tseg + CAN_CALC_SYNC_SEG); +- sample_point_error = abs(sample_point_nominal - sample_point); +- +- if (sample_point <= sample_point_nominal && +- sample_point_error < best_sample_point_error) { +- best_sample_point = sample_point; +- best_sample_point_error = sample_point_error; +- *tseg1_ptr = tseg1; +- *tseg2_ptr = tseg2; +- } +- } +- +- if (sample_point_error_ptr) +- *sample_point_error_ptr = best_sample_point_error; +- +- return best_sample_point; +-} +- +-static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, +- const struct can_bittiming_const *btc) +-{ +- struct can_priv *priv = netdev_priv(dev); +- unsigned int bitrate; /* current bitrate */ +- unsigned int bitrate_error; /* difference between current and nominal value */ +- unsigned int best_bitrate_error = UINT_MAX; +- unsigned int sample_point_error; /* difference between current and nominal value */ +- unsigned int best_sample_point_error = UINT_MAX; +- unsigned int sample_point_nominal; /* nominal sample point */ +- unsigned int best_tseg = 0; /* current best value for tseg */ +- unsigned int best_brp = 0; /* current best value for brp */ +- unsigned int brp, tsegall, tseg, tseg1 = 0, tseg2 = 0; +- u64 v64; +- +- /* Use CiA recommended sample points */ +- if (bt->sample_point) { +- sample_point_nominal = bt->sample_point; +- } else { +- if (bt->bitrate > 800000) +- sample_point_nominal = 750; +- else if (bt->bitrate > 500000) +- sample_point_nominal = 800; +- else +- sample_point_nominal = 875; +- } +- +- /* tseg even = round down, odd = round up */ +- for (tseg = (btc->tseg1_max + btc->tseg2_max) * 2 + 1; +- tseg >= (btc->tseg1_min + btc->tseg2_min) * 2; tseg--) { +- tsegall = CAN_CALC_SYNC_SEG + tseg / 2; +- +- /* Compute all possible tseg choices (tseg=tseg1+tseg2) */ +- brp = priv->clock.freq / (tsegall * bt->bitrate) + tseg % 2; +- +- /* choose brp step which is possible in system */ +- brp = (brp / btc->brp_inc) * btc->brp_inc; +- if (brp < btc->brp_min || brp > btc->brp_max) +- continue; +- +- bitrate = priv->clock.freq / (brp * tsegall); +- bitrate_error = abs(bt->bitrate - bitrate); +- +- /* tseg brp biterror */ +- if (bitrate_error > best_bitrate_error) +- continue; +- +- /* reset sample point error if we have a better bitrate */ +- if (bitrate_error < best_bitrate_error) +- best_sample_point_error = UINT_MAX; +- +- can_update_sample_point(btc, sample_point_nominal, tseg / 2, +- &tseg1, &tseg2, &sample_point_error); +- if (sample_point_error > best_sample_point_error) +- continue; +- +- best_sample_point_error = sample_point_error; +- best_bitrate_error = bitrate_error; +- best_tseg = tseg / 2; +- best_brp = brp; +- +- if (bitrate_error == 0 && sample_point_error == 0) +- break; +- } +- +- if (best_bitrate_error) { +- /* Error in one-tenth of a percent */ +- v64 = (u64)best_bitrate_error * 1000; +- do_div(v64, bt->bitrate); +- bitrate_error = (u32)v64; +- if (bitrate_error > CAN_CALC_MAX_ERROR) { +- netdev_err(dev, +- "bitrate error %d.%d%% too high\n", +- bitrate_error / 10, bitrate_error % 10); +- return -EDOM; +- } +- netdev_warn(dev, "bitrate error %d.%d%%\n", +- bitrate_error / 10, bitrate_error % 10); +- } +- +- /* real sample point */ +- bt->sample_point = can_update_sample_point(btc, sample_point_nominal, +- best_tseg, &tseg1, &tseg2, +- NULL); +- +- v64 = (u64)best_brp * 1000 * 1000 * 1000; +- do_div(v64, priv->clock.freq); +- bt->tq = (u32)v64; +- bt->prop_seg = tseg1 / 2; +- bt->phase_seg1 = tseg1 - bt->prop_seg; +- bt->phase_seg2 = tseg2; +- +- /* check for sjw user settings */ +- if (!bt->sjw || !btc->sjw_max) { +- bt->sjw = 1; +- } else { +- /* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */ +- if (bt->sjw > btc->sjw_max) +- bt->sjw = btc->sjw_max; +- /* bt->sjw must not be higher than tseg2 */ +- if (tseg2 < bt->sjw) +- bt->sjw = tseg2; +- } +- +- bt->brp = best_brp; +- +- /* real bitrate */ +- bt->bitrate = priv->clock.freq / +- (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); +- +- return 0; +-} +-#else /* !CONFIG_CAN_CALC_BITTIMING */ +-static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, +- const struct can_bittiming_const *btc) +-{ +- netdev_err(dev, "bit-timing calculation not available\n"); +- return -EINVAL; +-} +-#endif /* CONFIG_CAN_CALC_BITTIMING */ +- +-/* Checks the validity of the specified bit-timing parameters prop_seg, +- * phase_seg1, phase_seg2 and sjw and tries to determine the bitrate +- * prescaler value brp. You can find more information in the header +- * file linux/can/netlink.h. +- */ +-static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt, +- const struct can_bittiming_const *btc) +-{ +- struct can_priv *priv = netdev_priv(dev); +- int tseg1, alltseg; +- u64 brp64; +- +- tseg1 = bt->prop_seg + bt->phase_seg1; +- if (!bt->sjw) +- bt->sjw = 1; +- if (bt->sjw > btc->sjw_max || +- tseg1 < btc->tseg1_min || tseg1 > btc->tseg1_max || +- bt->phase_seg2 < btc->tseg2_min || bt->phase_seg2 > btc->tseg2_max) +- return -ERANGE; +- +- brp64 = (u64)priv->clock.freq * (u64)bt->tq; +- if (btc->brp_inc > 1) +- do_div(brp64, btc->brp_inc); +- brp64 += 500000000UL - 1; +- do_div(brp64, 1000000000UL); /* the practicable BRP */ +- if (btc->brp_inc > 1) +- brp64 *= btc->brp_inc; +- bt->brp = (u32)brp64; +- +- if (bt->brp < btc->brp_min || bt->brp > btc->brp_max) +- return -EINVAL; +- +- alltseg = bt->prop_seg + bt->phase_seg1 + bt->phase_seg2 + 1; +- bt->bitrate = priv->clock.freq / (bt->brp * alltseg); +- bt->sample_point = ((tseg1 + 1) * 1000) / alltseg; +- +- return 0; +-} +- +-/* Checks the validity of predefined bitrate settings */ +-static int +-can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, +- const u32 *bitrate_const, +- const unsigned int bitrate_const_cnt) +-{ +- struct can_priv *priv = netdev_priv(dev); +- unsigned int i; +- +- for (i = 0; i < bitrate_const_cnt; i++) { +- if (bt->bitrate == bitrate_const[i]) +- break; +- } +- +- if (i >= priv->bitrate_const_cnt) +- return -EINVAL; +- +- return 0; +-} +- +-static int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt, +- const struct can_bittiming_const *btc, +- const u32 *bitrate_const, +- const unsigned int bitrate_const_cnt) +-{ +- int err; +- +- /* Depending on the given can_bittiming parameter structure the CAN +- * timing parameters are calculated based on the provided bitrate OR +- * alternatively the CAN timing parameters (tq, prop_seg, etc.) are +- * provided directly which are then checked and fixed up. +- */ +- if (!bt->tq && bt->bitrate && btc) +- err = can_calc_bittiming(dev, bt, btc); +- else if (bt->tq && !bt->bitrate && btc) +- err = can_fixup_bittiming(dev, bt, btc); +- else if (!bt->tq && bt->bitrate && bitrate_const) +- err = can_validate_bitrate(dev, bt, bitrate_const, +- bitrate_const_cnt); +- else +- err = -EINVAL; +- +- return err; +-} +- +-static void can_update_state_error_stats(struct net_device *dev, +- enum can_state new_state) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- if (new_state <= priv->state) +- return; +- +- switch (new_state) { +- case CAN_STATE_ERROR_WARNING: +- priv->can_stats.error_warning++; +- break; +- case CAN_STATE_ERROR_PASSIVE: +- priv->can_stats.error_passive++; +- break; +- case CAN_STATE_BUS_OFF: +- priv->can_stats.bus_off++; +- break; +- default: +- break; +- } +-} +- +-static int can_tx_state_to_frame(struct net_device *dev, enum can_state state) +-{ +- switch (state) { +- case CAN_STATE_ERROR_ACTIVE: +- return CAN_ERR_CRTL_ACTIVE; +- case CAN_STATE_ERROR_WARNING: +- return CAN_ERR_CRTL_TX_WARNING; +- case CAN_STATE_ERROR_PASSIVE: +- return CAN_ERR_CRTL_TX_PASSIVE; +- default: +- return 0; +- } +-} +- +-static int can_rx_state_to_frame(struct net_device *dev, enum can_state state) +-{ +- switch (state) { +- case CAN_STATE_ERROR_ACTIVE: +- return CAN_ERR_CRTL_ACTIVE; +- case CAN_STATE_ERROR_WARNING: +- return CAN_ERR_CRTL_RX_WARNING; +- case CAN_STATE_ERROR_PASSIVE: +- return CAN_ERR_CRTL_RX_PASSIVE; +- default: +- return 0; +- } +-} +- +-void can_change_state(struct net_device *dev, struct can_frame *cf, +- enum can_state tx_state, enum can_state rx_state) +-{ +- struct can_priv *priv = netdev_priv(dev); +- enum can_state new_state = max(tx_state, rx_state); +- +- if (unlikely(new_state == priv->state)) { +- netdev_warn(dev, "%s: oops, state did not change", __func__); +- return; +- } +- +- netdev_dbg(dev, "New error state: %d\n", new_state); +- +- can_update_state_error_stats(dev, new_state); +- priv->state = new_state; +- +- if (!cf) +- return; +- +- if (unlikely(new_state == CAN_STATE_BUS_OFF)) { +- cf->can_id |= CAN_ERR_BUSOFF; +- return; +- } +- +- cf->can_id |= CAN_ERR_CRTL; +- cf->data[1] |= tx_state >= rx_state ? +- can_tx_state_to_frame(dev, tx_state) : 0; +- cf->data[1] |= tx_state <= rx_state ? +- can_rx_state_to_frame(dev, rx_state) : 0; +-} +-EXPORT_SYMBOL_GPL(can_change_state); +- +-/* Local echo of CAN messages +- * +- * CAN network devices *should* support a local echo functionality +- * (see Documentation/networking/can.rst). To test the handling of CAN +- * interfaces that do not support the local echo both driver types are +- * implemented. In the case that the driver does not support the echo +- * the IFF_ECHO remains clear in dev->flags. This causes the PF_CAN core +- * to perform the echo as a fallback solution. +- */ +-static void can_flush_echo_skb(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; +- int i; +- +- for (i = 0; i < priv->echo_skb_max; i++) { +- if (priv->echo_skb[i]) { +- kfree_skb(priv->echo_skb[i]); +- priv->echo_skb[i] = NULL; +- stats->tx_dropped++; +- stats->tx_aborted_errors++; +- } +- } +-} +- +-/* Put the skb on the stack to be looped backed locally lateron +- * +- * The function is typically called in the start_xmit function +- * of the device driver. The driver must protect access to +- * priv->echo_skb, if necessary. +- */ +-void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, +- unsigned int idx) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- BUG_ON(idx >= priv->echo_skb_max); +- +- /* check flag whether this packet has to be looped back */ +- if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK || +- (skb->protocol != htons(ETH_P_CAN) && +- skb->protocol != htons(ETH_P_CANFD))) { +- kfree_skb(skb); +- return; +- } +- +- if (!priv->echo_skb[idx]) { +- skb = can_create_echo_skb(skb); +- if (!skb) +- return; +- +- /* make settings for echo to reduce code in irq context */ +- skb->pkt_type = PACKET_BROADCAST; +- skb->ip_summed = CHECKSUM_UNNECESSARY; +- skb->dev = dev; +- +- /* save this skb for tx interrupt echo handling */ +- priv->echo_skb[idx] = skb; +- } else { +- /* locking problem with netif_stop_queue() ?? */ +- netdev_err(dev, "%s: BUG! echo_skb is occupied!\n", __func__); +- kfree_skb(skb); +- } +-} +-EXPORT_SYMBOL_GPL(can_put_echo_skb); +- +-struct sk_buff * +-__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- if (idx >= priv->echo_skb_max) { +- netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n", +- __func__, idx, priv->echo_skb_max); +- return NULL; +- } +- +- if (priv->echo_skb[idx]) { +- /* Using "struct canfd_frame::len" for the frame +- * length is supported on both CAN and CANFD frames. +- */ +- struct sk_buff *skb = priv->echo_skb[idx]; +- struct canfd_frame *cf = (struct canfd_frame *)skb->data; +- +- /* get the real payload length for netdev statistics */ +- if (cf->can_id & CAN_RTR_FLAG) +- *len_ptr = 0; +- else +- *len_ptr = cf->len; +- +- priv->echo_skb[idx] = NULL; +- +- return skb; +- } +- +- return NULL; +-} +- +-/* Get the skb from the stack and loop it back locally +- * +- * The function is typically called when the TX done interrupt +- * is handled in the device driver. The driver must protect +- * access to priv->echo_skb, if necessary. +- */ +-unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) +-{ +- struct sk_buff *skb; +- u8 len; +- +- skb = __can_get_echo_skb(dev, idx, &len); +- if (!skb) +- return 0; +- +- skb_get(skb); +- if (netif_rx(skb) == NET_RX_SUCCESS) +- dev_consume_skb_any(skb); +- else +- dev_kfree_skb_any(skb); +- +- return len; +-} +-EXPORT_SYMBOL_GPL(can_get_echo_skb); +- +-/* Remove the skb from the stack and free it. +- * +- * The function is typically called when TX failed. +- */ +-void can_free_echo_skb(struct net_device *dev, unsigned int idx) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- BUG_ON(idx >= priv->echo_skb_max); +- +- if (priv->echo_skb[idx]) { +- dev_kfree_skb_any(priv->echo_skb[idx]); +- priv->echo_skb[idx] = NULL; +- } +-} +-EXPORT_SYMBOL_GPL(can_free_echo_skb); +- +-/* CAN device restart for bus-off recovery */ +-static void can_restart(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- struct net_device_stats *stats = &dev->stats; +- struct sk_buff *skb; +- struct can_frame *cf; +- int err; +- +- BUG_ON(netif_carrier_ok(dev)); +- +- /* No synchronization needed because the device is bus-off and +- * no messages can come in or go out. +- */ +- can_flush_echo_skb(dev); +- +- /* send restart message upstream */ +- skb = alloc_can_err_skb(dev, &cf); +- if (!skb) { +- err = -ENOMEM; +- goto restart; +- } +- cf->can_id |= CAN_ERR_RESTARTED; +- +- stats->rx_packets++; +- stats->rx_bytes += cf->can_dlc; +- +- netif_rx_ni(skb); +- +-restart: +- netdev_dbg(dev, "restarted\n"); +- priv->can_stats.restarts++; +- +- /* Now restart the device */ +- err = priv->do_set_mode(dev, CAN_MODE_START); +- +- netif_carrier_on(dev); +- if (err) +- netdev_err(dev, "Error %d during restart", err); +-} +- +-static void can_restart_work(struct work_struct *work) +-{ +- struct delayed_work *dwork = to_delayed_work(work); +- struct can_priv *priv = container_of(dwork, struct can_priv, +- restart_work); +- +- can_restart(priv->dev); +-} +- +-int can_restart_now(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- /* A manual restart is only permitted if automatic restart is +- * disabled and the device is in the bus-off state +- */ +- if (priv->restart_ms) +- return -EINVAL; +- if (priv->state != CAN_STATE_BUS_OFF) +- return -EBUSY; +- +- cancel_delayed_work_sync(&priv->restart_work); +- can_restart(dev); +- +- return 0; +-} +- +-/* CAN bus-off +- * +- * This functions should be called when the device goes bus-off to +- * tell the netif layer that no more packets can be sent or received. +- * If enabled, a timer is started to trigger bus-off recovery. +- */ +-void can_bus_off(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- netdev_info(dev, "bus-off\n"); +- +- netif_carrier_off(dev); +- +- if (priv->restart_ms) +- schedule_delayed_work(&priv->restart_work, +- msecs_to_jiffies(priv->restart_ms)); +-} +-EXPORT_SYMBOL_GPL(can_bus_off); +- +-static void can_setup(struct net_device *dev) +-{ +- dev->type = ARPHRD_CAN; +- dev->mtu = CAN_MTU; +- dev->hard_header_len = 0; +- dev->addr_len = 0; +- dev->tx_queue_len = 10; +- +- /* New-style flags. */ +- dev->flags = IFF_NOARP; +- dev->features = NETIF_F_HW_CSUM; +-} +- +-struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) +-{ +- struct sk_buff *skb; +- +- skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) + +- sizeof(struct can_frame)); +- if (unlikely(!skb)) +- return NULL; +- +- skb->protocol = htons(ETH_P_CAN); +- skb->pkt_type = PACKET_BROADCAST; +- skb->ip_summed = CHECKSUM_UNNECESSARY; +- +- skb_reset_mac_header(skb); +- skb_reset_network_header(skb); +- skb_reset_transport_header(skb); +- +- can_skb_reserve(skb); +- can_skb_prv(skb)->ifindex = dev->ifindex; +- can_skb_prv(skb)->skbcnt = 0; +- +- *cf = skb_put_zero(skb, sizeof(struct can_frame)); +- +- return skb; +-} +-EXPORT_SYMBOL_GPL(alloc_can_skb); +- +-struct sk_buff *alloc_canfd_skb(struct net_device *dev, +- struct canfd_frame **cfd) +-{ +- struct sk_buff *skb; +- +- skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) + +- sizeof(struct canfd_frame)); +- if (unlikely(!skb)) +- return NULL; +- +- skb->protocol = htons(ETH_P_CANFD); +- skb->pkt_type = PACKET_BROADCAST; +- skb->ip_summed = CHECKSUM_UNNECESSARY; +- +- skb_reset_mac_header(skb); +- skb_reset_network_header(skb); +- skb_reset_transport_header(skb); +- +- can_skb_reserve(skb); +- can_skb_prv(skb)->ifindex = dev->ifindex; +- can_skb_prv(skb)->skbcnt = 0; +- +- *cfd = skb_put_zero(skb, sizeof(struct canfd_frame)); +- +- return skb; +-} +-EXPORT_SYMBOL_GPL(alloc_canfd_skb); +- +-struct sk_buff *alloc_can_err_skb(struct net_device *dev, struct can_frame **cf) +-{ +- struct sk_buff *skb; +- +- skb = alloc_can_skb(dev, cf); +- if (unlikely(!skb)) +- return NULL; +- +- (*cf)->can_id = CAN_ERR_FLAG; +- (*cf)->can_dlc = CAN_ERR_DLC; +- +- return skb; +-} +-EXPORT_SYMBOL_GPL(alloc_can_err_skb); +- +-/* Allocate and setup space for the CAN network device */ +-struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, +- unsigned int txqs, unsigned int rxqs) +-{ +- struct net_device *dev; +- struct can_priv *priv; +- int size; +- +- /* We put the driver's priv, the CAN mid layer priv and the +- * echo skb into the netdevice's priv. The memory layout for +- * the netdev_priv is like this: +- * +- * +-------------------------+ +- * | driver's priv | +- * +-------------------------+ +- * | struct can_ml_priv | +- * +-------------------------+ +- * | array of struct sk_buff | +- * +-------------------------+ +- */ +- +- size = ALIGN(sizeof_priv, NETDEV_ALIGN) + sizeof(struct can_ml_priv); +- +- if (echo_skb_max) +- size = ALIGN(size, sizeof(struct sk_buff *)) + +- echo_skb_max * sizeof(struct sk_buff *); +- +- dev = alloc_netdev_mqs(size, "can%d", NET_NAME_UNKNOWN, can_setup, +- txqs, rxqs); +- if (!dev) +- return NULL; +- +- priv = netdev_priv(dev); +- priv->dev = dev; +- +- dev->ml_priv = (void *)priv + ALIGN(sizeof_priv, NETDEV_ALIGN); +- +- if (echo_skb_max) { +- priv->echo_skb_max = echo_skb_max; +- priv->echo_skb = (void *)priv + +- (size - echo_skb_max * sizeof(struct sk_buff *)); +- } +- +- priv->state = CAN_STATE_STOPPED; +- +- INIT_DELAYED_WORK(&priv->restart_work, can_restart_work); +- +- return dev; +-} +-EXPORT_SYMBOL_GPL(alloc_candev_mqs); +- +-/* Free space of the CAN network device */ +-void free_candev(struct net_device *dev) +-{ +- free_netdev(dev); +-} +-EXPORT_SYMBOL_GPL(free_candev); +- +-/* changing MTU and control mode for CAN/CANFD devices */ +-int can_change_mtu(struct net_device *dev, int new_mtu) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- /* Do not allow changing the MTU while running */ +- if (dev->flags & IFF_UP) +- return -EBUSY; +- +- /* allow change of MTU according to the CANFD ability of the device */ +- switch (new_mtu) { +- case CAN_MTU: +- /* 'CANFD-only' controllers can not switch to CAN_MTU */ +- if (priv->ctrlmode_static & CAN_CTRLMODE_FD) +- return -EINVAL; +- +- priv->ctrlmode &= ~CAN_CTRLMODE_FD; +- break; +- +- case CANFD_MTU: +- /* check for potential CANFD ability */ +- if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) && +- !(priv->ctrlmode_static & CAN_CTRLMODE_FD)) +- return -EINVAL; +- +- priv->ctrlmode |= CAN_CTRLMODE_FD; +- break; +- +- default: +- return -EINVAL; +- } +- +- dev->mtu = new_mtu; +- return 0; +-} +-EXPORT_SYMBOL_GPL(can_change_mtu); +- +-/* Common open function when the device gets opened. +- * +- * This function should be called in the open function of the device +- * driver. +- */ +-int open_candev(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- if (!priv->bittiming.bitrate) { +- netdev_err(dev, "bit-timing not yet defined\n"); +- return -EINVAL; +- } +- +- /* For CAN FD the data bitrate has to be >= the arbitration bitrate */ +- if ((priv->ctrlmode & CAN_CTRLMODE_FD) && +- (!priv->data_bittiming.bitrate || +- priv->data_bittiming.bitrate < priv->bittiming.bitrate)) { +- netdev_err(dev, "incorrect/missing data bit-timing\n"); +- return -EINVAL; +- } +- +- /* Switch carrier on if device was stopped while in bus-off state */ +- if (!netif_carrier_ok(dev)) +- netif_carrier_on(dev); +- +- return 0; +-} +-EXPORT_SYMBOL_GPL(open_candev); +- +-#ifdef CONFIG_OF +-/* Common function that can be used to understand the limitation of +- * a transceiver when it provides no means to determine these limitations +- * at runtime. +- */ +-void of_can_transceiver(struct net_device *dev) +-{ +- struct device_node *dn; +- struct can_priv *priv = netdev_priv(dev); +- struct device_node *np = dev->dev.parent->of_node; +- int ret; +- +- dn = of_get_child_by_name(np, "can-transceiver"); +- if (!dn) +- return; +- +- ret = of_property_read_u32(dn, "max-bitrate", &priv->bitrate_max); +- of_node_put(dn); +- if ((ret && ret != -EINVAL) || (!ret && !priv->bitrate_max)) +- netdev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit.\n"); +-} +-EXPORT_SYMBOL_GPL(of_can_transceiver); +-#endif +- +-/* Common close function for cleanup before the device gets closed. +- * +- * This function should be called in the close function of the device +- * driver. +- */ +-void close_candev(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- cancel_delayed_work_sync(&priv->restart_work); +- can_flush_echo_skb(dev); +-} +-EXPORT_SYMBOL_GPL(close_candev); +- +-/* CAN netlink interface */ +-static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { +- [IFLA_CAN_STATE] = { .type = NLA_U32 }, +- [IFLA_CAN_CTRLMODE] = { .len = sizeof(struct can_ctrlmode) }, +- [IFLA_CAN_RESTART_MS] = { .type = NLA_U32 }, +- [IFLA_CAN_RESTART] = { .type = NLA_U32 }, +- [IFLA_CAN_BITTIMING] = { .len = sizeof(struct can_bittiming) }, +- [IFLA_CAN_BITTIMING_CONST] +- = { .len = sizeof(struct can_bittiming_const) }, +- [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) }, +- [IFLA_CAN_BERR_COUNTER] = { .len = sizeof(struct can_berr_counter) }, +- [IFLA_CAN_DATA_BITTIMING] +- = { .len = sizeof(struct can_bittiming) }, +- [IFLA_CAN_DATA_BITTIMING_CONST] +- = { .len = sizeof(struct can_bittiming_const) }, +- [IFLA_CAN_TERMINATION] = { .type = NLA_U16 }, +-}; +- +-static int can_validate(struct nlattr *tb[], struct nlattr *data[], +- struct netlink_ext_ack *extack) +-{ +- bool is_can_fd = false; +- +- /* Make sure that valid CAN FD configurations always consist of +- * - nominal/arbitration bittiming +- * - data bittiming +- * - control mode with CAN_CTRLMODE_FD set +- */ +- +- if (!data) +- return 0; +- +- if (data[IFLA_CAN_CTRLMODE]) { +- struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]); +- +- is_can_fd = cm->flags & cm->mask & CAN_CTRLMODE_FD; +- } +- +- if (is_can_fd) { +- if (!data[IFLA_CAN_BITTIMING] || !data[IFLA_CAN_DATA_BITTIMING]) +- return -EOPNOTSUPP; +- } +- +- if (data[IFLA_CAN_DATA_BITTIMING]) { +- if (!is_can_fd || !data[IFLA_CAN_BITTIMING]) +- return -EOPNOTSUPP; +- } +- +- return 0; +-} +- +-static int can_changelink(struct net_device *dev, struct nlattr *tb[], +- struct nlattr *data[], +- struct netlink_ext_ack *extack) +-{ +- struct can_priv *priv = netdev_priv(dev); +- int err; +- +- /* We need synchronization with dev->stop() */ +- ASSERT_RTNL(); +- +- if (data[IFLA_CAN_BITTIMING]) { +- struct can_bittiming bt; +- +- /* Do not allow changing bittiming while running */ +- if (dev->flags & IFF_UP) +- return -EBUSY; +- +- /* Calculate bittiming parameters based on +- * bittiming_const if set, otherwise pass bitrate +- * directly via do_set_bitrate(). Bail out if neither +- * is given. +- */ +- if (!priv->bittiming_const && !priv->do_set_bittiming) +- return -EOPNOTSUPP; +- +- memcpy(&bt, nla_data(data[IFLA_CAN_BITTIMING]), sizeof(bt)); +- err = can_get_bittiming(dev, &bt, +- priv->bittiming_const, +- priv->bitrate_const, +- priv->bitrate_const_cnt); +- if (err) +- return err; +- +- if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) { +- netdev_err(dev, "arbitration bitrate surpasses transceiver capabilities of %d bps\n", +- priv->bitrate_max); +- return -EINVAL; +- } +- +- memcpy(&priv->bittiming, &bt, sizeof(bt)); +- +- if (priv->do_set_bittiming) { +- /* Finally, set the bit-timing registers */ +- err = priv->do_set_bittiming(dev); +- if (err) +- return err; +- } +- } +- +- if (data[IFLA_CAN_CTRLMODE]) { +- struct can_ctrlmode *cm; +- u32 ctrlstatic; +- u32 maskedflags; +- +- /* Do not allow changing controller mode while running */ +- if (dev->flags & IFF_UP) +- return -EBUSY; +- cm = nla_data(data[IFLA_CAN_CTRLMODE]); +- ctrlstatic = priv->ctrlmode_static; +- maskedflags = cm->flags & cm->mask; +- +- /* check whether provided bits are allowed to be passed */ +- if (cm->mask & ~(priv->ctrlmode_supported | ctrlstatic)) +- return -EOPNOTSUPP; +- +- /* do not check for static fd-non-iso if 'fd' is disabled */ +- if (!(maskedflags & CAN_CTRLMODE_FD)) +- ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO; +- +- /* make sure static options are provided by configuration */ +- if ((maskedflags & ctrlstatic) != ctrlstatic) +- return -EOPNOTSUPP; +- +- /* clear bits to be modified and copy the flag values */ +- priv->ctrlmode &= ~cm->mask; +- priv->ctrlmode |= maskedflags; +- +- /* CAN_CTRLMODE_FD can only be set when driver supports FD */ +- if (priv->ctrlmode & CAN_CTRLMODE_FD) +- dev->mtu = CANFD_MTU; +- else +- dev->mtu = CAN_MTU; +- } +- +- if (data[IFLA_CAN_RESTART_MS]) { +- /* Do not allow changing restart delay while running */ +- if (dev->flags & IFF_UP) +- return -EBUSY; +- priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]); +- } +- +- if (data[IFLA_CAN_RESTART]) { +- /* Do not allow a restart while not running */ +- if (!(dev->flags & IFF_UP)) +- return -EINVAL; +- err = can_restart_now(dev); +- if (err) +- return err; +- } +- +- if (data[IFLA_CAN_DATA_BITTIMING]) { +- struct can_bittiming dbt; +- +- /* Do not allow changing bittiming while running */ +- if (dev->flags & IFF_UP) +- return -EBUSY; +- +- /* Calculate bittiming parameters based on +- * data_bittiming_const if set, otherwise pass bitrate +- * directly via do_set_bitrate(). Bail out if neither +- * is given. +- */ +- if (!priv->data_bittiming_const && !priv->do_set_data_bittiming) +- return -EOPNOTSUPP; +- +- memcpy(&dbt, nla_data(data[IFLA_CAN_DATA_BITTIMING]), +- sizeof(dbt)); +- err = can_get_bittiming(dev, &dbt, +- priv->data_bittiming_const, +- priv->data_bitrate_const, +- priv->data_bitrate_const_cnt); +- if (err) +- return err; +- +- if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) { +- netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n", +- priv->bitrate_max); +- return -EINVAL; +- } +- +- memcpy(&priv->data_bittiming, &dbt, sizeof(dbt)); +- +- if (priv->do_set_data_bittiming) { +- /* Finally, set the bit-timing registers */ +- err = priv->do_set_data_bittiming(dev); +- if (err) +- return err; +- } +- } +- +- if (data[IFLA_CAN_TERMINATION]) { +- const u16 termval = nla_get_u16(data[IFLA_CAN_TERMINATION]); +- const unsigned int num_term = priv->termination_const_cnt; +- unsigned int i; +- +- if (!priv->do_set_termination) +- return -EOPNOTSUPP; +- +- /* check whether given value is supported by the interface */ +- for (i = 0; i < num_term; i++) { +- if (termval == priv->termination_const[i]) +- break; +- } +- if (i >= num_term) +- return -EINVAL; +- +- /* Finally, set the termination value */ +- err = priv->do_set_termination(dev, termval); +- if (err) +- return err; +- +- priv->termination = termval; +- } +- +- return 0; +-} +- +-static size_t can_get_size(const struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- size_t size = 0; +- +- if (priv->bittiming.bitrate) /* IFLA_CAN_BITTIMING */ +- size += nla_total_size(sizeof(struct can_bittiming)); +- if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */ +- size += nla_total_size(sizeof(struct can_bittiming_const)); +- size += nla_total_size(sizeof(struct can_clock)); /* IFLA_CAN_CLOCK */ +- size += nla_total_size(sizeof(u32)); /* IFLA_CAN_STATE */ +- size += nla_total_size(sizeof(struct can_ctrlmode)); /* IFLA_CAN_CTRLMODE */ +- size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ +- if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ +- size += nla_total_size(sizeof(struct can_berr_counter)); +- if (priv->data_bittiming.bitrate) /* IFLA_CAN_DATA_BITTIMING */ +- size += nla_total_size(sizeof(struct can_bittiming)); +- if (priv->data_bittiming_const) /* IFLA_CAN_DATA_BITTIMING_CONST */ +- size += nla_total_size(sizeof(struct can_bittiming_const)); +- if (priv->termination_const) { +- size += nla_total_size(sizeof(priv->termination)); /* IFLA_CAN_TERMINATION */ +- size += nla_total_size(sizeof(*priv->termination_const) * /* IFLA_CAN_TERMINATION_CONST */ +- priv->termination_const_cnt); +- } +- if (priv->bitrate_const) /* IFLA_CAN_BITRATE_CONST */ +- size += nla_total_size(sizeof(*priv->bitrate_const) * +- priv->bitrate_const_cnt); +- if (priv->data_bitrate_const) /* IFLA_CAN_DATA_BITRATE_CONST */ +- size += nla_total_size(sizeof(*priv->data_bitrate_const) * +- priv->data_bitrate_const_cnt); +- size += sizeof(priv->bitrate_max); /* IFLA_CAN_BITRATE_MAX */ +- +- return size; +-} +- +-static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- struct can_ctrlmode cm = {.flags = priv->ctrlmode}; +- struct can_berr_counter bec = { }; +- enum can_state state = priv->state; +- +- if (priv->do_get_state) +- priv->do_get_state(dev, &state); +- +- if ((priv->bittiming.bitrate && +- nla_put(skb, IFLA_CAN_BITTIMING, +- sizeof(priv->bittiming), &priv->bittiming)) || +- +- (priv->bittiming_const && +- nla_put(skb, IFLA_CAN_BITTIMING_CONST, +- sizeof(*priv->bittiming_const), priv->bittiming_const)) || +- +- nla_put(skb, IFLA_CAN_CLOCK, sizeof(priv->clock), &priv->clock) || +- nla_put_u32(skb, IFLA_CAN_STATE, state) || +- nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || +- nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || +- +- (priv->do_get_berr_counter && +- !priv->do_get_berr_counter(dev, &bec) && +- nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) || +- +- (priv->data_bittiming.bitrate && +- nla_put(skb, IFLA_CAN_DATA_BITTIMING, +- sizeof(priv->data_bittiming), &priv->data_bittiming)) || +- +- (priv->data_bittiming_const && +- nla_put(skb, IFLA_CAN_DATA_BITTIMING_CONST, +- sizeof(*priv->data_bittiming_const), +- priv->data_bittiming_const)) || +- +- (priv->termination_const && +- (nla_put_u16(skb, IFLA_CAN_TERMINATION, priv->termination) || +- nla_put(skb, IFLA_CAN_TERMINATION_CONST, +- sizeof(*priv->termination_const) * +- priv->termination_const_cnt, +- priv->termination_const))) || +- +- (priv->bitrate_const && +- nla_put(skb, IFLA_CAN_BITRATE_CONST, +- sizeof(*priv->bitrate_const) * +- priv->bitrate_const_cnt, +- priv->bitrate_const)) || +- +- (priv->data_bitrate_const && +- nla_put(skb, IFLA_CAN_DATA_BITRATE_CONST, +- sizeof(*priv->data_bitrate_const) * +- priv->data_bitrate_const_cnt, +- priv->data_bitrate_const)) || +- +- (nla_put(skb, IFLA_CAN_BITRATE_MAX, +- sizeof(priv->bitrate_max), +- &priv->bitrate_max)) +- ) +- +- return -EMSGSIZE; +- +- return 0; +-} +- +-static size_t can_get_xstats_size(const struct net_device *dev) +-{ +- return sizeof(struct can_device_stats); +-} +- +-static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- if (nla_put(skb, IFLA_INFO_XSTATS, +- sizeof(priv->can_stats), &priv->can_stats)) +- goto nla_put_failure; +- return 0; +- +-nla_put_failure: +- return -EMSGSIZE; +-} +- +-static int can_newlink(struct net *src_net, struct net_device *dev, +- struct nlattr *tb[], struct nlattr *data[], +- struct netlink_ext_ack *extack) +-{ +- return -EOPNOTSUPP; +-} +- +-static void can_dellink(struct net_device *dev, struct list_head *head) +-{ +-} +- +-static struct rtnl_link_ops can_link_ops __read_mostly = { +- .kind = "can", +- .netns_refund = true, +- .maxtype = IFLA_CAN_MAX, +- .policy = can_policy, +- .setup = can_setup, +- .validate = can_validate, +- .newlink = can_newlink, +- .changelink = can_changelink, +- .dellink = can_dellink, +- .get_size = can_get_size, +- .fill_info = can_fill_info, +- .get_xstats_size = can_get_xstats_size, +- .fill_xstats = can_fill_xstats, +-}; +- +-/* Register the CAN network device */ +-int register_candev(struct net_device *dev) +-{ +- struct can_priv *priv = netdev_priv(dev); +- +- /* Ensure termination_const, termination_const_cnt and +- * do_set_termination consistency. All must be either set or +- * unset. +- */ +- if ((!priv->termination_const != !priv->termination_const_cnt) || +- (!priv->termination_const != !priv->do_set_termination)) +- return -EINVAL; +- +- if (!priv->bitrate_const != !priv->bitrate_const_cnt) +- return -EINVAL; +- +- if (!priv->data_bitrate_const != !priv->data_bitrate_const_cnt) +- return -EINVAL; +- +- dev->rtnl_link_ops = &can_link_ops; +- netif_carrier_off(dev); +- +- return register_netdev(dev); +-} +-EXPORT_SYMBOL_GPL(register_candev); +- +-/* Unregister the CAN network device */ +-void unregister_candev(struct net_device *dev) +-{ +- unregister_netdev(dev); +-} +-EXPORT_SYMBOL_GPL(unregister_candev); +- +-/* Test if a network device is a candev based device +- * and return the can_priv* if so. +- */ +-struct can_priv *safe_candev_priv(struct net_device *dev) +-{ +- if (dev->type != ARPHRD_CAN || dev->rtnl_link_ops != &can_link_ops) +- return NULL; +- +- return netdev_priv(dev); +-} +-EXPORT_SYMBOL_GPL(safe_candev_priv); +- +-static __init int can_dev_init(void) +-{ +- int err; +- +- can_led_notifier_init(); +- +- err = rtnl_link_register(&can_link_ops); +- if (!err) +- pr_info(MOD_DESC "\n"); +- +- return err; +-} +-module_init(can_dev_init); +- +-static __exit void can_dev_exit(void) +-{ +- rtnl_link_unregister(&can_link_ops); +- +- can_led_notifier_exit(); +-} +-module_exit(can_dev_exit); +- +-MODULE_ALIAS_RTNL_LINK("can"); +diff --git a/drivers/net/can/dev/Makefile b/drivers/net/can/dev/Makefile +new file mode 100644 +index 0000000000000..cba92e6bcf6f5 +--- /dev/null ++++ b/drivers/net/can/dev/Makefile +@@ -0,0 +1,7 @@ ++# SPDX-License-Identifier: GPL-2.0 ++ ++obj-$(CONFIG_CAN_DEV) += can-dev.o ++can-dev-y += dev.o ++can-dev-y += rx-offload.o ++ ++can-dev-$(CONFIG_CAN_LEDS) += led.o +diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c +new file mode 100644 +index 0000000000000..322da89cb9c60 +--- /dev/null ++++ b/drivers/net/can/dev/dev.c +@@ -0,0 +1,1312 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* Copyright (C) 2005 Marc Kleine-Budde, Pengutronix ++ * Copyright (C) 2006 Andrey Volkov, Varma Electronics ++ * Copyright (C) 2008-2009 Wolfgang Grandegger ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++#include ++ ++#define MOD_DESC "CAN device driver interface" ++ ++MODULE_DESCRIPTION(MOD_DESC); ++MODULE_LICENSE("GPL v2"); ++MODULE_AUTHOR("Wolfgang Grandegger "); ++ ++/* CAN DLC to real data length conversion helpers */ ++ ++static const u8 dlc2len[] = {0, 1, 2, 3, 4, 5, 6, 7, ++ 8, 12, 16, 20, 24, 32, 48, 64}; ++ ++/* get data length from can_dlc with sanitized can_dlc */ ++u8 can_dlc2len(u8 can_dlc) ++{ ++ return dlc2len[can_dlc & 0x0F]; ++} ++EXPORT_SYMBOL_GPL(can_dlc2len); ++ ++static const u8 len2dlc[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, /* 0 - 8 */ ++ 9, 9, 9, 9, /* 9 - 12 */ ++ 10, 10, 10, 10, /* 13 - 16 */ ++ 11, 11, 11, 11, /* 17 - 20 */ ++ 12, 12, 12, 12, /* 21 - 24 */ ++ 13, 13, 13, 13, 13, 13, 13, 13, /* 25 - 32 */ ++ 14, 14, 14, 14, 14, 14, 14, 14, /* 33 - 40 */ ++ 14, 14, 14, 14, 14, 14, 14, 14, /* 41 - 48 */ ++ 15, 15, 15, 15, 15, 15, 15, 15, /* 49 - 56 */ ++ 15, 15, 15, 15, 15, 15, 15, 15}; /* 57 - 64 */ ++ ++/* map the sanitized data length to an appropriate data length code */ ++u8 can_len2dlc(u8 len) ++{ ++ if (unlikely(len > 64)) ++ return 0xF; ++ ++ return len2dlc[len]; ++} ++EXPORT_SYMBOL_GPL(can_len2dlc); ++ ++#ifdef CONFIG_CAN_CALC_BITTIMING ++#define CAN_CALC_MAX_ERROR 50 /* in one-tenth of a percent */ ++#define CAN_CALC_SYNC_SEG 1 ++ ++/* Bit-timing calculation derived from: ++ * ++ * Code based on LinCAN sources and H8S2638 project ++ * Copyright 2004-2006 Pavel Pisa - DCE FELK CVUT cz ++ * Copyright 2005 Stanislav Marek ++ * email: pisa@cmp.felk.cvut.cz ++ * ++ * Calculates proper bit-timing parameters for a specified bit-rate ++ * and sample-point, which can then be used to set the bit-timing ++ * registers of the CAN controller. You can find more information ++ * in the header file linux/can/netlink.h. ++ */ ++static int ++can_update_sample_point(const struct can_bittiming_const *btc, ++ unsigned int sample_point_nominal, unsigned int tseg, ++ unsigned int *tseg1_ptr, unsigned int *tseg2_ptr, ++ unsigned int *sample_point_error_ptr) ++{ ++ unsigned int sample_point_error, best_sample_point_error = UINT_MAX; ++ unsigned int sample_point, best_sample_point = 0; ++ unsigned int tseg1, tseg2; ++ int i; ++ ++ for (i = 0; i <= 1; i++) { ++ tseg2 = tseg + CAN_CALC_SYNC_SEG - ++ (sample_point_nominal * (tseg + CAN_CALC_SYNC_SEG)) / ++ 1000 - i; ++ tseg2 = clamp(tseg2, btc->tseg2_min, btc->tseg2_max); ++ tseg1 = tseg - tseg2; ++ if (tseg1 > btc->tseg1_max) { ++ tseg1 = btc->tseg1_max; ++ tseg2 = tseg - tseg1; ++ } ++ ++ sample_point = 1000 * (tseg + CAN_CALC_SYNC_SEG - tseg2) / ++ (tseg + CAN_CALC_SYNC_SEG); ++ sample_point_error = abs(sample_point_nominal - sample_point); ++ ++ if (sample_point <= sample_point_nominal && ++ sample_point_error < best_sample_point_error) { ++ best_sample_point = sample_point; ++ best_sample_point_error = sample_point_error; ++ *tseg1_ptr = tseg1; ++ *tseg2_ptr = tseg2; ++ } ++ } ++ ++ if (sample_point_error_ptr) ++ *sample_point_error_ptr = best_sample_point_error; ++ ++ return best_sample_point; ++} ++ ++static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, ++ const struct can_bittiming_const *btc) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ unsigned int bitrate; /* current bitrate */ ++ unsigned int bitrate_error; /* difference between current and nominal value */ ++ unsigned int best_bitrate_error = UINT_MAX; ++ unsigned int sample_point_error; /* difference between current and nominal value */ ++ unsigned int best_sample_point_error = UINT_MAX; ++ unsigned int sample_point_nominal; /* nominal sample point */ ++ unsigned int best_tseg = 0; /* current best value for tseg */ ++ unsigned int best_brp = 0; /* current best value for brp */ ++ unsigned int brp, tsegall, tseg, tseg1 = 0, tseg2 = 0; ++ u64 v64; ++ ++ /* Use CiA recommended sample points */ ++ if (bt->sample_point) { ++ sample_point_nominal = bt->sample_point; ++ } else { ++ if (bt->bitrate > 800000) ++ sample_point_nominal = 750; ++ else if (bt->bitrate > 500000) ++ sample_point_nominal = 800; ++ else ++ sample_point_nominal = 875; ++ } ++ ++ /* tseg even = round down, odd = round up */ ++ for (tseg = (btc->tseg1_max + btc->tseg2_max) * 2 + 1; ++ tseg >= (btc->tseg1_min + btc->tseg2_min) * 2; tseg--) { ++ tsegall = CAN_CALC_SYNC_SEG + tseg / 2; ++ ++ /* Compute all possible tseg choices (tseg=tseg1+tseg2) */ ++ brp = priv->clock.freq / (tsegall * bt->bitrate) + tseg % 2; ++ ++ /* choose brp step which is possible in system */ ++ brp = (brp / btc->brp_inc) * btc->brp_inc; ++ if (brp < btc->brp_min || brp > btc->brp_max) ++ continue; ++ ++ bitrate = priv->clock.freq / (brp * tsegall); ++ bitrate_error = abs(bt->bitrate - bitrate); ++ ++ /* tseg brp biterror */ ++ if (bitrate_error > best_bitrate_error) ++ continue; ++ ++ /* reset sample point error if we have a better bitrate */ ++ if (bitrate_error < best_bitrate_error) ++ best_sample_point_error = UINT_MAX; ++ ++ can_update_sample_point(btc, sample_point_nominal, tseg / 2, ++ &tseg1, &tseg2, &sample_point_error); ++ if (sample_point_error > best_sample_point_error) ++ continue; ++ ++ best_sample_point_error = sample_point_error; ++ best_bitrate_error = bitrate_error; ++ best_tseg = tseg / 2; ++ best_brp = brp; ++ ++ if (bitrate_error == 0 && sample_point_error == 0) ++ break; ++ } ++ ++ if (best_bitrate_error) { ++ /* Error in one-tenth of a percent */ ++ v64 = (u64)best_bitrate_error * 1000; ++ do_div(v64, bt->bitrate); ++ bitrate_error = (u32)v64; ++ if (bitrate_error > CAN_CALC_MAX_ERROR) { ++ netdev_err(dev, ++ "bitrate error %d.%d%% too high\n", ++ bitrate_error / 10, bitrate_error % 10); ++ return -EDOM; ++ } ++ netdev_warn(dev, "bitrate error %d.%d%%\n", ++ bitrate_error / 10, bitrate_error % 10); ++ } ++ ++ /* real sample point */ ++ bt->sample_point = can_update_sample_point(btc, sample_point_nominal, ++ best_tseg, &tseg1, &tseg2, ++ NULL); ++ ++ v64 = (u64)best_brp * 1000 * 1000 * 1000; ++ do_div(v64, priv->clock.freq); ++ bt->tq = (u32)v64; ++ bt->prop_seg = tseg1 / 2; ++ bt->phase_seg1 = tseg1 - bt->prop_seg; ++ bt->phase_seg2 = tseg2; ++ ++ /* check for sjw user settings */ ++ if (!bt->sjw || !btc->sjw_max) { ++ bt->sjw = 1; ++ } else { ++ /* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */ ++ if (bt->sjw > btc->sjw_max) ++ bt->sjw = btc->sjw_max; ++ /* bt->sjw must not be higher than tseg2 */ ++ if (tseg2 < bt->sjw) ++ bt->sjw = tseg2; ++ } ++ ++ bt->brp = best_brp; ++ ++ /* real bitrate */ ++ bt->bitrate = priv->clock.freq / ++ (bt->brp * (CAN_CALC_SYNC_SEG + tseg1 + tseg2)); ++ ++ return 0; ++} ++#else /* !CONFIG_CAN_CALC_BITTIMING */ ++static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt, ++ const struct can_bittiming_const *btc) ++{ ++ netdev_err(dev, "bit-timing calculation not available\n"); ++ return -EINVAL; ++} ++#endif /* CONFIG_CAN_CALC_BITTIMING */ ++ ++/* Checks the validity of the specified bit-timing parameters prop_seg, ++ * phase_seg1, phase_seg2 and sjw and tries to determine the bitrate ++ * prescaler value brp. You can find more information in the header ++ * file linux/can/netlink.h. ++ */ ++static int can_fixup_bittiming(struct net_device *dev, struct can_bittiming *bt, ++ const struct can_bittiming_const *btc) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ int tseg1, alltseg; ++ u64 brp64; ++ ++ tseg1 = bt->prop_seg + bt->phase_seg1; ++ if (!bt->sjw) ++ bt->sjw = 1; ++ if (bt->sjw > btc->sjw_max || ++ tseg1 < btc->tseg1_min || tseg1 > btc->tseg1_max || ++ bt->phase_seg2 < btc->tseg2_min || bt->phase_seg2 > btc->tseg2_max) ++ return -ERANGE; ++ ++ brp64 = (u64)priv->clock.freq * (u64)bt->tq; ++ if (btc->brp_inc > 1) ++ do_div(brp64, btc->brp_inc); ++ brp64 += 500000000UL - 1; ++ do_div(brp64, 1000000000UL); /* the practicable BRP */ ++ if (btc->brp_inc > 1) ++ brp64 *= btc->brp_inc; ++ bt->brp = (u32)brp64; ++ ++ if (bt->brp < btc->brp_min || bt->brp > btc->brp_max) ++ return -EINVAL; ++ ++ alltseg = bt->prop_seg + bt->phase_seg1 + bt->phase_seg2 + 1; ++ bt->bitrate = priv->clock.freq / (bt->brp * alltseg); ++ bt->sample_point = ((tseg1 + 1) * 1000) / alltseg; ++ ++ return 0; ++} ++ ++/* Checks the validity of predefined bitrate settings */ ++static int ++can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt, ++ const u32 *bitrate_const, ++ const unsigned int bitrate_const_cnt) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ unsigned int i; ++ ++ for (i = 0; i < bitrate_const_cnt; i++) { ++ if (bt->bitrate == bitrate_const[i]) ++ break; ++ } ++ ++ if (i >= priv->bitrate_const_cnt) ++ return -EINVAL; ++ ++ return 0; ++} ++ ++static int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt, ++ const struct can_bittiming_const *btc, ++ const u32 *bitrate_const, ++ const unsigned int bitrate_const_cnt) ++{ ++ int err; ++ ++ /* Depending on the given can_bittiming parameter structure the CAN ++ * timing parameters are calculated based on the provided bitrate OR ++ * alternatively the CAN timing parameters (tq, prop_seg, etc.) are ++ * provided directly which are then checked and fixed up. ++ */ ++ if (!bt->tq && bt->bitrate && btc) ++ err = can_calc_bittiming(dev, bt, btc); ++ else if (bt->tq && !bt->bitrate && btc) ++ err = can_fixup_bittiming(dev, bt, btc); ++ else if (!bt->tq && bt->bitrate && bitrate_const) ++ err = can_validate_bitrate(dev, bt, bitrate_const, ++ bitrate_const_cnt); ++ else ++ err = -EINVAL; ++ ++ return err; ++} ++ ++static void can_update_state_error_stats(struct net_device *dev, ++ enum can_state new_state) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ if (new_state <= priv->state) ++ return; ++ ++ switch (new_state) { ++ case CAN_STATE_ERROR_WARNING: ++ priv->can_stats.error_warning++; ++ break; ++ case CAN_STATE_ERROR_PASSIVE: ++ priv->can_stats.error_passive++; ++ break; ++ case CAN_STATE_BUS_OFF: ++ priv->can_stats.bus_off++; ++ break; ++ default: ++ break; ++ } ++} ++ ++static int can_tx_state_to_frame(struct net_device *dev, enum can_state state) ++{ ++ switch (state) { ++ case CAN_STATE_ERROR_ACTIVE: ++ return CAN_ERR_CRTL_ACTIVE; ++ case CAN_STATE_ERROR_WARNING: ++ return CAN_ERR_CRTL_TX_WARNING; ++ case CAN_STATE_ERROR_PASSIVE: ++ return CAN_ERR_CRTL_TX_PASSIVE; ++ default: ++ return 0; ++ } ++} ++ ++static int can_rx_state_to_frame(struct net_device *dev, enum can_state state) ++{ ++ switch (state) { ++ case CAN_STATE_ERROR_ACTIVE: ++ return CAN_ERR_CRTL_ACTIVE; ++ case CAN_STATE_ERROR_WARNING: ++ return CAN_ERR_CRTL_RX_WARNING; ++ case CAN_STATE_ERROR_PASSIVE: ++ return CAN_ERR_CRTL_RX_PASSIVE; ++ default: ++ return 0; ++ } ++} ++ ++void can_change_state(struct net_device *dev, struct can_frame *cf, ++ enum can_state tx_state, enum can_state rx_state) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ enum can_state new_state = max(tx_state, rx_state); ++ ++ if (unlikely(new_state == priv->state)) { ++ netdev_warn(dev, "%s: oops, state did not change", __func__); ++ return; ++ } ++ ++ netdev_dbg(dev, "New error state: %d\n", new_state); ++ ++ can_update_state_error_stats(dev, new_state); ++ priv->state = new_state; ++ ++ if (!cf) ++ return; ++ ++ if (unlikely(new_state == CAN_STATE_BUS_OFF)) { ++ cf->can_id |= CAN_ERR_BUSOFF; ++ return; ++ } ++ ++ cf->can_id |= CAN_ERR_CRTL; ++ cf->data[1] |= tx_state >= rx_state ? ++ can_tx_state_to_frame(dev, tx_state) : 0; ++ cf->data[1] |= tx_state <= rx_state ? ++ can_rx_state_to_frame(dev, rx_state) : 0; ++} ++EXPORT_SYMBOL_GPL(can_change_state); ++ ++/* Local echo of CAN messages ++ * ++ * CAN network devices *should* support a local echo functionality ++ * (see Documentation/networking/can.rst). To test the handling of CAN ++ * interfaces that do not support the local echo both driver types are ++ * implemented. In the case that the driver does not support the echo ++ * the IFF_ECHO remains clear in dev->flags. This causes the PF_CAN core ++ * to perform the echo as a fallback solution. ++ */ ++static void can_flush_echo_skb(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ struct net_device_stats *stats = &dev->stats; ++ int i; ++ ++ for (i = 0; i < priv->echo_skb_max; i++) { ++ if (priv->echo_skb[i]) { ++ kfree_skb(priv->echo_skb[i]); ++ priv->echo_skb[i] = NULL; ++ stats->tx_dropped++; ++ stats->tx_aborted_errors++; ++ } ++ } ++} ++ ++/* Put the skb on the stack to be looped backed locally lateron ++ * ++ * The function is typically called in the start_xmit function ++ * of the device driver. The driver must protect access to ++ * priv->echo_skb, if necessary. ++ */ ++void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev, ++ unsigned int idx) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ BUG_ON(idx >= priv->echo_skb_max); ++ ++ /* check flag whether this packet has to be looped back */ ++ if (!(dev->flags & IFF_ECHO) || skb->pkt_type != PACKET_LOOPBACK || ++ (skb->protocol != htons(ETH_P_CAN) && ++ skb->protocol != htons(ETH_P_CANFD))) { ++ kfree_skb(skb); ++ return; ++ } ++ ++ if (!priv->echo_skb[idx]) { ++ skb = can_create_echo_skb(skb); ++ if (!skb) ++ return; ++ ++ /* make settings for echo to reduce code in irq context */ ++ skb->pkt_type = PACKET_BROADCAST; ++ skb->ip_summed = CHECKSUM_UNNECESSARY; ++ skb->dev = dev; ++ ++ /* save this skb for tx interrupt echo handling */ ++ priv->echo_skb[idx] = skb; ++ } else { ++ /* locking problem with netif_stop_queue() ?? */ ++ netdev_err(dev, "%s: BUG! echo_skb is occupied!\n", __func__); ++ kfree_skb(skb); ++ } ++} ++EXPORT_SYMBOL_GPL(can_put_echo_skb); ++ ++struct sk_buff * ++__can_get_echo_skb(struct net_device *dev, unsigned int idx, u8 *len_ptr) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ if (idx >= priv->echo_skb_max) { ++ netdev_err(dev, "%s: BUG! Trying to access can_priv::echo_skb out of bounds (%u/max %u)\n", ++ __func__, idx, priv->echo_skb_max); ++ return NULL; ++ } ++ ++ if (priv->echo_skb[idx]) { ++ /* Using "struct canfd_frame::len" for the frame ++ * length is supported on both CAN and CANFD frames. ++ */ ++ struct sk_buff *skb = priv->echo_skb[idx]; ++ struct canfd_frame *cf = (struct canfd_frame *)skb->data; ++ ++ /* get the real payload length for netdev statistics */ ++ if (cf->can_id & CAN_RTR_FLAG) ++ *len_ptr = 0; ++ else ++ *len_ptr = cf->len; ++ ++ priv->echo_skb[idx] = NULL; ++ ++ return skb; ++ } ++ ++ return NULL; ++} ++ ++/* Get the skb from the stack and loop it back locally ++ * ++ * The function is typically called when the TX done interrupt ++ * is handled in the device driver. The driver must protect ++ * access to priv->echo_skb, if necessary. ++ */ ++unsigned int can_get_echo_skb(struct net_device *dev, unsigned int idx) ++{ ++ struct sk_buff *skb; ++ u8 len; ++ ++ skb = __can_get_echo_skb(dev, idx, &len); ++ if (!skb) ++ return 0; ++ ++ skb_get(skb); ++ if (netif_rx(skb) == NET_RX_SUCCESS) ++ dev_consume_skb_any(skb); ++ else ++ dev_kfree_skb_any(skb); ++ ++ return len; ++} ++EXPORT_SYMBOL_GPL(can_get_echo_skb); ++ ++/* Remove the skb from the stack and free it. ++ * ++ * The function is typically called when TX failed. ++ */ ++void can_free_echo_skb(struct net_device *dev, unsigned int idx) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ BUG_ON(idx >= priv->echo_skb_max); ++ ++ if (priv->echo_skb[idx]) { ++ dev_kfree_skb_any(priv->echo_skb[idx]); ++ priv->echo_skb[idx] = NULL; ++ } ++} ++EXPORT_SYMBOL_GPL(can_free_echo_skb); ++ ++/* CAN device restart for bus-off recovery */ ++static void can_restart(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ struct net_device_stats *stats = &dev->stats; ++ struct sk_buff *skb; ++ struct can_frame *cf; ++ int err; ++ ++ BUG_ON(netif_carrier_ok(dev)); ++ ++ /* No synchronization needed because the device is bus-off and ++ * no messages can come in or go out. ++ */ ++ can_flush_echo_skb(dev); ++ ++ /* send restart message upstream */ ++ skb = alloc_can_err_skb(dev, &cf); ++ if (!skb) { ++ err = -ENOMEM; ++ goto restart; ++ } ++ cf->can_id |= CAN_ERR_RESTARTED; ++ ++ stats->rx_packets++; ++ stats->rx_bytes += cf->can_dlc; ++ ++ netif_rx_ni(skb); ++ ++restart: ++ netdev_dbg(dev, "restarted\n"); ++ priv->can_stats.restarts++; ++ ++ /* Now restart the device */ ++ err = priv->do_set_mode(dev, CAN_MODE_START); ++ ++ netif_carrier_on(dev); ++ if (err) ++ netdev_err(dev, "Error %d during restart", err); ++} ++ ++static void can_restart_work(struct work_struct *work) ++{ ++ struct delayed_work *dwork = to_delayed_work(work); ++ struct can_priv *priv = container_of(dwork, struct can_priv, ++ restart_work); ++ ++ can_restart(priv->dev); ++} ++ ++int can_restart_now(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ /* A manual restart is only permitted if automatic restart is ++ * disabled and the device is in the bus-off state ++ */ ++ if (priv->restart_ms) ++ return -EINVAL; ++ if (priv->state != CAN_STATE_BUS_OFF) ++ return -EBUSY; ++ ++ cancel_delayed_work_sync(&priv->restart_work); ++ can_restart(dev); ++ ++ return 0; ++} ++ ++/* CAN bus-off ++ * ++ * This functions should be called when the device goes bus-off to ++ * tell the netif layer that no more packets can be sent or received. ++ * If enabled, a timer is started to trigger bus-off recovery. ++ */ ++void can_bus_off(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ netdev_info(dev, "bus-off\n"); ++ ++ netif_carrier_off(dev); ++ ++ if (priv->restart_ms) ++ schedule_delayed_work(&priv->restart_work, ++ msecs_to_jiffies(priv->restart_ms)); ++} ++EXPORT_SYMBOL_GPL(can_bus_off); ++ ++static void can_setup(struct net_device *dev) ++{ ++ dev->type = ARPHRD_CAN; ++ dev->mtu = CAN_MTU; ++ dev->hard_header_len = 0; ++ dev->addr_len = 0; ++ dev->tx_queue_len = 10; ++ ++ /* New-style flags. */ ++ dev->flags = IFF_NOARP; ++ dev->features = NETIF_F_HW_CSUM; ++} ++ ++struct sk_buff *alloc_can_skb(struct net_device *dev, struct can_frame **cf) ++{ ++ struct sk_buff *skb; ++ ++ skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) + ++ sizeof(struct can_frame)); ++ if (unlikely(!skb)) ++ return NULL; ++ ++ skb->protocol = htons(ETH_P_CAN); ++ skb->pkt_type = PACKET_BROADCAST; ++ skb->ip_summed = CHECKSUM_UNNECESSARY; ++ ++ skb_reset_mac_header(skb); ++ skb_reset_network_header(skb); ++ skb_reset_transport_header(skb); ++ ++ can_skb_reserve(skb); ++ can_skb_prv(skb)->ifindex = dev->ifindex; ++ can_skb_prv(skb)->skbcnt = 0; ++ ++ *cf = skb_put_zero(skb, sizeof(struct can_frame)); ++ ++ return skb; ++} ++EXPORT_SYMBOL_GPL(alloc_can_skb); ++ ++struct sk_buff *alloc_canfd_skb(struct net_device *dev, ++ struct canfd_frame **cfd) ++{ ++ struct sk_buff *skb; ++ ++ skb = netdev_alloc_skb(dev, sizeof(struct can_skb_priv) + ++ sizeof(struct canfd_frame)); ++ if (unlikely(!skb)) ++ return NULL; ++ ++ skb->protocol = htons(ETH_P_CANFD); ++ skb->pkt_type = PACKET_BROADCAST; ++ skb->ip_summed = CHECKSUM_UNNECESSARY; ++ ++ skb_reset_mac_header(skb); ++ skb_reset_network_header(skb); ++ skb_reset_transport_header(skb); ++ ++ can_skb_reserve(skb); ++ can_skb_prv(skb)->ifindex = dev->ifindex; ++ can_skb_prv(skb)->skbcnt = 0; ++ ++ *cfd = skb_put_zero(skb, sizeof(struct canfd_frame)); ++ ++ return skb; ++} ++EXPORT_SYMBOL_GPL(alloc_canfd_skb); ++ ++struct sk_buff *alloc_can_err_skb(struct net_device *dev, struct can_frame **cf) ++{ ++ struct sk_buff *skb; ++ ++ skb = alloc_can_skb(dev, cf); ++ if (unlikely(!skb)) ++ return NULL; ++ ++ (*cf)->can_id = CAN_ERR_FLAG; ++ (*cf)->can_dlc = CAN_ERR_DLC; ++ ++ return skb; ++} ++EXPORT_SYMBOL_GPL(alloc_can_err_skb); ++ ++/* Allocate and setup space for the CAN network device */ ++struct net_device *alloc_candev_mqs(int sizeof_priv, unsigned int echo_skb_max, ++ unsigned int txqs, unsigned int rxqs) ++{ ++ struct can_ml_priv *can_ml; ++ struct net_device *dev; ++ struct can_priv *priv; ++ int size; ++ ++ /* We put the driver's priv, the CAN mid layer priv and the ++ * echo skb into the netdevice's priv. The memory layout for ++ * the netdev_priv is like this: ++ * ++ * +-------------------------+ ++ * | driver's priv | ++ * +-------------------------+ ++ * | struct can_ml_priv | ++ * +-------------------------+ ++ * | array of struct sk_buff | ++ * +-------------------------+ ++ */ ++ ++ size = ALIGN(sizeof_priv, NETDEV_ALIGN) + sizeof(struct can_ml_priv); ++ ++ if (echo_skb_max) ++ size = ALIGN(size, sizeof(struct sk_buff *)) + ++ echo_skb_max * sizeof(struct sk_buff *); ++ ++ dev = alloc_netdev_mqs(size, "can%d", NET_NAME_UNKNOWN, can_setup, ++ txqs, rxqs); ++ if (!dev) ++ return NULL; ++ ++ priv = netdev_priv(dev); ++ priv->dev = dev; ++ ++ can_ml = (void *)priv + ALIGN(sizeof_priv, NETDEV_ALIGN); ++ can_set_ml_priv(dev, can_ml); ++ ++ if (echo_skb_max) { ++ priv->echo_skb_max = echo_skb_max; ++ priv->echo_skb = (void *)priv + ++ (size - echo_skb_max * sizeof(struct sk_buff *)); ++ } ++ ++ priv->state = CAN_STATE_STOPPED; ++ ++ INIT_DELAYED_WORK(&priv->restart_work, can_restart_work); ++ ++ return dev; ++} ++EXPORT_SYMBOL_GPL(alloc_candev_mqs); ++ ++/* Free space of the CAN network device */ ++void free_candev(struct net_device *dev) ++{ ++ free_netdev(dev); ++} ++EXPORT_SYMBOL_GPL(free_candev); ++ ++/* changing MTU and control mode for CAN/CANFD devices */ ++int can_change_mtu(struct net_device *dev, int new_mtu) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ /* Do not allow changing the MTU while running */ ++ if (dev->flags & IFF_UP) ++ return -EBUSY; ++ ++ /* allow change of MTU according to the CANFD ability of the device */ ++ switch (new_mtu) { ++ case CAN_MTU: ++ /* 'CANFD-only' controllers can not switch to CAN_MTU */ ++ if (priv->ctrlmode_static & CAN_CTRLMODE_FD) ++ return -EINVAL; ++ ++ priv->ctrlmode &= ~CAN_CTRLMODE_FD; ++ break; ++ ++ case CANFD_MTU: ++ /* check for potential CANFD ability */ ++ if (!(priv->ctrlmode_supported & CAN_CTRLMODE_FD) && ++ !(priv->ctrlmode_static & CAN_CTRLMODE_FD)) ++ return -EINVAL; ++ ++ priv->ctrlmode |= CAN_CTRLMODE_FD; ++ break; ++ ++ default: ++ return -EINVAL; ++ } ++ ++ dev->mtu = new_mtu; ++ return 0; ++} ++EXPORT_SYMBOL_GPL(can_change_mtu); ++ ++/* Common open function when the device gets opened. ++ * ++ * This function should be called in the open function of the device ++ * driver. ++ */ ++int open_candev(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ if (!priv->bittiming.bitrate) { ++ netdev_err(dev, "bit-timing not yet defined\n"); ++ return -EINVAL; ++ } ++ ++ /* For CAN FD the data bitrate has to be >= the arbitration bitrate */ ++ if ((priv->ctrlmode & CAN_CTRLMODE_FD) && ++ (!priv->data_bittiming.bitrate || ++ priv->data_bittiming.bitrate < priv->bittiming.bitrate)) { ++ netdev_err(dev, "incorrect/missing data bit-timing\n"); ++ return -EINVAL; ++ } ++ ++ /* Switch carrier on if device was stopped while in bus-off state */ ++ if (!netif_carrier_ok(dev)) ++ netif_carrier_on(dev); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(open_candev); ++ ++#ifdef CONFIG_OF ++/* Common function that can be used to understand the limitation of ++ * a transceiver when it provides no means to determine these limitations ++ * at runtime. ++ */ ++void of_can_transceiver(struct net_device *dev) ++{ ++ struct device_node *dn; ++ struct can_priv *priv = netdev_priv(dev); ++ struct device_node *np = dev->dev.parent->of_node; ++ int ret; ++ ++ dn = of_get_child_by_name(np, "can-transceiver"); ++ if (!dn) ++ return; ++ ++ ret = of_property_read_u32(dn, "max-bitrate", &priv->bitrate_max); ++ of_node_put(dn); ++ if ((ret && ret != -EINVAL) || (!ret && !priv->bitrate_max)) ++ netdev_warn(dev, "Invalid value for transceiver max bitrate. Ignoring bitrate limit.\n"); ++} ++EXPORT_SYMBOL_GPL(of_can_transceiver); ++#endif ++ ++/* Common close function for cleanup before the device gets closed. ++ * ++ * This function should be called in the close function of the device ++ * driver. ++ */ ++void close_candev(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ cancel_delayed_work_sync(&priv->restart_work); ++ can_flush_echo_skb(dev); ++} ++EXPORT_SYMBOL_GPL(close_candev); ++ ++/* CAN netlink interface */ ++static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = { ++ [IFLA_CAN_STATE] = { .type = NLA_U32 }, ++ [IFLA_CAN_CTRLMODE] = { .len = sizeof(struct can_ctrlmode) }, ++ [IFLA_CAN_RESTART_MS] = { .type = NLA_U32 }, ++ [IFLA_CAN_RESTART] = { .type = NLA_U32 }, ++ [IFLA_CAN_BITTIMING] = { .len = sizeof(struct can_bittiming) }, ++ [IFLA_CAN_BITTIMING_CONST] ++ = { .len = sizeof(struct can_bittiming_const) }, ++ [IFLA_CAN_CLOCK] = { .len = sizeof(struct can_clock) }, ++ [IFLA_CAN_BERR_COUNTER] = { .len = sizeof(struct can_berr_counter) }, ++ [IFLA_CAN_DATA_BITTIMING] ++ = { .len = sizeof(struct can_bittiming) }, ++ [IFLA_CAN_DATA_BITTIMING_CONST] ++ = { .len = sizeof(struct can_bittiming_const) }, ++ [IFLA_CAN_TERMINATION] = { .type = NLA_U16 }, ++}; ++ ++static int can_validate(struct nlattr *tb[], struct nlattr *data[], ++ struct netlink_ext_ack *extack) ++{ ++ bool is_can_fd = false; ++ ++ /* Make sure that valid CAN FD configurations always consist of ++ * - nominal/arbitration bittiming ++ * - data bittiming ++ * - control mode with CAN_CTRLMODE_FD set ++ */ ++ ++ if (!data) ++ return 0; ++ ++ if (data[IFLA_CAN_CTRLMODE]) { ++ struct can_ctrlmode *cm = nla_data(data[IFLA_CAN_CTRLMODE]); ++ ++ is_can_fd = cm->flags & cm->mask & CAN_CTRLMODE_FD; ++ } ++ ++ if (is_can_fd) { ++ if (!data[IFLA_CAN_BITTIMING] || !data[IFLA_CAN_DATA_BITTIMING]) ++ return -EOPNOTSUPP; ++ } ++ ++ if (data[IFLA_CAN_DATA_BITTIMING]) { ++ if (!is_can_fd || !data[IFLA_CAN_BITTIMING]) ++ return -EOPNOTSUPP; ++ } ++ ++ return 0; ++} ++ ++static int can_changelink(struct net_device *dev, struct nlattr *tb[], ++ struct nlattr *data[], ++ struct netlink_ext_ack *extack) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ int err; ++ ++ /* We need synchronization with dev->stop() */ ++ ASSERT_RTNL(); ++ ++ if (data[IFLA_CAN_BITTIMING]) { ++ struct can_bittiming bt; ++ ++ /* Do not allow changing bittiming while running */ ++ if (dev->flags & IFF_UP) ++ return -EBUSY; ++ ++ /* Calculate bittiming parameters based on ++ * bittiming_const if set, otherwise pass bitrate ++ * directly via do_set_bitrate(). Bail out if neither ++ * is given. ++ */ ++ if (!priv->bittiming_const && !priv->do_set_bittiming) ++ return -EOPNOTSUPP; ++ ++ memcpy(&bt, nla_data(data[IFLA_CAN_BITTIMING]), sizeof(bt)); ++ err = can_get_bittiming(dev, &bt, ++ priv->bittiming_const, ++ priv->bitrate_const, ++ priv->bitrate_const_cnt); ++ if (err) ++ return err; ++ ++ if (priv->bitrate_max && bt.bitrate > priv->bitrate_max) { ++ netdev_err(dev, "arbitration bitrate surpasses transceiver capabilities of %d bps\n", ++ priv->bitrate_max); ++ return -EINVAL; ++ } ++ ++ memcpy(&priv->bittiming, &bt, sizeof(bt)); ++ ++ if (priv->do_set_bittiming) { ++ /* Finally, set the bit-timing registers */ ++ err = priv->do_set_bittiming(dev); ++ if (err) ++ return err; ++ } ++ } ++ ++ if (data[IFLA_CAN_CTRLMODE]) { ++ struct can_ctrlmode *cm; ++ u32 ctrlstatic; ++ u32 maskedflags; ++ ++ /* Do not allow changing controller mode while running */ ++ if (dev->flags & IFF_UP) ++ return -EBUSY; ++ cm = nla_data(data[IFLA_CAN_CTRLMODE]); ++ ctrlstatic = priv->ctrlmode_static; ++ maskedflags = cm->flags & cm->mask; ++ ++ /* check whether provided bits are allowed to be passed */ ++ if (cm->mask & ~(priv->ctrlmode_supported | ctrlstatic)) ++ return -EOPNOTSUPP; ++ ++ /* do not check for static fd-non-iso if 'fd' is disabled */ ++ if (!(maskedflags & CAN_CTRLMODE_FD)) ++ ctrlstatic &= ~CAN_CTRLMODE_FD_NON_ISO; ++ ++ /* make sure static options are provided by configuration */ ++ if ((maskedflags & ctrlstatic) != ctrlstatic) ++ return -EOPNOTSUPP; ++ ++ /* clear bits to be modified and copy the flag values */ ++ priv->ctrlmode &= ~cm->mask; ++ priv->ctrlmode |= maskedflags; ++ ++ /* CAN_CTRLMODE_FD can only be set when driver supports FD */ ++ if (priv->ctrlmode & CAN_CTRLMODE_FD) ++ dev->mtu = CANFD_MTU; ++ else ++ dev->mtu = CAN_MTU; ++ } ++ ++ if (data[IFLA_CAN_RESTART_MS]) { ++ /* Do not allow changing restart delay while running */ ++ if (dev->flags & IFF_UP) ++ return -EBUSY; ++ priv->restart_ms = nla_get_u32(data[IFLA_CAN_RESTART_MS]); ++ } ++ ++ if (data[IFLA_CAN_RESTART]) { ++ /* Do not allow a restart while not running */ ++ if (!(dev->flags & IFF_UP)) ++ return -EINVAL; ++ err = can_restart_now(dev); ++ if (err) ++ return err; ++ } ++ ++ if (data[IFLA_CAN_DATA_BITTIMING]) { ++ struct can_bittiming dbt; ++ ++ /* Do not allow changing bittiming while running */ ++ if (dev->flags & IFF_UP) ++ return -EBUSY; ++ ++ /* Calculate bittiming parameters based on ++ * data_bittiming_const if set, otherwise pass bitrate ++ * directly via do_set_bitrate(). Bail out if neither ++ * is given. ++ */ ++ if (!priv->data_bittiming_const && !priv->do_set_data_bittiming) ++ return -EOPNOTSUPP; ++ ++ memcpy(&dbt, nla_data(data[IFLA_CAN_DATA_BITTIMING]), ++ sizeof(dbt)); ++ err = can_get_bittiming(dev, &dbt, ++ priv->data_bittiming_const, ++ priv->data_bitrate_const, ++ priv->data_bitrate_const_cnt); ++ if (err) ++ return err; ++ ++ if (priv->bitrate_max && dbt.bitrate > priv->bitrate_max) { ++ netdev_err(dev, "canfd data bitrate surpasses transceiver capabilities of %d bps\n", ++ priv->bitrate_max); ++ return -EINVAL; ++ } ++ ++ memcpy(&priv->data_bittiming, &dbt, sizeof(dbt)); ++ ++ if (priv->do_set_data_bittiming) { ++ /* Finally, set the bit-timing registers */ ++ err = priv->do_set_data_bittiming(dev); ++ if (err) ++ return err; ++ } ++ } ++ ++ if (data[IFLA_CAN_TERMINATION]) { ++ const u16 termval = nla_get_u16(data[IFLA_CAN_TERMINATION]); ++ const unsigned int num_term = priv->termination_const_cnt; ++ unsigned int i; ++ ++ if (!priv->do_set_termination) ++ return -EOPNOTSUPP; ++ ++ /* check whether given value is supported by the interface */ ++ for (i = 0; i < num_term; i++) { ++ if (termval == priv->termination_const[i]) ++ break; ++ } ++ if (i >= num_term) ++ return -EINVAL; ++ ++ /* Finally, set the termination value */ ++ err = priv->do_set_termination(dev, termval); ++ if (err) ++ return err; ++ ++ priv->termination = termval; ++ } ++ ++ return 0; ++} ++ ++static size_t can_get_size(const struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ size_t size = 0; ++ ++ if (priv->bittiming.bitrate) /* IFLA_CAN_BITTIMING */ ++ size += nla_total_size(sizeof(struct can_bittiming)); ++ if (priv->bittiming_const) /* IFLA_CAN_BITTIMING_CONST */ ++ size += nla_total_size(sizeof(struct can_bittiming_const)); ++ size += nla_total_size(sizeof(struct can_clock)); /* IFLA_CAN_CLOCK */ ++ size += nla_total_size(sizeof(u32)); /* IFLA_CAN_STATE */ ++ size += nla_total_size(sizeof(struct can_ctrlmode)); /* IFLA_CAN_CTRLMODE */ ++ size += nla_total_size(sizeof(u32)); /* IFLA_CAN_RESTART_MS */ ++ if (priv->do_get_berr_counter) /* IFLA_CAN_BERR_COUNTER */ ++ size += nla_total_size(sizeof(struct can_berr_counter)); ++ if (priv->data_bittiming.bitrate) /* IFLA_CAN_DATA_BITTIMING */ ++ size += nla_total_size(sizeof(struct can_bittiming)); ++ if (priv->data_bittiming_const) /* IFLA_CAN_DATA_BITTIMING_CONST */ ++ size += nla_total_size(sizeof(struct can_bittiming_const)); ++ if (priv->termination_const) { ++ size += nla_total_size(sizeof(priv->termination)); /* IFLA_CAN_TERMINATION */ ++ size += nla_total_size(sizeof(*priv->termination_const) * /* IFLA_CAN_TERMINATION_CONST */ ++ priv->termination_const_cnt); ++ } ++ if (priv->bitrate_const) /* IFLA_CAN_BITRATE_CONST */ ++ size += nla_total_size(sizeof(*priv->bitrate_const) * ++ priv->bitrate_const_cnt); ++ if (priv->data_bitrate_const) /* IFLA_CAN_DATA_BITRATE_CONST */ ++ size += nla_total_size(sizeof(*priv->data_bitrate_const) * ++ priv->data_bitrate_const_cnt); ++ size += sizeof(priv->bitrate_max); /* IFLA_CAN_BITRATE_MAX */ ++ ++ return size; ++} ++ ++static int can_fill_info(struct sk_buff *skb, const struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ struct can_ctrlmode cm = {.flags = priv->ctrlmode}; ++ struct can_berr_counter bec = { }; ++ enum can_state state = priv->state; ++ ++ if (priv->do_get_state) ++ priv->do_get_state(dev, &state); ++ ++ if ((priv->bittiming.bitrate && ++ nla_put(skb, IFLA_CAN_BITTIMING, ++ sizeof(priv->bittiming), &priv->bittiming)) || ++ ++ (priv->bittiming_const && ++ nla_put(skb, IFLA_CAN_BITTIMING_CONST, ++ sizeof(*priv->bittiming_const), priv->bittiming_const)) || ++ ++ nla_put(skb, IFLA_CAN_CLOCK, sizeof(priv->clock), &priv->clock) || ++ nla_put_u32(skb, IFLA_CAN_STATE, state) || ++ nla_put(skb, IFLA_CAN_CTRLMODE, sizeof(cm), &cm) || ++ nla_put_u32(skb, IFLA_CAN_RESTART_MS, priv->restart_ms) || ++ ++ (priv->do_get_berr_counter && ++ !priv->do_get_berr_counter(dev, &bec) && ++ nla_put(skb, IFLA_CAN_BERR_COUNTER, sizeof(bec), &bec)) || ++ ++ (priv->data_bittiming.bitrate && ++ nla_put(skb, IFLA_CAN_DATA_BITTIMING, ++ sizeof(priv->data_bittiming), &priv->data_bittiming)) || ++ ++ (priv->data_bittiming_const && ++ nla_put(skb, IFLA_CAN_DATA_BITTIMING_CONST, ++ sizeof(*priv->data_bittiming_const), ++ priv->data_bittiming_const)) || ++ ++ (priv->termination_const && ++ (nla_put_u16(skb, IFLA_CAN_TERMINATION, priv->termination) || ++ nla_put(skb, IFLA_CAN_TERMINATION_CONST, ++ sizeof(*priv->termination_const) * ++ priv->termination_const_cnt, ++ priv->termination_const))) || ++ ++ (priv->bitrate_const && ++ nla_put(skb, IFLA_CAN_BITRATE_CONST, ++ sizeof(*priv->bitrate_const) * ++ priv->bitrate_const_cnt, ++ priv->bitrate_const)) || ++ ++ (priv->data_bitrate_const && ++ nla_put(skb, IFLA_CAN_DATA_BITRATE_CONST, ++ sizeof(*priv->data_bitrate_const) * ++ priv->data_bitrate_const_cnt, ++ priv->data_bitrate_const)) || ++ ++ (nla_put(skb, IFLA_CAN_BITRATE_MAX, ++ sizeof(priv->bitrate_max), ++ &priv->bitrate_max)) ++ ) ++ ++ return -EMSGSIZE; ++ ++ return 0; ++} ++ ++static size_t can_get_xstats_size(const struct net_device *dev) ++{ ++ return sizeof(struct can_device_stats); ++} ++ ++static int can_fill_xstats(struct sk_buff *skb, const struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ if (nla_put(skb, IFLA_INFO_XSTATS, ++ sizeof(priv->can_stats), &priv->can_stats)) ++ goto nla_put_failure; ++ return 0; ++ ++nla_put_failure: ++ return -EMSGSIZE; ++} ++ ++static int can_newlink(struct net *src_net, struct net_device *dev, ++ struct nlattr *tb[], struct nlattr *data[], ++ struct netlink_ext_ack *extack) ++{ ++ return -EOPNOTSUPP; ++} ++ ++static void can_dellink(struct net_device *dev, struct list_head *head) ++{ ++} ++ ++static struct rtnl_link_ops can_link_ops __read_mostly = { ++ .kind = "can", ++ .netns_refund = true, ++ .maxtype = IFLA_CAN_MAX, ++ .policy = can_policy, ++ .setup = can_setup, ++ .validate = can_validate, ++ .newlink = can_newlink, ++ .changelink = can_changelink, ++ .dellink = can_dellink, ++ .get_size = can_get_size, ++ .fill_info = can_fill_info, ++ .get_xstats_size = can_get_xstats_size, ++ .fill_xstats = can_fill_xstats, ++}; ++ ++/* Register the CAN network device */ ++int register_candev(struct net_device *dev) ++{ ++ struct can_priv *priv = netdev_priv(dev); ++ ++ /* Ensure termination_const, termination_const_cnt and ++ * do_set_termination consistency. All must be either set or ++ * unset. ++ */ ++ if ((!priv->termination_const != !priv->termination_const_cnt) || ++ (!priv->termination_const != !priv->do_set_termination)) ++ return -EINVAL; ++ ++ if (!priv->bitrate_const != !priv->bitrate_const_cnt) ++ return -EINVAL; ++ ++ if (!priv->data_bitrate_const != !priv->data_bitrate_const_cnt) ++ return -EINVAL; ++ ++ dev->rtnl_link_ops = &can_link_ops; ++ netif_carrier_off(dev); ++ ++ return register_netdev(dev); ++} ++EXPORT_SYMBOL_GPL(register_candev); ++ ++/* Unregister the CAN network device */ ++void unregister_candev(struct net_device *dev) ++{ ++ unregister_netdev(dev); ++} ++EXPORT_SYMBOL_GPL(unregister_candev); ++ ++/* Test if a network device is a candev based device ++ * and return the can_priv* if so. ++ */ ++struct can_priv *safe_candev_priv(struct net_device *dev) ++{ ++ if (dev->type != ARPHRD_CAN || dev->rtnl_link_ops != &can_link_ops) ++ return NULL; ++ ++ return netdev_priv(dev); ++} ++EXPORT_SYMBOL_GPL(safe_candev_priv); ++ ++static __init int can_dev_init(void) ++{ ++ int err; ++ ++ can_led_notifier_init(); ++ ++ err = rtnl_link_register(&can_link_ops); ++ if (!err) ++ pr_info(MOD_DESC "\n"); ++ ++ return err; ++} ++module_init(can_dev_init); ++ ++static __exit void can_dev_exit(void) ++{ ++ rtnl_link_unregister(&can_link_ops); ++ ++ can_led_notifier_exit(); ++} ++module_exit(can_dev_exit); ++ ++MODULE_ALIAS_RTNL_LINK("can"); +diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c +new file mode 100644 +index 0000000000000..7e75a87a8a6a9 +--- /dev/null ++++ b/drivers/net/can/dev/rx-offload.c +@@ -0,0 +1,395 @@ ++// SPDX-License-Identifier: GPL-2.0-only ++/* ++ * Copyright (c) 2014 David Jander, Protonic Holland ++ * Copyright (C) 2014-2017 Pengutronix, Marc Kleine-Budde ++ */ ++ ++#include ++#include ++ ++struct can_rx_offload_cb { ++ u32 timestamp; ++}; ++ ++static inline struct can_rx_offload_cb *can_rx_offload_get_cb(struct sk_buff *skb) ++{ ++ BUILD_BUG_ON(sizeof(struct can_rx_offload_cb) > sizeof(skb->cb)); ++ ++ return (struct can_rx_offload_cb *)skb->cb; ++} ++ ++static inline bool can_rx_offload_le(struct can_rx_offload *offload, unsigned int a, unsigned int b) ++{ ++ if (offload->inc) ++ return a <= b; ++ else ++ return a >= b; ++} ++ ++static inline unsigned int can_rx_offload_inc(struct can_rx_offload *offload, unsigned int *val) ++{ ++ if (offload->inc) ++ return (*val)++; ++ else ++ return (*val)--; ++} ++ ++static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota) ++{ ++ struct can_rx_offload *offload = container_of(napi, struct can_rx_offload, napi); ++ struct net_device *dev = offload->dev; ++ struct net_device_stats *stats = &dev->stats; ++ struct sk_buff *skb; ++ int work_done = 0; ++ ++ while ((work_done < quota) && ++ (skb = skb_dequeue(&offload->skb_queue))) { ++ struct can_frame *cf = (struct can_frame *)skb->data; ++ ++ work_done++; ++ stats->rx_packets++; ++ stats->rx_bytes += cf->can_dlc; ++ netif_receive_skb(skb); ++ } ++ ++ if (work_done < quota) { ++ napi_complete_done(napi, work_done); ++ ++ /* Check if there was another interrupt */ ++ if (!skb_queue_empty(&offload->skb_queue)) ++ napi_reschedule(&offload->napi); ++ } ++ ++ can_led_event(offload->dev, CAN_LED_EVENT_RX); ++ ++ return work_done; ++} ++ ++static inline void __skb_queue_add_sort(struct sk_buff_head *head, struct sk_buff *new, ++ int (*compare)(struct sk_buff *a, struct sk_buff *b)) ++{ ++ struct sk_buff *pos, *insert = NULL; ++ ++ skb_queue_reverse_walk(head, pos) { ++ const struct can_rx_offload_cb *cb_pos, *cb_new; ++ ++ cb_pos = can_rx_offload_get_cb(pos); ++ cb_new = can_rx_offload_get_cb(new); ++ ++ netdev_dbg(new->dev, ++ "%s: pos=0x%08x, new=0x%08x, diff=%10d, queue_len=%d\n", ++ __func__, ++ cb_pos->timestamp, cb_new->timestamp, ++ cb_new->timestamp - cb_pos->timestamp, ++ skb_queue_len(head)); ++ ++ if (compare(pos, new) < 0) ++ continue; ++ insert = pos; ++ break; ++ } ++ if (!insert) ++ __skb_queue_head(head, new); ++ else ++ __skb_queue_after(head, insert, new); ++} ++ ++static int can_rx_offload_compare(struct sk_buff *a, struct sk_buff *b) ++{ ++ const struct can_rx_offload_cb *cb_a, *cb_b; ++ ++ cb_a = can_rx_offload_get_cb(a); ++ cb_b = can_rx_offload_get_cb(b); ++ ++ /* Substract two u32 and return result as int, to keep ++ * difference steady around the u32 overflow. ++ */ ++ return cb_b->timestamp - cb_a->timestamp; ++} ++ ++/** ++ * can_rx_offload_offload_one() - Read one CAN frame from HW ++ * @offload: pointer to rx_offload context ++ * @n: number of mailbox to read ++ * ++ * The task of this function is to read a CAN frame from mailbox @n ++ * from the device and return the mailbox's content as a struct ++ * sk_buff. ++ * ++ * If the struct can_rx_offload::skb_queue exceeds the maximal queue ++ * length (struct can_rx_offload::skb_queue_len_max) or no skb can be ++ * allocated, the mailbox contents is discarded by reading it into an ++ * overflow buffer. This way the mailbox is marked as free by the ++ * driver. ++ * ++ * Return: A pointer to skb containing the CAN frame on success. ++ * ++ * NULL if the mailbox @n is empty. ++ * ++ * ERR_PTR() in case of an error ++ */ ++static struct sk_buff * ++can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) ++{ ++ struct sk_buff *skb = NULL, *skb_error = NULL; ++ struct can_rx_offload_cb *cb; ++ struct can_frame *cf; ++ int ret; ++ ++ if (likely(skb_queue_len(&offload->skb_queue) < ++ offload->skb_queue_len_max)) { ++ skb = alloc_can_skb(offload->dev, &cf); ++ if (unlikely(!skb)) ++ skb_error = ERR_PTR(-ENOMEM); /* skb alloc failed */ ++ } else { ++ skb_error = ERR_PTR(-ENOBUFS); /* skb_queue is full */ ++ } ++ ++ /* If queue is full or skb not available, drop by reading into ++ * overflow buffer. ++ */ ++ if (unlikely(skb_error)) { ++ struct can_frame cf_overflow; ++ u32 timestamp; ++ ++ ret = offload->mailbox_read(offload, &cf_overflow, ++ ×tamp, n); ++ ++ /* Mailbox was empty. */ ++ if (unlikely(!ret)) ++ return NULL; ++ ++ /* Mailbox has been read and we're dropping it or ++ * there was a problem reading the mailbox. ++ * ++ * Increment error counters in any case. ++ */ ++ offload->dev->stats.rx_dropped++; ++ offload->dev->stats.rx_fifo_errors++; ++ ++ /* There was a problem reading the mailbox, propagate ++ * error value. ++ */ ++ if (unlikely(ret < 0)) ++ return ERR_PTR(ret); ++ ++ return skb_error; ++ } ++ ++ cb = can_rx_offload_get_cb(skb); ++ ret = offload->mailbox_read(offload, cf, &cb->timestamp, n); ++ ++ /* Mailbox was empty. */ ++ if (unlikely(!ret)) { ++ kfree_skb(skb); ++ return NULL; ++ } ++ ++ /* There was a problem reading the mailbox, propagate error value. */ ++ if (unlikely(ret < 0)) { ++ kfree_skb(skb); ++ ++ offload->dev->stats.rx_dropped++; ++ offload->dev->stats.rx_fifo_errors++; ++ ++ return ERR_PTR(ret); ++ } ++ ++ /* Mailbox was read. */ ++ return skb; ++} ++ ++int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 pending) ++{ ++ struct sk_buff_head skb_queue; ++ unsigned int i; ++ ++ __skb_queue_head_init(&skb_queue); ++ ++ for (i = offload->mb_first; ++ can_rx_offload_le(offload, i, offload->mb_last); ++ can_rx_offload_inc(offload, &i)) { ++ struct sk_buff *skb; ++ ++ if (!(pending & BIT_ULL(i))) ++ continue; ++ ++ skb = can_rx_offload_offload_one(offload, i); ++ if (IS_ERR_OR_NULL(skb)) ++ continue; ++ ++ __skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare); ++ } ++ ++ if (!skb_queue_empty(&skb_queue)) { ++ unsigned long flags; ++ u32 queue_len; ++ ++ spin_lock_irqsave(&offload->skb_queue.lock, flags); ++ skb_queue_splice_tail(&skb_queue, &offload->skb_queue); ++ spin_unlock_irqrestore(&offload->skb_queue.lock, flags); ++ ++ if ((queue_len = skb_queue_len(&offload->skb_queue)) > ++ (offload->skb_queue_len_max / 8)) ++ netdev_dbg(offload->dev, "%s: queue_len=%d\n", ++ __func__, queue_len); ++ ++ can_rx_offload_schedule(offload); ++ } ++ ++ return skb_queue_len(&skb_queue); ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_timestamp); ++ ++int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload) ++{ ++ struct sk_buff *skb; ++ int received = 0; ++ ++ while (1) { ++ skb = can_rx_offload_offload_one(offload, 0); ++ if (IS_ERR(skb)) ++ continue; ++ if (!skb) ++ break; ++ ++ skb_queue_tail(&offload->skb_queue, skb); ++ received++; ++ } ++ ++ if (received) ++ can_rx_offload_schedule(offload); ++ ++ return received; ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo); ++ ++int can_rx_offload_queue_sorted(struct can_rx_offload *offload, ++ struct sk_buff *skb, u32 timestamp) ++{ ++ struct can_rx_offload_cb *cb; ++ unsigned long flags; ++ ++ if (skb_queue_len(&offload->skb_queue) > ++ offload->skb_queue_len_max) { ++ dev_kfree_skb_any(skb); ++ return -ENOBUFS; ++ } ++ ++ cb = can_rx_offload_get_cb(skb); ++ cb->timestamp = timestamp; ++ ++ spin_lock_irqsave(&offload->skb_queue.lock, flags); ++ __skb_queue_add_sort(&offload->skb_queue, skb, can_rx_offload_compare); ++ spin_unlock_irqrestore(&offload->skb_queue.lock, flags); ++ ++ can_rx_offload_schedule(offload); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_queue_sorted); ++ ++unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload, ++ unsigned int idx, u32 timestamp) ++{ ++ struct net_device *dev = offload->dev; ++ struct net_device_stats *stats = &dev->stats; ++ struct sk_buff *skb; ++ u8 len; ++ int err; ++ ++ skb = __can_get_echo_skb(dev, idx, &len); ++ if (!skb) ++ return 0; ++ ++ err = can_rx_offload_queue_sorted(offload, skb, timestamp); ++ if (err) { ++ stats->rx_errors++; ++ stats->tx_fifo_errors++; ++ } ++ ++ return len; ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb); ++ ++int can_rx_offload_queue_tail(struct can_rx_offload *offload, ++ struct sk_buff *skb) ++{ ++ if (skb_queue_len(&offload->skb_queue) > ++ offload->skb_queue_len_max) { ++ dev_kfree_skb_any(skb); ++ return -ENOBUFS; ++ } ++ ++ skb_queue_tail(&offload->skb_queue, skb); ++ can_rx_offload_schedule(offload); ++ ++ return 0; ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail); ++ ++static int can_rx_offload_init_queue(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) ++{ ++ offload->dev = dev; ++ ++ /* Limit queue len to 4x the weight (rounted to next power of two) */ ++ offload->skb_queue_len_max = 2 << fls(weight); ++ offload->skb_queue_len_max *= 4; ++ skb_queue_head_init(&offload->skb_queue); ++ ++ can_rx_offload_reset(offload); ++ netif_napi_add(dev, &offload->napi, can_rx_offload_napi_poll, weight); ++ ++ dev_dbg(dev->dev.parent, "%s: skb_queue_len_max=%d\n", ++ __func__, offload->skb_queue_len_max); ++ ++ return 0; ++} ++ ++int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload) ++{ ++ unsigned int weight; ++ ++ if (offload->mb_first > BITS_PER_LONG_LONG || ++ offload->mb_last > BITS_PER_LONG_LONG || !offload->mailbox_read) ++ return -EINVAL; ++ ++ if (offload->mb_first < offload->mb_last) { ++ offload->inc = true; ++ weight = offload->mb_last - offload->mb_first; ++ } else { ++ offload->inc = false; ++ weight = offload->mb_first - offload->mb_last; ++ } ++ ++ return can_rx_offload_init_queue(dev, offload, weight); ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_add_timestamp); ++ ++int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) ++{ ++ if (!offload->mailbox_read) ++ return -EINVAL; ++ ++ return can_rx_offload_init_queue(dev, offload, weight); ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_add_fifo); ++ ++void can_rx_offload_enable(struct can_rx_offload *offload) ++{ ++ can_rx_offload_reset(offload); ++ napi_enable(&offload->napi); ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_enable); ++ ++void can_rx_offload_del(struct can_rx_offload *offload) ++{ ++ netif_napi_del(&offload->napi); ++ skb_queue_purge(&offload->skb_queue); ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_del); ++ ++void can_rx_offload_reset(struct can_rx_offload *offload) ++{ ++} ++EXPORT_SYMBOL_GPL(can_rx_offload_reset); +diff --git a/drivers/net/can/m_can/tcan4x5x.c b/drivers/net/can/m_can/tcan4x5x.c +index 32cb479fe6ac8..0d66582bd3560 100644 +--- a/drivers/net/can/m_can/tcan4x5x.c ++++ b/drivers/net/can/m_can/tcan4x5x.c +@@ -88,7 +88,7 @@ + + #define TCAN4X5X_MRAM_START 0x8000 + #define TCAN4X5X_MCAN_OFFSET 0x1000 +-#define TCAN4X5X_MAX_REGISTER 0x8fff ++#define TCAN4X5X_MAX_REGISTER 0x8ffc + + #define TCAN4X5X_CLEAR_ALL_INT 0xffffffff + #define TCAN4X5X_SET_ALL_INT 0xffffffff +diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c +deleted file mode 100644 +index 7e75a87a8a6a9..0000000000000 +--- a/drivers/net/can/rx-offload.c ++++ /dev/null +@@ -1,395 +0,0 @@ +-// SPDX-License-Identifier: GPL-2.0-only +-/* +- * Copyright (c) 2014 David Jander, Protonic Holland +- * Copyright (C) 2014-2017 Pengutronix, Marc Kleine-Budde +- */ +- +-#include +-#include +- +-struct can_rx_offload_cb { +- u32 timestamp; +-}; +- +-static inline struct can_rx_offload_cb *can_rx_offload_get_cb(struct sk_buff *skb) +-{ +- BUILD_BUG_ON(sizeof(struct can_rx_offload_cb) > sizeof(skb->cb)); +- +- return (struct can_rx_offload_cb *)skb->cb; +-} +- +-static inline bool can_rx_offload_le(struct can_rx_offload *offload, unsigned int a, unsigned int b) +-{ +- if (offload->inc) +- return a <= b; +- else +- return a >= b; +-} +- +-static inline unsigned int can_rx_offload_inc(struct can_rx_offload *offload, unsigned int *val) +-{ +- if (offload->inc) +- return (*val)++; +- else +- return (*val)--; +-} +- +-static int can_rx_offload_napi_poll(struct napi_struct *napi, int quota) +-{ +- struct can_rx_offload *offload = container_of(napi, struct can_rx_offload, napi); +- struct net_device *dev = offload->dev; +- struct net_device_stats *stats = &dev->stats; +- struct sk_buff *skb; +- int work_done = 0; +- +- while ((work_done < quota) && +- (skb = skb_dequeue(&offload->skb_queue))) { +- struct can_frame *cf = (struct can_frame *)skb->data; +- +- work_done++; +- stats->rx_packets++; +- stats->rx_bytes += cf->can_dlc; +- netif_receive_skb(skb); +- } +- +- if (work_done < quota) { +- napi_complete_done(napi, work_done); +- +- /* Check if there was another interrupt */ +- if (!skb_queue_empty(&offload->skb_queue)) +- napi_reschedule(&offload->napi); +- } +- +- can_led_event(offload->dev, CAN_LED_EVENT_RX); +- +- return work_done; +-} +- +-static inline void __skb_queue_add_sort(struct sk_buff_head *head, struct sk_buff *new, +- int (*compare)(struct sk_buff *a, struct sk_buff *b)) +-{ +- struct sk_buff *pos, *insert = NULL; +- +- skb_queue_reverse_walk(head, pos) { +- const struct can_rx_offload_cb *cb_pos, *cb_new; +- +- cb_pos = can_rx_offload_get_cb(pos); +- cb_new = can_rx_offload_get_cb(new); +- +- netdev_dbg(new->dev, +- "%s: pos=0x%08x, new=0x%08x, diff=%10d, queue_len=%d\n", +- __func__, +- cb_pos->timestamp, cb_new->timestamp, +- cb_new->timestamp - cb_pos->timestamp, +- skb_queue_len(head)); +- +- if (compare(pos, new) < 0) +- continue; +- insert = pos; +- break; +- } +- if (!insert) +- __skb_queue_head(head, new); +- else +- __skb_queue_after(head, insert, new); +-} +- +-static int can_rx_offload_compare(struct sk_buff *a, struct sk_buff *b) +-{ +- const struct can_rx_offload_cb *cb_a, *cb_b; +- +- cb_a = can_rx_offload_get_cb(a); +- cb_b = can_rx_offload_get_cb(b); +- +- /* Substract two u32 and return result as int, to keep +- * difference steady around the u32 overflow. +- */ +- return cb_b->timestamp - cb_a->timestamp; +-} +- +-/** +- * can_rx_offload_offload_one() - Read one CAN frame from HW +- * @offload: pointer to rx_offload context +- * @n: number of mailbox to read +- * +- * The task of this function is to read a CAN frame from mailbox @n +- * from the device and return the mailbox's content as a struct +- * sk_buff. +- * +- * If the struct can_rx_offload::skb_queue exceeds the maximal queue +- * length (struct can_rx_offload::skb_queue_len_max) or no skb can be +- * allocated, the mailbox contents is discarded by reading it into an +- * overflow buffer. This way the mailbox is marked as free by the +- * driver. +- * +- * Return: A pointer to skb containing the CAN frame on success. +- * +- * NULL if the mailbox @n is empty. +- * +- * ERR_PTR() in case of an error +- */ +-static struct sk_buff * +-can_rx_offload_offload_one(struct can_rx_offload *offload, unsigned int n) +-{ +- struct sk_buff *skb = NULL, *skb_error = NULL; +- struct can_rx_offload_cb *cb; +- struct can_frame *cf; +- int ret; +- +- if (likely(skb_queue_len(&offload->skb_queue) < +- offload->skb_queue_len_max)) { +- skb = alloc_can_skb(offload->dev, &cf); +- if (unlikely(!skb)) +- skb_error = ERR_PTR(-ENOMEM); /* skb alloc failed */ +- } else { +- skb_error = ERR_PTR(-ENOBUFS); /* skb_queue is full */ +- } +- +- /* If queue is full or skb not available, drop by reading into +- * overflow buffer. +- */ +- if (unlikely(skb_error)) { +- struct can_frame cf_overflow; +- u32 timestamp; +- +- ret = offload->mailbox_read(offload, &cf_overflow, +- ×tamp, n); +- +- /* Mailbox was empty. */ +- if (unlikely(!ret)) +- return NULL; +- +- /* Mailbox has been read and we're dropping it or +- * there was a problem reading the mailbox. +- * +- * Increment error counters in any case. +- */ +- offload->dev->stats.rx_dropped++; +- offload->dev->stats.rx_fifo_errors++; +- +- /* There was a problem reading the mailbox, propagate +- * error value. +- */ +- if (unlikely(ret < 0)) +- return ERR_PTR(ret); +- +- return skb_error; +- } +- +- cb = can_rx_offload_get_cb(skb); +- ret = offload->mailbox_read(offload, cf, &cb->timestamp, n); +- +- /* Mailbox was empty. */ +- if (unlikely(!ret)) { +- kfree_skb(skb); +- return NULL; +- } +- +- /* There was a problem reading the mailbox, propagate error value. */ +- if (unlikely(ret < 0)) { +- kfree_skb(skb); +- +- offload->dev->stats.rx_dropped++; +- offload->dev->stats.rx_fifo_errors++; +- +- return ERR_PTR(ret); +- } +- +- /* Mailbox was read. */ +- return skb; +-} +- +-int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 pending) +-{ +- struct sk_buff_head skb_queue; +- unsigned int i; +- +- __skb_queue_head_init(&skb_queue); +- +- for (i = offload->mb_first; +- can_rx_offload_le(offload, i, offload->mb_last); +- can_rx_offload_inc(offload, &i)) { +- struct sk_buff *skb; +- +- if (!(pending & BIT_ULL(i))) +- continue; +- +- skb = can_rx_offload_offload_one(offload, i); +- if (IS_ERR_OR_NULL(skb)) +- continue; +- +- __skb_queue_add_sort(&skb_queue, skb, can_rx_offload_compare); +- } +- +- if (!skb_queue_empty(&skb_queue)) { +- unsigned long flags; +- u32 queue_len; +- +- spin_lock_irqsave(&offload->skb_queue.lock, flags); +- skb_queue_splice_tail(&skb_queue, &offload->skb_queue); +- spin_unlock_irqrestore(&offload->skb_queue.lock, flags); +- +- if ((queue_len = skb_queue_len(&offload->skb_queue)) > +- (offload->skb_queue_len_max / 8)) +- netdev_dbg(offload->dev, "%s: queue_len=%d\n", +- __func__, queue_len); +- +- can_rx_offload_schedule(offload); +- } +- +- return skb_queue_len(&skb_queue); +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_timestamp); +- +-int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload) +-{ +- struct sk_buff *skb; +- int received = 0; +- +- while (1) { +- skb = can_rx_offload_offload_one(offload, 0); +- if (IS_ERR(skb)) +- continue; +- if (!skb) +- break; +- +- skb_queue_tail(&offload->skb_queue, skb); +- received++; +- } +- +- if (received) +- can_rx_offload_schedule(offload); +- +- return received; +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_irq_offload_fifo); +- +-int can_rx_offload_queue_sorted(struct can_rx_offload *offload, +- struct sk_buff *skb, u32 timestamp) +-{ +- struct can_rx_offload_cb *cb; +- unsigned long flags; +- +- if (skb_queue_len(&offload->skb_queue) > +- offload->skb_queue_len_max) { +- dev_kfree_skb_any(skb); +- return -ENOBUFS; +- } +- +- cb = can_rx_offload_get_cb(skb); +- cb->timestamp = timestamp; +- +- spin_lock_irqsave(&offload->skb_queue.lock, flags); +- __skb_queue_add_sort(&offload->skb_queue, skb, can_rx_offload_compare); +- spin_unlock_irqrestore(&offload->skb_queue.lock, flags); +- +- can_rx_offload_schedule(offload); +- +- return 0; +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_queue_sorted); +- +-unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload, +- unsigned int idx, u32 timestamp) +-{ +- struct net_device *dev = offload->dev; +- struct net_device_stats *stats = &dev->stats; +- struct sk_buff *skb; +- u8 len; +- int err; +- +- skb = __can_get_echo_skb(dev, idx, &len); +- if (!skb) +- return 0; +- +- err = can_rx_offload_queue_sorted(offload, skb, timestamp); +- if (err) { +- stats->rx_errors++; +- stats->tx_fifo_errors++; +- } +- +- return len; +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb); +- +-int can_rx_offload_queue_tail(struct can_rx_offload *offload, +- struct sk_buff *skb) +-{ +- if (skb_queue_len(&offload->skb_queue) > +- offload->skb_queue_len_max) { +- dev_kfree_skb_any(skb); +- return -ENOBUFS; +- } +- +- skb_queue_tail(&offload->skb_queue, skb); +- can_rx_offload_schedule(offload); +- +- return 0; +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail); +- +-static int can_rx_offload_init_queue(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) +-{ +- offload->dev = dev; +- +- /* Limit queue len to 4x the weight (rounted to next power of two) */ +- offload->skb_queue_len_max = 2 << fls(weight); +- offload->skb_queue_len_max *= 4; +- skb_queue_head_init(&offload->skb_queue); +- +- can_rx_offload_reset(offload); +- netif_napi_add(dev, &offload->napi, can_rx_offload_napi_poll, weight); +- +- dev_dbg(dev->dev.parent, "%s: skb_queue_len_max=%d\n", +- __func__, offload->skb_queue_len_max); +- +- return 0; +-} +- +-int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload) +-{ +- unsigned int weight; +- +- if (offload->mb_first > BITS_PER_LONG_LONG || +- offload->mb_last > BITS_PER_LONG_LONG || !offload->mailbox_read) +- return -EINVAL; +- +- if (offload->mb_first < offload->mb_last) { +- offload->inc = true; +- weight = offload->mb_last - offload->mb_first; +- } else { +- offload->inc = false; +- weight = offload->mb_first - offload->mb_last; +- } +- +- return can_rx_offload_init_queue(dev, offload, weight); +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_add_timestamp); +- +-int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight) +-{ +- if (!offload->mailbox_read) +- return -EINVAL; +- +- return can_rx_offload_init_queue(dev, offload, weight); +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_add_fifo); +- +-void can_rx_offload_enable(struct can_rx_offload *offload) +-{ +- can_rx_offload_reset(offload); +- napi_enable(&offload->napi); +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_enable); +- +-void can_rx_offload_del(struct can_rx_offload *offload) +-{ +- netif_napi_del(&offload->napi); +- skb_queue_purge(&offload->skb_queue); +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_del); +- +-void can_rx_offload_reset(struct can_rx_offload *offload) +-{ +-} +-EXPORT_SYMBOL_GPL(can_rx_offload_reset); +diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c +index 4dfa459ef5c73..95fefb1eef361 100644 +--- a/drivers/net/can/slcan.c ++++ b/drivers/net/can/slcan.c +@@ -519,6 +519,7 @@ static struct slcan *slc_alloc(void) + int i; + char name[IFNAMSIZ]; + struct net_device *dev = NULL; ++ struct can_ml_priv *can_ml; + struct slcan *sl; + int size; + +@@ -541,7 +542,8 @@ static struct slcan *slc_alloc(void) + + dev->base_addr = i; + sl = netdev_priv(dev); +- dev->ml_priv = (void *)sl + ALIGN(sizeof(*sl), NETDEV_ALIGN); ++ can_ml = (void *)sl + ALIGN(sizeof(*sl), NETDEV_ALIGN); ++ can_set_ml_priv(dev, can_ml); + + /* Initialize channel control data */ + sl->magic = SLCAN_MAGIC; +diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c +index 39ca14b0585dc..067705e2850b3 100644 +--- a/drivers/net/can/vcan.c ++++ b/drivers/net/can/vcan.c +@@ -153,7 +153,7 @@ static void vcan_setup(struct net_device *dev) + dev->addr_len = 0; + dev->tx_queue_len = 0; + dev->flags = IFF_NOARP; +- dev->ml_priv = netdev_priv(dev); ++ can_set_ml_priv(dev, netdev_priv(dev)); + + /* set flags according to driver capabilities */ + if (echo) +diff --git a/drivers/net/can/vxcan.c b/drivers/net/can/vxcan.c +index b1baa4ac1d537..7000c6cd1e48b 100644 +--- a/drivers/net/can/vxcan.c ++++ b/drivers/net/can/vxcan.c +@@ -141,6 +141,8 @@ static const struct net_device_ops vxcan_netdev_ops = { + + static void vxcan_setup(struct net_device *dev) + { ++ struct can_ml_priv *can_ml; ++ + dev->type = ARPHRD_CAN; + dev->mtu = CANFD_MTU; + dev->hard_header_len = 0; +@@ -149,7 +151,9 @@ static void vxcan_setup(struct net_device *dev) + dev->flags = (IFF_NOARP|IFF_ECHO); + dev->netdev_ops = &vxcan_netdev_ops; + dev->needs_free_netdev = true; +- dev->ml_priv = netdev_priv(dev) + ALIGN(sizeof(struct vxcan_priv), NETDEV_ALIGN); ++ ++ can_ml = netdev_priv(dev) + ALIGN(sizeof(struct vxcan_priv), NETDEV_ALIGN); ++ can_set_ml_priv(dev, can_ml); + } + + /* forward declaration for rtnl_create_link() */ +diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_main.c b/drivers/net/ethernet/aquantia/atlantic/aq_main.c +index bb65dd39f8474..72c7404ae6c5b 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/aq_main.c ++++ b/drivers/net/ethernet/aquantia/atlantic/aq_main.c +@@ -66,8 +66,10 @@ static int aq_ndev_open(struct net_device *ndev) + goto err_exit; + + err = aq_nic_start(aq_nic); +- if (err < 0) ++ if (err < 0) { ++ aq_nic_stop(aq_nic); + goto err_exit; ++ } + + err_exit: + if (err < 0) +diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +index 9a77b70ad601b..491bcfd36ac25 100644 +--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c ++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c +@@ -1073,7 +1073,7 @@ static void mvpp2_interrupts_unmask(void *arg) + u32 val; + + /* If the thread isn't used, don't do anything */ +- if (smp_processor_id() > port->priv->nthreads) ++ if (smp_processor_id() >= port->priv->nthreads) + return; + + val = MVPP2_CAUSE_MISC_SUM_MASK | +@@ -2078,7 +2078,7 @@ static void mvpp2_txq_sent_counter_clear(void *arg) + int queue; + + /* If the thread isn't used, don't do anything */ +- if (smp_processor_id() > port->priv->nthreads) ++ if (smp_processor_id() >= port->priv->nthreads) + return; + + for (queue = 0; queue < port->ntxqs; queue++) { +diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c +index 0e6a51525d913..f3deb2a2fa47d 100644 +--- a/drivers/net/wan/lmc/lmc_main.c ++++ b/drivers/net/wan/lmc/lmc_main.c +@@ -912,6 +912,8 @@ static int lmc_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) + break; + default: + printk(KERN_WARNING "%s: LMC UNKNOWN CARD!\n", dev->name); ++ unregister_hdlc_device(dev); ++ return -EIO; + break; + } + +diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c +index 3ec71f52e8fe1..d38276ac375e9 100644 +--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c ++++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c +@@ -445,13 +445,13 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb) + case WMI_TDLS_TEARDOWN_REASON_TX: + case WMI_TDLS_TEARDOWN_REASON_RSSI: + case WMI_TDLS_TEARDOWN_REASON_PTR_TIMEOUT: ++ rcu_read_lock(); + station = ieee80211_find_sta_by_ifaddr(ar->hw, + ev->peer_macaddr.addr, + NULL); + if (!station) { + ath10k_warn(ar, "did not find station from tdls peer event"); +- kfree(tb); +- return; ++ goto exit; + } + arvif = ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id)); + ieee80211_tdls_oper_request( +@@ -462,6 +462,9 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb) + ); + break; + } ++ ++exit: ++ rcu_read_unlock(); + kfree(tb); + } + +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +index 4ca50353538ef..cd813c69a1781 100644 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c +@@ -5382,7 +5382,8 @@ static bool brcmf_is_linkup(struct brcmf_cfg80211_vif *vif, + return false; + } + +-static bool brcmf_is_linkdown(const struct brcmf_event_msg *e) ++static bool brcmf_is_linkdown(struct brcmf_cfg80211_vif *vif, ++ const struct brcmf_event_msg *e) + { + u32 event = e->event_code; + u16 flags = e->flags; +@@ -5391,6 +5392,8 @@ static bool brcmf_is_linkdown(const struct brcmf_event_msg *e) + (event == BRCMF_E_DISASSOC_IND) || + ((event == BRCMF_E_LINK) && (!(flags & BRCMF_EVENT_MSG_LINK)))) { + brcmf_dbg(CONN, "Processing link down\n"); ++ clear_bit(BRCMF_VIF_STATUS_EAP_SUCCESS, &vif->sme_state); ++ clear_bit(BRCMF_VIF_STATUS_ASSOC_SUCCESS, &vif->sme_state); + return true; + } + return false; +@@ -5683,7 +5686,7 @@ brcmf_notify_connect_status(struct brcmf_if *ifp, + } else + brcmf_bss_connect_done(cfg, ndev, e, true); + brcmf_net_setcarrier(ifp, true); +- } else if (brcmf_is_linkdown(e)) { ++ } else if (brcmf_is_linkdown(ifp->vif, e)) { + brcmf_dbg(CONN, "Linkdown\n"); + if (!brcmf_is_ibssmode(ifp->vif)) { + brcmf_bss_connect_done(cfg, ndev, e, false); +diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c +index 930edfc32f597..59fe3204e965d 100644 +--- a/drivers/pinctrl/pinctrl-rockchip.c ++++ b/drivers/pinctrl/pinctrl-rockchip.c +@@ -3386,12 +3386,15 @@ static int __maybe_unused rockchip_pinctrl_suspend(struct device *dev) + static int __maybe_unused rockchip_pinctrl_resume(struct device *dev) + { + struct rockchip_pinctrl *info = dev_get_drvdata(dev); +- int ret = regmap_write(info->regmap_base, RK3288_GRF_GPIO6C_IOMUX, +- rk3288_grf_gpio6c_iomux | +- GPIO6C6_SEL_WRITE_ENABLE); ++ int ret; + +- if (ret) +- return ret; ++ if (info->ctrl->type == RK3288) { ++ ret = regmap_write(info->regmap_base, RK3288_GRF_GPIO6C_IOMUX, ++ rk3288_grf_gpio6c_iomux | ++ GPIO6C6_SEL_WRITE_ENABLE); ++ if (ret) ++ return ret; ++ } + + return pinctrl_force_default(info->pctl_dev); + } +diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h +index d006f0a97b8cf..2236751a3a568 100644 +--- a/drivers/scsi/qla2xxx/qla_target.h ++++ b/drivers/scsi/qla2xxx/qla_target.h +@@ -116,7 +116,6 @@ + (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \ + QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0)) + #endif +-#endif + + #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha)) \ + ? le16_to_cpu((iocb)->u.isp2x.target.extended) \ +@@ -244,6 +243,7 @@ struct ctio_to_2xxx { + #ifndef CTIO_RET_TYPE + #define CTIO_RET_TYPE 0x17 /* CTIO return entry */ + #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */ ++#endif + + struct fcp_hdr { + uint8_t r_ctl; +diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c +index e3266a64a4770..2121e44c342f8 100644 +--- a/drivers/scsi/st.c ++++ b/drivers/scsi/st.c +@@ -1267,8 +1267,8 @@ static int st_open(struct inode *inode, struct file *filp) + spin_lock(&st_use_lock); + if (STp->in_use) { + spin_unlock(&st_use_lock); +- scsi_tape_put(STp); + DEBC_printk(STp, "Device already in use.\n"); ++ scsi_tape_put(STp); + return (-EBUSY); + } + +diff --git a/drivers/staging/comedi/drivers/cb_pcidas.c b/drivers/staging/comedi/drivers/cb_pcidas.c +index 1893c70de0b93..10f097a7d847d 100644 +--- a/drivers/staging/comedi/drivers/cb_pcidas.c ++++ b/drivers/staging/comedi/drivers/cb_pcidas.c +@@ -1281,7 +1281,7 @@ static int cb_pcidas_auto_attach(struct comedi_device *dev, + devpriv->amcc + AMCC_OP_REG_INTCSR); + + ret = request_irq(pcidev->irq, cb_pcidas_interrupt, IRQF_SHARED, +- dev->board_name, dev); ++ "cb_pcidas", dev); + if (ret) { + dev_dbg(dev->class_dev, "unable to allocate irq %d\n", + pcidev->irq); +diff --git a/drivers/staging/comedi/drivers/cb_pcidas64.c b/drivers/staging/comedi/drivers/cb_pcidas64.c +index e1774e09a3203..9fe8b65cd9e3a 100644 +--- a/drivers/staging/comedi/drivers/cb_pcidas64.c ++++ b/drivers/staging/comedi/drivers/cb_pcidas64.c +@@ -4035,7 +4035,7 @@ static int auto_attach(struct comedi_device *dev, + init_stc_registers(dev); + + retval = request_irq(pcidev->irq, handle_interrupt, IRQF_SHARED, +- dev->board_name, dev); ++ "cb_pcidas64", dev); + if (retval) { + dev_dbg(dev->class_dev, "unable to allocate irq %u\n", + pcidev->irq); +diff --git a/drivers/staging/rtl8192e/rtllib.h b/drivers/staging/rtl8192e/rtllib.h +index 328f410daa035..2eeb9a43734e3 100644 +--- a/drivers/staging/rtl8192e/rtllib.h ++++ b/drivers/staging/rtl8192e/rtllib.h +@@ -1105,7 +1105,7 @@ struct rtllib_network { + bool bWithAironetIE; + bool bCkipSupported; + bool bCcxRmEnable; +- u16 CcxRmState[2]; ++ u8 CcxRmState[2]; + bool bMBssidValid; + u8 MBssidMask; + u8 MBssid[ETH_ALEN]; +diff --git a/drivers/staging/rtl8192e/rtllib_rx.c b/drivers/staging/rtl8192e/rtllib_rx.c +index 0bae0a0a4cbe1..83c30e2d82f5f 100644 +--- a/drivers/staging/rtl8192e/rtllib_rx.c ++++ b/drivers/staging/rtl8192e/rtllib_rx.c +@@ -1968,7 +1968,7 @@ static void rtllib_parse_mife_generic(struct rtllib_device *ieee, + info_element->data[2] == 0x96 && + info_element->data[3] == 0x01) { + if (info_element->len == 6) { +- memcpy(network->CcxRmState, &info_element[4], 2); ++ memcpy(network->CcxRmState, &info_element->data[4], 2); + if (network->CcxRmState[0] != 0) + network->bCcxRmEnable = true; + else +diff --git a/drivers/thermal/thermal_sysfs.c b/drivers/thermal/thermal_sysfs.c +index aa99edb4dff7d..4dce4a8f71ed9 100644 +--- a/drivers/thermal/thermal_sysfs.c ++++ b/drivers/thermal/thermal_sysfs.c +@@ -770,6 +770,9 @@ void thermal_cooling_device_stats_update(struct thermal_cooling_device *cdev, + { + struct cooling_dev_stats *stats = cdev->stats; + ++ if (!stats) ++ return; ++ + spin_lock(&stats->lock); + + if (stats->state == new_state) +diff --git a/drivers/usb/class/cdc-acm.c b/drivers/usb/class/cdc-acm.c +index 00bfc81f24702..2b672840dfd9a 100644 +--- a/drivers/usb/class/cdc-acm.c ++++ b/drivers/usb/class/cdc-acm.c +@@ -147,17 +147,29 @@ static inline int acm_set_control(struct acm *acm, int control) + #define acm_send_break(acm, ms) \ + acm_ctrl_msg(acm, USB_CDC_REQ_SEND_BREAK, ms, NULL, 0) + +-static void acm_kill_urbs(struct acm *acm) ++static void acm_poison_urbs(struct acm *acm) + { + int i; + +- usb_kill_urb(acm->ctrlurb); ++ usb_poison_urb(acm->ctrlurb); + for (i = 0; i < ACM_NW; i++) +- usb_kill_urb(acm->wb[i].urb); ++ usb_poison_urb(acm->wb[i].urb); + for (i = 0; i < acm->rx_buflimit; i++) +- usb_kill_urb(acm->read_urbs[i]); ++ usb_poison_urb(acm->read_urbs[i]); + } + ++static void acm_unpoison_urbs(struct acm *acm) ++{ ++ int i; ++ ++ for (i = 0; i < acm->rx_buflimit; i++) ++ usb_unpoison_urb(acm->read_urbs[i]); ++ for (i = 0; i < ACM_NW; i++) ++ usb_unpoison_urb(acm->wb[i].urb); ++ usb_unpoison_urb(acm->ctrlurb); ++} ++ ++ + /* + * Write buffer management. + * All of these assume proper locks taken by the caller. +@@ -225,9 +237,10 @@ static int acm_start_wb(struct acm *acm, struct acm_wb *wb) + + rc = usb_submit_urb(wb->urb, GFP_ATOMIC); + if (rc < 0) { +- dev_err(&acm->data->dev, +- "%s - usb_submit_urb(write bulk) failed: %d\n", +- __func__, rc); ++ if (rc != -EPERM) ++ dev_err(&acm->data->dev, ++ "%s - usb_submit_urb(write bulk) failed: %d\n", ++ __func__, rc); + acm_write_done(acm, wb); + } + return rc; +@@ -312,8 +325,10 @@ static void acm_process_notification(struct acm *acm, unsigned char *buf) + acm->iocount.dsr++; + if (difference & ACM_CTRL_DCD) + acm->iocount.dcd++; +- if (newctrl & ACM_CTRL_BRK) ++ if (newctrl & ACM_CTRL_BRK) { + acm->iocount.brk++; ++ tty_insert_flip_char(&acm->port, 0, TTY_BREAK); ++ } + if (newctrl & ACM_CTRL_RI) + acm->iocount.rng++; + if (newctrl & ACM_CTRL_FRAMING) +@@ -479,11 +494,6 @@ static void acm_read_bulk_callback(struct urb *urb) + dev_vdbg(&acm->data->dev, "got urb %d, len %d, status %d\n", + rb->index, urb->actual_length, status); + +- if (!acm->dev) { +- dev_dbg(&acm->data->dev, "%s - disconnected\n", __func__); +- return; +- } +- + switch (status) { + case 0: + usb_mark_last_busy(acm->dev); +@@ -648,7 +658,8 @@ static void acm_port_dtr_rts(struct tty_port *port, int raise) + + res = acm_set_control(acm, val); + if (res && (acm->ctrl_caps & USB_CDC_CAP_LINE)) +- dev_err(&acm->control->dev, "failed to set dtr/rts\n"); ++ /* This is broken in too many devices to spam the logs */ ++ dev_dbg(&acm->control->dev, "failed to set dtr/rts\n"); + } + + static int acm_port_activate(struct tty_port *port, struct tty_struct *tty) +@@ -730,6 +741,7 @@ static void acm_port_shutdown(struct tty_port *port) + * Need to grab write_lock to prevent race with resume, but no need to + * hold it due to the tty-port initialised flag. + */ ++ acm_poison_urbs(acm); + spin_lock_irq(&acm->write_lock); + spin_unlock_irq(&acm->write_lock); + +@@ -746,7 +758,8 @@ static void acm_port_shutdown(struct tty_port *port) + usb_autopm_put_interface_async(acm->control); + } + +- acm_kill_urbs(acm); ++ acm_unpoison_urbs(acm); ++ + } + + static void acm_tty_cleanup(struct tty_struct *tty) +@@ -1516,12 +1529,16 @@ skip_countries: + + return 0; + alloc_fail6: ++ if (!acm->combined_interfaces) { ++ /* Clear driver data so that disconnect() returns early. */ ++ usb_set_intfdata(data_interface, NULL); ++ usb_driver_release_interface(&acm_driver, data_interface); ++ } + if (acm->country_codes) { + device_remove_file(&acm->control->dev, + &dev_attr_wCountryCodes); + device_remove_file(&acm->control->dev, + &dev_attr_iCountryCodeRelDate); +- kfree(acm->country_codes); + } + device_remove_file(&acm->control->dev, &dev_attr_bmCapabilities); + alloc_fail5: +@@ -1553,8 +1570,14 @@ static void acm_disconnect(struct usb_interface *intf) + if (!acm) + return; + +- mutex_lock(&acm->mutex); + acm->disconnected = true; ++ /* ++ * there is a circular dependency. acm_softint() can resubmit ++ * the URBs in error handling so we need to block any ++ * submission right away ++ */ ++ acm_poison_urbs(acm); ++ mutex_lock(&acm->mutex); + if (acm->country_codes) { + device_remove_file(&acm->control->dev, + &dev_attr_wCountryCodes); +@@ -1573,7 +1596,6 @@ static void acm_disconnect(struct usb_interface *intf) + tty_kref_put(tty); + } + +- acm_kill_urbs(acm); + cancel_delayed_work_sync(&acm->dwork); + + tty_unregister_device(acm_tty_driver, acm->minor); +@@ -1615,7 +1637,7 @@ static int acm_suspend(struct usb_interface *intf, pm_message_t message) + if (cnt) + return 0; + +- acm_kill_urbs(acm); ++ acm_poison_urbs(acm); + cancel_delayed_work_sync(&acm->dwork); + acm->urbs_in_error_delay = 0; + +@@ -1628,6 +1650,7 @@ static int acm_resume(struct usb_interface *intf) + struct urb *urb; + int rv = 0; + ++ acm_unpoison_urbs(acm); + spin_lock_irq(&acm->write_lock); + + if (--acm->susp_count) +diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c +index 239443ce52001..b8a4707dfafab 100644 +--- a/drivers/usb/core/quirks.c ++++ b/drivers/usb/core/quirks.c +@@ -498,6 +498,10 @@ static const struct usb_device_id usb_quirk_list[] = { + /* DJI CineSSD */ + { USB_DEVICE(0x2ca3, 0x0031), .driver_info = USB_QUIRK_NO_LPM }, + ++ /* Fibocom L850-GL LTE Modem */ ++ { USB_DEVICE(0x2cb7, 0x0007), .driver_info = ++ USB_QUIRK_IGNORE_REMOTE_WAKEUP }, ++ + /* INTEL VALUE SSD */ + { USB_DEVICE(0x8086, 0xf1a5), .driver_info = USB_QUIRK_RESET_RESUME }, + +diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c +index a91f2aa24118a..258056c822069 100644 +--- a/drivers/usb/dwc2/hcd.c ++++ b/drivers/usb/dwc2/hcd.c +@@ -4322,7 +4322,8 @@ static int _dwc2_hcd_suspend(struct usb_hcd *hcd) + if (hsotg->op_state == OTG_STATE_B_PERIPHERAL) + goto unlock; + +- if (hsotg->params.power_down > DWC2_POWER_DOWN_PARAM_PARTIAL) ++ if (hsotg->params.power_down != DWC2_POWER_DOWN_PARAM_PARTIAL || ++ hsotg->flags.b.port_connect_status == 0) + goto skip_power_saving; + + /* +@@ -5398,7 +5399,7 @@ int dwc2_host_enter_hibernation(struct dwc2_hsotg *hsotg) + dwc2_writel(hsotg, hprt0, HPRT0); + + /* Wait for the HPRT0.PrtSusp register field to be set */ +- if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 3000)) ++ if (dwc2_hsotg_wait_bit_set(hsotg, HPRT0, HPRT0_SUSP, 5000)) + dev_warn(hsotg->dev, "Suspend wasn't generated\n"); + + /* +diff --git a/drivers/usb/gadget/udc/amd5536udc_pci.c b/drivers/usb/gadget/udc/amd5536udc_pci.c +index 57b6f66331cfa..362284057d307 100644 +--- a/drivers/usb/gadget/udc/amd5536udc_pci.c ++++ b/drivers/usb/gadget/udc/amd5536udc_pci.c +@@ -154,6 +154,11 @@ static int udc_pci_probe( + pci_set_master(pdev); + pci_try_set_mwi(pdev); + ++ dev->phys_addr = resource; ++ dev->irq = pdev->irq; ++ dev->pdev = pdev; ++ dev->dev = &pdev->dev; ++ + /* init dma pools */ + if (use_dma) { + retval = init_dma_pools(dev); +@@ -161,11 +166,6 @@ static int udc_pci_probe( + goto err_dma; + } + +- dev->phys_addr = resource; +- dev->irq = pdev->irq; +- dev->pdev = pdev; +- dev->dev = &pdev->dev; +- + /* general probing */ + if (udc_probe(dev)) { + retval = -ENODEV; +diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c +index 09b67219fd146..5fc3ea6d46c56 100644 +--- a/drivers/usb/host/xhci-mtk.c ++++ b/drivers/usb/host/xhci-mtk.c +@@ -397,6 +397,13 @@ static void xhci_mtk_quirks(struct device *dev, struct xhci_hcd *xhci) + xhci->quirks |= XHCI_SPURIOUS_SUCCESS; + if (mtk->lpm_support) + xhci->quirks |= XHCI_LPM_SUPPORT; ++ ++ /* ++ * MTK xHCI 0.96: PSA is 1 by default even if doesn't support stream, ++ * and it's 3 when support it. ++ */ ++ if (xhci->hci_version < 0x100 && HCC_MAX_PSA(xhci->hcc_params) == 4) ++ xhci->quirks |= XHCI_BROKEN_STREAMS; + } + + /* called during probe() after chip reset completes */ +@@ -553,7 +560,8 @@ static int xhci_mtk_probe(struct platform_device *pdev) + if (ret) + goto put_usb3_hcd; + +- if (HCC_MAX_PSA(xhci->hcc_params) >= 4) ++ if (HCC_MAX_PSA(xhci->hcc_params) >= 4 && ++ !(xhci->quirks & XHCI_BROKEN_STREAMS)) + xhci->shared_hcd->can_do_streams = 1; + + ret = usb_add_hcd(xhci->shared_hcd, irq, IRQF_SHARED); +diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c +index 9fcff4e94484e..166f68f639c28 100644 +--- a/drivers/usb/musb/musb_core.c ++++ b/drivers/usb/musb/musb_core.c +@@ -1866,10 +1866,14 @@ static void musb_pm_runtime_check_session(struct musb *musb) + MUSB_DEVCTL_HR; + switch (devctl & ~s) { + case MUSB_QUIRK_B_DISCONNECT_99: +- musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n"); +- schedule_delayed_work(&musb->irq_work, +- msecs_to_jiffies(1000)); +- break; ++ if (musb->quirk_retries && !musb->flush_irq_work) { ++ musb_dbg(musb, "Poll devctl in case of suspend after disconnect\n"); ++ schedule_delayed_work(&musb->irq_work, ++ msecs_to_jiffies(1000)); ++ musb->quirk_retries--; ++ break; ++ } ++ fallthrough; + case MUSB_QUIRK_B_INVALID_VBUS_91: + if (musb->quirk_retries && !musb->flush_irq_work) { + musb_dbg(musb, +diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c +index fee511437abe3..1e0b618e2e6ec 100644 +--- a/drivers/usb/usbip/vhci_hcd.c ++++ b/drivers/usb/usbip/vhci_hcd.c +@@ -595,6 +595,8 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, + pr_err("invalid port number %d\n", wIndex); + goto error; + } ++ if (wValue >= 32) ++ goto error; + if (hcd->speed == HCD_USB3) { + if ((vhci_hcd->port_status[rhport] & + USB_SS_PORT_STAT_POWER) != 0) { +diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig +index ac3c1dd3edeff..4abddbebd4b23 100644 +--- a/drivers/vfio/pci/Kconfig ++++ b/drivers/vfio/pci/Kconfig +@@ -42,6 +42,6 @@ config VFIO_PCI_IGD + + config VFIO_PCI_NVLINK2 + def_bool y +- depends on VFIO_PCI && PPC_POWERNV ++ depends on VFIO_PCI && PPC_POWERNV && SPAPR_TCE_IOMMU + help + VFIO PCI support for P9 Witherspoon machine with NVIDIA V100 GPUs +diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c +index 57ab79fbcee95..a279ecacbf60a 100644 +--- a/drivers/vhost/vhost.c ++++ b/drivers/vhost/vhost.c +@@ -320,8 +320,8 @@ static void vhost_vq_reset(struct vhost_dev *dev, + vq->kick = NULL; + vq->call_ctx = NULL; + vq->log_ctx = NULL; +- vhost_reset_is_le(vq); + vhost_disable_cross_endian(vq); ++ vhost_reset_is_le(vq); + vq->busyloop_timeout = 0; + vq->umem = NULL; + vq->iotlb = NULL; +diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c +index 4cf71ee0965a6..0a9202176ffc9 100644 +--- a/drivers/video/fbdev/core/fbcon.c ++++ b/drivers/video/fbdev/core/fbcon.c +@@ -1339,6 +1339,9 @@ static void fbcon_cursor(struct vc_data *vc, int mode) + + ops->cursor_flash = (mode == CM_ERASE) ? 0 : 1; + ++ if (!ops->cursor) ++ return; ++ + ops->cursor(vc, info, mode, get_color(vc, info, c, 1), + get_color(vc, info, c, 0)); + } +diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c +index 5aba67a504cf8..031ff3f190184 100644 +--- a/fs/ext4/balloc.c ++++ b/fs/ext4/balloc.c +@@ -612,27 +612,41 @@ int ext4_claim_free_clusters(struct ext4_sb_info *sbi, + + /** + * ext4_should_retry_alloc() - check if a block allocation should be retried +- * @sb: super block +- * @retries: number of attemps has been made ++ * @sb: superblock ++ * @retries: number of retry attempts made so far + * +- * ext4_should_retry_alloc() is called when ENOSPC is returned, and if +- * it is profitable to retry the operation, this function will wait +- * for the current or committing transaction to complete, and then +- * return TRUE. We will only retry once. ++ * ext4_should_retry_alloc() is called when ENOSPC is returned while ++ * attempting to allocate blocks. If there's an indication that a pending ++ * journal transaction might free some space and allow another attempt to ++ * succeed, this function will wait for the current or committing transaction ++ * to complete and then return TRUE. + */ + int ext4_should_retry_alloc(struct super_block *sb, int *retries) + { +- if (!ext4_has_free_clusters(EXT4_SB(sb), 1, 0) || +- (*retries)++ > 1 || +- !EXT4_SB(sb)->s_journal) ++ struct ext4_sb_info *sbi = EXT4_SB(sb); ++ ++ if (!sbi->s_journal) + return 0; + +- smp_mb(); +- if (EXT4_SB(sb)->s_mb_free_pending == 0) ++ if (++(*retries) > 3) { ++ percpu_counter_inc(&sbi->s_sra_exceeded_retry_limit); + return 0; ++ } + ++ /* ++ * if there's no indication that blocks are about to be freed it's ++ * possible we just missed a transaction commit that did so ++ */ ++ smp_mb(); ++ if (sbi->s_mb_free_pending == 0) ++ return ext4_has_free_clusters(sbi, 1, 0); ++ ++ /* ++ * it's possible we've just missed a transaction commit here, ++ * so ignore the returned status ++ */ + jbd_debug(1, "%s: retrying operation after ENOSPC\n", sb->s_id); +- jbd2_journal_force_commit_nested(EXT4_SB(sb)->s_journal); ++ (void) jbd2_journal_force_commit_nested(sbi->s_journal); + return 1; + } + +diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h +index 1c558b5547889..bf3eaa9030335 100644 +--- a/fs/ext4/ext4.h ++++ b/fs/ext4/ext4.h +@@ -1420,6 +1420,7 @@ struct ext4_sb_info { + struct percpu_counter s_freeinodes_counter; + struct percpu_counter s_dirs_counter; + struct percpu_counter s_dirtyclusters_counter; ++ struct percpu_counter s_sra_exceeded_retry_limit; + struct blockgroup_lock *s_blockgroup_lock; + struct proc_dir_entry *s_proc; + struct kobject s_kobj; +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index efce97b938b7a..1429d01d836bb 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -2076,13 +2076,13 @@ static int __ext4_journalled_writepage(struct page *page, + if (!ret) + ret = err; + +- if (!ext4_has_inline_data(inode)) +- ext4_walk_page_buffers(NULL, page_bufs, 0, len, +- NULL, bput_one); + ext4_set_inode_state(inode, EXT4_STATE_JDATA); + out: + unlock_page(page); + out_no_pagelock: ++ if (!inline_data && page_bufs) ++ ext4_walk_page_buffers(NULL, page_bufs, 0, len, ++ NULL, bput_one); + brelse(inode_bh); + return ret; + } +diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c +index e992a9f156714..4c37abe768512 100644 +--- a/fs/ext4/namei.c ++++ b/fs/ext4/namei.c +@@ -3731,14 +3731,14 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, + */ + retval = -ENOENT; + if (!old.bh || le32_to_cpu(old.de->inode) != old.inode->i_ino) +- goto end_rename; ++ goto release_bh; + + new.bh = ext4_find_entry(new.dir, &new.dentry->d_name, + &new.de, &new.inlined); + if (IS_ERR(new.bh)) { + retval = PTR_ERR(new.bh); + new.bh = NULL; +- goto end_rename; ++ goto release_bh; + } + if (new.bh) { + if (!new.inode) { +@@ -3755,15 +3755,13 @@ static int ext4_rename(struct inode *old_dir, struct dentry *old_dentry, + handle = ext4_journal_start(old.dir, EXT4_HT_DIR, credits); + if (IS_ERR(handle)) { + retval = PTR_ERR(handle); +- handle = NULL; +- goto end_rename; ++ goto release_bh; + } + } else { + whiteout = ext4_whiteout_for_rename(&old, credits, &handle); + if (IS_ERR(whiteout)) { + retval = PTR_ERR(whiteout); +- whiteout = NULL; +- goto end_rename; ++ goto release_bh; + } + } + +@@ -3871,16 +3869,18 @@ end_rename: + ext4_resetent(handle, &old, + old.inode->i_ino, old_file_type); + drop_nlink(whiteout); ++ ext4_orphan_add(handle, whiteout); + } + unlock_new_inode(whiteout); ++ ext4_journal_stop(handle); + iput(whiteout); +- ++ } else { ++ ext4_journal_stop(handle); + } ++release_bh: + brelse(old.dir_bh); + brelse(old.bh); + brelse(new.bh); +- if (handle) +- ext4_journal_stop(handle); + return retval; + } + +diff --git a/fs/ext4/super.c b/fs/ext4/super.c +index 06568467b0c27..2ecf4594a20dd 100644 +--- a/fs/ext4/super.c ++++ b/fs/ext4/super.c +@@ -1017,6 +1017,7 @@ static void ext4_put_super(struct super_block *sb) + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyclusters_counter); ++ percpu_counter_destroy(&sbi->s_sra_exceeded_retry_limit); + percpu_free_rwsem(&sbi->s_writepages_rwsem); + #ifdef CONFIG_QUOTA + for (i = 0; i < EXT4_MAXQUOTAS; i++) +@@ -4597,6 +4598,9 @@ no_journal: + if (!err) + err = percpu_counter_init(&sbi->s_dirtyclusters_counter, 0, + GFP_KERNEL); ++ if (!err) ++ err = percpu_counter_init(&sbi->s_sra_exceeded_retry_limit, 0, ++ GFP_KERNEL); + if (!err) + err = percpu_init_rwsem(&sbi->s_writepages_rwsem); + +@@ -4699,6 +4703,7 @@ failed_mount6: + percpu_counter_destroy(&sbi->s_freeinodes_counter); + percpu_counter_destroy(&sbi->s_dirs_counter); + percpu_counter_destroy(&sbi->s_dirtyclusters_counter); ++ percpu_counter_destroy(&sbi->s_sra_exceeded_retry_limit); + percpu_free_rwsem(&sbi->s_writepages_rwsem); + failed_mount5: + ext4_ext_release(sb); +diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c +index eb1efad0e20a3..9394360ff1373 100644 +--- a/fs/ext4/sysfs.c ++++ b/fs/ext4/sysfs.c +@@ -23,6 +23,7 @@ typedef enum { + attr_session_write_kbytes, + attr_lifetime_write_kbytes, + attr_reserved_clusters, ++ attr_sra_exceeded_retry_limit, + attr_inode_readahead, + attr_trigger_test_error, + attr_first_error_time, +@@ -176,6 +177,7 @@ EXT4_ATTR_FUNC(delayed_allocation_blocks, 0444); + EXT4_ATTR_FUNC(session_write_kbytes, 0444); + EXT4_ATTR_FUNC(lifetime_write_kbytes, 0444); + EXT4_ATTR_FUNC(reserved_clusters, 0644); ++EXT4_ATTR_FUNC(sra_exceeded_retry_limit, 0444); + + EXT4_ATTR_OFFSET(inode_readahead_blks, 0644, inode_readahead, + ext4_sb_info, s_inode_readahead_blks); +@@ -207,6 +209,7 @@ static struct attribute *ext4_attrs[] = { + ATTR_LIST(session_write_kbytes), + ATTR_LIST(lifetime_write_kbytes), + ATTR_LIST(reserved_clusters), ++ ATTR_LIST(sra_exceeded_retry_limit), + ATTR_LIST(inode_readahead_blks), + ATTR_LIST(inode_goal), + ATTR_LIST(mb_stats), +@@ -308,6 +311,10 @@ static ssize_t ext4_attr_show(struct kobject *kobj, + return snprintf(buf, PAGE_SIZE, "%llu\n", + (unsigned long long) + atomic64_read(&sbi->s_resv_clusters)); ++ case attr_sra_exceeded_retry_limit: ++ return snprintf(buf, PAGE_SIZE, "%llu\n", ++ (unsigned long long) ++ percpu_counter_sum(&sbi->s_sra_exceeded_retry_limit)); + case attr_inode_readahead: + case attr_pointer_ui: + if (!ptr) +diff --git a/fs/iomap/swapfile.c b/fs/iomap/swapfile.c +index 152a230f668d4..bd0cc3dcc9807 100644 +--- a/fs/iomap/swapfile.c ++++ b/fs/iomap/swapfile.c +@@ -169,6 +169,16 @@ int iomap_swapfile_activate(struct swap_info_struct *sis, + return ret; + } + ++ /* ++ * If this swapfile doesn't contain even a single page-aligned ++ * contiguous range of blocks, reject this useless swapfile to ++ * prevent confusion later on. ++ */ ++ if (isi.nr_pages == 0) { ++ pr_warn("swapon: Cannot find a single usable page in file.\n"); ++ return -EINVAL; ++ } ++ + *pagespan = 1 + isi.highest_ppage - isi.lowest_ppage; + sis->max = isi.nr_pages; + sis->pages = isi.nr_pages - 1; +diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig +index f2f81561ebb65..4d6e71335bce2 100644 +--- a/fs/nfsd/Kconfig ++++ b/fs/nfsd/Kconfig +@@ -73,6 +73,7 @@ config NFSD_V4 + select NFSD_V3 + select FS_POSIX_ACL + select SUNRPC_GSS ++ select CRYPTO + select CRYPTO_MD5 + select CRYPTO_SHA256 + select GRACE_PERIOD +diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c +index efe55d101b0ed..3c50d18fe8a9b 100644 +--- a/fs/nfsd/nfs4callback.c ++++ b/fs/nfsd/nfs4callback.c +@@ -1121,6 +1121,7 @@ static void nfsd4_cb_done(struct rpc_task *task, void *calldata) + switch (task->tk_status) { + case -EIO: + case -ETIMEDOUT: ++ case -EACCES: + nfsd4_mark_cb_down(clp, task->tk_status); + } + break; +diff --git a/fs/reiserfs/xattr.h b/fs/reiserfs/xattr.h +index c764352447ba1..81bec2c80b25c 100644 +--- a/fs/reiserfs/xattr.h ++++ b/fs/reiserfs/xattr.h +@@ -43,7 +43,7 @@ void reiserfs_security_free(struct reiserfs_security_handle *sec); + + static inline int reiserfs_xattrs_initialized(struct super_block *sb) + { +- return REISERFS_SB(sb)->priv_root != NULL; ++ return REISERFS_SB(sb)->priv_root && REISERFS_SB(sb)->xattr_root; + } + + #define xattr_size(size) ((size) + sizeof(struct reiserfs_xattr_header)) +diff --git a/include/linux/can/can-ml.h b/include/linux/can/can-ml.h +index 2f5d731ae251d..8afa92d15a664 100644 +--- a/include/linux/can/can-ml.h ++++ b/include/linux/can/can-ml.h +@@ -44,6 +44,7 @@ + + #include + #include ++#include + + #define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS) + #define CAN_EFF_RCV_HASH_BITS 10 +@@ -65,4 +66,15 @@ struct can_ml_priv { + #endif + }; + ++static inline struct can_ml_priv *can_get_ml_priv(struct net_device *dev) ++{ ++ return netdev_get_ml_priv(dev, ML_PRIV_CAN); ++} ++ ++static inline void can_set_ml_priv(struct net_device *dev, ++ struct can_ml_priv *ml_priv) ++{ ++ netdev_set_ml_priv(dev, ml_priv, ML_PRIV_CAN); ++} ++ + #endif /* CAN_ML_H */ +diff --git a/include/linux/extcon.h b/include/linux/extcon.h +index 2bdf643d85937..47d3e19a49ae4 100644 +--- a/include/linux/extcon.h ++++ b/include/linux/extcon.h +@@ -271,6 +271,29 @@ static inline void devm_extcon_unregister_notifier(struct device *dev, + struct extcon_dev *edev, unsigned int id, + struct notifier_block *nb) { } + ++static inline int extcon_register_notifier_all(struct extcon_dev *edev, ++ struct notifier_block *nb) ++{ ++ return 0; ++} ++ ++static inline int extcon_unregister_notifier_all(struct extcon_dev *edev, ++ struct notifier_block *nb) ++{ ++ return 0; ++} ++ ++static inline int devm_extcon_register_notifier_all(struct device *dev, ++ struct extcon_dev *edev, ++ struct notifier_block *nb) ++{ ++ return 0; ++} ++ ++static inline void devm_extcon_unregister_notifier_all(struct device *dev, ++ struct extcon_dev *edev, ++ struct notifier_block *nb) { } ++ + static inline struct extcon_dev *extcon_get_extcon_dev(const char *extcon_name) + { + return ERR_PTR(-ENODEV); +diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h +index db1b9623977c8..11a52f2fa35de 100644 +--- a/include/linux/netdevice.h ++++ b/include/linux/netdevice.h +@@ -1555,6 +1555,12 @@ enum netdev_priv_flags { + #define IFF_L3MDEV_RX_HANDLER IFF_L3MDEV_RX_HANDLER + #define IFF_LIVE_RENAME_OK IFF_LIVE_RENAME_OK + ++/* Specifies the type of the struct net_device::ml_priv pointer */ ++enum netdev_ml_priv_type { ++ ML_PRIV_NONE, ++ ML_PRIV_CAN, ++}; ++ + /** + * struct net_device - The DEVICE structure. + * +@@ -1732,6 +1738,7 @@ enum netdev_priv_flags { + * @nd_net: Network namespace this network device is inside + * + * @ml_priv: Mid-layer private ++ * @ml_priv_type: Mid-layer private type + * @lstats: Loopback statistics + * @tstats: Tunnel statistics + * @dstats: Dummy statistics +@@ -2019,8 +2026,10 @@ struct net_device { + possible_net_t nd_net; + + /* mid-layer private */ ++ void *ml_priv; ++ enum netdev_ml_priv_type ml_priv_type; ++ + union { +- void *ml_priv; + struct pcpu_lstats __percpu *lstats; + struct pcpu_sw_netstats __percpu *tstats; + struct pcpu_dstats __percpu *dstats; +@@ -2167,6 +2176,29 @@ static inline void netdev_reset_rx_headroom(struct net_device *dev) + netdev_set_rx_headroom(dev, -1); + } + ++static inline void *netdev_get_ml_priv(struct net_device *dev, ++ enum netdev_ml_priv_type type) ++{ ++ if (dev->ml_priv_type != type) ++ return NULL; ++ ++ return dev->ml_priv; ++} ++ ++static inline void netdev_set_ml_priv(struct net_device *dev, ++ void *ml_priv, ++ enum netdev_ml_priv_type type) ++{ ++ WARN(dev->ml_priv_type && dev->ml_priv_type != type, ++ "Overwriting already set ml_priv_type (%u) with different ml_priv_type (%u)!\n", ++ dev->ml_priv_type, type); ++ WARN(!dev->ml_priv_type && dev->ml_priv, ++ "Overwriting already set ml_priv and ml_priv_type is ML_PRIV_NONE!\n"); ++ ++ dev->ml_priv = ml_priv; ++ dev->ml_priv_type = type; ++} ++ + /* + * Net namespace inlines + */ +diff --git a/kernel/locking/mutex.c b/kernel/locking/mutex.c +index 468a9b8422e39..07a9f9f46e035 100644 +--- a/kernel/locking/mutex.c ++++ b/kernel/locking/mutex.c +@@ -636,7 +636,7 @@ static inline int mutex_can_spin_on_owner(struct mutex *lock) + */ + static __always_inline bool + mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx, +- const bool use_ww_ctx, struct mutex_waiter *waiter) ++ struct mutex_waiter *waiter) + { + if (!waiter) { + /* +@@ -712,7 +712,7 @@ fail: + #else + static __always_inline bool + mutex_optimistic_spin(struct mutex *lock, struct ww_acquire_ctx *ww_ctx, +- const bool use_ww_ctx, struct mutex_waiter *waiter) ++ struct mutex_waiter *waiter) + { + return false; + } +@@ -932,6 +932,9 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + struct ww_mutex *ww; + int ret; + ++ if (!use_ww_ctx) ++ ww_ctx = NULL; ++ + might_sleep(); + + #ifdef CONFIG_DEBUG_MUTEXES +@@ -939,7 +942,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + #endif + + ww = container_of(lock, struct ww_mutex, base); +- if (use_ww_ctx && ww_ctx) { ++ if (ww_ctx) { + if (unlikely(ww_ctx == READ_ONCE(ww->ctx))) + return -EALREADY; + +@@ -956,10 +959,10 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + mutex_acquire_nest(&lock->dep_map, subclass, 0, nest_lock, ip); + + if (__mutex_trylock(lock) || +- mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, NULL)) { ++ mutex_optimistic_spin(lock, ww_ctx, NULL)) { + /* got the lock, yay! */ + lock_acquired(&lock->dep_map, ip); +- if (use_ww_ctx && ww_ctx) ++ if (ww_ctx) + ww_mutex_set_context_fastpath(ww, ww_ctx); + preempt_enable(); + return 0; +@@ -970,7 +973,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + * After waiting to acquire the wait_lock, try again. + */ + if (__mutex_trylock(lock)) { +- if (use_ww_ctx && ww_ctx) ++ if (ww_ctx) + __ww_mutex_check_waiters(lock, ww_ctx); + + goto skip_wait; +@@ -1023,7 +1026,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + goto err; + } + +- if (use_ww_ctx && ww_ctx) { ++ if (ww_ctx) { + ret = __ww_mutex_check_kill(lock, &waiter, ww_ctx); + if (ret) + goto err; +@@ -1036,7 +1039,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + * ww_mutex needs to always recheck its position since its waiter + * list is not FIFO ordered. + */ +- if ((use_ww_ctx && ww_ctx) || !first) { ++ if (ww_ctx || !first) { + first = __mutex_waiter_is_first(lock, &waiter); + if (first) + __mutex_set_flag(lock, MUTEX_FLAG_HANDOFF); +@@ -1049,7 +1052,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + * or we must see its unlock and acquire. + */ + if (__mutex_trylock(lock) || +- (first && mutex_optimistic_spin(lock, ww_ctx, use_ww_ctx, &waiter))) ++ (first && mutex_optimistic_spin(lock, ww_ctx, &waiter))) + break; + + spin_lock(&lock->wait_lock); +@@ -1058,7 +1061,7 @@ __mutex_lock_common(struct mutex *lock, long state, unsigned int subclass, + acquired: + __set_current_state(TASK_RUNNING); + +- if (use_ww_ctx && ww_ctx) { ++ if (ww_ctx) { + /* + * Wound-Wait; we stole the lock (!first_waiter), check the + * waiters as anyone might want to wound us. +@@ -1078,7 +1081,7 @@ skip_wait: + /* got the lock - cleanup and rejoice! */ + lock_acquired(&lock->dep_map, ip); + +- if (use_ww_ctx && ww_ctx) ++ if (ww_ctx) + ww_mutex_lock_acquired(ww, ww_ctx); + + spin_unlock(&lock->wait_lock); +diff --git a/kernel/module.c b/kernel/module.c +index ab1f97cfe18dc..c60559b5bf101 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -2908,20 +2908,14 @@ static int module_sig_check(struct load_info *info, int flags) + * enforcing, certain errors are non-fatal. + */ + case -ENODATA: +- reason = "Loading of unsigned module"; +- goto decide; ++ reason = "unsigned module"; ++ break; + case -ENOPKG: +- reason = "Loading of module with unsupported crypto"; +- goto decide; ++ reason = "module with unsupported crypto"; ++ break; + case -ENOKEY: +- reason = "Loading of module with unavailable key"; +- decide: +- if (is_module_sig_enforced()) { +- pr_notice("%s is rejected\n", reason); +- return -EKEYREJECTED; +- } +- +- return security_locked_down(LOCKDOWN_MODULE_SIGNATURE); ++ reason = "module with unavailable key"; ++ break; + + /* All other errors are fatal, including nomem, unparseable + * signatures and signature check failures - even if signatures +@@ -2930,6 +2924,13 @@ static int module_sig_check(struct load_info *info, int flags) + default: + return err; + } ++ ++ if (is_module_sig_enforced()) { ++ pr_notice("Loading of %s is rejected\n", reason); ++ return -EKEYREJECTED; ++ } ++ ++ return security_locked_down(LOCKDOWN_MODULE_SIGNATURE); + } + #else /* !CONFIG_MODULE_SIG */ + static int module_sig_check(struct load_info *info, int flags) +@@ -2938,9 +2939,33 @@ static int module_sig_check(struct load_info *info, int flags) + } + #endif /* !CONFIG_MODULE_SIG */ + +-/* Sanity checks against invalid binaries, wrong arch, weird elf version. */ +-static int elf_header_check(struct load_info *info) ++static int validate_section_offset(struct load_info *info, Elf_Shdr *shdr) ++{ ++ unsigned long secend; ++ ++ /* ++ * Check for both overflow and offset/size being ++ * too large. ++ */ ++ secend = shdr->sh_offset + shdr->sh_size; ++ if (secend < shdr->sh_offset || secend > info->len) ++ return -ENOEXEC; ++ ++ return 0; ++} ++ ++/* ++ * Sanity checks against invalid binaries, wrong arch, weird elf version. ++ * ++ * Also do basic validity checks against section offsets and sizes, the ++ * section name string table, and the indices used for it (sh_name). ++ */ ++static int elf_validity_check(struct load_info *info) + { ++ unsigned int i; ++ Elf_Shdr *shdr, *strhdr; ++ int err; ++ + if (info->len < sizeof(*(info->hdr))) + return -ENOEXEC; + +@@ -2950,11 +2975,78 @@ static int elf_header_check(struct load_info *info) + || info->hdr->e_shentsize != sizeof(Elf_Shdr)) + return -ENOEXEC; + ++ /* ++ * e_shnum is 16 bits, and sizeof(Elf_Shdr) is ++ * known and small. So e_shnum * sizeof(Elf_Shdr) ++ * will not overflow unsigned long on any platform. ++ */ + if (info->hdr->e_shoff >= info->len + || (info->hdr->e_shnum * sizeof(Elf_Shdr) > + info->len - info->hdr->e_shoff)) + return -ENOEXEC; + ++ info->sechdrs = (void *)info->hdr + info->hdr->e_shoff; ++ ++ /* ++ * Verify if the section name table index is valid. ++ */ ++ if (info->hdr->e_shstrndx == SHN_UNDEF ++ || info->hdr->e_shstrndx >= info->hdr->e_shnum) ++ return -ENOEXEC; ++ ++ strhdr = &info->sechdrs[info->hdr->e_shstrndx]; ++ err = validate_section_offset(info, strhdr); ++ if (err < 0) ++ return err; ++ ++ /* ++ * The section name table must be NUL-terminated, as required ++ * by the spec. This makes strcmp and pr_* calls that access ++ * strings in the section safe. ++ */ ++ info->secstrings = (void *)info->hdr + strhdr->sh_offset; ++ if (info->secstrings[strhdr->sh_size - 1] != '\0') ++ return -ENOEXEC; ++ ++ /* ++ * The code assumes that section 0 has a length of zero and ++ * an addr of zero, so check for it. ++ */ ++ if (info->sechdrs[0].sh_type != SHT_NULL ++ || info->sechdrs[0].sh_size != 0 ++ || info->sechdrs[0].sh_addr != 0) ++ return -ENOEXEC; ++ ++ for (i = 1; i < info->hdr->e_shnum; i++) { ++ shdr = &info->sechdrs[i]; ++ switch (shdr->sh_type) { ++ case SHT_NULL: ++ case SHT_NOBITS: ++ continue; ++ case SHT_SYMTAB: ++ if (shdr->sh_link == SHN_UNDEF ++ || shdr->sh_link >= info->hdr->e_shnum) ++ return -ENOEXEC; ++ fallthrough; ++ default: ++ err = validate_section_offset(info, shdr); ++ if (err < 0) { ++ pr_err("Invalid ELF section in module (section %u type %u)\n", ++ i, shdr->sh_type); ++ return err; ++ } ++ ++ if (shdr->sh_flags & SHF_ALLOC) { ++ if (shdr->sh_name >= strhdr->sh_size) { ++ pr_err("Invalid ELF section name in module (section %u type %u)\n", ++ i, shdr->sh_type); ++ return -ENOEXEC; ++ } ++ } ++ break; ++ } ++ } ++ + return 0; + } + +@@ -3051,11 +3143,6 @@ static int rewrite_section_headers(struct load_info *info, int flags) + + for (i = 1; i < info->hdr->e_shnum; i++) { + Elf_Shdr *shdr = &info->sechdrs[i]; +- if (shdr->sh_type != SHT_NOBITS +- && info->len < shdr->sh_offset + shdr->sh_size) { +- pr_err("Module len %lu truncated\n", info->len); +- return -ENOEXEC; +- } + + /* Mark all sections sh_addr with their address in the + temporary image. */ +@@ -3087,11 +3174,6 @@ static int setup_load_info(struct load_info *info, int flags) + { + unsigned int i; + +- /* Set up the convenience variables */ +- info->sechdrs = (void *)info->hdr + info->hdr->e_shoff; +- info->secstrings = (void *)info->hdr +- + info->sechdrs[info->hdr->e_shstrndx].sh_offset; +- + /* Try to find a name early so we can log errors with a module name */ + info->index.info = find_sec(info, ".modinfo"); + if (info->index.info) +@@ -3819,23 +3901,49 @@ static int load_module(struct load_info *info, const char __user *uargs, + long err = 0; + char *after_dashes; + +- err = elf_header_check(info); ++ /* ++ * Do the signature check (if any) first. All that ++ * the signature check needs is info->len, it does ++ * not need any of the section info. That can be ++ * set up later. This will minimize the chances ++ * of a corrupt module causing problems before ++ * we even get to the signature check. ++ * ++ * The check will also adjust info->len by stripping ++ * off the sig length at the end of the module, making ++ * checks against info->len more correct. ++ */ ++ err = module_sig_check(info, flags); + if (err) + goto free_copy; + ++ /* ++ * Do basic sanity checks against the ELF header and ++ * sections. ++ */ ++ err = elf_validity_check(info); ++ if (err) { ++ pr_err("Module has invalid ELF structures\n"); ++ goto free_copy; ++ } ++ ++ /* ++ * Everything checks out, so set up the section info ++ * in the info structure. ++ */ + err = setup_load_info(info, flags); + if (err) + goto free_copy; + ++ /* ++ * Now that we know we have the correct module name, check ++ * if it's blacklisted. ++ */ + if (blacklisted(info->name)) { + err = -EPERM; + goto free_copy; + } + +- err = module_sig_check(info, flags); +- if (err) +- goto free_copy; +- + err = rewrite_section_headers(info, flags); + if (err) + goto free_copy; +diff --git a/kernel/module_signature.c b/kernel/module_signature.c +index 4224a1086b7d8..00132d12487cd 100644 +--- a/kernel/module_signature.c ++++ b/kernel/module_signature.c +@@ -25,7 +25,7 @@ int mod_check_sig(const struct module_signature *ms, size_t file_len, + return -EBADMSG; + + if (ms->id_type != PKEY_ID_PKCS7) { +- pr_err("%s: Module is not signed with expected PKCS#7 message\n", ++ pr_err("%s: not signed with expected PKCS#7 message\n", + name); + return -ENOPKG; + } +diff --git a/kernel/module_signing.c b/kernel/module_signing.c +index 9d9fc678c91d6..8723ae70ea1fe 100644 +--- a/kernel/module_signing.c ++++ b/kernel/module_signing.c +@@ -30,7 +30,7 @@ int mod_verify_sig(const void *mod, struct load_info *info) + + memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms)); + +- ret = mod_check_sig(&ms, modlen, info->name); ++ ret = mod_check_sig(&ms, modlen, "module"); + if (ret) + return ret; + +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 1a75610f5f57b..1b5f54b309be5 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -2857,7 +2857,8 @@ static void __ftrace_trace_stack(struct ring_buffer *buffer, + + size = nr_entries * sizeof(unsigned long); + event = __trace_buffer_lock_reserve(buffer, TRACE_STACK, +- sizeof(*entry) + size, flags, pc); ++ (sizeof(*entry) - sizeof(entry->caller)) + size, ++ flags, pc); + if (!event) + goto out; + entry = ring_buffer_event_data(event); +diff --git a/mm/memory.c b/mm/memory.c +index c432e7c764451..13a575ce2ec8f 100644 +--- a/mm/memory.c ++++ b/mm/memory.c +@@ -150,7 +150,7 @@ static int __init init_zero_pfn(void) + zero_pfn = page_to_pfn(ZERO_PAGE(0)); + return 0; + } +-core_initcall(init_zero_pfn); ++early_initcall(init_zero_pfn); + + + #if defined(SPLIT_RSS_COUNTING) +diff --git a/net/appletalk/ddp.c b/net/appletalk/ddp.c +index b41375d4d295d..4610c352849bc 100644 +--- a/net/appletalk/ddp.c ++++ b/net/appletalk/ddp.c +@@ -1568,8 +1568,8 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + struct sk_buff *skb; + struct net_device *dev; + struct ddpehdr *ddp; +- int size; +- struct atalk_route *rt; ++ int size, hard_header_len; ++ struct atalk_route *rt, *rt_lo = NULL; + int err; + + if (flags & ~(MSG_DONTWAIT|MSG_CMSG_COMPAT)) +@@ -1632,7 +1632,22 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + SOCK_DEBUG(sk, "SK %p: Size needed %d, device %s\n", + sk, size, dev->name); + +- size += dev->hard_header_len; ++ hard_header_len = dev->hard_header_len; ++ /* Leave room for loopback hardware header if necessary */ ++ if (usat->sat_addr.s_node == ATADDR_BCAST && ++ (dev->flags & IFF_LOOPBACK || !(rt->flags & RTF_GATEWAY))) { ++ struct atalk_addr at_lo; ++ ++ at_lo.s_node = 0; ++ at_lo.s_net = 0; ++ ++ rt_lo = atrtr_find(&at_lo); ++ ++ if (rt_lo && rt_lo->dev->hard_header_len > hard_header_len) ++ hard_header_len = rt_lo->dev->hard_header_len; ++ } ++ ++ size += hard_header_len; + release_sock(sk); + skb = sock_alloc_send_skb(sk, size, (flags & MSG_DONTWAIT), &err); + lock_sock(sk); +@@ -1640,7 +1655,7 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + goto out; + + skb_reserve(skb, ddp_dl->header_length); +- skb_reserve(skb, dev->hard_header_len); ++ skb_reserve(skb, hard_header_len); + skb->dev = dev; + + SOCK_DEBUG(sk, "SK %p: Begin build.\n", sk); +@@ -1691,18 +1706,12 @@ static int atalk_sendmsg(struct socket *sock, struct msghdr *msg, size_t len) + /* loop back */ + skb_orphan(skb); + if (ddp->deh_dnode == ATADDR_BCAST) { +- struct atalk_addr at_lo; +- +- at_lo.s_node = 0; +- at_lo.s_net = 0; +- +- rt = atrtr_find(&at_lo); +- if (!rt) { ++ if (!rt_lo) { + kfree_skb(skb); + err = -ENETUNREACH; + goto out; + } +- dev = rt->dev; ++ dev = rt_lo->dev; + skb->dev = dev; + } + ddp_dl->request(ddp_dl, skb, dev->dev_addr); +diff --git a/net/can/af_can.c b/net/can/af_can.c +index 306d3584a4417..c758a12ffe461 100644 +--- a/net/can/af_can.c ++++ b/net/can/af_can.c +@@ -304,8 +304,8 @@ static struct can_dev_rcv_lists *can_dev_rcv_lists_find(struct net *net, + struct net_device *dev) + { + if (dev) { +- struct can_ml_priv *ml_priv = dev->ml_priv; +- return &ml_priv->dev_rcv_lists; ++ struct can_ml_priv *can_ml = can_get_ml_priv(dev); ++ return &can_ml->dev_rcv_lists; + } else { + return net->can.rx_alldev_list; + } +@@ -788,25 +788,6 @@ void can_proto_unregister(const struct can_proto *cp) + } + EXPORT_SYMBOL(can_proto_unregister); + +-/* af_can notifier to create/remove CAN netdevice specific structs */ +-static int can_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; +- +- switch (msg) { +- case NETDEV_REGISTER: +- WARN(!dev->ml_priv, +- "No CAN mid layer private allocated, please fix your driver and use alloc_candev()!\n"); +- break; +- } +- +- return NOTIFY_DONE; +-} +- + static int can_pernet_init(struct net *net) + { + spin_lock_init(&net->can.rcvlists_lock); +@@ -874,11 +855,6 @@ static const struct net_proto_family can_family_ops = { + .owner = THIS_MODULE, + }; + +-/* notifier block for netdevice event */ +-static struct notifier_block can_netdev_notifier __read_mostly = { +- .notifier_call = can_notifier, +-}; +- + static struct pernet_operations can_pernet_ops __read_mostly = { + .init = can_pernet_init, + .exit = can_pernet_exit, +@@ -909,17 +885,12 @@ static __init int can_init(void) + err = sock_register(&can_family_ops); + if (err) + goto out_sock; +- err = register_netdevice_notifier(&can_netdev_notifier); +- if (err) +- goto out_notifier; + + dev_add_pack(&can_packet); + dev_add_pack(&canfd_packet); + + return 0; + +-out_notifier: +- sock_unregister(PF_CAN); + out_sock: + unregister_pernet_subsys(&can_pernet_ops); + out_pernet: +@@ -933,7 +904,6 @@ static __exit void can_exit(void) + /* protocol unregister */ + dev_remove_pack(&canfd_packet); + dev_remove_pack(&can_packet); +- unregister_netdevice_notifier(&can_netdev_notifier); + sock_unregister(PF_CAN); + + unregister_pernet_subsys(&can_pernet_ops); +diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c +index 137054bff9ec7..e52330f628c9f 100644 +--- a/net/can/j1939/main.c ++++ b/net/can/j1939/main.c +@@ -140,9 +140,9 @@ static struct j1939_priv *j1939_priv_create(struct net_device *ndev) + static inline void j1939_priv_set(struct net_device *ndev, + struct j1939_priv *priv) + { +- struct can_ml_priv *can_ml_priv = ndev->ml_priv; ++ struct can_ml_priv *can_ml = can_get_ml_priv(ndev); + +- can_ml_priv->j1939_priv = priv; ++ can_ml->j1939_priv = priv; + } + + static void __j1939_priv_release(struct kref *kref) +@@ -211,12 +211,9 @@ static void __j1939_rx_release(struct kref *kref) + /* get pointer to priv without increasing ref counter */ + static inline struct j1939_priv *j1939_ndev_to_priv(struct net_device *ndev) + { +- struct can_ml_priv *can_ml_priv = ndev->ml_priv; ++ struct can_ml_priv *can_ml = can_get_ml_priv(ndev); + +- if (!can_ml_priv) +- return NULL; +- +- return can_ml_priv->j1939_priv; ++ return can_ml->j1939_priv; + } + + static struct j1939_priv *j1939_priv_get_by_ndev_locked(struct net_device *ndev) +@@ -225,9 +222,6 @@ static struct j1939_priv *j1939_priv_get_by_ndev_locked(struct net_device *ndev) + + lockdep_assert_held(&j1939_netdev_lock); + +- if (ndev->type != ARPHRD_CAN) +- return NULL; +- + priv = j1939_ndev_to_priv(ndev); + if (priv) + j1939_priv_get(priv); +@@ -348,15 +342,16 @@ static int j1939_netdev_notify(struct notifier_block *nb, + unsigned long msg, void *data) + { + struct net_device *ndev = netdev_notifier_info_to_dev(data); ++ struct can_ml_priv *can_ml = can_get_ml_priv(ndev); + struct j1939_priv *priv; + ++ if (!can_ml) ++ goto notify_done; ++ + priv = j1939_priv_get_by_ndev(ndev); + if (!priv) + goto notify_done; + +- if (ndev->type != ARPHRD_CAN) +- goto notify_put; +- + switch (msg) { + case NETDEV_DOWN: + j1939_cancel_active_session(priv, NULL); +@@ -365,7 +360,6 @@ static int j1939_netdev_notify(struct notifier_block *nb, + break; + } + +-notify_put: + j1939_priv_put(priv); + + notify_done: +diff --git a/net/can/j1939/socket.c b/net/can/j1939/socket.c +index 0470909605392..d57475c8ba07f 100644 +--- a/net/can/j1939/socket.c ++++ b/net/can/j1939/socket.c +@@ -12,6 +12,7 @@ + + #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + ++#include + #include + #include + #include +@@ -453,6 +454,7 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len) + j1939_jsk_del(priv, jsk); + j1939_local_ecu_put(priv, jsk->addr.src_name, jsk->addr.sa); + } else { ++ struct can_ml_priv *can_ml; + struct net_device *ndev; + + ndev = dev_get_by_index(net, addr->can_ifindex); +@@ -461,15 +463,8 @@ static int j1939_sk_bind(struct socket *sock, struct sockaddr *uaddr, int len) + goto out_release_sock; + } + +- if (ndev->type != ARPHRD_CAN) { +- dev_put(ndev); +- ret = -ENODEV; +- goto out_release_sock; +- } +- +- if (!ndev->ml_priv) { +- netdev_warn_once(ndev, +- "No CAN mid layer private allocated, please fix your driver and use alloc_candev()!\n"); ++ can_ml = can_get_ml_priv(ndev); ++ if (!can_ml) { + dev_put(ndev); + ret = -ENODEV; + goto out_release_sock; +diff --git a/net/can/proc.c b/net/can/proc.c +index 077af42c26ba5..a5fc63c78370e 100644 +--- a/net/can/proc.c ++++ b/net/can/proc.c +@@ -329,8 +329,11 @@ static int can_rcvlist_proc_show(struct seq_file *m, void *v) + + /* receive list for registered CAN devices */ + for_each_netdev_rcu(net, dev) { +- if (dev->type == ARPHRD_CAN && dev->ml_priv) +- can_rcvlist_proc_show_one(m, idx, dev, dev->ml_priv); ++ struct can_ml_priv *can_ml = can_get_ml_priv(dev); ++ ++ if (can_ml) ++ can_rcvlist_proc_show_one(m, idx, dev, ++ &can_ml->dev_rcv_lists); + } + + rcu_read_unlock(); +@@ -382,8 +385,10 @@ static int can_rcvlist_sff_proc_show(struct seq_file *m, void *v) + + /* sff receive list for registered CAN devices */ + for_each_netdev_rcu(net, dev) { +- if (dev->type == ARPHRD_CAN && dev->ml_priv) { +- dev_rcv_lists = dev->ml_priv; ++ struct can_ml_priv *can_ml = can_get_ml_priv(dev); ++ ++ if (can_ml) { ++ dev_rcv_lists = &can_ml->dev_rcv_lists; + can_rcvlist_proc_show_array(m, dev, dev_rcv_lists->rx_sff, + ARRAY_SIZE(dev_rcv_lists->rx_sff)); + } +@@ -413,8 +418,10 @@ static int can_rcvlist_eff_proc_show(struct seq_file *m, void *v) + + /* eff receive list for registered CAN devices */ + for_each_netdev_rcu(net, dev) { +- if (dev->type == ARPHRD_CAN && dev->ml_priv) { +- dev_rcv_lists = dev->ml_priv; ++ struct can_ml_priv *can_ml = can_get_ml_priv(dev); ++ ++ if (can_ml) { ++ dev_rcv_lists = &can_ml->dev_rcv_lists; + can_rcvlist_proc_show_array(m, dev, dev_rcv_lists->rx_eff, + ARRAY_SIZE(dev_rcv_lists->rx_eff)); + } +diff --git a/net/core/filter.c b/net/core/filter.c +index 524f3364f8a05..7fbb274b7fe32 100644 +--- a/net/core/filter.c ++++ b/net/core/filter.c +@@ -3146,18 +3146,14 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, u32 off, u32 len_diff, + return 0; + } + +-static u32 __bpf_skb_max_len(const struct sk_buff *skb) +-{ +- return skb->dev ? skb->dev->mtu + skb->dev->hard_header_len : +- SKB_MAX_ALLOC; +-} ++#define BPF_SKB_MAX_LEN SKB_MAX_ALLOC + + BPF_CALL_4(bpf_skb_adjust_room, struct sk_buff *, skb, s32, len_diff, + u32, mode, u64, flags) + { + u32 len_cur, len_diff_abs = abs(len_diff); + u32 len_min = bpf_skb_net_base_len(skb); +- u32 len_max = __bpf_skb_max_len(skb); ++ u32 len_max = BPF_SKB_MAX_LEN; + __be16 proto = skb->protocol; + bool shrink = len_diff < 0; + u32 off; +@@ -3237,7 +3233,7 @@ static int bpf_skb_trim_rcsum(struct sk_buff *skb, unsigned int new_len) + static inline int __bpf_skb_change_tail(struct sk_buff *skb, u32 new_len, + u64 flags) + { +- u32 max_len = __bpf_skb_max_len(skb); ++ u32 max_len = BPF_SKB_MAX_LEN; + u32 min_len = __bpf_skb_min_len(skb); + int ret; + +@@ -3313,7 +3309,7 @@ static const struct bpf_func_proto sk_skb_change_tail_proto = { + static inline int __bpf_skb_change_head(struct sk_buff *skb, u32 head_room, + u64 flags) + { +- u32 max_len = __bpf_skb_max_len(skb); ++ u32 max_len = BPF_SKB_MAX_LEN; + u32 new_len = skb->len + head_room; + int ret; + +diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c +index e3bdd859c895c..da86c0e1b677d 100644 +--- a/net/core/flow_dissector.c ++++ b/net/core/flow_dissector.c +@@ -1028,6 +1028,9 @@ proto_again: + key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS; + } + ++ __skb_flow_dissect_ipv4(skb, flow_dissector, ++ target_container, data, iph); ++ + if (ip_is_fragment(iph)) { + key_control->flags |= FLOW_DIS_IS_FRAGMENT; + +@@ -1044,9 +1047,6 @@ proto_again: + } + } + +- __skb_flow_dissect_ipv4(skb, flow_dissector, +- target_container, data, iph); +- + break; + } + case htons(ETH_P_IPV6): { +diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c +index 1e5e08cc0bfc3..9f73ccf46c9b1 100644 +--- a/net/dccp/ipv6.c ++++ b/net/dccp/ipv6.c +@@ -319,6 +319,11 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) + if (!ipv6_unicast_destination(skb)) + return 0; /* discard, don't send a reset here */ + ++ if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) { ++ __IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS); ++ return 0; ++ } ++ + if (dccp_bad_service_code(sk, service)) { + dcb->dccpd_reset_code = DCCP_RESET_CODE_BAD_SERVICE_CODE; + goto drop; +diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c +index 3d71c7d6102c4..7e5df23cbe7bf 100644 +--- a/net/ipv6/ip6_input.c ++++ b/net/ipv6/ip6_input.c +@@ -223,16 +223,6 @@ static struct sk_buff *ip6_rcv_core(struct sk_buff *skb, struct net_device *dev, + if (ipv6_addr_is_multicast(&hdr->saddr)) + goto err; + +- /* While RFC4291 is not explicit about v4mapped addresses +- * in IPv6 headers, it seems clear linux dual-stack +- * model can not deal properly with these. +- * Security models could be fooled by ::ffff:127.0.0.1 for example. +- * +- * https://tools.ietf.org/html/draft-itojun-v6ops-v4mapped-harmful-02 +- */ +- if (ipv6_addr_v4mapped(&hdr->saddr)) +- goto err; +- + skb->transport_header = skb->network_header + sizeof(*hdr); + IP6CB(skb)->nhoff = offsetof(struct ipv6hdr, nexthdr); + +diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c +index b42fa41cfceb5..2f061a911bc2c 100644 +--- a/net/ipv6/tcp_ipv6.c ++++ b/net/ipv6/tcp_ipv6.c +@@ -1093,6 +1093,11 @@ static int tcp_v6_conn_request(struct sock *sk, struct sk_buff *skb) + if (!ipv6_unicast_destination(skb)) + goto drop; + ++ if (ipv6_addr_v4mapped(&ipv6_hdr(skb)->saddr)) { ++ __IP6_INC_STATS(sock_net(sk), NULL, IPSTATS_MIB_INHDRERRORS); ++ return 0; ++ } ++ + return tcp_conn_request(&tcp6_request_sock_ops, + &tcp_request_sock_ipv6_ops, sk, skb); + +diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c +index cf4d6d7e72822..d5470c7fe8792 100644 +--- a/net/sunrpc/auth_gss/svcauth_gss.c ++++ b/net/sunrpc/auth_gss/svcauth_gss.c +@@ -1782,11 +1782,14 @@ static int + svcauth_gss_release(struct svc_rqst *rqstp) + { + struct gss_svc_data *gsd = (struct gss_svc_data *)rqstp->rq_auth_data; +- struct rpc_gss_wire_cred *gc = &gsd->clcred; ++ struct rpc_gss_wire_cred *gc; + struct xdr_buf *resbuf = &rqstp->rq_res; + int stat = -EINVAL; + struct sunrpc_net *sn = net_generic(SVC_NET(rqstp), sunrpc_net_id); + ++ if (!gsd) ++ goto out; ++ gc = &gsd->clcred; + if (gc->gc_proc != RPC_GSS_PROC_DATA) + goto out; + /* Release can be called twice, but we only wrap once. */ +@@ -1827,10 +1830,10 @@ out_err: + if (rqstp->rq_cred.cr_group_info) + put_group_info(rqstp->rq_cred.cr_group_info); + rqstp->rq_cred.cr_group_info = NULL; +- if (gsd->rsci) ++ if (gsd && gsd->rsci) { + cache_put(&gsd->rsci->h, sn->rsc_cache); +- gsd->rsci = NULL; +- ++ gsd->rsci = NULL; ++ } + return stat; + } + +diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c +index 5d323574d04fe..c82e7b52ab1f8 100644 +--- a/net/vmw_vsock/af_vsock.c ++++ b/net/vmw_vsock/af_vsock.c +@@ -620,6 +620,7 @@ struct sock *__vsock_create(struct net *net, + vsk->trusted = psk->trusted; + vsk->owner = get_cred(psk->owner); + vsk->connect_timeout = psk->connect_timeout; ++ security_sk_clone(parent, sk); + } else { + vsk->trusted = ns_capable_noaudit(&init_user_ns, CAP_NET_ADMIN); + vsk->owner = get_current_cred(); +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c +index febd16c9efd7a..ebb1ee69dd0c3 100644 +--- a/sound/pci/hda/hda_intel.c ++++ b/sound/pci/hda/hda_intel.c +@@ -1022,8 +1022,12 @@ static int azx_prepare(struct device *dev) + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip; + ++ if (!azx_is_pm_ready(card)) ++ return 0; ++ + chip = card->private_data; + chip->pm_prepared = 1; ++ snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); + + flush_work(&azx_bus(chip)->unsol_work); + +@@ -1038,7 +1042,11 @@ static void azx_complete(struct device *dev) + struct snd_card *card = dev_get_drvdata(dev); + struct azx *chip; + ++ if (!azx_is_pm_ready(card)) ++ return; ++ + chip = card->private_data; ++ snd_power_change_state(card, SNDRV_CTL_POWER_D0); + chip->pm_prepared = 0; + } + +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 73580e8208ed1..3c9e072db3538 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -5192,7 +5192,7 @@ static void alc_determine_headset_type(struct hda_codec *codec) + case 0x10ec0274: + case 0x10ec0294: + alc_process_coef_fw(codec, coef0274); +- msleep(80); ++ msleep(850); + val = alc_read_coef_idx(codec, 0x46); + is_ctia = (val & 0x00f0) == 0x00f0; + break; +@@ -5376,6 +5376,7 @@ static void alc_update_headset_jack_cb(struct hda_codec *codec, + struct hda_jack_callback *jack) + { + snd_hda_gen_hp_automute(codec, jack); ++ alc_update_headset_mode(codec); + } + + static void alc_probe_headset_mode(struct hda_codec *codec) +diff --git a/sound/soc/codecs/cs42l42.c b/sound/soc/codecs/cs42l42.c +index 5125bb9b37b55..dcd2acb2c3cef 100644 +--- a/sound/soc/codecs/cs42l42.c ++++ b/sound/soc/codecs/cs42l42.c +@@ -401,7 +401,7 @@ static const struct regmap_config cs42l42_regmap = { + }; + + static DECLARE_TLV_DB_SCALE(adc_tlv, -9600, 100, false); +-static DECLARE_TLV_DB_SCALE(mixer_tlv, -6200, 100, false); ++static DECLARE_TLV_DB_SCALE(mixer_tlv, -6300, 100, true); + + static const char * const cs42l42_hpf_freq_text[] = { + "1.86Hz", "120Hz", "235Hz", "466Hz" +@@ -458,7 +458,7 @@ static const struct snd_kcontrol_new cs42l42_snd_controls[] = { + CS42L42_DAC_HPF_EN_SHIFT, true, false), + SOC_DOUBLE_R_TLV("Mixer Volume", CS42L42_MIXER_CHA_VOL, + CS42L42_MIXER_CHB_VOL, CS42L42_MIXER_CH_VOL_SHIFT, +- 0x3e, 1, mixer_tlv) ++ 0x3f, 1, mixer_tlv) + }; + + static int cs42l42_hpdrv_evt(struct snd_soc_dapm_widget *w, +@@ -691,24 +691,6 @@ static int cs42l42_pll_config(struct snd_soc_component *component) + CS42L42_CLK_OASRC_SEL_MASK, + CS42L42_CLK_OASRC_SEL_12 << + CS42L42_CLK_OASRC_SEL_SHIFT); +- /* channel 1 on low LRCLK, 32 bit */ +- snd_soc_component_update_bits(component, +- CS42L42_ASP_RX_DAI0_CH1_AP_RES, +- CS42L42_ASP_RX_CH_AP_MASK | +- CS42L42_ASP_RX_CH_RES_MASK, +- (CS42L42_ASP_RX_CH_AP_LOW << +- CS42L42_ASP_RX_CH_AP_SHIFT) | +- (CS42L42_ASP_RX_CH_RES_32 << +- CS42L42_ASP_RX_CH_RES_SHIFT)); +- /* Channel 2 on high LRCLK, 32 bit */ +- snd_soc_component_update_bits(component, +- CS42L42_ASP_RX_DAI0_CH2_AP_RES, +- CS42L42_ASP_RX_CH_AP_MASK | +- CS42L42_ASP_RX_CH_RES_MASK, +- (CS42L42_ASP_RX_CH_AP_HI << +- CS42L42_ASP_RX_CH_AP_SHIFT) | +- (CS42L42_ASP_RX_CH_RES_32 << +- CS42L42_ASP_RX_CH_RES_SHIFT)); + if (pll_ratio_table[i].mclk_src_sel == 0) { + /* Pass the clock straight through */ + snd_soc_component_update_bits(component, +@@ -797,27 +779,23 @@ static int cs42l42_set_dai_fmt(struct snd_soc_dai *codec_dai, unsigned int fmt) + /* Bitclock/frame inversion */ + switch (fmt & SND_SOC_DAIFMT_INV_MASK) { + case SND_SOC_DAIFMT_NB_NF: ++ asp_cfg_val |= CS42L42_ASP_SCPOL_NOR << CS42L42_ASP_SCPOL_SHIFT; + break; + case SND_SOC_DAIFMT_NB_IF: +- asp_cfg_val |= CS42L42_ASP_POL_INV << +- CS42L42_ASP_LCPOL_IN_SHIFT; ++ asp_cfg_val |= CS42L42_ASP_SCPOL_NOR << CS42L42_ASP_SCPOL_SHIFT; ++ asp_cfg_val |= CS42L42_ASP_LCPOL_INV << CS42L42_ASP_LCPOL_SHIFT; + break; + case SND_SOC_DAIFMT_IB_NF: +- asp_cfg_val |= CS42L42_ASP_POL_INV << +- CS42L42_ASP_SCPOL_IN_DAC_SHIFT; + break; + case SND_SOC_DAIFMT_IB_IF: +- asp_cfg_val |= CS42L42_ASP_POL_INV << +- CS42L42_ASP_LCPOL_IN_SHIFT; +- asp_cfg_val |= CS42L42_ASP_POL_INV << +- CS42L42_ASP_SCPOL_IN_DAC_SHIFT; ++ asp_cfg_val |= CS42L42_ASP_LCPOL_INV << CS42L42_ASP_LCPOL_SHIFT; + break; + } + +- snd_soc_component_update_bits(component, CS42L42_ASP_CLK_CFG, +- CS42L42_ASP_MODE_MASK | +- CS42L42_ASP_SCPOL_IN_DAC_MASK | +- CS42L42_ASP_LCPOL_IN_MASK, asp_cfg_val); ++ snd_soc_component_update_bits(component, CS42L42_ASP_CLK_CFG, CS42L42_ASP_MODE_MASK | ++ CS42L42_ASP_SCPOL_MASK | ++ CS42L42_ASP_LCPOL_MASK, ++ asp_cfg_val); + + return 0; + } +@@ -828,14 +806,29 @@ static int cs42l42_pcm_hw_params(struct snd_pcm_substream *substream, + { + struct snd_soc_component *component = dai->component; + struct cs42l42_private *cs42l42 = snd_soc_component_get_drvdata(component); +- int retval; ++ unsigned int width = (params_width(params) / 8) - 1; ++ unsigned int val = 0; + + cs42l42->srate = params_rate(params); +- cs42l42->swidth = params_width(params); + +- retval = cs42l42_pll_config(component); ++ switch(substream->stream) { ++ case SNDRV_PCM_STREAM_PLAYBACK: ++ val |= width << CS42L42_ASP_RX_CH_RES_SHIFT; ++ /* channel 1 on low LRCLK */ ++ snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH1_AP_RES, ++ CS42L42_ASP_RX_CH_AP_MASK | ++ CS42L42_ASP_RX_CH_RES_MASK, val); ++ /* Channel 2 on high LRCLK */ ++ val |= CS42L42_ASP_RX_CH_AP_HI << CS42L42_ASP_RX_CH_AP_SHIFT; ++ snd_soc_component_update_bits(component, CS42L42_ASP_RX_DAI0_CH2_AP_RES, ++ CS42L42_ASP_RX_CH_AP_MASK | ++ CS42L42_ASP_RX_CH_RES_MASK, val); ++ break; ++ default: ++ break; ++ } + +- return retval; ++ return cs42l42_pll_config(component); + } + + static int cs42l42_set_sysclk(struct snd_soc_dai *dai, +@@ -900,9 +893,9 @@ static int cs42l42_digital_mute(struct snd_soc_dai *dai, int mute) + return 0; + } + +-#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S18_3LE | \ +- SNDRV_PCM_FMTBIT_S20_3LE | SNDRV_PCM_FMTBIT_S24_LE | \ +- SNDRV_PCM_FMTBIT_S32_LE) ++#define CS42L42_FORMATS (SNDRV_PCM_FMTBIT_S16_LE |\ ++ SNDRV_PCM_FMTBIT_S24_LE |\ ++ SNDRV_PCM_FMTBIT_S32_LE ) + + + static const struct snd_soc_dai_ops cs42l42_ops = { +@@ -1803,7 +1796,7 @@ static int cs42l42_i2c_probe(struct i2c_client *i2c_client, + dev_dbg(&i2c_client->dev, "Found reset GPIO\n"); + gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); + } +- mdelay(3); ++ usleep_range(CS42L42_BOOT_TIME_US, CS42L42_BOOT_TIME_US * 2); + + /* Request IRQ */ + ret = devm_request_threaded_irq(&i2c_client->dev, +@@ -1928,6 +1921,7 @@ static int cs42l42_runtime_resume(struct device *dev) + } + + gpiod_set_value_cansleep(cs42l42->reset_gpio, 1); ++ usleep_range(CS42L42_BOOT_TIME_US, CS42L42_BOOT_TIME_US * 2); + + regcache_cache_only(cs42l42->regmap, false); + regcache_sync(cs42l42->regmap); +diff --git a/sound/soc/codecs/cs42l42.h b/sound/soc/codecs/cs42l42.h +index 9e3cc528dcff0..866d7c873e3c9 100644 +--- a/sound/soc/codecs/cs42l42.h ++++ b/sound/soc/codecs/cs42l42.h +@@ -258,11 +258,12 @@ + #define CS42L42_ASP_SLAVE_MODE 0x00 + #define CS42L42_ASP_MODE_SHIFT 4 + #define CS42L42_ASP_MODE_MASK (1 << CS42L42_ASP_MODE_SHIFT) +-#define CS42L42_ASP_SCPOL_IN_DAC_SHIFT 2 +-#define CS42L42_ASP_SCPOL_IN_DAC_MASK (1 << CS42L42_ASP_SCPOL_IN_DAC_SHIFT) +-#define CS42L42_ASP_LCPOL_IN_SHIFT 0 +-#define CS42L42_ASP_LCPOL_IN_MASK (1 << CS42L42_ASP_LCPOL_IN_SHIFT) +-#define CS42L42_ASP_POL_INV 1 ++#define CS42L42_ASP_SCPOL_SHIFT 2 ++#define CS42L42_ASP_SCPOL_MASK (3 << CS42L42_ASP_SCPOL_SHIFT) ++#define CS42L42_ASP_SCPOL_NOR 3 ++#define CS42L42_ASP_LCPOL_SHIFT 0 ++#define CS42L42_ASP_LCPOL_MASK (3 << CS42L42_ASP_LCPOL_SHIFT) ++#define CS42L42_ASP_LCPOL_INV 3 + + #define CS42L42_ASP_FRM_CFG (CS42L42_PAGE_12 + 0x08) + #define CS42L42_ASP_STP_SHIFT 4 +@@ -739,6 +740,7 @@ + #define CS42L42_FRAC2_VAL(val) (((val) & 0xff0000) >> 16) + + #define CS42L42_NUM_SUPPLIES 5 ++#define CS42L42_BOOT_TIME_US 3000 + + static const char *const cs42l42_supply_names[CS42L42_NUM_SUPPLIES] = { + "VA", +@@ -756,7 +758,6 @@ struct cs42l42_private { + struct completion pdn_done; + u32 sclk; + u32 srate; +- u32 swidth; + u8 plug_state; + u8 hs_type; + u8 ts_inv; +diff --git a/sound/soc/codecs/es8316.c b/sound/soc/codecs/es8316.c +index 36eef1fb3d181..b781b28de0126 100644 +--- a/sound/soc/codecs/es8316.c ++++ b/sound/soc/codecs/es8316.c +@@ -63,13 +63,8 @@ static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(adc_pga_gain_tlv, + 1, 1, TLV_DB_SCALE_ITEM(0, 0, 0), + 2, 2, TLV_DB_SCALE_ITEM(250, 0, 0), + 3, 3, TLV_DB_SCALE_ITEM(450, 0, 0), +- 4, 4, TLV_DB_SCALE_ITEM(700, 0, 0), +- 5, 5, TLV_DB_SCALE_ITEM(1000, 0, 0), +- 6, 6, TLV_DB_SCALE_ITEM(1300, 0, 0), +- 7, 7, TLV_DB_SCALE_ITEM(1600, 0, 0), +- 8, 8, TLV_DB_SCALE_ITEM(1800, 0, 0), +- 9, 9, TLV_DB_SCALE_ITEM(2100, 0, 0), +- 10, 10, TLV_DB_SCALE_ITEM(2400, 0, 0), ++ 4, 7, TLV_DB_SCALE_ITEM(700, 300, 0), ++ 8, 10, TLV_DB_SCALE_ITEM(1800, 300, 0), + ); + + static const SNDRV_CTL_TLVD_DECLARE_DB_RANGE(hpout_vol_tlv, +diff --git a/sound/soc/codecs/rt5640.c b/sound/soc/codecs/rt5640.c +index 747ca248bf10c..3bc63fbcb1889 100644 +--- a/sound/soc/codecs/rt5640.c ++++ b/sound/soc/codecs/rt5640.c +@@ -339,9 +339,9 @@ static bool rt5640_readable_register(struct device *dev, unsigned int reg) + } + + static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); +-static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); ++static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0); + static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); +-static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); ++static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000); + static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); + + /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ +diff --git a/sound/soc/codecs/rt5651.c b/sound/soc/codecs/rt5651.c +index c506c9305043e..829cf552fe3e8 100644 +--- a/sound/soc/codecs/rt5651.c ++++ b/sound/soc/codecs/rt5651.c +@@ -285,9 +285,9 @@ static bool rt5651_readable_register(struct device *dev, unsigned int reg) + } + + static const DECLARE_TLV_DB_SCALE(out_vol_tlv, -4650, 150, 0); +-static const DECLARE_TLV_DB_SCALE(dac_vol_tlv, -65625, 375, 0); ++static const DECLARE_TLV_DB_MINMAX(dac_vol_tlv, -6562, 0); + static const DECLARE_TLV_DB_SCALE(in_vol_tlv, -3450, 150, 0); +-static const DECLARE_TLV_DB_SCALE(adc_vol_tlv, -17625, 375, 0); ++static const DECLARE_TLV_DB_MINMAX(adc_vol_tlv, -1762, 3000); + static const DECLARE_TLV_DB_SCALE(adc_bst_tlv, 0, 1200, 0); + + /* {0, +20, +24, +30, +35, +40, +44, +50, +52} dB */ +diff --git a/sound/soc/codecs/rt5659.c b/sound/soc/codecs/rt5659.c +index e66d08398f746..afd61599d94c9 100644 +--- a/sound/soc/codecs/rt5659.c ++++ b/sound/soc/codecs/rt5659.c +@@ -3463,12 +3463,17 @@ static int rt5659_set_component_sysclk(struct snd_soc_component *component, int + { + struct rt5659_priv *rt5659 = snd_soc_component_get_drvdata(component); + unsigned int reg_val = 0; ++ int ret; + + if (freq == rt5659->sysclk && clk_id == rt5659->sysclk_src) + return 0; + + switch (clk_id) { + case RT5659_SCLK_S_MCLK: ++ ret = clk_set_rate(rt5659->mclk, freq); ++ if (ret) ++ return ret; ++ + reg_val |= RT5659_SCLK_SRC_MCLK; + break; + case RT5659_SCLK_S_PLL1: +diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c +index f5b59305c957a..8a1e485982d81 100644 +--- a/sound/soc/codecs/sgtl5000.c ++++ b/sound/soc/codecs/sgtl5000.c +@@ -71,7 +71,7 @@ static const struct reg_default sgtl5000_reg_defaults[] = { + { SGTL5000_DAP_EQ_BASS_BAND4, 0x002f }, + { SGTL5000_DAP_MAIN_CHAN, 0x8000 }, + { SGTL5000_DAP_MIX_CHAN, 0x0000 }, +- { SGTL5000_DAP_AVC_CTRL, 0x0510 }, ++ { SGTL5000_DAP_AVC_CTRL, 0x5100 }, + { SGTL5000_DAP_AVC_THRESHOLD, 0x1473 }, + { SGTL5000_DAP_AVC_ATTACK, 0x0028 }, + { SGTL5000_DAP_AVC_DECAY, 0x0050 }, +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 9fb03c646a88f..3d1585c12b074 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1453,6 +1453,7 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) + case USB_ID(0x21B4, 0x0081): /* AudioQuest DragonFly */ + case USB_ID(0x2912, 0x30c8): /* Audioengine D1 */ + case USB_ID(0x413c, 0xa506): /* Dell AE515 sound bar */ ++ case USB_ID(0x046d, 0x084c): /* Logitech ConferenceCam Connect */ + return true; + } + +diff --git a/tools/testing/selftests/net/forwarding/tc_flower.sh b/tools/testing/selftests/net/forwarding/tc_flower.sh +index 058c746ee3006..b11d8e6b5bc14 100755 +--- a/tools/testing/selftests/net/forwarding/tc_flower.sh ++++ b/tools/testing/selftests/net/forwarding/tc_flower.sh +@@ -3,7 +3,7 @@ + + ALL_TESTS="match_dst_mac_test match_src_mac_test match_dst_ip_test \ + match_src_ip_test match_ip_flags_test match_pcp_test match_vlan_test \ +- match_ip_tos_test match_indev_test" ++ match_ip_tos_test match_indev_test match_ip_ttl_test" + NUM_NETIFS=2 + source tc_common.sh + source lib.sh +@@ -310,6 +310,42 @@ match_ip_tos_test() + log_test "ip_tos match ($tcflags)" + } + ++match_ip_ttl_test() ++{ ++ RET=0 ++ ++ tc filter add dev $h2 ingress protocol ip pref 1 handle 101 flower \ ++ $tcflags dst_ip 192.0.2.2 ip_ttl 63 action drop ++ tc filter add dev $h2 ingress protocol ip pref 2 handle 102 flower \ ++ $tcflags dst_ip 192.0.2.2 action drop ++ ++ $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ ++ -t ip "ttl=63" -q ++ ++ $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ ++ -t ip "ttl=63,mf,frag=256" -q ++ ++ tc_check_packets "dev $h2 ingress" 102 1 ++ check_fail $? "Matched on the wrong filter (no check on ttl)" ++ ++ tc_check_packets "dev $h2 ingress" 101 2 ++ check_err $? "Did not match on correct filter (ttl=63)" ++ ++ $MZ $h1 -c 1 -p 64 -a $h1mac -b $h2mac -A 192.0.2.1 -B 192.0.2.2 \ ++ -t ip "ttl=255" -q ++ ++ tc_check_packets "dev $h2 ingress" 101 3 ++ check_fail $? "Matched on a wrong filter (ttl=63)" ++ ++ tc_check_packets "dev $h2 ingress" 102 1 ++ check_err $? "Did not match on correct filter (no check on ttl)" ++ ++ tc filter del dev $h2 ingress protocol ip pref 2 handle 102 flower ++ tc filter del dev $h2 ingress protocol ip pref 1 handle 101 flower ++ ++ log_test "ip_ttl match ($tcflags)" ++} ++ + match_indev_test() + { + RET=0 diff --git a/patch/kernel/archive/odroidxu4-5.4/patch-5.4.110-111.patch b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.110-111.patch new file mode 100644 index 0000000000..906775ca51 --- /dev/null +++ b/patch/kernel/archive/odroidxu4-5.4/patch-5.4.110-111.patch @@ -0,0 +1,434 @@ +diff --git a/Makefile b/Makefile +index b028b5ead5f7e..25680098f51b2 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 5 + PATCHLEVEL = 4 +-SUBLEVEL = 110 ++SUBLEVEL = 111 + EXTRAVERSION = + NAME = Kleptomaniac Octopus + +diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi +index fb6b8aa12cc56..77fa7c0f21046 100644 +--- a/arch/arm/boot/dts/am33xx.dtsi ++++ b/arch/arm/boot/dts/am33xx.dtsi +@@ -40,6 +40,9 @@ + ethernet1 = &cpsw_emac1; + spi0 = &spi0; + spi1 = &spi1; ++ mmc0 = &mmc1; ++ mmc1 = &mmc2; ++ mmc2 = &mmc3; + }; + + cpus { +diff --git a/arch/ia64/kernel/err_inject.c b/arch/ia64/kernel/err_inject.c +index 8b5b8e6bc9d9a..dd5bfed52031d 100644 +--- a/arch/ia64/kernel/err_inject.c ++++ b/arch/ia64/kernel/err_inject.c +@@ -59,7 +59,7 @@ show_##name(struct device *dev, struct device_attribute *attr, \ + char *buf) \ + { \ + u32 cpu=dev->id; \ +- return sprintf(buf, "%lx\n", name[cpu]); \ ++ return sprintf(buf, "%llx\n", name[cpu]); \ + } + + #define store(name) \ +@@ -86,9 +86,9 @@ store_call_start(struct device *dev, struct device_attribute *attr, + + #ifdef ERR_INJ_DEBUG + printk(KERN_DEBUG "pal_mc_err_inject for cpu%d:\n", cpu); +- printk(KERN_DEBUG "err_type_info=%lx,\n", err_type_info[cpu]); +- printk(KERN_DEBUG "err_struct_info=%lx,\n", err_struct_info[cpu]); +- printk(KERN_DEBUG "err_data_buffer=%lx, %lx, %lx.\n", ++ printk(KERN_DEBUG "err_type_info=%llx,\n", err_type_info[cpu]); ++ printk(KERN_DEBUG "err_struct_info=%llx,\n", err_struct_info[cpu]); ++ printk(KERN_DEBUG "err_data_buffer=%llx, %llx, %llx.\n", + err_data_buffer[cpu].data1, + err_data_buffer[cpu].data2, + err_data_buffer[cpu].data3); +@@ -117,8 +117,8 @@ store_call_start(struct device *dev, struct device_attribute *attr, + + #ifdef ERR_INJ_DEBUG + printk(KERN_DEBUG "Returns: status=%d,\n", (int)status[cpu]); +- printk(KERN_DEBUG "capabilities=%lx,\n", capabilities[cpu]); +- printk(KERN_DEBUG "resources=%lx\n", resources[cpu]); ++ printk(KERN_DEBUG "capabilities=%llx,\n", capabilities[cpu]); ++ printk(KERN_DEBUG "resources=%llx\n", resources[cpu]); + #endif + return size; + } +@@ -131,7 +131,7 @@ show_virtual_to_phys(struct device *dev, struct device_attribute *attr, + char *buf) + { + unsigned int cpu=dev->id; +- return sprintf(buf, "%lx\n", phys_addr[cpu]); ++ return sprintf(buf, "%llx\n", phys_addr[cpu]); + } + + static ssize_t +@@ -145,7 +145,7 @@ store_virtual_to_phys(struct device *dev, struct device_attribute *attr, + ret = get_user_pages_fast(virt_addr, 1, FOLL_WRITE, NULL); + if (ret<=0) { + #ifdef ERR_INJ_DEBUG +- printk("Virtual address %lx is not existing.\n",virt_addr); ++ printk("Virtual address %llx is not existing.\n", virt_addr); + #endif + return -EINVAL; + } +@@ -163,7 +163,7 @@ show_err_data_buffer(struct device *dev, + { + unsigned int cpu=dev->id; + +- return sprintf(buf, "%lx, %lx, %lx\n", ++ return sprintf(buf, "%llx, %llx, %llx\n", + err_data_buffer[cpu].data1, + err_data_buffer[cpu].data2, + err_data_buffer[cpu].data3); +@@ -178,13 +178,13 @@ store_err_data_buffer(struct device *dev, + int ret; + + #ifdef ERR_INJ_DEBUG +- printk("write err_data_buffer=[%lx,%lx,%lx] on cpu%d\n", ++ printk("write err_data_buffer=[%llx,%llx,%llx] on cpu%d\n", + err_data_buffer[cpu].data1, + err_data_buffer[cpu].data2, + err_data_buffer[cpu].data3, + cpu); + #endif +- ret=sscanf(buf, "%lx, %lx, %lx", ++ ret = sscanf(buf, "%llx, %llx, %llx", + &err_data_buffer[cpu].data1, + &err_data_buffer[cpu].data2, + &err_data_buffer[cpu].data3); +diff --git a/arch/ia64/kernel/mca.c b/arch/ia64/kernel/mca.c +index bf2cb9294795c..d96c68122eae0 100644 +--- a/arch/ia64/kernel/mca.c ++++ b/arch/ia64/kernel/mca.c +@@ -1851,7 +1851,7 @@ ia64_mca_cpu_init(void *cpu_data) + data = mca_bootmem(); + first_time = 0; + } else +- data = (void *)__get_free_pages(GFP_KERNEL, ++ data = (void *)__get_free_pages(GFP_ATOMIC, + get_order(sz)); + if (!data) + panic("Could not allocate MCA memory for cpu %d\n", +diff --git a/arch/x86/Makefile b/arch/x86/Makefile +index 8ca3cf7c5ec97..59942e349e5f0 100644 +--- a/arch/x86/Makefile ++++ b/arch/x86/Makefile +@@ -34,7 +34,7 @@ M16_CFLAGS := $(call cc-option, -m16, $(CODE16GCC_CFLAGS)) + REALMODE_CFLAGS := $(M16_CFLAGS) -g -Os -DDISABLE_BRANCH_PROFILING \ + -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ + -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ +- -mno-mmx -mno-sse ++ -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none) + + REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -ffreestanding) + REALMODE_CFLAGS += $(call __cc-option, $(CC), $(REALMODE_CFLAGS), -fno-stack-protector) +diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c +index 18936533666e3..6e884f17634fe 100644 +--- a/arch/x86/net/bpf_jit_comp.c ++++ b/arch/x86/net/bpf_jit_comp.c +@@ -1050,7 +1050,16 @@ emit_jmp: + } + + if (image) { +- if (unlikely(proglen + ilen > oldproglen)) { ++ /* ++ * When populating the image, assert that: ++ * ++ * i) We do not write beyond the allocated space, and ++ * ii) addrs[i] did not change from the prior run, in order ++ * to validate assumptions made for computing branch ++ * displacements. ++ */ ++ if (unlikely(proglen + ilen > oldproglen || ++ proglen + ilen != addrs[i])) { + pr_err("bpf_jit: fatal error\n"); + return -EFAULT; + } +@@ -1118,7 +1127,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) + extra_pass = true; + goto skip_init_addrs; + } +- addrs = kmalloc_array(prog->len + 1, sizeof(*addrs), GFP_KERNEL); ++ addrs = kvmalloc_array(prog->len + 1, sizeof(*addrs), GFP_KERNEL); + if (!addrs) { + prog = orig_prog; + goto out_addrs; +@@ -1195,7 +1204,7 @@ out_image: + if (image) + bpf_prog_fill_jited_linfo(prog, addrs + 1); + out_addrs: +- kfree(addrs); ++ kvfree(addrs); + kfree(jit_data); + prog->aux->jit_data = NULL; + } +diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c +index 66cd150b7e541..0fcba32077c87 100644 +--- a/arch/x86/net/bpf_jit_comp32.c ++++ b/arch/x86/net/bpf_jit_comp32.c +@@ -2278,7 +2278,16 @@ notyet: + } + + if (image) { +- if (unlikely(proglen + ilen > oldproglen)) { ++ /* ++ * When populating the image, assert that: ++ * ++ * i) We do not write beyond the allocated space, and ++ * ii) addrs[i] did not change from the prior run, in order ++ * to validate assumptions made for computing branch ++ * displacements. ++ */ ++ if (unlikely(proglen + ilen > oldproglen || ++ proglen + ilen != addrs[i])) { + pr_err("bpf_jit: fatal error\n"); + return -EFAULT; + } +diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c +index 3934ce3385ac3..f9ff6d433dfe1 100644 +--- a/drivers/bus/ti-sysc.c ++++ b/drivers/bus/ti-sysc.c +@@ -2685,7 +2685,9 @@ static int sysc_remove(struct platform_device *pdev) + + pm_runtime_put_sync(&pdev->dev); + pm_runtime_disable(&pdev->dev); +- reset_control_assert(ddata->rsts); ++ ++ if (!reset_control_status(ddata->rsts)) ++ reset_control_assert(ddata->rsts); + + unprepare: + sysc_unprepare(ddata); +diff --git a/drivers/gpu/drm/msm/adreno/a5xx_power.c b/drivers/gpu/drm/msm/adreno/a5xx_power.c +index a3a06db675ba3..ee3ff32da0048 100644 +--- a/drivers/gpu/drm/msm/adreno/a5xx_power.c ++++ b/drivers/gpu/drm/msm/adreno/a5xx_power.c +@@ -300,7 +300,7 @@ int a5xx_power_init(struct msm_gpu *gpu) + /* Set up the limits management */ + if (adreno_is_a530(adreno_gpu)) + a530_lm_setup(gpu); +- else ++ else if (adreno_is_a540(adreno_gpu)) + a540_lm_setup(gpu); + + /* Set up SP/TP power collpase */ +diff --git a/drivers/gpu/drm/msm/msm_fence.c b/drivers/gpu/drm/msm/msm_fence.c +index ad2703698b052..cd59a59180385 100644 +--- a/drivers/gpu/drm/msm/msm_fence.c ++++ b/drivers/gpu/drm/msm/msm_fence.c +@@ -45,7 +45,7 @@ int msm_wait_fence(struct msm_fence_context *fctx, uint32_t fence, + int ret; + + if (fence > fctx->last_fence) { +- DRM_ERROR("%s: waiting on invalid fence: %u (of %u)\n", ++ DRM_ERROR_RATELIMITED("%s: waiting on invalid fence: %u (of %u)\n", + fctx->name, fence, fctx->last_fence); + return -EINVAL; + } +diff --git a/drivers/isdn/hardware/mISDN/mISDNipac.c b/drivers/isdn/hardware/mISDN/mISDNipac.c +index bca880213e919..51e3d45daaa78 100644 +--- a/drivers/isdn/hardware/mISDN/mISDNipac.c ++++ b/drivers/isdn/hardware/mISDN/mISDNipac.c +@@ -694,7 +694,7 @@ isac_release(struct isac_hw *isac) + { + if (isac->type & IPAC_TYPE_ISACX) + WriteISAC(isac, ISACX_MASK, 0xff); +- else ++ else if (isac->type != 0) + WriteISAC(isac, ISAC_MASK, 0xff); + if (isac->dch.timer.function != NULL) { + del_timer(&isac->dch.timer); +diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c +index 51b77c2de400a..235bbb2940a88 100644 +--- a/drivers/net/ethernet/marvell/pxa168_eth.c ++++ b/drivers/net/ethernet/marvell/pxa168_eth.c +@@ -1554,8 +1554,8 @@ static int pxa168_eth_remove(struct platform_device *pdev) + + mdiobus_unregister(pep->smi_bus); + mdiobus_free(pep->smi_bus); +- unregister_netdev(dev); + cancel_work_sync(&pep->tx_timeout_task); ++ unregister_netdev(dev); + free_netdev(dev); + return 0; + } +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +index 8b8581f71e793..36b9a364ef26b 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +@@ -2365,8 +2365,9 @@ static u8 mlx5e_build_icosq_log_wq_sz(struct mlx5e_params *params, + { + switch (params->rq_wq_type) { + case MLX5_WQ_TYPE_LINKED_LIST_STRIDING_RQ: +- return order_base_2(MLX5E_UMR_WQEBBS) + +- mlx5e_get_rq_log_wq_sz(rqp->rqc); ++ return max_t(u8, MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE, ++ order_base_2(MLX5E_UMR_WQEBBS) + ++ mlx5e_get_rq_log_wq_sz(rqp->rqc)); + default: /* MLX5_WQ_TYPE_CYCLIC */ + return MLX5E_PARAMS_MINIMUM_LOG_SQ_SIZE; + } +diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c +index 0ac0bd4c65c4c..207a88ea10f38 100644 +--- a/drivers/nvme/host/multipath.c ++++ b/drivers/nvme/host/multipath.c +@@ -330,7 +330,7 @@ static blk_qc_t nvme_ns_head_make_request(struct request_queue *q, + trace_block_bio_remap(bio->bi_disk->queue, bio, + disk_devt(ns->head->disk), + bio->bi_iter.bi_sector); +- ret = direct_make_request(bio); ++ ret = generic_make_request(bio); + } else if (nvme_available_path(head)) { + dev_warn_ratelimited(dev, "no usable path - requeuing I/O\n"); + +diff --git a/drivers/platform/x86/intel-hid.c b/drivers/platform/x86/intel-hid.c +index ad1399dcb21f5..164bebbfea214 100644 +--- a/drivers/platform/x86/intel-hid.c ++++ b/drivers/platform/x86/intel-hid.c +@@ -84,6 +84,13 @@ static const struct dmi_system_id button_array_table[] = { + DMI_MATCH(DMI_PRODUCT_NAME, "HP Spectre x2 Detachable"), + }, + }, ++ { ++ .ident = "Lenovo ThinkPad X1 Tablet Gen 2", ++ .matches = { ++ DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), ++ DMI_MATCH(DMI_PRODUCT_FAMILY, "ThinkPad X1 Tablet Gen 2"), ++ }, ++ }, + { } + }; + +diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c +index 8c54d3707fba3..e8257de495fd3 100644 +--- a/drivers/platform/x86/thinkpad_acpi.c ++++ b/drivers/platform/x86/thinkpad_acpi.c +@@ -4089,13 +4089,19 @@ static bool hotkey_notify_6xxx(const u32 hkey, + + case TP_HKEY_EV_KEY_NUMLOCK: + case TP_HKEY_EV_KEY_FN: +- case TP_HKEY_EV_KEY_FN_ESC: + /* key press events, we just ignore them as long as the EC + * is still reporting them in the normal keyboard stream */ + *send_acpi_ev = false; + *ignore_acpi_ev = true; + return true; + ++ case TP_HKEY_EV_KEY_FN_ESC: ++ /* Get the media key status to foce the status LED to update */ ++ acpi_evalf(hkey_handle, NULL, "GMKS", "v"); ++ *send_acpi_ev = false; ++ *ignore_acpi_ev = true; ++ return true; ++ + case TP_HKEY_EV_TABLET_CHANGED: + tpacpi_input_send_tabletsw(); + hotkey_tablet_mode_notify_change(); +diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c +index c9d92b3e777d9..5a047ce77bc0b 100644 +--- a/drivers/target/target_core_pscsi.c ++++ b/drivers/target/target_core_pscsi.c +@@ -939,6 +939,14 @@ new_bio: + + return 0; + fail: ++ if (bio) ++ bio_put(bio); ++ while (req->bio) { ++ bio = req->bio; ++ req->bio = bio->bi_next; ++ bio_put(bio); ++ } ++ req->biotail = NULL; + return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; + } + +diff --git a/fs/cifs/file.c b/fs/cifs/file.c +index 31d578739341b..1aac8d38f887d 100644 +--- a/fs/cifs/file.c ++++ b/fs/cifs/file.c +@@ -164,6 +164,7 @@ int cifs_posix_open(char *full_path, struct inode **pinode, + goto posix_open_ret; + } + } else { ++ cifs_revalidate_mapping(*pinode); + cifs_fattr_to_inode(*pinode, &fattr); + } + +diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c +index 7d875a47d0226..7177720e822e1 100644 +--- a/fs/cifs/smb2misc.c ++++ b/fs/cifs/smb2misc.c +@@ -738,8 +738,8 @@ smb2_is_valid_oplock_break(char *buffer, struct TCP_Server_Info *server) + } + } + spin_unlock(&cifs_tcp_ses_lock); +- cifs_dbg(FYI, "Can not process oplock break for non-existent connection\n"); +- return false; ++ cifs_dbg(FYI, "No file id matched, oplock break ignored\n"); ++ return true; + } + + void +diff --git a/init/Kconfig b/init/Kconfig +index 96fc45d1b686b..4f9fd78e2200b 100644 +--- a/init/Kconfig ++++ b/init/Kconfig +@@ -76,8 +76,7 @@ config INIT_ENV_ARG_LIMIT + + config COMPILE_TEST + bool "Compile also drivers which will not load" +- depends on !UML +- default n ++ depends on HAS_IOMEM + help + Some drivers can be compiled on a different platform than they are + intended to be run on. Despite they cannot be loaded there (or even +diff --git a/net/mac80211/main.c b/net/mac80211/main.c +index 3e8561c3b0e7b..5b3189a376802 100644 +--- a/net/mac80211/main.c ++++ b/net/mac80211/main.c +@@ -954,8 +954,19 @@ int ieee80211_register_hw(struct ieee80211_hw *hw) + continue; + + if (!dflt_chandef.chan) { ++ /* ++ * Assign the first enabled channel to dflt_chandef ++ * from the list of channels ++ */ ++ for (i = 0; i < sband->n_channels; i++) ++ if (!(sband->channels[i].flags & ++ IEEE80211_CHAN_DISABLED)) ++ break; ++ /* if none found then use the first anyway */ ++ if (i == sband->n_channels) ++ i = 0; + cfg80211_chandef_create(&dflt_chandef, +- &sband->channels[0], ++ &sband->channels[i], + NL80211_CHAN_NO_HT); + /* init channel we're on */ + if (!local->use_chanctx && !local->_oper_chandef.chan) { +diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c +index 5b05487a60d21..db11e403d8187 100644 +--- a/net/netfilter/nf_conntrack_proto_gre.c ++++ b/net/netfilter/nf_conntrack_proto_gre.c +@@ -218,9 +218,6 @@ int nf_conntrack_gre_packet(struct nf_conn *ct, + enum ip_conntrack_info ctinfo, + const struct nf_hook_state *state) + { +- if (state->pf != NFPROTO_IPV4) +- return -NF_ACCEPT; +- + if (!nf_ct_is_confirmed(ct)) { + unsigned int *timeouts = nf_ct_timeout_lookup(ct); +