From ed101821004323b62dbaa09ff9c40ca96ba4a302 Mon Sep 17 00:00:00 2001 From: Igor Pecovnik Date: Thu, 27 Jun 2019 20:56:19 +0200 Subject: [PATCH] sunxi-next Upstream patches Signed-off-by: Igor Pecovnik --- .../kernel/sunxi-next/patch-4.19.53-54.patch | 1700 +++++++++ .../kernel/sunxi-next/patch-4.19.54-55.patch | 27 + .../kernel/sunxi-next/patch-4.19.55-56.patch | 3375 +++++++++++++++++ 3 files changed, 5102 insertions(+) create mode 100644 patch/kernel/sunxi-next/patch-4.19.53-54.patch create mode 100644 patch/kernel/sunxi-next/patch-4.19.54-55.patch create mode 100644 patch/kernel/sunxi-next/patch-4.19.55-56.patch diff --git a/patch/kernel/sunxi-next/patch-4.19.53-54.patch b/patch/kernel/sunxi-next/patch-4.19.53-54.patch new file mode 100644 index 000000000..e75cc51b4 --- /dev/null +++ b/patch/kernel/sunxi-next/patch-4.19.53-54.patch @@ -0,0 +1,1700 @@ +diff --git a/Makefile b/Makefile +index bedcb121dc3d..b234837e4d07 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 19 +-SUBLEVEL = 53 ++SUBLEVEL = 54 + EXTRAVERSION = + NAME = "People's Front" + +diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h +index ad8be16a39c9..58102652bf9e 100644 +--- a/arch/arm64/include/asm/syscall.h ++++ b/arch/arm64/include/asm/syscall.h +@@ -20,7 +20,7 @@ + #include + #include + +-typedef long (*syscall_fn_t)(struct pt_regs *regs); ++typedef long (*syscall_fn_t)(const struct pt_regs *regs); + + extern const syscall_fn_t sys_call_table[]; + +diff --git a/arch/arm64/include/asm/syscall_wrapper.h b/arch/arm64/include/asm/syscall_wrapper.h +index a4477e515b79..507d0ee6bc69 100644 +--- a/arch/arm64/include/asm/syscall_wrapper.h ++++ b/arch/arm64/include/asm/syscall_wrapper.h +@@ -30,10 +30,10 @@ + } \ + static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) + +-#define COMPAT_SYSCALL_DEFINE0(sname) \ +- asmlinkage long __arm64_compat_sys_##sname(void); \ +- ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \ +- asmlinkage long __arm64_compat_sys_##sname(void) ++#define COMPAT_SYSCALL_DEFINE0(sname) \ ++ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused); \ ++ ALLOW_ERROR_INJECTION(__arm64_compat_sys_##sname, ERRNO); \ ++ asmlinkage long __arm64_compat_sys_##sname(const struct pt_regs *__unused) + + #define COND_SYSCALL_COMPAT(name) \ + cond_syscall(__arm64_compat_sys_##name); +@@ -62,11 +62,11 @@ + static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) + + #ifndef SYSCALL_DEFINE0 +-#define SYSCALL_DEFINE0(sname) \ +- SYSCALL_METADATA(_##sname, 0); \ +- asmlinkage long __arm64_sys_##sname(void); \ +- ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ +- asmlinkage long __arm64_sys_##sname(void) ++#define SYSCALL_DEFINE0(sname) \ ++ SYSCALL_METADATA(_##sname, 0); \ ++ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused); \ ++ ALLOW_ERROR_INJECTION(__arm64_sys_##sname, ERRNO); \ ++ asmlinkage long __arm64_sys_##sname(const struct pt_regs *__unused) + #endif + + #ifndef COND_SYSCALL +diff --git a/arch/arm64/kernel/sys.c b/arch/arm64/kernel/sys.c +index 162a95ed0881..fe20c461582a 100644 +--- a/arch/arm64/kernel/sys.c ++++ b/arch/arm64/kernel/sys.c +@@ -47,22 +47,26 @@ SYSCALL_DEFINE1(arm64_personality, unsigned int, personality) + return ksys_personality(personality); + } + ++asmlinkage long sys_ni_syscall(void); ++ ++asmlinkage long __arm64_sys_ni_syscall(const struct pt_regs *__unused) ++{ ++ return sys_ni_syscall(); ++} ++ + /* + * Wrappers to pass the pt_regs argument. + */ + #define __arm64_sys_personality __arm64_sys_arm64_personality + +-asmlinkage long sys_ni_syscall(const struct pt_regs *); +-#define __arm64_sys_ni_syscall sys_ni_syscall +- + #undef __SYSCALL + #define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); + #include + + #undef __SYSCALL +-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym, ++#define __SYSCALL(nr, sym) [nr] = __arm64_##sym, + + const syscall_fn_t sys_call_table[__NR_syscalls] = { +- [0 ... __NR_syscalls - 1] = (syscall_fn_t)sys_ni_syscall, ++ [0 ... __NR_syscalls - 1] = __arm64_sys_ni_syscall, + #include + }; +diff --git a/arch/arm64/kernel/sys32.c b/arch/arm64/kernel/sys32.c +index 0f8bcb7de700..3c80a40c1c9d 100644 +--- a/arch/arm64/kernel/sys32.c ++++ b/arch/arm64/kernel/sys32.c +@@ -133,17 +133,14 @@ COMPAT_SYSCALL_DEFINE6(aarch32_fallocate, int, fd, int, mode, + return ksys_fallocate(fd, mode, arg_u64(offset), arg_u64(len)); + } + +-asmlinkage long sys_ni_syscall(const struct pt_regs *); +-#define __arm64_sys_ni_syscall sys_ni_syscall +- + #undef __SYSCALL + #define __SYSCALL(nr, sym) asmlinkage long __arm64_##sym(const struct pt_regs *); + #include + + #undef __SYSCALL +-#define __SYSCALL(nr, sym) [nr] = (syscall_fn_t)__arm64_##sym, ++#define __SYSCALL(nr, sym) [nr] = __arm64_##sym, + + const syscall_fn_t compat_sys_call_table[__NR_compat_syscalls] = { +- [0 ... __NR_compat_syscalls - 1] = (syscall_fn_t)sys_ni_syscall, ++ [0 ... __NR_compat_syscalls - 1] = __arm64_sys_ni_syscall, + #include + }; +diff --git a/arch/ia64/mm/numa.c b/arch/ia64/mm/numa.c +index aa19b7ac8222..476c7b4be378 100644 +--- a/arch/ia64/mm/numa.c ++++ b/arch/ia64/mm/numa.c +@@ -49,6 +49,7 @@ paddr_to_nid(unsigned long paddr) + + return (i < num_node_memblks) ? node_memblk[i].nid : (num_node_memblks ? -1 : 0); + } ++EXPORT_SYMBOL(paddr_to_nid); + + #if defined(CONFIG_SPARSEMEM) && defined(CONFIG_NUMA) + /* +diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h +index bccc5051249e..2b6049e83970 100644 +--- a/arch/powerpc/include/asm/kvm_host.h ++++ b/arch/powerpc/include/asm/kvm_host.h +@@ -299,6 +299,7 @@ struct kvm_arch { + #ifdef CONFIG_PPC_BOOK3S_64 + struct list_head spapr_tce_tables; + struct list_head rtas_tokens; ++ struct mutex rtas_token_lock; + DECLARE_BITMAP(enabled_hcalls, MAX_HCALL_OPCODE/4 + 1); + #endif + #ifdef CONFIG_KVM_MPIC +diff --git a/arch/powerpc/kvm/book3s.c b/arch/powerpc/kvm/book3s.c +index 87348e498c89..281f074581a3 100644 +--- a/arch/powerpc/kvm/book3s.c ++++ b/arch/powerpc/kvm/book3s.c +@@ -840,6 +840,7 @@ int kvmppc_core_init_vm(struct kvm *kvm) + #ifdef CONFIG_PPC64 + INIT_LIST_HEAD_RCU(&kvm->arch.spapr_tce_tables); + INIT_LIST_HEAD(&kvm->arch.rtas_tokens); ++ mutex_init(&kvm->arch.rtas_token_lock); + #endif + + return kvm->arch.kvm_ops->init_vm(kvm); +diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c +index 3e3a71594e63..083dcedba11c 100644 +--- a/arch/powerpc/kvm/book3s_hv.c ++++ b/arch/powerpc/kvm/book3s_hv.c +@@ -426,12 +426,7 @@ static void kvmppc_dump_regs(struct kvm_vcpu *vcpu) + + static struct kvm_vcpu *kvmppc_find_vcpu(struct kvm *kvm, int id) + { +- struct kvm_vcpu *ret; +- +- mutex_lock(&kvm->lock); +- ret = kvm_get_vcpu_by_id(kvm, id); +- mutex_unlock(&kvm->lock); +- return ret; ++ return kvm_get_vcpu_by_id(kvm, id); + } + + static void init_vpa(struct kvm_vcpu *vcpu, struct lppaca *vpa) +@@ -1309,7 +1304,6 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr, + struct kvmppc_vcore *vc = vcpu->arch.vcore; + u64 mask; + +- mutex_lock(&kvm->lock); + spin_lock(&vc->lock); + /* + * If ILE (interrupt little-endian) has changed, update the +@@ -1349,7 +1343,6 @@ static void kvmppc_set_lpcr(struct kvm_vcpu *vcpu, u64 new_lpcr, + mask &= 0xFFFFFFFF; + vc->lpcr = (vc->lpcr & ~mask) | (new_lpcr & mask); + spin_unlock(&vc->lock); +- mutex_unlock(&kvm->lock); + } + + static int kvmppc_get_one_reg_hv(struct kvm_vcpu *vcpu, u64 id, +diff --git a/arch/powerpc/kvm/book3s_rtas.c b/arch/powerpc/kvm/book3s_rtas.c +index 2d3b2b1cc272..8f2355138f80 100644 +--- a/arch/powerpc/kvm/book3s_rtas.c ++++ b/arch/powerpc/kvm/book3s_rtas.c +@@ -146,7 +146,7 @@ static int rtas_token_undefine(struct kvm *kvm, char *name) + { + struct rtas_token_definition *d, *tmp; + +- lockdep_assert_held(&kvm->lock); ++ lockdep_assert_held(&kvm->arch.rtas_token_lock); + + list_for_each_entry_safe(d, tmp, &kvm->arch.rtas_tokens, list) { + if (rtas_name_matches(d->handler->name, name)) { +@@ -167,7 +167,7 @@ static int rtas_token_define(struct kvm *kvm, char *name, u64 token) + bool found; + int i; + +- lockdep_assert_held(&kvm->lock); ++ lockdep_assert_held(&kvm->arch.rtas_token_lock); + + list_for_each_entry(d, &kvm->arch.rtas_tokens, list) { + if (d->token == token) +@@ -206,14 +206,14 @@ int kvm_vm_ioctl_rtas_define_token(struct kvm *kvm, void __user *argp) + if (copy_from_user(&args, argp, sizeof(args))) + return -EFAULT; + +- mutex_lock(&kvm->lock); ++ mutex_lock(&kvm->arch.rtas_token_lock); + + if (args.token) + rc = rtas_token_define(kvm, args.name, args.token); + else + rc = rtas_token_undefine(kvm, args.name); + +- mutex_unlock(&kvm->lock); ++ mutex_unlock(&kvm->arch.rtas_token_lock); + + return rc; + } +@@ -245,7 +245,7 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) + orig_rets = args.rets; + args.rets = &args.args[be32_to_cpu(args.nargs)]; + +- mutex_lock(&vcpu->kvm->lock); ++ mutex_lock(&vcpu->kvm->arch.rtas_token_lock); + + rc = -ENOENT; + list_for_each_entry(d, &vcpu->kvm->arch.rtas_tokens, list) { +@@ -256,7 +256,7 @@ int kvmppc_rtas_hcall(struct kvm_vcpu *vcpu) + } + } + +- mutex_unlock(&vcpu->kvm->lock); ++ mutex_unlock(&vcpu->kvm->arch.rtas_token_lock); + + if (rc == 0) { + args.rets = orig_rets; +@@ -282,8 +282,6 @@ void kvmppc_rtas_tokens_free(struct kvm *kvm) + { + struct rtas_token_definition *d, *tmp; + +- lockdep_assert_held(&kvm->lock); +- + list_for_each_entry_safe(d, tmp, &kvm->arch.rtas_tokens, list) { + list_del(&d->list); + kfree(d); +diff --git a/arch/powerpc/platforms/powernv/opal-imc.c b/arch/powerpc/platforms/powernv/opal-imc.c +index 3d27f02695e4..828f6656f8f7 100644 +--- a/arch/powerpc/platforms/powernv/opal-imc.c ++++ b/arch/powerpc/platforms/powernv/opal-imc.c +@@ -161,6 +161,10 @@ static int imc_pmu_create(struct device_node *parent, int pmu_index, int domain) + struct imc_pmu *pmu_ptr; + u32 offset; + ++ /* Return for unknown domain */ ++ if (domain < 0) ++ return -EINVAL; ++ + /* memory for pmu */ + pmu_ptr = kzalloc(sizeof(*pmu_ptr), GFP_KERNEL); + if (!pmu_ptr) +diff --git a/arch/x86/events/intel/ds.c b/arch/x86/events/intel/ds.c +index b7b01d762d32..e91814d1a27f 100644 +--- a/arch/x86/events/intel/ds.c ++++ b/arch/x86/events/intel/ds.c +@@ -684,7 +684,7 @@ struct event_constraint intel_core2_pebs_event_constraints[] = { + INTEL_FLAGS_UEVENT_CONSTRAINT(0x1fc7, 0x1), /* SIMD_INST_RETURED.ANY */ + INTEL_FLAGS_EVENT_CONSTRAINT(0xcb, 0x1), /* MEM_LOAD_RETIRED.* */ + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x01), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x01), + EVENT_CONSTRAINT_END + }; + +@@ -693,7 +693,7 @@ struct event_constraint intel_atom_pebs_event_constraints[] = { + INTEL_FLAGS_UEVENT_CONSTRAINT(0x00c5, 0x1), /* MISPREDICTED_BRANCH_RETIRED */ + INTEL_FLAGS_EVENT_CONSTRAINT(0xcb, 0x1), /* MEM_LOAD_RETIRED.* */ + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x01), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x01), + /* Allow all events as PEBS with no flags */ + INTEL_ALL_EVENT_CONSTRAINT(0, 0x1), + EVENT_CONSTRAINT_END +@@ -701,7 +701,7 @@ struct event_constraint intel_atom_pebs_event_constraints[] = { + + struct event_constraint intel_slm_pebs_event_constraints[] = { + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x1), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x1), + /* Allow all events as PEBS with no flags */ + INTEL_ALL_EVENT_CONSTRAINT(0, 0x1), + EVENT_CONSTRAINT_END +@@ -726,7 +726,7 @@ struct event_constraint intel_nehalem_pebs_event_constraints[] = { + INTEL_FLAGS_EVENT_CONSTRAINT(0xcb, 0xf), /* MEM_LOAD_RETIRED.* */ + INTEL_FLAGS_EVENT_CONSTRAINT(0xf7, 0xf), /* FP_ASSIST.* */ + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x0f), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x0f), + EVENT_CONSTRAINT_END + }; + +@@ -743,7 +743,7 @@ struct event_constraint intel_westmere_pebs_event_constraints[] = { + INTEL_FLAGS_EVENT_CONSTRAINT(0xcb, 0xf), /* MEM_LOAD_RETIRED.* */ + INTEL_FLAGS_EVENT_CONSTRAINT(0xf7, 0xf), /* FP_ASSIST.* */ + /* INST_RETIRED.ANY_P, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x0f), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x0f), + EVENT_CONSTRAINT_END + }; + +@@ -752,7 +752,7 @@ struct event_constraint intel_snb_pebs_event_constraints[] = { + INTEL_PLD_CONSTRAINT(0x01cd, 0x8), /* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ + INTEL_PST_CONSTRAINT(0x02cd, 0x8), /* MEM_TRANS_RETIRED.PRECISE_STORES */ + /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), + INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */ + INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */ + INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */ +@@ -767,9 +767,9 @@ struct event_constraint intel_ivb_pebs_event_constraints[] = { + INTEL_PLD_CONSTRAINT(0x01cd, 0x8), /* MEM_TRANS_RETIRED.LAT_ABOVE_THR */ + INTEL_PST_CONSTRAINT(0x02cd, 0x8), /* MEM_TRANS_RETIRED.PRECISE_STORES */ + /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), + /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_EXCLEVT_CONSTRAINT(0xd0, 0xf), /* MEM_UOP_RETIRED.* */ + INTEL_EXCLEVT_CONSTRAINT(0xd1, 0xf), /* MEM_LOAD_UOPS_RETIRED.* */ + INTEL_EXCLEVT_CONSTRAINT(0xd2, 0xf), /* MEM_LOAD_UOPS_LLC_HIT_RETIRED.* */ +@@ -783,9 +783,9 @@ struct event_constraint intel_hsw_pebs_event_constraints[] = { + INTEL_FLAGS_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PRECDIST */ + INTEL_PLD_CONSTRAINT(0x01cd, 0xf), /* MEM_TRANS_RETIRED.* */ + /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), + /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA(0x01c2, 0xf), /* UOPS_RETIRED.ALL */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD(0x11d0, 0xf), /* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_XLD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */ +@@ -806,9 +806,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = { + INTEL_FLAGS_UEVENT_CONSTRAINT(0x01c0, 0x2), /* INST_RETIRED.PRECDIST */ + INTEL_PLD_CONSTRAINT(0x01cd, 0xf), /* MEM_TRANS_RETIRED.* */ + /* UOPS_RETIRED.ALL, inv=1, cmask=16 (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c2, 0xf), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c2, 0xf), + /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_NA(0x01c2, 0xf), /* UOPS_RETIRED.ALL */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_UOPS_RETIRED.STLB_MISS_LOADS */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x21d0, 0xf), /* MEM_UOPS_RETIRED.LOCK_LOADS */ +@@ -829,9 +829,9 @@ struct event_constraint intel_bdw_pebs_event_constraints[] = { + struct event_constraint intel_skl_pebs_event_constraints[] = { + INTEL_FLAGS_UEVENT_CONSTRAINT(0x1c0, 0x2), /* INST_RETIRED.PREC_DIST */ + /* INST_RETIRED.PREC_DIST, inv=1, cmask=16 (cycles:ppp). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108001c0, 0x2), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108001c0, 0x2), + /* INST_RETIRED.TOTAL_CYCLES_PS (inv=1, cmask=16) (cycles:p). */ +- INTEL_FLAGS_EVENT_CONSTRAINT(0x108000c0, 0x0f), ++ INTEL_FLAGS_UEVENT_CONSTRAINT(0x108000c0, 0x0f), + INTEL_PLD_CONSTRAINT(0x1cd, 0xf), /* MEM_TRANS_RETIRED.* */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_LD(0x11d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_LOADS */ + INTEL_FLAGS_UEVENT_CONSTRAINT_DATALA_ST(0x12d0, 0xf), /* MEM_INST_RETIRED.STLB_MISS_STORES */ +diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c +index 6a25278e0092..da1f5e78363e 100644 +--- a/arch/x86/kernel/cpu/amd.c ++++ b/arch/x86/kernel/cpu/amd.c +@@ -819,8 +819,11 @@ static void init_amd_zn(struct cpuinfo_x86 *c) + { + set_cpu_cap(c, X86_FEATURE_ZEN); + +- /* Fix erratum 1076: CPB feature bit not being set in CPUID. */ +- if (!cpu_has(c, X86_FEATURE_CPB)) ++ /* ++ * Fix erratum 1076: CPB feature bit not being set in CPUID. ++ * Always set it, except when running under a hypervisor. ++ */ ++ if (!cpu_has(c, X86_FEATURE_HYPERVISOR) && !cpu_has(c, X86_FEATURE_CPB)) + set_cpu_cap(c, X86_FEATURE_CPB); + } + +diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c +index a7c2673ffd36..1806260938e8 100644 +--- a/drivers/acpi/device_pm.c ++++ b/drivers/acpi/device_pm.c +@@ -948,8 +948,8 @@ static bool acpi_dev_needs_resume(struct device *dev, struct acpi_device *adev) + u32 sys_target = acpi_target_system_state(); + int ret, state; + +- if (!pm_runtime_suspended(dev) || !adev || +- device_may_wakeup(dev) != !!adev->wakeup.prepare_count) ++ if (!pm_runtime_suspended(dev) || !adev || (adev->wakeup.flags.valid && ++ device_may_wakeup(dev) != !!adev->wakeup.prepare_count)) + return true; + + if (sys_target == ACPI_STATE_S0) +diff --git a/drivers/clk/ti/clkctrl.c b/drivers/clk/ti/clkctrl.c +index 421b05392220..ca3218337fd7 100644 +--- a/drivers/clk/ti/clkctrl.c ++++ b/drivers/clk/ti/clkctrl.c +@@ -137,9 +137,6 @@ static int _omap4_clkctrl_clk_enable(struct clk_hw *hw) + int ret; + union omap4_timeout timeout = { 0 }; + +- if (!clk->enable_bit) +- return 0; +- + if (clk->clkdm) { + ret = ti_clk_ll_ops->clkdm_clk_enable(clk->clkdm, hw->clk); + if (ret) { +@@ -151,6 +148,9 @@ static int _omap4_clkctrl_clk_enable(struct clk_hw *hw) + } + } + ++ if (!clk->enable_bit) ++ return 0; ++ + val = ti_clk_ll_ops->clk_readl(&clk->enable_reg); + + val &= ~OMAP4_MODULEMODE_MASK; +@@ -179,7 +179,7 @@ static void _omap4_clkctrl_clk_disable(struct clk_hw *hw) + union omap4_timeout timeout = { 0 }; + + if (!clk->enable_bit) +- return; ++ goto exit; + + val = ti_clk_ll_ops->clk_readl(&clk->enable_reg); + +diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig +index 4f52c3a8ec99..ed51221621a5 100644 +--- a/drivers/gpio/Kconfig ++++ b/drivers/gpio/Kconfig +@@ -784,6 +784,7 @@ config GPIO_ADP5588 + config GPIO_ADP5588_IRQ + bool "Interrupt controller support for ADP5588" + depends on GPIO_ADP5588=y ++ select GPIOLIB_IRQCHIP + help + Say yes here to enable the adp5588 to be used as an interrupt + controller. It requires the driver to be built in the kernel. +diff --git a/drivers/gpu/drm/etnaviv/etnaviv_dump.c b/drivers/gpu/drm/etnaviv/etnaviv_dump.c +index 9146e30e24a6..468dff2f7904 100644 +--- a/drivers/gpu/drm/etnaviv/etnaviv_dump.c ++++ b/drivers/gpu/drm/etnaviv/etnaviv_dump.c +@@ -124,6 +124,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) + return; + etnaviv_dump_core = false; + ++ mutex_lock(&gpu->mmu->lock); ++ + mmu_size = etnaviv_iommu_dump_size(gpu->mmu); + + /* We always dump registers, mmu, ring and end marker */ +@@ -166,6 +168,7 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) + iter.start = __vmalloc(file_size, GFP_KERNEL | __GFP_NOWARN | __GFP_NORETRY, + PAGE_KERNEL); + if (!iter.start) { ++ mutex_unlock(&gpu->mmu->lock); + dev_warn(gpu->dev, "failed to allocate devcoredump file\n"); + return; + } +@@ -233,6 +236,8 @@ void etnaviv_core_dump(struct etnaviv_gpu *gpu) + obj->base.size); + } + ++ mutex_unlock(&gpu->mmu->lock); ++ + etnaviv_core_dump_header(&iter, ETDUMP_BUF_END, iter.data); + + dev_coredumpv(gpu->dev, iter.start, iter.data - iter.start, GFP_KERNEL); +diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c +index ccd76c71af09..cb07651f4b46 100644 +--- a/drivers/i2c/i2c-dev.c ++++ b/drivers/i2c/i2c-dev.c +@@ -283,6 +283,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, + msgs[i].len < 1 || msgs[i].buf[0] < 1 || + msgs[i].len < msgs[i].buf[0] + + I2C_SMBUS_BLOCK_MAX) { ++ i++; + res = -EINVAL; + break; + } +diff --git a/drivers/isdn/mISDN/socket.c b/drivers/isdn/mISDN/socket.c +index b2abc44fa5cb..a73337b74f41 100644 +--- a/drivers/isdn/mISDN/socket.c ++++ b/drivers/isdn/mISDN/socket.c +@@ -394,7 +394,7 @@ data_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) + memcpy(di.channelmap, dev->channelmap, + sizeof(di.channelmap)); + di.nrbchan = dev->nrbchan; +- strcpy(di.name, dev_name(&dev->dev)); ++ strscpy(di.name, dev_name(&dev->dev), sizeof(di.name)); + if (copy_to_user((void __user *)arg, &di, sizeof(di))) + err = -EFAULT; + } else +@@ -677,7 +677,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) + memcpy(di.channelmap, dev->channelmap, + sizeof(di.channelmap)); + di.nrbchan = dev->nrbchan; +- strcpy(di.name, dev_name(&dev->dev)); ++ strscpy(di.name, dev_name(&dev->dev), sizeof(di.name)); + if (copy_to_user((void __user *)arg, &di, sizeof(di))) + err = -EFAULT; + } else +@@ -691,6 +691,7 @@ base_sock_ioctl(struct socket *sock, unsigned int cmd, unsigned long arg) + err = -EFAULT; + break; + } ++ dn.name[sizeof(dn.name) - 1] = '\0'; + dev = get_mdevice(dn.id); + if (dev) + err = device_rename(&dev->dev, dn.name); +diff --git a/drivers/net/dsa/rtl8366.c b/drivers/net/dsa/rtl8366.c +index 6dedd43442cc..35b767baf21f 100644 +--- a/drivers/net/dsa/rtl8366.c ++++ b/drivers/net/dsa/rtl8366.c +@@ -307,7 +307,8 @@ int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering) + struct rtl8366_vlan_4k vlan4k; + int ret; + +- if (!smi->ops->is_vlan_valid(smi, port)) ++ /* Use VLAN nr port + 1 since VLAN0 is not valid */ ++ if (!smi->ops->is_vlan_valid(smi, port + 1)) + return -EINVAL; + + dev_info(smi->dev, "%s filtering on port %d\n", +@@ -318,12 +319,12 @@ int rtl8366_vlan_filtering(struct dsa_switch *ds, int port, bool vlan_filtering) + * The hardware support filter ID (FID) 0..7, I have no clue how to + * support this in the driver when the callback only says on/off. + */ +- ret = smi->ops->get_vlan_4k(smi, port, &vlan4k); ++ ret = smi->ops->get_vlan_4k(smi, port + 1, &vlan4k); + if (ret) + return ret; + + /* Just set the filter to FID 1 for now then */ +- ret = rtl8366_set_vlan(smi, port, ++ ret = rtl8366_set_vlan(smi, port + 1, + vlan4k.member, + vlan4k.untag, + 1); +diff --git a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +index 6f3312350cac..b3c7994d73eb 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/aq_ring.c ++++ b/drivers/net/ethernet/aquantia/atlantic/aq_ring.c +@@ -139,10 +139,10 @@ void aq_ring_queue_stop(struct aq_ring_s *ring) + bool aq_ring_tx_clean(struct aq_ring_s *self) + { + struct device *dev = aq_nic_get_dev(self->aq_nic); +- unsigned int budget = AQ_CFG_TX_CLEAN_BUDGET; ++ unsigned int budget; + +- for (; self->sw_head != self->hw_head && budget--; +- self->sw_head = aq_ring_next_dx(self, self->sw_head)) { ++ for (budget = AQ_CFG_TX_CLEAN_BUDGET; ++ budget && self->sw_head != self->hw_head; budget--) { + struct aq_ring_buff_s *buff = &self->buff_ring[self->sw_head]; + + if (likely(buff->is_mapped)) { +@@ -167,6 +167,7 @@ bool aq_ring_tx_clean(struct aq_ring_s *self) + + buff->pa = 0U; + buff->eop_index = 0xffffU; ++ self->sw_head = aq_ring_next_dx(self, self->sw_head); + } + + return !!budget; +diff --git a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +index 56363ff5c891..51cd1f98bcf0 100644 +--- a/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c ++++ b/drivers/net/ethernet/aquantia/atlantic/hw_atl/hw_atl_b0.c +@@ -695,38 +695,41 @@ static int hw_atl_b0_hw_ring_rx_receive(struct aq_hw_s *self, + if ((rx_stat & BIT(0)) || rxd_wb->type & 0x1000U) { + /* MAC error or DMA error */ + buff->is_error = 1U; +- } else { +- if (self->aq_nic_cfg->is_rss) { +- /* last 4 byte */ +- u16 rss_type = rxd_wb->type & 0xFU; +- +- if (rss_type && rss_type < 0x8U) { +- buff->is_hash_l4 = (rss_type == 0x4 || +- rss_type == 0x5); +- buff->rss_hash = rxd_wb->rss_hash; +- } ++ } ++ if (self->aq_nic_cfg->is_rss) { ++ /* last 4 byte */ ++ u16 rss_type = rxd_wb->type & 0xFU; ++ ++ if (rss_type && rss_type < 0x8U) { ++ buff->is_hash_l4 = (rss_type == 0x4 || ++ rss_type == 0x5); ++ buff->rss_hash = rxd_wb->rss_hash; + } ++ } + +- if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) { +- buff->len = rxd_wb->pkt_len % +- AQ_CFG_RX_FRAME_MAX; +- buff->len = buff->len ? +- buff->len : AQ_CFG_RX_FRAME_MAX; +- buff->next = 0U; +- buff->is_eop = 1U; ++ if (HW_ATL_B0_RXD_WB_STAT2_EOP & rxd_wb->status) { ++ buff->len = rxd_wb->pkt_len % ++ AQ_CFG_RX_FRAME_MAX; ++ buff->len = buff->len ? ++ buff->len : AQ_CFG_RX_FRAME_MAX; ++ buff->next = 0U; ++ buff->is_eop = 1U; ++ } else { ++ buff->len = ++ rxd_wb->pkt_len > AQ_CFG_RX_FRAME_MAX ? ++ AQ_CFG_RX_FRAME_MAX : rxd_wb->pkt_len; ++ ++ if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT & ++ rxd_wb->status) { ++ /* LRO */ ++ buff->next = rxd_wb->next_desc_ptr; ++ ++ring->stats.rx.lro_packets; + } else { +- if (HW_ATL_B0_RXD_WB_STAT2_RSCCNT & +- rxd_wb->status) { +- /* LRO */ +- buff->next = rxd_wb->next_desc_ptr; +- ++ring->stats.rx.lro_packets; +- } else { +- /* jumbo */ +- buff->next = +- aq_ring_next_dx(ring, +- ring->hw_head); +- ++ring->stats.rx.jumbo_packets; +- } ++ /* jumbo */ ++ buff->next = ++ aq_ring_next_dx(ring, ++ ring->hw_head); ++ ++ring->stats.rx.jumbo_packets; + } + } + } +diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c +index 66535d1653f6..f16853c3c851 100644 +--- a/drivers/net/ethernet/dec/tulip/de4x5.c ++++ b/drivers/net/ethernet/dec/tulip/de4x5.c +@@ -2107,7 +2107,6 @@ static struct eisa_driver de4x5_eisa_driver = { + .remove = de4x5_eisa_remove, + } + }; +-MODULE_DEVICE_TABLE(eisa, de4x5_eisa_ids); + #endif + + #ifdef CONFIG_PCI +diff --git a/drivers/net/ethernet/emulex/benet/be_ethtool.c b/drivers/net/ethernet/emulex/benet/be_ethtool.c +index 3f6749fc889f..bfb16a474490 100644 +--- a/drivers/net/ethernet/emulex/benet/be_ethtool.c ++++ b/drivers/net/ethernet/emulex/benet/be_ethtool.c +@@ -1105,7 +1105,7 @@ static int be_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *cmd, + cmd->data = be_get_rss_hash_opts(adapter, cmd->flow_type); + break; + case ETHTOOL_GRXRINGS: +- cmd->data = adapter->num_rx_qs - 1; ++ cmd->data = adapter->num_rx_qs; + break; + default: + return -EINVAL; +diff --git a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c +index 392fd895f278..ae2240074d8e 100644 +--- a/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c ++++ b/drivers/net/ethernet/marvell/mvpp2/mvpp2_prs.c +@@ -1905,8 +1905,7 @@ static int mvpp2_prs_ip6_init(struct mvpp2 *priv) + } + + /* Find tcam entry with matched pair */ +-static int mvpp2_prs_vid_range_find(struct mvpp2 *priv, int pmap, u16 vid, +- u16 mask) ++static int mvpp2_prs_vid_range_find(struct mvpp2_port *port, u16 vid, u16 mask) + { + unsigned char byte[2], enable[2]; + struct mvpp2_prs_entry pe; +@@ -1914,13 +1913,13 @@ static int mvpp2_prs_vid_range_find(struct mvpp2 *priv, int pmap, u16 vid, + int tid; + + /* Go through the all entries with MVPP2_PRS_LU_VID */ +- for (tid = MVPP2_PE_VID_FILT_RANGE_START; +- tid <= MVPP2_PE_VID_FILT_RANGE_END; tid++) { +- if (!priv->prs_shadow[tid].valid || +- priv->prs_shadow[tid].lu != MVPP2_PRS_LU_VID) ++ for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id); ++ tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) { ++ if (!port->priv->prs_shadow[tid].valid || ++ port->priv->prs_shadow[tid].lu != MVPP2_PRS_LU_VID) + continue; + +- mvpp2_prs_init_from_hw(priv, &pe, tid); ++ mvpp2_prs_init_from_hw(port->priv, &pe, tid); + + mvpp2_prs_tcam_data_byte_get(&pe, 2, &byte[0], &enable[0]); + mvpp2_prs_tcam_data_byte_get(&pe, 3, &byte[1], &enable[1]); +@@ -1950,7 +1949,7 @@ int mvpp2_prs_vid_entry_add(struct mvpp2_port *port, u16 vid) + memset(&pe, 0, sizeof(pe)); + + /* Scan TCAM and see if entry with this already exist */ +- tid = mvpp2_prs_vid_range_find(priv, (1 << port->id), vid, mask); ++ tid = mvpp2_prs_vid_range_find(port, vid, mask); + + reg_val = mvpp2_read(priv, MVPP2_MH_REG(port->id)); + if (reg_val & MVPP2_DSA_EXTENDED) +@@ -2008,7 +2007,7 @@ void mvpp2_prs_vid_entry_remove(struct mvpp2_port *port, u16 vid) + int tid; + + /* Scan TCAM and see if entry with this already exist */ +- tid = mvpp2_prs_vid_range_find(priv, (1 << port->id), vid, 0xfff); ++ tid = mvpp2_prs_vid_range_find(port, vid, 0xfff); + + /* No such entry */ + if (tid < 0) +@@ -2026,8 +2025,10 @@ void mvpp2_prs_vid_remove_all(struct mvpp2_port *port) + + for (tid = MVPP2_PRS_VID_PORT_FIRST(port->id); + tid <= MVPP2_PRS_VID_PORT_LAST(port->id); tid++) { +- if (priv->prs_shadow[tid].valid) +- mvpp2_prs_vid_entry_remove(port, tid); ++ if (priv->prs_shadow[tid].valid) { ++ mvpp2_prs_hw_inv(priv, tid); ++ priv->prs_shadow[tid].valid = false; ++ } + } + } + +diff --git a/drivers/net/ethernet/mellanox/mlx5/core/dev.c b/drivers/net/ethernet/mellanox/mlx5/core/dev.c +index 37ba7c78859d..1c225be9c7db 100644 +--- a/drivers/net/ethernet/mellanox/mlx5/core/dev.c ++++ b/drivers/net/ethernet/mellanox/mlx5/core/dev.c +@@ -342,11 +342,32 @@ void mlx5_unregister_interface(struct mlx5_interface *intf) + } + EXPORT_SYMBOL(mlx5_unregister_interface); + ++/* Must be called with intf_mutex held */ ++static bool mlx5_has_added_dev_by_protocol(struct mlx5_core_dev *mdev, int protocol) ++{ ++ struct mlx5_device_context *dev_ctx; ++ struct mlx5_interface *intf; ++ bool found = false; ++ ++ list_for_each_entry(intf, &intf_list, list) { ++ if (intf->protocol == protocol) { ++ dev_ctx = mlx5_get_device(intf, &mdev->priv); ++ if (dev_ctx && test_bit(MLX5_INTERFACE_ADDED, &dev_ctx->state)) ++ found = true; ++ break; ++ } ++ } ++ ++ return found; ++} ++ + void mlx5_reload_interface(struct mlx5_core_dev *mdev, int protocol) + { + mutex_lock(&mlx5_intf_mutex); +- mlx5_remove_dev_by_protocol(mdev, protocol); +- mlx5_add_dev_by_protocol(mdev, protocol); ++ if (mlx5_has_added_dev_by_protocol(mdev, protocol)) { ++ mlx5_remove_dev_by_protocol(mdev, protocol); ++ mlx5_add_dev_by_protocol(mdev, protocol); ++ } + mutex_unlock(&mlx5_intf_mutex); + } + +diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +index c5b82e283d13..ff2f6b8e2fab 100644 +--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c ++++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c +@@ -2488,6 +2488,10 @@ mlxsw_sp_port_set_link_ksettings(struct net_device *dev, + mlxsw_reg_ptys_eth_unpack(ptys_pl, ð_proto_cap, NULL, NULL); + + autoneg = cmd->base.autoneg == AUTONEG_ENABLE; ++ if (!autoneg && cmd->base.speed == SPEED_56000) { ++ netdev_err(dev, "56G not supported with autoneg off\n"); ++ return -EINVAL; ++ } + eth_proto_new = autoneg ? + mlxsw_sp_to_ptys_advert_link(cmd) : + mlxsw_sp_to_ptys_speed(cmd->base.speed); +diff --git a/drivers/net/ethernet/renesas/sh_eth.c b/drivers/net/ethernet/renesas/sh_eth.c +index f27a0dc8c563..5e3e6e262ba3 100644 +--- a/drivers/net/ethernet/renesas/sh_eth.c ++++ b/drivers/net/ethernet/renesas/sh_eth.c +@@ -1588,6 +1588,10 @@ static void sh_eth_dev_exit(struct net_device *ndev) + sh_eth_get_stats(ndev); + mdp->cd->soft_reset(ndev); + ++ /* Set the RMII mode again if required */ ++ if (mdp->cd->rmiimode) ++ sh_eth_write(ndev, 0x1, RMIIMODE); ++ + /* Set MAC address again */ + update_mac_address(ndev); + } +diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +index 50c00822b2d8..45e64d71a93f 100644 +--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c ++++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +@@ -3319,6 +3319,7 @@ static inline void stmmac_rx_refill(struct stmmac_priv *priv, u32 queue) + entry = STMMAC_GET_ENTRY(entry, DMA_RX_SIZE); + } + rx_q->dirty_rx = entry; ++ stmmac_set_rx_tail_ptr(priv, priv->ioaddr, rx_q->rx_tail_addr, queue); + } + + /** +diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c +index 9d699bd5f715..cf6b9b1771f1 100644 +--- a/drivers/net/hyperv/netvsc_drv.c ++++ b/drivers/net/hyperv/netvsc_drv.c +@@ -2405,7 +2405,7 @@ static struct hv_driver netvsc_drv = { + .probe = netvsc_probe, + .remove = netvsc_remove, + .driver = { +- .probe_type = PROBE_PREFER_ASYNCHRONOUS, ++ .probe_type = PROBE_FORCE_SYNCHRONOUS, + }, + }; + +diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c +index b3935778b19f..e4bf9e7d7583 100644 +--- a/drivers/net/phy/dp83867.c ++++ b/drivers/net/phy/dp83867.c +@@ -260,10 +260,8 @@ static int dp83867_config_init(struct phy_device *phydev) + ret = phy_write(phydev, MII_DP83867_PHYCTRL, val); + if (ret) + return ret; +- } + +- if ((phydev->interface >= PHY_INTERFACE_MODE_RGMII_ID) && +- (phydev->interface <= PHY_INTERFACE_MODE_RGMII_RXID)) { ++ /* Set up RGMII delays */ + val = phy_read_mmd(phydev, DP83867_DEVADDR, DP83867_RGMIICTL); + + if (phydev->interface == PHY_INTERFACE_MODE_RGMII_ID) +diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c +index f6e70f2dfd12..e029c7977a56 100644 +--- a/drivers/net/phy/phylink.c ++++ b/drivers/net/phy/phylink.c +@@ -54,6 +54,10 @@ struct phylink { + + /* The link configuration settings */ + struct phylink_link_state link_config; ++ ++ /* The current settings */ ++ phy_interface_t cur_interface; ++ + struct gpio_desc *link_gpio; + struct timer_list link_poll; + void (*get_fixed_state)(struct net_device *dev, +@@ -477,12 +481,12 @@ static void phylink_resolve(struct work_struct *w) + if (!link_state.link) { + netif_carrier_off(ndev); + pl->ops->mac_link_down(ndev, pl->link_an_mode, +- pl->phy_state.interface); ++ pl->cur_interface); + netdev_info(ndev, "Link is Down\n"); + } else { ++ pl->cur_interface = link_state.interface; + pl->ops->mac_link_up(ndev, pl->link_an_mode, +- pl->phy_state.interface, +- pl->phydev); ++ pl->cur_interface, pl->phydev); + + netif_carrier_on(ndev); + +diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c +index f8436d1c4d45..f7218c1673ce 100644 +--- a/drivers/pci/pci-acpi.c ++++ b/drivers/pci/pci-acpi.c +@@ -625,7 +625,8 @@ static bool acpi_pci_need_resume(struct pci_dev *dev) + if (!adev || !acpi_device_power_manageable(adev)) + return false; + +- if (device_may_wakeup(&dev->dev) != !!adev->wakeup.prepare_count) ++ if (adev->wakeup.flags.valid && ++ device_may_wakeup(&dev->dev) != !!adev->wakeup.prepare_count) + return true; + + if (acpi_target_system_state() == ACPI_STATE_S0) +diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c +index f2c561ca731a..cd2c247d6d0c 100644 +--- a/drivers/scsi/cxgbi/libcxgbi.c ++++ b/drivers/scsi/cxgbi/libcxgbi.c +@@ -641,6 +641,10 @@ cxgbi_check_route(struct sockaddr *dst_addr, int ifindex) + + if (ndev->flags & IFF_LOOPBACK) { + ndev = ip_dev_find(&init_net, daddr->sin_addr.s_addr); ++ if (!ndev) { ++ err = -ENETUNREACH; ++ goto rel_neigh; ++ } + mtu = ndev->mtu; + pr_info("rt dev %s, loopback -> %s, mtu %u.\n", + n->dev->name, ndev->name, mtu); +diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c +index 12dc7100bb4c..d1154baa9436 100644 +--- a/drivers/scsi/device_handler/scsi_dh_alua.c ++++ b/drivers/scsi/device_handler/scsi_dh_alua.c +@@ -1173,10 +1173,8 @@ static int __init alua_init(void) + int r; + + kaluad_wq = alloc_workqueue("kaluad", WQ_MEM_RECLAIM, 0); +- if (!kaluad_wq) { +- /* Temporary failure, bypass */ +- return SCSI_DH_DEV_TEMP_BUSY; +- } ++ if (!kaluad_wq) ++ return -ENOMEM; + + r = scsi_register_device_handler(&alua_dh); + if (r != 0) { +diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c +index 231eb79efa32..b141d1061f38 100644 +--- a/drivers/scsi/libsas/sas_expander.c ++++ b/drivers/scsi/libsas/sas_expander.c +@@ -989,6 +989,8 @@ static struct domain_device *sas_ex_discover_expander( + list_del(&child->dev_list_node); + spin_unlock_irq(&parent->port->dev_list_lock); + sas_put_device(child); ++ sas_port_delete(phy->port); ++ phy->port = NULL; + return NULL; + } + list_add_tail(&child->siblings, &parent->ex_dev.children); +diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c +index 3781e8109dd7..411d656f2530 100644 +--- a/drivers/scsi/smartpqi/smartpqi_init.c ++++ b/drivers/scsi/smartpqi/smartpqi_init.c +@@ -6378,7 +6378,7 @@ static int pqi_pci_init(struct pqi_ctrl_info *ctrl_info) + else + mask = DMA_BIT_MASK(32); + +- rc = dma_set_mask(&ctrl_info->pci_dev->dev, mask); ++ rc = dma_set_mask_and_coherent(&ctrl_info->pci_dev->dev, mask); + if (rc) { + dev_err(&ctrl_info->pci_dev->dev, "failed to set DMA mask\n"); + goto disable_device; +diff --git a/drivers/staging/vc04_services/bcm2835-camera/controls.c b/drivers/staging/vc04_services/bcm2835-camera/controls.c +index cff7b1e07153..b688ebc01740 100644 +--- a/drivers/staging/vc04_services/bcm2835-camera/controls.c ++++ b/drivers/staging/vc04_services/bcm2835-camera/controls.c +@@ -576,7 +576,7 @@ exit: + dev->colourfx.enable ? "true" : "false", + dev->colourfx.u, dev->colourfx.v, + ret, (ret == 0 ? 0 : -EINVAL)); +- return (ret == 0 ? 0 : EINVAL); ++ return (ret == 0 ? 0 : -EINVAL); + } + + static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, +@@ -600,7 +600,7 @@ static int ctrl_set_colfx(struct bm2835_mmal_dev *dev, + "%s: After: mmal_ctrl:%p ctrl id:0x%x ctrl val:%d ret %d(%d)\n", + __func__, mmal_ctrl, ctrl->id, ctrl->val, ret, + (ret == 0 ? 0 : -EINVAL)); +- return (ret == 0 ? 0 : EINVAL); ++ return (ret == 0 ? 0 : -EINVAL); + } + + static int ctrl_set_bitrate(struct bm2835_mmal_dev *dev, +diff --git a/drivers/tty/serial/sunhv.c b/drivers/tty/serial/sunhv.c +index 63e34d868de8..f8503f8fc44e 100644 +--- a/drivers/tty/serial/sunhv.c ++++ b/drivers/tty/serial/sunhv.c +@@ -397,7 +397,7 @@ static const struct uart_ops sunhv_pops = { + static struct uart_driver sunhv_reg = { + .owner = THIS_MODULE, + .driver_name = "sunhv", +- .dev_name = "ttyS", ++ .dev_name = "ttyHV", + .major = TTY_MAJOR, + }; + +diff --git a/drivers/usb/host/xhci-debugfs.c b/drivers/usb/host/xhci-debugfs.c +index cadc01336bf8..7ba6afc7ef23 100644 +--- a/drivers/usb/host/xhci-debugfs.c ++++ b/drivers/usb/host/xhci-debugfs.c +@@ -440,6 +440,9 @@ void xhci_debugfs_create_endpoint(struct xhci_hcd *xhci, + struct xhci_ep_priv *epriv; + struct xhci_slot_priv *spriv = dev->debugfs_private; + ++ if (!spriv) ++ return; ++ + if (spriv->eps[ep_index]) + return; + +diff --git a/drivers/xen/pvcalls-front.c b/drivers/xen/pvcalls-front.c +index 91da7e44d5d4..3a144eecb6a7 100644 +--- a/drivers/xen/pvcalls-front.c ++++ b/drivers/xen/pvcalls-front.c +@@ -538,7 +538,6 @@ out: + int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg, + size_t len) + { +- struct pvcalls_bedata *bedata; + struct sock_mapping *map; + int sent, tot_sent = 0; + int count = 0, flags; +@@ -550,7 +549,6 @@ int pvcalls_front_sendmsg(struct socket *sock, struct msghdr *msg, + map = pvcalls_enter_sock(sock); + if (IS_ERR(map)) + return PTR_ERR(map); +- bedata = dev_get_drvdata(&pvcalls_front_dev->dev); + + mutex_lock(&map->active.out_mutex); + if ((flags & MSG_DONTWAIT) && !pvcalls_front_write_todo(map)) { +@@ -633,7 +631,6 @@ out: + int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + int flags) + { +- struct pvcalls_bedata *bedata; + int ret; + struct sock_mapping *map; + +@@ -643,7 +640,6 @@ int pvcalls_front_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + map = pvcalls_enter_sock(sock); + if (IS_ERR(map)) + return PTR_ERR(map); +- bedata = dev_get_drvdata(&pvcalls_front_dev->dev); + + mutex_lock(&map->active.in_mutex); + if (len > XEN_FLEX_RING_SIZE(PVCALLS_RING_ORDER)) +diff --git a/drivers/xen/xenbus/xenbus.h b/drivers/xen/xenbus/xenbus.h +index 092981171df1..d75a2385b37c 100644 +--- a/drivers/xen/xenbus/xenbus.h ++++ b/drivers/xen/xenbus/xenbus.h +@@ -83,6 +83,7 @@ struct xb_req_data { + int num_vecs; + int err; + enum xb_req_state state; ++ bool user_req; + void (*cb)(struct xb_req_data *); + void *par; + }; +@@ -133,4 +134,6 @@ void xenbus_ring_ops_init(void); + int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par); + void xenbus_dev_queue_reply(struct xb_req_data *req); + ++extern unsigned int xb_dev_generation_id; ++ + #endif +diff --git a/drivers/xen/xenbus/xenbus_dev_frontend.c b/drivers/xen/xenbus/xenbus_dev_frontend.c +index 0782ff3c2273..39c63152a358 100644 +--- a/drivers/xen/xenbus/xenbus_dev_frontend.c ++++ b/drivers/xen/xenbus/xenbus_dev_frontend.c +@@ -62,6 +62,8 @@ + + #include "xenbus.h" + ++unsigned int xb_dev_generation_id; ++ + /* + * An element of a list of outstanding transactions, for which we're + * still waiting a reply. +@@ -69,6 +71,7 @@ + struct xenbus_transaction_holder { + struct list_head list; + struct xenbus_transaction handle; ++ unsigned int generation_id; + }; + + /* +@@ -441,6 +444,7 @@ static int xenbus_write_transaction(unsigned msg_type, + rc = -ENOMEM; + goto out; + } ++ trans->generation_id = xb_dev_generation_id; + list_add(&trans->list, &u->transactions); + } else if (msg->hdr.tx_id != 0 && + !xenbus_get_transaction(u, msg->hdr.tx_id)) +@@ -449,6 +453,20 @@ static int xenbus_write_transaction(unsigned msg_type, + !(msg->hdr.len == 2 && + (!strcmp(msg->body, "T") || !strcmp(msg->body, "F")))) + return xenbus_command_reply(u, XS_ERROR, "EINVAL"); ++ else if (msg_type == XS_TRANSACTION_END) { ++ trans = xenbus_get_transaction(u, msg->hdr.tx_id); ++ if (trans && trans->generation_id != xb_dev_generation_id) { ++ list_del(&trans->list); ++ kfree(trans); ++ if (!strcmp(msg->body, "T")) ++ return xenbus_command_reply(u, XS_ERROR, ++ "EAGAIN"); ++ else ++ return xenbus_command_reply(u, ++ XS_TRANSACTION_END, ++ "OK"); ++ } ++ } + + rc = xenbus_dev_request_and_reply(&msg->hdr, u); + if (rc && trans) { +diff --git a/drivers/xen/xenbus/xenbus_xs.c b/drivers/xen/xenbus/xenbus_xs.c +index 49a3874ae6bb..ddc18da61834 100644 +--- a/drivers/xen/xenbus/xenbus_xs.c ++++ b/drivers/xen/xenbus/xenbus_xs.c +@@ -105,6 +105,7 @@ static void xs_suspend_enter(void) + + static void xs_suspend_exit(void) + { ++ xb_dev_generation_id++; + spin_lock(&xs_state_lock); + xs_suspend_active--; + spin_unlock(&xs_state_lock); +@@ -125,7 +126,7 @@ static uint32_t xs_request_enter(struct xb_req_data *req) + spin_lock(&xs_state_lock); + } + +- if (req->type == XS_TRANSACTION_START) ++ if (req->type == XS_TRANSACTION_START && !req->user_req) + xs_state_users++; + xs_state_users++; + rq_id = xs_request_id++; +@@ -140,7 +141,7 @@ void xs_request_exit(struct xb_req_data *req) + spin_lock(&xs_state_lock); + xs_state_users--; + if ((req->type == XS_TRANSACTION_START && req->msg.type == XS_ERROR) || +- (req->type == XS_TRANSACTION_END && ++ (req->type == XS_TRANSACTION_END && !req->user_req && + !WARN_ON_ONCE(req->msg.type == XS_ERROR && + !strcmp(req->body, "ENOENT")))) + xs_state_users--; +@@ -286,6 +287,7 @@ int xenbus_dev_request_and_reply(struct xsd_sockmsg *msg, void *par) + req->num_vecs = 1; + req->cb = xenbus_dev_queue_reply; + req->par = par; ++ req->user_req = true; + + xs_send(req, msg); + +@@ -313,6 +315,7 @@ static void *xs_talkv(struct xenbus_transaction t, + req->vec = iovec; + req->num_vecs = num_vecs; + req->cb = xs_wake_up; ++ req->user_req = false; + + msg.req_id = 0; + msg.tx_id = t.id; +diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c +index 920d350df37b..809c1edffbaf 100644 +--- a/fs/configfs/dir.c ++++ b/fs/configfs/dir.c +@@ -58,15 +58,13 @@ static void configfs_d_iput(struct dentry * dentry, + if (sd) { + /* Coordinate with configfs_readdir */ + spin_lock(&configfs_dirent_lock); +- /* Coordinate with configfs_attach_attr where will increase +- * sd->s_count and update sd->s_dentry to new allocated one. +- * Only set sd->dentry to null when this dentry is the only +- * sd owner. +- * If not do so, configfs_d_iput may run just after +- * configfs_attach_attr and set sd->s_dentry to null +- * even it's still in use. ++ /* ++ * Set sd->s_dentry to null only when this dentry is the one ++ * that is going to be killed. Otherwise configfs_d_iput may ++ * run just after configfs_attach_attr and set sd->s_dentry to ++ * NULL even it's still in use. + */ +- if (atomic_read(&sd->s_count) <= 2) ++ if (sd->s_dentry == dentry) + sd->s_dentry = NULL; + + spin_unlock(&configfs_dirent_lock); +diff --git a/fs/inode.c b/fs/inode.c +index 42f6d25f32a5..5c63693326bb 100644 +--- a/fs/inode.c ++++ b/fs/inode.c +@@ -1817,8 +1817,13 @@ int file_remove_privs(struct file *file) + int kill; + int error = 0; + +- /* Fast path for nothing security related */ +- if (IS_NOSEC(inode)) ++ /* ++ * Fast path for nothing security related. ++ * As well for non-regular files, e.g. blkdev inodes. ++ * For example, blkdev_write_iter() might get here ++ * trying to remove privs which it is not allowed to. ++ */ ++ if (IS_NOSEC(inode) || !S_ISREG(inode->i_mode)) + return 0; + + kill = dentry_needs_remove_privs(dentry); +diff --git a/fs/ocfs2/filecheck.c b/fs/ocfs2/filecheck.c +index f65f2b2f594d..1906cc962c4d 100644 +--- a/fs/ocfs2/filecheck.c ++++ b/fs/ocfs2/filecheck.c +@@ -193,6 +193,7 @@ int ocfs2_filecheck_create_sysfs(struct ocfs2_super *osb) + ret = kobject_init_and_add(&entry->fs_kobj, &ocfs2_ktype_filecheck, + NULL, "filecheck"); + if (ret) { ++ kobject_put(&entry->fs_kobj); + kfree(fcheck); + return ret; + } +diff --git a/include/linux/sched/mm.h b/include/linux/sched/mm.h +index cebb79fe2c72..0d10b7ce0da7 100644 +--- a/include/linux/sched/mm.h ++++ b/include/linux/sched/mm.h +@@ -54,6 +54,10 @@ static inline void mmdrop(struct mm_struct *mm) + * followed by taking the mmap_sem for writing before modifying the + * vmas or anything the coredump pretends not to change from under it. + * ++ * It also has to be called when mmgrab() is used in the context of ++ * the process, but then the mm_count refcount is transferred outside ++ * the context of the process to run down_write() on that pinned mm. ++ * + * NOTE: find_extend_vma() called from GUP context is the only place + * that can modify the "mm" (notably the vm_start/end) under mmap_sem + * for reading and outside the context of the process, so it is also +diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c +index 99c7f199f2d4..12f351b253bb 100644 +--- a/kernel/events/ring_buffer.c ++++ b/kernel/events/ring_buffer.c +@@ -49,14 +49,30 @@ static void perf_output_put_handle(struct perf_output_handle *handle) + unsigned long head; + + again: ++ /* ++ * In order to avoid publishing a head value that goes backwards, ++ * we must ensure the load of @rb->head happens after we've ++ * incremented @rb->nest. ++ * ++ * Otherwise we can observe a @rb->head value before one published ++ * by an IRQ/NMI happening between the load and the increment. ++ */ ++ barrier(); + head = local_read(&rb->head); + + /* +- * IRQ/NMI can happen here, which means we can miss a head update. ++ * IRQ/NMI can happen here and advance @rb->head, causing our ++ * load above to be stale. + */ + +- if (!local_dec_and_test(&rb->nest)) ++ /* ++ * If this isn't the outermost nesting, we don't have to update ++ * @rb->user_page->data_head. ++ */ ++ if (local_read(&rb->nest) > 1) { ++ local_dec(&rb->nest); + goto out; ++ } + + /* + * Since the mmap() consumer (userspace) can run on a different CPU: +@@ -85,12 +101,21 @@ again: + * See perf_output_begin(). + */ + smp_wmb(); /* B, matches C */ +- rb->user_page->data_head = head; ++ WRITE_ONCE(rb->user_page->data_head, head); ++ ++ /* ++ * We must publish the head before decrementing the nest count, ++ * otherwise an IRQ/NMI can publish a more recent head value and our ++ * write will (temporarily) publish a stale value. ++ */ ++ barrier(); ++ local_set(&rb->nest, 0); + + /* +- * Now check if we missed an update -- rely on previous implied +- * compiler barriers to force a re-read. ++ * Ensure we decrement @rb->nest before we validate the @rb->head. ++ * Otherwise we cannot be sure we caught the 'last' nested update. + */ ++ barrier(); + if (unlikely(head != local_read(&rb->head))) { + local_inc(&rb->nest); + goto again; +@@ -465,7 +490,7 @@ void perf_aux_output_end(struct perf_output_handle *handle, unsigned long size) + handle->aux_flags); + } + +- rb->user_page->aux_head = rb->aux_head; ++ WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); + if (rb_need_aux_wakeup(rb)) + wakeup = true; + +@@ -497,7 +522,7 @@ int perf_aux_output_skip(struct perf_output_handle *handle, unsigned long size) + + rb->aux_head += size; + +- rb->user_page->aux_head = rb->aux_head; ++ WRITE_ONCE(rb->user_page->aux_head, rb->aux_head); + if (rb_need_aux_wakeup(rb)) { + perf_output_wakeup(handle); + handle->wakeup = rb->aux_wakeup + rb->aux_watermark; +diff --git a/mm/khugepaged.c b/mm/khugepaged.c +index fde5820be24d..ecefdba4b0dd 100644 +--- a/mm/khugepaged.c ++++ b/mm/khugepaged.c +@@ -1005,6 +1005,9 @@ static void collapse_huge_page(struct mm_struct *mm, + * handled by the anon_vma lock + PG_lock. + */ + down_write(&mm->mmap_sem); ++ result = SCAN_ANY_PROCESS; ++ if (!mmget_still_valid(mm)) ++ goto out; + result = hugepage_vma_revalidate(mm, address, &vma); + if (result) + goto out; +diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c +index 66f74c85cf6b..66d54fc11831 100644 +--- a/net/ax25/ax25_route.c ++++ b/net/ax25/ax25_route.c +@@ -429,9 +429,11 @@ int ax25_rt_autobind(ax25_cb *ax25, ax25_address *addr) + } + + if (ax25->sk != NULL) { ++ local_bh_disable(); + bh_lock_sock(ax25->sk); + sock_reset_flag(ax25->sk, SOCK_ZAPPED); + bh_unlock_sock(ax25->sk); ++ local_bh_enable(); + } + + put: +diff --git a/net/core/neighbour.c b/net/core/neighbour.c +index 4e4ac77c6816..cd9e991f21d7 100644 +--- a/net/core/neighbour.c ++++ b/net/core/neighbour.c +@@ -2751,6 +2751,7 @@ static void *neigh_get_idx_any(struct seq_file *seq, loff_t *pos) + } + + void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl, unsigned int neigh_seq_flags) ++ __acquires(tbl->lock) + __acquires(rcu_bh) + { + struct neigh_seq_state *state = seq->private; +@@ -2761,6 +2762,7 @@ void *neigh_seq_start(struct seq_file *seq, loff_t *pos, struct neigh_table *tbl + + rcu_read_lock_bh(); + state->nht = rcu_dereference_bh(tbl->nht); ++ read_lock(&tbl->lock); + + return *pos ? neigh_get_idx_any(seq, pos) : SEQ_START_TOKEN; + } +@@ -2794,8 +2796,13 @@ out: + EXPORT_SYMBOL(neigh_seq_next); + + void neigh_seq_stop(struct seq_file *seq, void *v) ++ __releases(tbl->lock) + __releases(rcu_bh) + { ++ struct neigh_seq_state *state = seq->private; ++ struct neigh_table *tbl = state->tbl; ++ ++ read_unlock(&tbl->lock); + rcu_read_unlock_bh(); + } + EXPORT_SYMBOL(neigh_seq_stop); +diff --git a/net/ipv6/ip6_flowlabel.c b/net/ipv6/ip6_flowlabel.c +index be5f3d7ceb96..f994f50e1516 100644 +--- a/net/ipv6/ip6_flowlabel.c ++++ b/net/ipv6/ip6_flowlabel.c +@@ -254,9 +254,9 @@ struct ip6_flowlabel *fl6_sock_lookup(struct sock *sk, __be32 label) + rcu_read_lock_bh(); + for_each_sk_fl_rcu(np, sfl) { + struct ip6_flowlabel *fl = sfl->fl; +- if (fl->label == label) { ++ ++ if (fl->label == label && atomic_inc_not_zero(&fl->users)) { + fl->lastuse = jiffies; +- atomic_inc(&fl->users); + rcu_read_unlock_bh(); + return fl; + } +@@ -622,7 +622,8 @@ int ipv6_flowlabel_opt(struct sock *sk, char __user *optval, int optlen) + goto done; + } + fl1 = sfl->fl; +- atomic_inc(&fl1->users); ++ if (!atomic_inc_not_zero(&fl1->users)) ++ fl1 = NULL; + break; + } + } +diff --git a/net/lapb/lapb_iface.c b/net/lapb/lapb_iface.c +index db6e0afe3a20..1740f852002e 100644 +--- a/net/lapb/lapb_iface.c ++++ b/net/lapb/lapb_iface.c +@@ -182,6 +182,7 @@ int lapb_unregister(struct net_device *dev) + lapb = __lapb_devtostruct(dev); + if (!lapb) + goto out; ++ lapb_put(lapb); + + lapb_stop_t1timer(lapb); + lapb_stop_t2timer(lapb); +diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c +index a42c1bc7c698..62c0e80dcd71 100644 +--- a/net/netfilter/ipvs/ip_vs_core.c ++++ b/net/netfilter/ipvs/ip_vs_core.c +@@ -2280,7 +2280,6 @@ static void __net_exit __ip_vs_cleanup(struct net *net) + { + struct netns_ipvs *ipvs = net_ipvs(net); + +- nf_unregister_net_hooks(net, ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); + ip_vs_service_net_cleanup(ipvs); /* ip_vs_flush() with locks */ + ip_vs_conn_net_cleanup(ipvs); + ip_vs_app_net_cleanup(ipvs); +@@ -2295,6 +2294,7 @@ static void __net_exit __ip_vs_dev_cleanup(struct net *net) + { + struct netns_ipvs *ipvs = net_ipvs(net); + EnterFunction(2); ++ nf_unregister_net_hooks(net, ip_vs_ops, ARRAY_SIZE(ip_vs_ops)); + ipvs->enable = 0; /* Disable packet reception */ + smp_wmb(); + ip_vs_sync_net_cleanup(ipvs); +diff --git a/net/netfilter/nf_queue.c b/net/netfilter/nf_queue.c +index d67a96a25a68..7569ba00e732 100644 +--- a/net/netfilter/nf_queue.c ++++ b/net/netfilter/nf_queue.c +@@ -238,6 +238,7 @@ static unsigned int nf_iterate(struct sk_buff *skb, + repeat: + verdict = nf_hook_entry_hookfn(hook, skb, state); + if (verdict != NF_ACCEPT) { ++ *index = i; + if (verdict != NF_REPEAT) + return verdict; + goto repeat; +diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c +index 376181cc1def..9f2875efb4ac 100644 +--- a/net/nfc/netlink.c ++++ b/net/nfc/netlink.c +@@ -922,7 +922,8 @@ static int nfc_genl_deactivate_target(struct sk_buff *skb, + u32 device_idx, target_idx; + int rc; + +- if (!info->attrs[NFC_ATTR_DEVICE_INDEX]) ++ if (!info->attrs[NFC_ATTR_DEVICE_INDEX] || ++ !info->attrs[NFC_ATTR_TARGET_INDEX]) + return -EINVAL; + + device_idx = nla_get_u32(info->attrs[NFC_ATTR_DEVICE_INDEX]); +diff --git a/net/openvswitch/vport-internal_dev.c b/net/openvswitch/vport-internal_dev.c +index bb95c43aae76..5a304cfc8423 100644 +--- a/net/openvswitch/vport-internal_dev.c ++++ b/net/openvswitch/vport-internal_dev.c +@@ -169,7 +169,9 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) + { + struct vport *vport; + struct internal_dev *internal_dev; ++ struct net_device *dev; + int err; ++ bool free_vport = true; + + vport = ovs_vport_alloc(0, &ovs_internal_vport_ops, parms); + if (IS_ERR(vport)) { +@@ -177,8 +179,9 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) + goto error; + } + +- vport->dev = alloc_netdev(sizeof(struct internal_dev), +- parms->name, NET_NAME_USER, do_setup); ++ dev = alloc_netdev(sizeof(struct internal_dev), ++ parms->name, NET_NAME_USER, do_setup); ++ vport->dev = dev; + if (!vport->dev) { + err = -ENOMEM; + goto error_free_vport; +@@ -199,8 +202,10 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) + + rtnl_lock(); + err = register_netdevice(vport->dev); +- if (err) ++ if (err) { ++ free_vport = false; + goto error_unlock; ++ } + + dev_set_promiscuity(vport->dev, 1); + rtnl_unlock(); +@@ -210,11 +215,12 @@ static struct vport *internal_dev_create(const struct vport_parms *parms) + + error_unlock: + rtnl_unlock(); +- free_percpu(vport->dev->tstats); ++ free_percpu(dev->tstats); + error_free_netdev: +- free_netdev(vport->dev); ++ free_netdev(dev); + error_free_vport: +- ovs_vport_free(vport); ++ if (free_vport) ++ ovs_vport_free(vport); + error: + return ERR_PTR(err); + } +diff --git a/net/sctp/sm_make_chunk.c b/net/sctp/sm_make_chunk.c +index ae65a1cfa596..fb546b2d67ca 100644 +--- a/net/sctp/sm_make_chunk.c ++++ b/net/sctp/sm_make_chunk.c +@@ -2600,6 +2600,8 @@ do_addr_param: + case SCTP_PARAM_STATE_COOKIE: + asoc->peer.cookie_len = + ntohs(param.p->length) - sizeof(struct sctp_paramhdr); ++ if (asoc->peer.cookie) ++ kfree(asoc->peer.cookie); + asoc->peer.cookie = kmemdup(param.cookie->body, asoc->peer.cookie_len, gfp); + if (!asoc->peer.cookie) + retval = 0; +@@ -2664,6 +2666,8 @@ do_addr_param: + goto fall_through; + + /* Save peer's random parameter */ ++ if (asoc->peer.peer_random) ++ kfree(asoc->peer.peer_random); + asoc->peer.peer_random = kmemdup(param.p, + ntohs(param.p->length), gfp); + if (!asoc->peer.peer_random) { +@@ -2677,6 +2681,8 @@ do_addr_param: + goto fall_through; + + /* Save peer's HMAC list */ ++ if (asoc->peer.peer_hmacs) ++ kfree(asoc->peer.peer_hmacs); + asoc->peer.peer_hmacs = kmemdup(param.p, + ntohs(param.p->length), gfp); + if (!asoc->peer.peer_hmacs) { +@@ -2692,6 +2698,8 @@ do_addr_param: + if (!ep->auth_enable) + goto fall_through; + ++ if (asoc->peer.peer_chunks) ++ kfree(asoc->peer.peer_chunks); + asoc->peer.peer_chunks = kmemdup(param.p, + ntohs(param.p->length), gfp); + if (!asoc->peer.peer_chunks) +diff --git a/net/tipc/group.c b/net/tipc/group.c +index 06fee142f09f..3ee93b5c19b6 100644 +--- a/net/tipc/group.c ++++ b/net/tipc/group.c +@@ -218,6 +218,7 @@ void tipc_group_delete(struct net *net, struct tipc_group *grp) + + rbtree_postorder_for_each_entry_safe(m, tmp, tree, tree_node) { + tipc_group_proto_xmit(grp, m, GRP_LEAVE_MSG, &xmitq); ++ __skb_queue_purge(&m->deferredq); + list_del(&m->list); + kfree(m); + } +diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c +index f3f3d06cb6d8..e30f53728725 100644 +--- a/net/vmw_vsock/virtio_transport_common.c ++++ b/net/vmw_vsock/virtio_transport_common.c +@@ -871,8 +871,10 @@ virtio_transport_recv_connected(struct sock *sk, + if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SHUTDOWN_SEND) + vsk->peer_shutdown |= SEND_SHUTDOWN; + if (vsk->peer_shutdown == SHUTDOWN_MASK && +- vsock_stream_has_data(vsk) <= 0) ++ vsock_stream_has_data(vsk) <= 0) { ++ sock_set_flag(sk, SOCK_DONE); + sk->sk_state = TCP_CLOSING; ++ } + if (le32_to_cpu(pkt->hdr.flags)) + sk->sk_state_change(sk); + break; +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c +index 45bf89ed31de..308ce76149cc 100644 +--- a/sound/pci/hda/hda_intel.c ++++ b/sound/pci/hda/hda_intel.c +@@ -378,6 +378,7 @@ enum { + + #define IS_BXT(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x5a98) + #define IS_CFL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0xa348) ++#define IS_CNL(pci) ((pci)->vendor == 0x8086 && (pci)->device == 0x9dc8) + + static char *driver_short_names[] = { + [AZX_DRIVER_ICH] = "HDA Intel", +@@ -1795,8 +1796,8 @@ static int azx_create(struct snd_card *card, struct pci_dev *pci, + else + chip->bdl_pos_adj = bdl_pos_adj[dev]; + +- /* Workaround for a communication error on CFL (bko#199007) */ +- if (IS_CFL(pci)) ++ /* Workaround for a communication error on CFL (bko#199007) and CNL */ ++ if (IS_CFL(pci) || IS_CNL(pci)) + chip->polling_mode = 1; + + err = azx_bus_init(chip, model[dev], &pci_hda_io_ops); +diff --git a/tools/perf/arch/s390/util/machine.c b/tools/perf/arch/s390/util/machine.c +index 0b2054007314..a19690a17291 100644 +--- a/tools/perf/arch/s390/util/machine.c ++++ b/tools/perf/arch/s390/util/machine.c +@@ -5,16 +5,19 @@ + #include "util.h" + #include "machine.h" + #include "api/fs/fs.h" ++#include "debug.h" + + int arch__fix_module_text_start(u64 *start, const char *name) + { ++ u64 m_start = *start; + char path[PATH_MAX]; + + snprintf(path, PATH_MAX, "module/%.*s/sections/.text", + (int)strlen(name) - 2, name + 1); +- +- if (sysfs__read_ull(path, (unsigned long long *)start) < 0) +- return -1; ++ if (sysfs__read_ull(path, (unsigned long long *)start) < 0) { ++ pr_debug2("Using module %s start:%#lx\n", path, m_start); ++ *start = m_start; ++ } + + return 0; + } +diff --git a/tools/perf/util/data-convert-bt.c b/tools/perf/util/data-convert-bt.c +index abd38abf1d91..24f2a87cf91d 100644 +--- a/tools/perf/util/data-convert-bt.c ++++ b/tools/perf/util/data-convert-bt.c +@@ -271,7 +271,7 @@ static int string_set_value(struct bt_ctf_field *field, const char *string) + if (i > 0) + strncpy(buffer, string, i); + } +- strncat(buffer + p, numstr, 4); ++ memcpy(buffer + p, numstr, 4); + p += 3; + } + } +diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c +index 2048d393ece6..56007a7e0b4d 100644 +--- a/tools/perf/util/thread.c ++++ b/tools/perf/util/thread.c +@@ -128,7 +128,7 @@ void thread__put(struct thread *thread) + } + } + +-struct namespaces *thread__namespaces(const struct thread *thread) ++static struct namespaces *__thread__namespaces(const struct thread *thread) + { + if (list_empty(&thread->namespaces_list)) + return NULL; +@@ -136,10 +136,21 @@ struct namespaces *thread__namespaces(const struct thread *thread) + return list_first_entry(&thread->namespaces_list, struct namespaces, list); + } + ++struct namespaces *thread__namespaces(const struct thread *thread) ++{ ++ struct namespaces *ns; ++ ++ down_read((struct rw_semaphore *)&thread->namespaces_lock); ++ ns = __thread__namespaces(thread); ++ up_read((struct rw_semaphore *)&thread->namespaces_lock); ++ ++ return ns; ++} ++ + static int __thread__set_namespaces(struct thread *thread, u64 timestamp, + struct namespaces_event *event) + { +- struct namespaces *new, *curr = thread__namespaces(thread); ++ struct namespaces *new, *curr = __thread__namespaces(thread); + + new = namespaces__new(event); + if (!new) +diff --git a/tools/testing/selftests/netfilter/nft_nat.sh b/tools/testing/selftests/netfilter/nft_nat.sh +index 8ec76681605c..f25f72a75cf3 100755 +--- a/tools/testing/selftests/netfilter/nft_nat.sh ++++ b/tools/testing/selftests/netfilter/nft_nat.sh +@@ -23,7 +23,11 @@ ip netns add ns0 + ip netns add ns1 + ip netns add ns2 + +-ip link add veth0 netns ns0 type veth peer name eth0 netns ns1 ++ip link add veth0 netns ns0 type veth peer name eth0 netns ns1 > /dev/null 2>&1 ++if [ $? -ne 0 ];then ++ echo "SKIP: No virtual ethernet pair device support in kernel" ++ exit $ksft_skip ++fi + ip link add veth1 netns ns0 type veth peer name eth0 netns ns2 + + ip -net ns0 link set lo up diff --git a/patch/kernel/sunxi-next/patch-4.19.54-55.patch b/patch/kernel/sunxi-next/patch-4.19.54-55.patch new file mode 100644 index 000000000..ee0b99794 --- /dev/null +++ b/patch/kernel/sunxi-next/patch-4.19.54-55.patch @@ -0,0 +1,27 @@ +diff --git a/Makefile b/Makefile +index b234837e4d07..3addd4c286fa 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 19 +-SUBLEVEL = 54 ++SUBLEVEL = 55 + EXTRAVERSION = + NAME = "People's Front" + +diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c +index 147ed82b73d3..221d9b72423b 100644 +--- a/net/ipv4/tcp_output.c ++++ b/net/ipv4/tcp_output.c +@@ -1299,7 +1299,8 @@ int tcp_fragment(struct sock *sk, enum tcp_queue tcp_queue, + if (nsize < 0) + nsize = 0; + +- if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf)) { ++ if (unlikely((sk->sk_wmem_queued >> 1) > sk->sk_sndbuf && ++ tcp_queue != TCP_FRAG_IN_WRITE_QUEUE)) { + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPWQUEUETOOBIG); + return -ENOMEM; + } diff --git a/patch/kernel/sunxi-next/patch-4.19.55-56.patch b/patch/kernel/sunxi-next/patch-4.19.55-56.patch new file mode 100644 index 000000000..fbc387cc9 --- /dev/null +++ b/patch/kernel/sunxi-next/patch-4.19.55-56.patch @@ -0,0 +1,3375 @@ +diff --git a/Makefile b/Makefile +index 3addd4c286fa..a76c61f77bcd 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,7 +1,7 @@ + # SPDX-License-Identifier: GPL-2.0 + VERSION = 4 + PATCHLEVEL = 19 +-SUBLEVEL = 55 ++SUBLEVEL = 56 + EXTRAVERSION = + NAME = "People's Front" + +@@ -652,6 +652,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning,frame-address,) + KBUILD_CFLAGS += $(call cc-disable-warning, format-truncation) + KBUILD_CFLAGS += $(call cc-disable-warning, format-overflow) + KBUILD_CFLAGS += $(call cc-disable-warning, int-in-bool-context) ++KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) + + ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE + KBUILD_CFLAGS += -Os $(call cc-disable-warning,maybe-uninitialized,) +@@ -696,7 +697,6 @@ ifeq ($(cc-name),clang) + KBUILD_CPPFLAGS += $(call cc-option,-Qunused-arguments,) + KBUILD_CFLAGS += $(call cc-disable-warning, format-invalid-specifier) + KBUILD_CFLAGS += $(call cc-disable-warning, gnu) +-KBUILD_CFLAGS += $(call cc-disable-warning, address-of-packed-member) + # Quiet clang warning: comparison of unsigned expression < 0 is always false + KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare) + # CLANG uses a _MergedGlobals as optimization, but this breaks modpost, as the +diff --git a/arch/arc/boot/dts/hsdk.dts b/arch/arc/boot/dts/hsdk.dts +index ef149f59929a..d131c54acd3e 100644 +--- a/arch/arc/boot/dts/hsdk.dts ++++ b/arch/arc/boot/dts/hsdk.dts +@@ -175,6 +175,7 @@ + interrupt-names = "macirq"; + phy-mode = "rgmii"; + snps,pbl = <32>; ++ snps,multicast-filter-bins = <256>; + clocks = <&gmacclk>; + clock-names = "stmmaceth"; + phy-handle = <&phy0>; +@@ -183,6 +184,9 @@ + mac-address = [00 00 00 00 00 00]; /* Filled in by U-Boot */ + dma-coherent; + ++ tx-fifo-depth = <4096>; ++ rx-fifo-depth = <4096>; ++ + mdio { + #address-cells = <1>; + #size-cells = <0>; +diff --git a/arch/arc/include/asm/cmpxchg.h b/arch/arc/include/asm/cmpxchg.h +index d819de1c5d10..3ea4112c8302 100644 +--- a/arch/arc/include/asm/cmpxchg.h ++++ b/arch/arc/include/asm/cmpxchg.h +@@ -92,8 +92,11 @@ __cmpxchg(volatile void *ptr, unsigned long expected, unsigned long new) + + #endif /* CONFIG_ARC_HAS_LLSC */ + +-#define cmpxchg(ptr, o, n) ((typeof(*(ptr)))__cmpxchg((ptr), \ +- (unsigned long)(o), (unsigned long)(n))) ++#define cmpxchg(ptr, o, n) ({ \ ++ (typeof(*(ptr)))__cmpxchg((ptr), \ ++ (unsigned long)(o), \ ++ (unsigned long)(n)); \ ++}) + + /* + * atomic_cmpxchg is same as cmpxchg +@@ -198,8 +201,11 @@ static inline unsigned long __xchg(unsigned long val, volatile void *ptr, + return __xchg_bad_pointer(); + } + +-#define xchg(ptr, with) ((typeof(*(ptr)))__xchg((unsigned long)(with), (ptr), \ +- sizeof(*(ptr)))) ++#define xchg(ptr, with) ({ \ ++ (typeof(*(ptr)))__xchg((unsigned long)(with), \ ++ (ptr), \ ++ sizeof(*(ptr))); \ ++}) + + #endif /* CONFIG_ARC_PLAT_EZNPS */ + +diff --git a/arch/arc/mm/tlb.c b/arch/arc/mm/tlb.c +index 4097764fea23..fa18c00b0cfd 100644 +--- a/arch/arc/mm/tlb.c ++++ b/arch/arc/mm/tlb.c +@@ -911,9 +911,11 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address, + struct pt_regs *regs) + { + struct cpuinfo_arc_mmu *mmu = &cpuinfo_arc700[smp_processor_id()].mmu; +- unsigned int pd0[mmu->ways]; + unsigned long flags; +- int set; ++ int set, n_ways = mmu->ways; ++ ++ n_ways = min(n_ways, 4); ++ BUG_ON(mmu->ways > 4); + + local_irq_save(flags); + +@@ -921,9 +923,10 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address, + for (set = 0; set < mmu->sets; set++) { + + int is_valid, way; ++ unsigned int pd0[4]; + + /* read out all the ways of current set */ +- for (way = 0, is_valid = 0; way < mmu->ways; way++) { ++ for (way = 0, is_valid = 0; way < n_ways; way++) { + write_aux_reg(ARC_REG_TLBINDEX, + SET_WAY_TO_IDX(mmu, set, way)); + write_aux_reg(ARC_REG_TLBCOMMAND, TLBRead); +@@ -937,14 +940,14 @@ void do_tlb_overlap_fault(unsigned long cause, unsigned long address, + continue; + + /* Scan the set for duplicate ways: needs a nested loop */ +- for (way = 0; way < mmu->ways - 1; way++) { ++ for (way = 0; way < n_ways - 1; way++) { + + int n; + + if (!pd0[way]) + continue; + +- for (n = way + 1; n < mmu->ways; n++) { ++ for (n = way + 1; n < n_ways; n++) { + if (pd0[way] != pd0[n]) + continue; + +diff --git a/arch/arm/boot/dts/am57xx-idk-common.dtsi b/arch/arm/boot/dts/am57xx-idk-common.dtsi +index c9063ffca524..3fd9a1676d88 100644 +--- a/arch/arm/boot/dts/am57xx-idk-common.dtsi ++++ b/arch/arm/boot/dts/am57xx-idk-common.dtsi +@@ -410,6 +410,7 @@ + vqmmc-supply = <&ldo1_reg>; + bus-width = <4>; + cd-gpios = <&gpio6 27 GPIO_ACTIVE_LOW>; /* gpio 219 */ ++ no-1-8-v; + }; + + &mmc2 { +diff --git a/arch/arm/boot/dts/dra76x-mmc-iodelay.dtsi b/arch/arm/boot/dts/dra76x-mmc-iodelay.dtsi +index baba7b00eca7..fdca48186916 100644 +--- a/arch/arm/boot/dts/dra76x-mmc-iodelay.dtsi ++++ b/arch/arm/boot/dts/dra76x-mmc-iodelay.dtsi +@@ -22,7 +22,7 @@ + * + * Datamanual Revisions: + * +- * DRA76x Silicon Revision 1.0: SPRS993A, Revised July 2017 ++ * DRA76x Silicon Revision 1.0: SPRS993E, Revised December 2018 + * + */ + +@@ -169,25 +169,25 @@ + /* Corresponds to MMC2_HS200_MANUAL1 in datamanual */ + mmc2_iodelay_hs200_conf: mmc2_iodelay_hs200_conf { + pinctrl-pin-array = < +- 0x190 A_DELAY_PS(384) G_DELAY_PS(0) /* CFG_GPMC_A19_OEN */ +- 0x194 A_DELAY_PS(0) G_DELAY_PS(174) /* CFG_GPMC_A19_OUT */ +- 0x1a8 A_DELAY_PS(410) G_DELAY_PS(0) /* CFG_GPMC_A20_OEN */ +- 0x1ac A_DELAY_PS(85) G_DELAY_PS(0) /* CFG_GPMC_A20_OUT */ +- 0x1b4 A_DELAY_PS(468) G_DELAY_PS(0) /* CFG_GPMC_A21_OEN */ +- 0x1b8 A_DELAY_PS(139) G_DELAY_PS(0) /* CFG_GPMC_A21_OUT */ +- 0x1c0 A_DELAY_PS(676) G_DELAY_PS(0) /* CFG_GPMC_A22_OEN */ +- 0x1c4 A_DELAY_PS(69) G_DELAY_PS(0) /* CFG_GPMC_A22_OUT */ +- 0x1d0 A_DELAY_PS(1062) G_DELAY_PS(154) /* CFG_GPMC_A23_OUT */ +- 0x1d8 A_DELAY_PS(640) G_DELAY_PS(0) /* CFG_GPMC_A24_OEN */ +- 0x1dc A_DELAY_PS(0) G_DELAY_PS(0) /* CFG_GPMC_A24_OUT */ +- 0x1e4 A_DELAY_PS(356) G_DELAY_PS(0) /* CFG_GPMC_A25_OEN */ +- 0x1e8 A_DELAY_PS(0) G_DELAY_PS(0) /* CFG_GPMC_A25_OUT */ +- 0x1f0 A_DELAY_PS(579) G_DELAY_PS(0) /* CFG_GPMC_A26_OEN */ +- 0x1f4 A_DELAY_PS(0) G_DELAY_PS(0) /* CFG_GPMC_A26_OUT */ +- 0x1fc A_DELAY_PS(435) G_DELAY_PS(0) /* CFG_GPMC_A27_OEN */ +- 0x200 A_DELAY_PS(36) G_DELAY_PS(0) /* CFG_GPMC_A27_OUT */ +- 0x364 A_DELAY_PS(759) G_DELAY_PS(0) /* CFG_GPMC_CS1_OEN */ +- 0x368 A_DELAY_PS(72) G_DELAY_PS(0) /* CFG_GPMC_CS1_OUT */ ++ 0x190 A_DELAY_PS(384) G_DELAY_PS(0) /* CFG_GPMC_A19_OEN */ ++ 0x194 A_DELAY_PS(350) G_DELAY_PS(174) /* CFG_GPMC_A19_OUT */ ++ 0x1a8 A_DELAY_PS(410) G_DELAY_PS(0) /* CFG_GPMC_A20_OEN */ ++ 0x1ac A_DELAY_PS(335) G_DELAY_PS(0) /* CFG_GPMC_A20_OUT */ ++ 0x1b4 A_DELAY_PS(468) G_DELAY_PS(0) /* CFG_GPMC_A21_OEN */ ++ 0x1b8 A_DELAY_PS(339) G_DELAY_PS(0) /* CFG_GPMC_A21_OUT */ ++ 0x1c0 A_DELAY_PS(676) G_DELAY_PS(0) /* CFG_GPMC_A22_OEN */ ++ 0x1c4 A_DELAY_PS(219) G_DELAY_PS(0) /* CFG_GPMC_A22_OUT */ ++ 0x1d0 A_DELAY_PS(1062) G_DELAY_PS(154) /* CFG_GPMC_A23_OUT */ ++ 0x1d8 A_DELAY_PS(640) G_DELAY_PS(0) /* CFG_GPMC_A24_OEN */ ++ 0x1dc A_DELAY_PS(150) G_DELAY_PS(0) /* CFG_GPMC_A24_OUT */ ++ 0x1e4 A_DELAY_PS(356) G_DELAY_PS(0) /* CFG_GPMC_A25_OEN */ ++ 0x1e8 A_DELAY_PS(150) G_DELAY_PS(0) /* CFG_GPMC_A25_OUT */ ++ 0x1f0 A_DELAY_PS(579) G_DELAY_PS(0) /* CFG_GPMC_A26_OEN */ ++ 0x1f4 A_DELAY_PS(200) G_DELAY_PS(0) /* CFG_GPMC_A26_OUT */ ++ 0x1fc A_DELAY_PS(435) G_DELAY_PS(0) /* CFG_GPMC_A27_OEN */ ++ 0x200 A_DELAY_PS(236) G_DELAY_PS(0) /* CFG_GPMC_A27_OUT */ ++ 0x364 A_DELAY_PS(759) G_DELAY_PS(0) /* CFG_GPMC_CS1_OEN */ ++ 0x368 A_DELAY_PS(372) G_DELAY_PS(0) /* CFG_GPMC_CS1_OUT */ + >; + }; + +diff --git a/arch/arm/mach-imx/cpuidle-imx6sx.c b/arch/arm/mach-imx/cpuidle-imx6sx.c +index fd0053e47a15..3708a71f30e6 100644 +--- a/arch/arm/mach-imx/cpuidle-imx6sx.c ++++ b/arch/arm/mach-imx/cpuidle-imx6sx.c +@@ -15,6 +15,7 @@ + + #include "common.h" + #include "cpuidle.h" ++#include "hardware.h" + + static int imx6sx_idle_finish(unsigned long val) + { +@@ -110,7 +111,7 @@ int __init imx6sx_cpuidle_init(void) + * except for power up sw2iso which need to be + * larger than LDO ramp up time. + */ +- imx_gpc_set_arm_power_up_timing(0xf, 1); ++ imx_gpc_set_arm_power_up_timing(cpu_is_imx6sx() ? 0xf : 0x2, 1); + imx_gpc_set_arm_power_down_timing(1, 1); + + return cpuidle_register(&imx6sx_cpuidle_driver, NULL); +diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile +index 35649ee8ad56..c12ff63265a9 100644 +--- a/arch/arm64/Makefile ++++ b/arch/arm64/Makefile +@@ -51,6 +51,7 @@ endif + + KBUILD_CFLAGS += -mgeneral-regs-only $(lseinstr) $(brokengasinst) + KBUILD_CFLAGS += -fno-asynchronous-unwind-tables ++KBUILD_CFLAGS += -Wno-psabi + KBUILD_AFLAGS += $(lseinstr) $(brokengasinst) + + KBUILD_CFLAGS += $(call cc-option,-mabi=lp64) +diff --git a/arch/arm64/include/uapi/asm/ptrace.h b/arch/arm64/include/uapi/asm/ptrace.h +index ad64d2c92ef5..5dff8eccd17d 100644 +--- a/arch/arm64/include/uapi/asm/ptrace.h ++++ b/arch/arm64/include/uapi/asm/ptrace.h +@@ -64,8 +64,6 @@ + + #ifndef __ASSEMBLY__ + +-#include +- + /* + * User structures for general purpose, floating point and debug registers. + */ +@@ -112,10 +110,10 @@ struct user_sve_header { + + /* + * Common SVE_PT_* flags: +- * These must be kept in sync with prctl interface in ++ * These must be kept in sync with prctl interface in + */ +-#define SVE_PT_VL_INHERIT (PR_SVE_VL_INHERIT >> 16) +-#define SVE_PT_VL_ONEXEC (PR_SVE_SET_VL_ONEXEC >> 16) ++#define SVE_PT_VL_INHERIT ((1 << 17) /* PR_SVE_VL_INHERIT */ >> 16) ++#define SVE_PT_VL_ONEXEC ((1 << 18) /* PR_SVE_SET_VL_ONEXEC */ >> 16) + + + /* +diff --git a/arch/arm64/kernel/ssbd.c b/arch/arm64/kernel/ssbd.c +index 3432e5ef9f41..388f8fc13080 100644 +--- a/arch/arm64/kernel/ssbd.c ++++ b/arch/arm64/kernel/ssbd.c +@@ -4,6 +4,7 @@ + */ + + #include ++#include + #include + #include + +diff --git a/arch/mips/kernel/uprobes.c b/arch/mips/kernel/uprobes.c +index 4aaff3b3175c..6dbe4eab0a0e 100644 +--- a/arch/mips/kernel/uprobes.c ++++ b/arch/mips/kernel/uprobes.c +@@ -112,9 +112,6 @@ int arch_uprobe_pre_xol(struct arch_uprobe *aup, struct pt_regs *regs) + */ + aup->resume_epc = regs->cp0_epc + 4; + if (insn_has_delay_slot((union mips_instruction) aup->insn[0])) { +- unsigned long epc; +- +- epc = regs->cp0_epc; + __compute_return_epc_for_insn(regs, + (union mips_instruction) aup->insn[0]); + aup->resume_epc = regs->cp0_epc; +diff --git a/arch/parisc/math-emu/cnv_float.h b/arch/parisc/math-emu/cnv_float.h +index 933423fa5144..b0db61188a61 100644 +--- a/arch/parisc/math-emu/cnv_float.h ++++ b/arch/parisc/math-emu/cnv_float.h +@@ -60,19 +60,19 @@ + ((exponent < (SGL_P - 1)) ? \ + (Sall(sgl_value) << (SGL_EXP_LENGTH + 1 + exponent)) : FALSE) + +-#define Int_isinexact_to_sgl(int_value) (int_value << 33 - SGL_EXP_LENGTH) ++#define Int_isinexact_to_sgl(int_value) ((int_value << 33 - SGL_EXP_LENGTH) != 0) + + #define Sgl_roundnearest_from_int(int_value,sgl_value) \ + if (int_value & 1<<(SGL_EXP_LENGTH - 2)) /* round bit */ \ +- if ((int_value << 34 - SGL_EXP_LENGTH) || Slow(sgl_value)) \ ++ if (((int_value << 34 - SGL_EXP_LENGTH) != 0) || Slow(sgl_value)) \ + Sall(sgl_value)++ + + #define Dint_isinexact_to_sgl(dint_valueA,dint_valueB) \ +- ((Dintp1(dint_valueA) << 33 - SGL_EXP_LENGTH) || Dintp2(dint_valueB)) ++ (((Dintp1(dint_valueA) << 33 - SGL_EXP_LENGTH) != 0) || Dintp2(dint_valueB)) + + #define Sgl_roundnearest_from_dint(dint_valueA,dint_valueB,sgl_value) \ + if (Dintp1(dint_valueA) & 1<<(SGL_EXP_LENGTH - 2)) \ +- if ((Dintp1(dint_valueA) << 34 - SGL_EXP_LENGTH) || \ ++ if (((Dintp1(dint_valueA) << 34 - SGL_EXP_LENGTH) != 0) || \ + Dintp2(dint_valueB) || Slow(sgl_value)) Sall(sgl_value)++ + + #define Dint_isinexact_to_dbl(dint_value) \ +diff --git a/arch/powerpc/include/asm/ppc-opcode.h b/arch/powerpc/include/asm/ppc-opcode.h +index 2b7135391231..d9d5391b2af6 100644 +--- a/arch/powerpc/include/asm/ppc-opcode.h ++++ b/arch/powerpc/include/asm/ppc-opcode.h +@@ -336,6 +336,7 @@ + #define PPC_INST_MULLI 0x1c000000 + #define PPC_INST_DIVWU 0x7c000396 + #define PPC_INST_DIVD 0x7c0003d2 ++#define PPC_INST_DIVDU 0x7c000392 + #define PPC_INST_RLWINM 0x54000000 + #define PPC_INST_RLWIMI 0x50000000 + #define PPC_INST_RLDICL 0x78000000 +diff --git a/arch/powerpc/mm/mmu_context_book3s64.c b/arch/powerpc/mm/mmu_context_book3s64.c +index dbd8f762140b..68984d85ad6b 100644 +--- a/arch/powerpc/mm/mmu_context_book3s64.c ++++ b/arch/powerpc/mm/mmu_context_book3s64.c +@@ -53,14 +53,48 @@ int hash__alloc_context_id(void) + } + EXPORT_SYMBOL_GPL(hash__alloc_context_id); + ++static int realloc_context_ids(mm_context_t *ctx) ++{ ++ int i, id; ++ ++ /* ++ * id 0 (aka. ctx->id) is special, we always allocate a new one, even if ++ * there wasn't one allocated previously (which happens in the exec ++ * case where ctx is newly allocated). ++ * ++ * We have to be a bit careful here. We must keep the existing ids in ++ * the array, so that we can test if they're non-zero to decide if we ++ * need to allocate a new one. However in case of error we must free the ++ * ids we've allocated but *not* any of the existing ones (or risk a ++ * UAF). That's why we decrement i at the start of the error handling ++ * loop, to skip the id that we just tested but couldn't reallocate. ++ */ ++ for (i = 0; i < ARRAY_SIZE(ctx->extended_id); i++) { ++ if (i == 0 || ctx->extended_id[i]) { ++ id = hash__alloc_context_id(); ++ if (id < 0) ++ goto error; ++ ++ ctx->extended_id[i] = id; ++ } ++ } ++ ++ /* The caller expects us to return id */ ++ return ctx->id; ++ ++error: ++ for (i--; i >= 0; i--) { ++ if (ctx->extended_id[i]) ++ ida_free(&mmu_context_ida, ctx->extended_id[i]); ++ } ++ ++ return id; ++} ++ + static int hash__init_new_context(struct mm_struct *mm) + { + int index; + +- index = hash__alloc_context_id(); +- if (index < 0) +- return index; +- + /* + * The old code would re-promote on fork, we don't do that when using + * slices as it could cause problem promoting slices that have been +@@ -78,6 +112,10 @@ static int hash__init_new_context(struct mm_struct *mm) + if (mm->context.id == 0) + slice_init_new_context_exec(mm); + ++ index = realloc_context_ids(&mm->context); ++ if (index < 0) ++ return index; ++ + subpage_prot_init_new_context(mm); + + pkey_mm_init(mm); +diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h +index 68dece206048..e5c1d30ee968 100644 +--- a/arch/powerpc/net/bpf_jit.h ++++ b/arch/powerpc/net/bpf_jit.h +@@ -116,7 +116,7 @@ + ___PPC_RA(a) | IMM_L(i)) + #define PPC_DIVWU(d, a, b) EMIT(PPC_INST_DIVWU | ___PPC_RT(d) | \ + ___PPC_RA(a) | ___PPC_RB(b)) +-#define PPC_DIVD(d, a, b) EMIT(PPC_INST_DIVD | ___PPC_RT(d) | \ ++#define PPC_DIVDU(d, a, b) EMIT(PPC_INST_DIVDU | ___PPC_RT(d) | \ + ___PPC_RA(a) | ___PPC_RB(b)) + #define PPC_AND(d, a, b) EMIT(PPC_INST_AND | ___PPC_RA(d) | \ + ___PPC_RS(a) | ___PPC_RB(b)) +diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c +index 226eec62d125..279a51bf94d0 100644 +--- a/arch/powerpc/net/bpf_jit_comp64.c ++++ b/arch/powerpc/net/bpf_jit_comp64.c +@@ -372,12 +372,12 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, + case BPF_ALU64 | BPF_DIV | BPF_X: /* dst /= src */ + case BPF_ALU64 | BPF_MOD | BPF_X: /* dst %= src */ + if (BPF_OP(code) == BPF_MOD) { +- PPC_DIVD(b2p[TMP_REG_1], dst_reg, src_reg); ++ PPC_DIVDU(b2p[TMP_REG_1], dst_reg, src_reg); + PPC_MULD(b2p[TMP_REG_1], src_reg, + b2p[TMP_REG_1]); + PPC_SUB(dst_reg, dst_reg, b2p[TMP_REG_1]); + } else +- PPC_DIVD(dst_reg, dst_reg, src_reg); ++ PPC_DIVDU(dst_reg, dst_reg, src_reg); + break; + case BPF_ALU | BPF_MOD | BPF_K: /* (u32) dst %= (u32) imm */ + case BPF_ALU | BPF_DIV | BPF_K: /* (u32) dst /= (u32) imm */ +@@ -405,7 +405,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, + break; + case BPF_ALU64: + if (BPF_OP(code) == BPF_MOD) { +- PPC_DIVD(b2p[TMP_REG_2], dst_reg, ++ PPC_DIVDU(b2p[TMP_REG_2], dst_reg, + b2p[TMP_REG_1]); + PPC_MULD(b2p[TMP_REG_1], + b2p[TMP_REG_1], +@@ -413,7 +413,7 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, + PPC_SUB(dst_reg, dst_reg, + b2p[TMP_REG_1]); + } else +- PPC_DIVD(dst_reg, dst_reg, ++ PPC_DIVDU(dst_reg, dst_reg, + b2p[TMP_REG_1]); + break; + } +diff --git a/arch/riscv/mm/fault.c b/arch/riscv/mm/fault.c +index 88401d5125bc..523dbfbac03d 100644 +--- a/arch/riscv/mm/fault.c ++++ b/arch/riscv/mm/fault.c +@@ -29,6 +29,7 @@ + + #include + #include ++#include + + /* + * This routine handles page faults. It determines the address and the +@@ -281,6 +282,18 @@ vmalloc_fault: + pte_k = pte_offset_kernel(pmd_k, addr); + if (!pte_present(*pte_k)) + goto no_context; ++ ++ /* ++ * The kernel assumes that TLBs don't cache invalid ++ * entries, but in RISC-V, SFENCE.VMA specifies an ++ * ordering constraint, not a cache flush; it is ++ * necessary even after writing invalid entries. ++ * Relying on flush_tlb_fix_spurious_fault would ++ * suffice, but the extra traps reduce ++ * performance. So, eagerly SFENCE.VMA. ++ */ ++ local_flush_tlb_page(addr); ++ + return; + } + } +diff --git a/arch/s390/include/asm/ap.h b/arch/s390/include/asm/ap.h +index 8c00fd509c45..1a6a7092d942 100644 +--- a/arch/s390/include/asm/ap.h ++++ b/arch/s390/include/asm/ap.h +@@ -221,16 +221,22 @@ static inline struct ap_queue_status ap_aqic(ap_qid_t qid, + void *ind) + { + register unsigned long reg0 asm ("0") = qid | (3UL << 24); +- register struct ap_qirq_ctrl reg1_in asm ("1") = qirqctrl; +- register struct ap_queue_status reg1_out asm ("1"); ++ register union { ++ unsigned long value; ++ struct ap_qirq_ctrl qirqctrl; ++ struct ap_queue_status status; ++ } reg1 asm ("1"); + register void *reg2 asm ("2") = ind; + ++ reg1.qirqctrl = qirqctrl; ++ + asm volatile( + ".long 0xb2af0000" /* PQAP(AQIC) */ +- : "=d" (reg1_out) +- : "d" (reg0), "d" (reg1_in), "d" (reg2) ++ : "+d" (reg1) ++ : "d" (reg0), "d" (reg2) + : "cc"); +- return reg1_out; ++ ++ return reg1.status; + } + + /* +@@ -264,17 +270,21 @@ static inline struct ap_queue_status ap_qact(ap_qid_t qid, int ifbit, + { + register unsigned long reg0 asm ("0") = qid | (5UL << 24) + | ((ifbit & 0x01) << 22); +- register unsigned long reg1_in asm ("1") = apinfo->val; +- register struct ap_queue_status reg1_out asm ("1"); ++ register union { ++ unsigned long value; ++ struct ap_queue_status status; ++ } reg1 asm ("1"); + register unsigned long reg2 asm ("2"); + ++ reg1.value = apinfo->val; ++ + asm volatile( + ".long 0xb2af0000" /* PQAP(QACT) */ +- : "+d" (reg1_in), "=d" (reg1_out), "=d" (reg2) ++ : "+d" (reg1), "=d" (reg2) + : "d" (reg0) + : "cc"); + apinfo->val = reg2; +- return reg1_out; ++ return reg1.status; + } + + /** +diff --git a/arch/s390/include/asm/jump_label.h b/arch/s390/include/asm/jump_label.h +index 40f651292aa7..9c7dc970e966 100644 +--- a/arch/s390/include/asm/jump_label.h ++++ b/arch/s390/include/asm/jump_label.h +@@ -10,6 +10,12 @@ + #define JUMP_LABEL_NOP_SIZE 6 + #define JUMP_LABEL_NOP_OFFSET 2 + ++#if __GNUC__ < 9 ++#define JUMP_LABEL_STATIC_KEY_CONSTRAINT "X" ++#else ++#define JUMP_LABEL_STATIC_KEY_CONSTRAINT "jdd" ++#endif ++ + /* + * We use a brcl 0,2 instruction for jump labels at compile time so it + * can be easily distinguished from a hotpatch generated instruction. +@@ -19,9 +25,9 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran + asm_volatile_goto("0: brcl 0,"__stringify(JUMP_LABEL_NOP_OFFSET)"\n" + ".pushsection __jump_table, \"aw\"\n" + ".balign 8\n" +- ".quad 0b, %l[label], %0\n" ++ ".quad 0b, %l[label], %0+%1\n" + ".popsection\n" +- : : "X" (&((char *)key)[branch]) : : label); ++ : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label); + + return false; + label: +@@ -33,9 +39,9 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool + asm_volatile_goto("0: brcl 15, %l[label]\n" + ".pushsection __jump_table, \"aw\"\n" + ".balign 8\n" +- ".quad 0b, %l[label], %0\n" ++ ".quad 0b, %l[label], %0+%1\n" + ".popsection\n" +- : : "X" (&((char *)key)[branch]) : : label); ++ : : JUMP_LABEL_STATIC_KEY_CONSTRAINT (key), "i" (branch) : : label); + + return false; + label: +diff --git a/arch/sparc/kernel/mdesc.c b/arch/sparc/kernel/mdesc.c +index 39a2503fa3e1..51028abe5e90 100644 +--- a/arch/sparc/kernel/mdesc.c ++++ b/arch/sparc/kernel/mdesc.c +@@ -357,6 +357,8 @@ static int get_vdev_port_node_info(struct mdesc_handle *md, u64 node, + + node_info->vdev_port.id = *idp; + node_info->vdev_port.name = kstrdup_const(name, GFP_KERNEL); ++ if (!node_info->vdev_port.name) ++ return -1; + node_info->vdev_port.parent_cfg_hdl = *parent_cfg_hdlp; + + return 0; +diff --git a/arch/sparc/kernel/perf_event.c b/arch/sparc/kernel/perf_event.c +index 67b3e6b3ce5d..1ad5911f62b4 100644 +--- a/arch/sparc/kernel/perf_event.c ++++ b/arch/sparc/kernel/perf_event.c +@@ -891,6 +891,10 @@ static int sparc_perf_event_set_period(struct perf_event *event, + s64 period = hwc->sample_period; + int ret = 0; + ++ /* The period may have been changed by PERF_EVENT_IOC_PERIOD */ ++ if (unlikely(period != hwc->last_period)) ++ left = period - (hwc->last_period - left); ++ + if (unlikely(left <= -period)) { + left = period; + local64_set(&hwc->period_left, left); +diff --git a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +index 643670fb8943..274d220d0a83 100644 +--- a/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c ++++ b/arch/x86/kernel/cpu/intel_rdt_rdtgroup.c +@@ -2379,7 +2379,7 @@ static int rdtgroup_init_alloc(struct rdtgroup *rdtgrp) + if (closid_allocated(i) && i != closid) { + mode = rdtgroup_mode_by_closid(i); + if (mode == RDT_MODE_PSEUDO_LOCKSETUP) +- break; ++ continue; + used_b |= *ctrl; + if (mode == RDT_MODE_SHAREABLE) + d->new_ctrl |= *ctrl; +diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c +index 351283b60df6..a285fbd0fd9b 100644 +--- a/arch/xtensa/kernel/setup.c ++++ b/arch/xtensa/kernel/setup.c +@@ -310,7 +310,8 @@ extern char _SecondaryResetVector_text_start; + extern char _SecondaryResetVector_text_end; + #endif + +-static inline int mem_reserve(unsigned long start, unsigned long end) ++static inline int __init_memblock mem_reserve(unsigned long start, ++ unsigned long end) + { + return memblock_reserve(start, end - start); + } +diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +index c4eb55e3011c..c05ef7f1d7b6 100644 +--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c ++++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c +@@ -512,7 +512,8 @@ dma_chan_prep_dma_memcpy(struct dma_chan *dchan, dma_addr_t dst_adr, + return vchan_tx_prep(&chan->vc, &first->vd, flags); + + err_desc_get: +- axi_desc_put(first); ++ if (first) ++ axi_desc_put(first); + return NULL; + } + +diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c +index 55df0d41355b..1ed1c7efa288 100644 +--- a/drivers/dma/sprd-dma.c ++++ b/drivers/dma/sprd-dma.c +@@ -663,7 +663,7 @@ static int sprd_dma_fill_desc(struct dma_chan *chan, + temp |= slave_cfg->src_maxburst & SPRD_DMA_FRG_LEN_MASK; + hw->frg_len = temp; + +- hw->blk_len = len & SPRD_DMA_BLK_LEN_MASK; ++ hw->blk_len = slave_cfg->src_maxburst & SPRD_DMA_BLK_LEN_MASK; + hw->trsc_len = len & SPRD_DMA_TRSC_LEN_MASK; + + temp = (dst_step & SPRD_DMA_TRSF_STEP_MASK) << SPRD_DMA_DEST_TRSF_STEP_OFFSET; +diff --git a/drivers/fpga/dfl-afu-dma-region.c b/drivers/fpga/dfl-afu-dma-region.c +index 0e81d33af856..c9a613dc9eb7 100644 +--- a/drivers/fpga/dfl-afu-dma-region.c ++++ b/drivers/fpga/dfl-afu-dma-region.c +@@ -399,7 +399,7 @@ int afu_dma_map_region(struct dfl_feature_platform_data *pdata, + region->pages[0], 0, + region->length, + DMA_BIDIRECTIONAL); +- if (dma_mapping_error(&pdata->dev->dev, region->iova)) { ++ if (dma_mapping_error(dfl_fpga_pdata_to_parent(pdata), region->iova)) { + dev_err(&pdata->dev->dev, "failed to map for dma\n"); + ret = -EFAULT; + goto unpin_pages; +diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c +index a9b521bccb06..ab361ec78df4 100644 +--- a/drivers/fpga/dfl.c ++++ b/drivers/fpga/dfl.c +@@ -40,6 +40,13 @@ enum dfl_fpga_devt_type { + DFL_FPGA_DEVT_MAX, + }; + ++static struct lock_class_key dfl_pdata_keys[DFL_ID_MAX]; ++ ++static const char *dfl_pdata_key_strings[DFL_ID_MAX] = { ++ "dfl-fme-pdata", ++ "dfl-port-pdata", ++}; ++ + /** + * dfl_dev_info - dfl feature device information. + * @name: name string of the feature platform device. +@@ -443,11 +450,16 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo) + struct platform_device *fdev = binfo->feature_dev; + struct dfl_feature_platform_data *pdata; + struct dfl_feature_info *finfo, *p; ++ enum dfl_id_type type; + int ret, index = 0; + + if (!fdev) + return 0; + ++ type = feature_dev_id_type(fdev); ++ if (WARN_ON_ONCE(type >= DFL_ID_MAX)) ++ return -EINVAL; ++ + /* + * we do not need to care for the memory which is associated with + * the platform device. After calling platform_device_unregister(), +@@ -463,6 +475,8 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo) + pdata->num = binfo->feature_num; + pdata->dfl_cdev = binfo->cdev; + mutex_init(&pdata->lock); ++ lockdep_set_class_and_name(&pdata->lock, &dfl_pdata_keys[type], ++ dfl_pdata_key_strings[type]); + + /* + * the count should be initialized to 0 to make sure +@@ -497,7 +511,7 @@ static int build_info_commit_dev(struct build_feature_devs_info *binfo) + + ret = platform_device_add(binfo->feature_dev); + if (!ret) { +- if (feature_dev_id_type(binfo->feature_dev) == PORT_ID) ++ if (type == PORT_ID) + dfl_fpga_cdev_add_port_dev(binfo->cdev, + binfo->feature_dev); + else +diff --git a/drivers/gpu/drm/arm/hdlcd_crtc.c b/drivers/gpu/drm/arm/hdlcd_crtc.c +index e4d67b70244d..e69d996eabad 100644 +--- a/drivers/gpu/drm/arm/hdlcd_crtc.c ++++ b/drivers/gpu/drm/arm/hdlcd_crtc.c +@@ -186,20 +186,20 @@ static void hdlcd_crtc_atomic_disable(struct drm_crtc *crtc, + clk_disable_unprepare(hdlcd->clk); + } + +-static int hdlcd_crtc_atomic_check(struct drm_crtc *crtc, +- struct drm_crtc_state *state) ++static enum drm_mode_status hdlcd_crtc_mode_valid(struct drm_crtc *crtc, ++ const struct drm_display_mode *mode) + { + struct hdlcd_drm_private *hdlcd = crtc_to_hdlcd_priv(crtc); +- struct drm_display_mode *mode = &state->adjusted_mode; + long rate, clk_rate = mode->clock * 1000; + + rate = clk_round_rate(hdlcd->clk, clk_rate); +- if (rate != clk_rate) { ++ /* 0.1% seems a close enough tolerance for the TDA19988 on Juno */ ++ if (abs(rate - clk_rate) * 1000 > clk_rate) { + /* clock required by mode not supported by hardware */ +- return -EINVAL; ++ return MODE_NOCLOCK; + } + +- return 0; ++ return MODE_OK; + } + + static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc, +@@ -220,7 +220,7 @@ static void hdlcd_crtc_atomic_begin(struct drm_crtc *crtc, + } + + static const struct drm_crtc_helper_funcs hdlcd_crtc_helper_funcs = { +- .atomic_check = hdlcd_crtc_atomic_check, ++ .mode_valid = hdlcd_crtc_mode_valid, + .atomic_begin = hdlcd_crtc_atomic_begin, + .atomic_enable = hdlcd_crtc_atomic_enable, + .atomic_disable = hdlcd_crtc_atomic_disable, +diff --git a/drivers/gpu/drm/arm/malidp_drv.c b/drivers/gpu/drm/arm/malidp_drv.c +index 94d6dabec2dc..1ab511e33243 100644 +--- a/drivers/gpu/drm/arm/malidp_drv.c ++++ b/drivers/gpu/drm/arm/malidp_drv.c +@@ -190,6 +190,7 @@ static void malidp_atomic_commit_hw_done(struct drm_atomic_state *state) + { + struct drm_device *drm = state->dev; + struct malidp_drm *malidp = drm->dev_private; ++ int loop = 5; + + malidp->event = malidp->crtc.state->event; + malidp->crtc.state->event = NULL; +@@ -204,8 +205,18 @@ static void malidp_atomic_commit_hw_done(struct drm_atomic_state *state) + drm_crtc_vblank_get(&malidp->crtc); + + /* only set config_valid if the CRTC is enabled */ +- if (malidp_set_and_wait_config_valid(drm) < 0) ++ if (malidp_set_and_wait_config_valid(drm) < 0) { ++ /* ++ * make a loop around the second CVAL setting and ++ * try 5 times before giving up. ++ */ ++ while (loop--) { ++ if (!malidp_set_and_wait_config_valid(drm)) ++ break; ++ } + DRM_DEBUG_DRIVER("timed out waiting for updated configuration\n"); ++ } ++ + } else if (malidp->event) { + /* CRTC inactive means vblank IRQ is disabled, send event directly */ + spin_lock_irq(&drm->event_lock); +diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +index 8b9270f31409..e4e09d47c5c0 100644 +--- a/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c ++++ b/drivers/gpu/drm/vmwgfx/vmwgfx_msg.c +@@ -136,6 +136,114 @@ static int vmw_close_channel(struct rpc_channel *channel) + return 0; + } + ++/** ++ * vmw_port_hb_out - Send the message payload either through the ++ * high-bandwidth port if available, or through the backdoor otherwise. ++ * @channel: The rpc channel. ++ * @msg: NULL-terminated message. ++ * @hb: Whether the high-bandwidth port is available. ++ * ++ * Return: The port status. ++ */ ++static unsigned long vmw_port_hb_out(struct rpc_channel *channel, ++ const char *msg, bool hb) ++{ ++ unsigned long si, di, eax, ebx, ecx, edx; ++ unsigned long msg_len = strlen(msg); ++ ++ if (hb) { ++ unsigned long bp = channel->cookie_high; ++ ++ si = (uintptr_t) msg; ++ di = channel->cookie_low; ++ ++ VMW_PORT_HB_OUT( ++ (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, ++ msg_len, si, di, ++ VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), ++ VMW_HYPERVISOR_MAGIC, bp, ++ eax, ebx, ecx, edx, si, di); ++ ++ return ebx; ++ } ++ ++ /* HB port not available. Send the message 4 bytes at a time. */ ++ ecx = MESSAGE_STATUS_SUCCESS << 16; ++ while (msg_len && (HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS)) { ++ unsigned int bytes = min_t(size_t, msg_len, 4); ++ unsigned long word = 0; ++ ++ memcpy(&word, msg, bytes); ++ msg_len -= bytes; ++ msg += bytes; ++ si = channel->cookie_high; ++ di = channel->cookie_low; ++ ++ VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_SENDPAYLOAD << 16), ++ word, si, di, ++ VMW_HYPERVISOR_PORT | (channel->channel_id << 16), ++ VMW_HYPERVISOR_MAGIC, ++ eax, ebx, ecx, edx, si, di); ++ } ++ ++ return ecx; ++} ++ ++/** ++ * vmw_port_hb_in - Receive the message payload either through the ++ * high-bandwidth port if available, or through the backdoor otherwise. ++ * @channel: The rpc channel. ++ * @reply: Pointer to buffer holding reply. ++ * @reply_len: Length of the reply. ++ * @hb: Whether the high-bandwidth port is available. ++ * ++ * Return: The port status. ++ */ ++static unsigned long vmw_port_hb_in(struct rpc_channel *channel, char *reply, ++ unsigned long reply_len, bool hb) ++{ ++ unsigned long si, di, eax, ebx, ecx, edx; ++ ++ if (hb) { ++ unsigned long bp = channel->cookie_low; ++ ++ si = channel->cookie_high; ++ di = (uintptr_t) reply; ++ ++ VMW_PORT_HB_IN( ++ (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, ++ reply_len, si, di, ++ VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), ++ VMW_HYPERVISOR_MAGIC, bp, ++ eax, ebx, ecx, edx, si, di); ++ ++ return ebx; ++ } ++ ++ /* HB port not available. Retrieve the message 4 bytes at a time. */ ++ ecx = MESSAGE_STATUS_SUCCESS << 16; ++ while (reply_len) { ++ unsigned int bytes = min_t(unsigned long, reply_len, 4); ++ ++ si = channel->cookie_high; ++ di = channel->cookie_low; ++ ++ VMW_PORT(VMW_PORT_CMD_MSG | (MSG_TYPE_RECVPAYLOAD << 16), ++ MESSAGE_STATUS_SUCCESS, si, di, ++ VMW_HYPERVISOR_PORT | (channel->channel_id << 16), ++ VMW_HYPERVISOR_MAGIC, ++ eax, ebx, ecx, edx, si, di); ++ ++ if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) ++ break; ++ ++ memcpy(reply, &ebx, bytes); ++ reply_len -= bytes; ++ reply += bytes; ++ } ++ ++ return ecx; ++} + + + /** +@@ -148,11 +256,10 @@ static int vmw_close_channel(struct rpc_channel *channel) + */ + static int vmw_send_msg(struct rpc_channel *channel, const char *msg) + { +- unsigned long eax, ebx, ecx, edx, si, di, bp; ++ unsigned long eax, ebx, ecx, edx, si, di; + size_t msg_len = strlen(msg); + int retries = 0; + +- + while (retries < RETRIES) { + retries++; + +@@ -166,23 +273,14 @@ static int vmw_send_msg(struct rpc_channel *channel, const char *msg) + VMW_HYPERVISOR_MAGIC, + eax, ebx, ecx, edx, si, di); + +- if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0 || +- (HIGH_WORD(ecx) & MESSAGE_STATUS_HB) == 0) { +- /* Expected success + high-bandwidth. Give up. */ ++ if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { ++ /* Expected success. Give up. */ + return -EINVAL; + } + + /* Send msg */ +- si = (uintptr_t) msg; +- di = channel->cookie_low; +- bp = channel->cookie_high; +- +- VMW_PORT_HB_OUT( +- (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, +- msg_len, si, di, +- VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), +- VMW_HYPERVISOR_MAGIC, bp, +- eax, ebx, ecx, edx, si, di); ++ ebx = vmw_port_hb_out(channel, msg, ++ !!(HIGH_WORD(ecx) & MESSAGE_STATUS_HB)); + + if ((HIGH_WORD(ebx) & MESSAGE_STATUS_SUCCESS) != 0) { + return 0; +@@ -211,7 +309,7 @@ STACK_FRAME_NON_STANDARD(vmw_send_msg); + static int vmw_recv_msg(struct rpc_channel *channel, void **msg, + size_t *msg_len) + { +- unsigned long eax, ebx, ecx, edx, si, di, bp; ++ unsigned long eax, ebx, ecx, edx, si, di; + char *reply; + size_t reply_len; + int retries = 0; +@@ -233,8 +331,7 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, + VMW_HYPERVISOR_MAGIC, + eax, ebx, ecx, edx, si, di); + +- if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0 || +- (HIGH_WORD(ecx) & MESSAGE_STATUS_HB) == 0) { ++ if ((HIGH_WORD(ecx) & MESSAGE_STATUS_SUCCESS) == 0) { + DRM_ERROR("Failed to get reply size for host message.\n"); + return -EINVAL; + } +@@ -252,17 +349,8 @@ static int vmw_recv_msg(struct rpc_channel *channel, void **msg, + + + /* Receive buffer */ +- si = channel->cookie_high; +- di = (uintptr_t) reply; +- bp = channel->cookie_low; +- +- VMW_PORT_HB_IN( +- (MESSAGE_STATUS_SUCCESS << 16) | VMW_PORT_CMD_HB_MSG, +- reply_len, si, di, +- VMW_HYPERVISOR_HB_PORT | (channel->channel_id << 16), +- VMW_HYPERVISOR_MAGIC, bp, +- eax, ebx, ecx, edx, si, di); +- ++ ebx = vmw_port_hb_in(channel, reply, reply_len, ++ !!(HIGH_WORD(ecx) & MESSAGE_STATUS_HB)); + if ((HIGH_WORD(ebx) & MESSAGE_STATUS_SUCCESS) == 0) { + kfree(reply); + +diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c +index fcdbac4a56e3..6b3559f58b67 100644 +--- a/drivers/hwmon/hwmon.c ++++ b/drivers/hwmon/hwmon.c +@@ -619,7 +619,7 @@ __hwmon_device_register(struct device *dev, const char *name, void *drvdata, + if (err) + goto free_hwmon; + +- if (dev && chip && chip->ops->read && ++ if (dev && dev->of_node && chip && chip->ops->read && + chip->info[0]->type == hwmon_chip && + (chip->info[0]->config[0] & HWMON_C_REGISTER_TZ)) { + const struct hwmon_channel_info **info = chip->info; +diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c +index 2e2b5851139c..cd24b375df1e 100644 +--- a/drivers/hwmon/pmbus/pmbus_core.c ++++ b/drivers/hwmon/pmbus/pmbus_core.c +@@ -1230,7 +1230,8 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, + const struct pmbus_driver_info *info, + const char *name, + int index, int page, +- const struct pmbus_sensor_attr *attr) ++ const struct pmbus_sensor_attr *attr, ++ bool paged) + { + struct pmbus_sensor *base; + bool upper = !!(attr->gbit & 0xff00); /* need to check STATUS_WORD */ +@@ -1238,7 +1239,7 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, + + if (attr->label) { + ret = pmbus_add_label(data, name, index, attr->label, +- attr->paged ? page + 1 : 0); ++ paged ? page + 1 : 0); + if (ret) + return ret; + } +@@ -1271,6 +1272,30 @@ static int pmbus_add_sensor_attrs_one(struct i2c_client *client, + return 0; + } + ++static bool pmbus_sensor_is_paged(const struct pmbus_driver_info *info, ++ const struct pmbus_sensor_attr *attr) ++{ ++ int p; ++ ++ if (attr->paged) ++ return true; ++ ++ /* ++ * Some attributes may be present on more than one page despite ++ * not being marked with the paged attribute. If that is the case, ++ * then treat the sensor as being paged and add the page suffix to the ++ * attribute name. ++ * We don't just add the paged attribute to all such attributes, in ++ * order to maintain the un-suffixed labels in the case where the ++ * attribute is only on page 0. ++ */ ++ for (p = 1; p < info->pages; p++) { ++ if (info->func[p] & attr->func) ++ return true; ++ } ++ return false; ++} ++ + static int pmbus_add_sensor_attrs(struct i2c_client *client, + struct pmbus_data *data, + const char *name, +@@ -1284,14 +1309,15 @@ static int pmbus_add_sensor_attrs(struct i2c_client *client, + index = 1; + for (i = 0; i < nattrs; i++) { + int page, pages; ++ bool paged = pmbus_sensor_is_paged(info, attrs); + +- pages = attrs->paged ? info->pages : 1; ++ pages = paged ? info->pages : 1; + for (page = 0; page < pages; page++) { + if (!(info->func[page] & attrs->func)) + continue; + ret = pmbus_add_sensor_attrs_one(client, data, info, + name, index, page, +- attrs); ++ attrs, paged); + if (ret) + return ret; + index++; +diff --git a/drivers/iio/temperature/mlx90632.c b/drivers/iio/temperature/mlx90632.c +index 9851311aa3fd..2d54d9cac61d 100644 +--- a/drivers/iio/temperature/mlx90632.c ++++ b/drivers/iio/temperature/mlx90632.c +@@ -81,6 +81,8 @@ + /* Magic constants */ + #define MLX90632_ID_MEDICAL 0x0105 /* EEPROM DSPv5 Medical device id */ + #define MLX90632_ID_CONSUMER 0x0205 /* EEPROM DSPv5 Consumer device id */ ++#define MLX90632_DSP_VERSION 5 /* DSP version */ ++#define MLX90632_DSP_MASK GENMASK(7, 0) /* DSP version in EE_VERSION */ + #define MLX90632_RESET_CMD 0x0006 /* Reset sensor (address or global) */ + #define MLX90632_REF_12 12LL /**< ResCtrlRef value of Ch 1 or Ch 2 */ + #define MLX90632_REF_3 12LL /**< ResCtrlRef value of Channel 3 */ +@@ -666,10 +668,13 @@ static int mlx90632_probe(struct i2c_client *client, + } else if (read == MLX90632_ID_CONSUMER) { + dev_dbg(&client->dev, + "Detected Consumer EEPROM calibration %x\n", read); ++ } else if ((read & MLX90632_DSP_MASK) == MLX90632_DSP_VERSION) { ++ dev_dbg(&client->dev, ++ "Detected Unknown EEPROM calibration %x\n", read); + } else { + dev_err(&client->dev, +- "EEPROM version mismatch %x (expected %x or %x)\n", +- read, MLX90632_ID_CONSUMER, MLX90632_ID_MEDICAL); ++ "Wrong DSP version %x (expected %x)\n", ++ read, MLX90632_DSP_VERSION); + return -EPROTONOSUPPORT; + } + +diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c +index b12c8ff8ed66..d8eb4dc04d69 100644 +--- a/drivers/infiniband/hw/hfi1/chip.c ++++ b/drivers/infiniband/hw/hfi1/chip.c +@@ -9849,6 +9849,7 @@ void hfi1_quiet_serdes(struct hfi1_pportdata *ppd) + + /* disable the port */ + clear_rcvctrl(dd, RCV_CTRL_RCV_PORT_ENABLE_SMASK); ++ cancel_work_sync(&ppd->freeze_work); + } + + static inline int init_cpu_counters(struct hfi1_devdata *dd) +diff --git a/drivers/infiniband/hw/hfi1/fault.c b/drivers/infiniband/hw/hfi1/fault.c +index e2290f32c8d9..7eaff4dcbfd7 100644 +--- a/drivers/infiniband/hw/hfi1/fault.c ++++ b/drivers/infiniband/hw/hfi1/fault.c +@@ -153,6 +153,7 @@ static ssize_t fault_opcodes_write(struct file *file, const char __user *buf, + char *dash; + unsigned long range_start, range_end, i; + bool remove = false; ++ unsigned long bound = 1U << BITS_PER_BYTE; + + end = strchr(ptr, ','); + if (end) +@@ -178,6 +179,10 @@ static ssize_t fault_opcodes_write(struct file *file, const char __user *buf, + BITS_PER_BYTE); + break; + } ++ /* Check the inputs */ ++ if (range_start >= bound || range_end >= bound) ++ break; ++ + for (i = range_start; i <= range_end; i++) { + if (remove) + clear_bit(i, fault->opcodes); +diff --git a/drivers/infiniband/hw/hfi1/user_exp_rcv.c b/drivers/infiniband/hw/hfi1/user_exp_rcv.c +index dbe7d14a5c76..4e986ca4dd35 100644 +--- a/drivers/infiniband/hw/hfi1/user_exp_rcv.c ++++ b/drivers/infiniband/hw/hfi1/user_exp_rcv.c +@@ -324,6 +324,9 @@ int hfi1_user_exp_rcv_setup(struct hfi1_filedata *fd, + u32 *tidlist = NULL; + struct tid_user_buf *tidbuf; + ++ if (!PAGE_ALIGNED(tinfo->vaddr)) ++ return -EINVAL; ++ + tidbuf = kzalloc(sizeof(*tidbuf), GFP_KERNEL); + if (!tidbuf) + return -ENOMEM; +diff --git a/drivers/infiniband/hw/hfi1/verbs.c b/drivers/infiniband/hw/hfi1/verbs.c +index 48692adbe811..27d9c4cefdc7 100644 +--- a/drivers/infiniband/hw/hfi1/verbs.c ++++ b/drivers/infiniband/hw/hfi1/verbs.c +@@ -1418,8 +1418,6 @@ static void hfi1_fill_device_attr(struct hfi1_devdata *dd) + rdi->dparms.props.max_cq = hfi1_max_cqs; + rdi->dparms.props.max_ah = hfi1_max_ahs; + rdi->dparms.props.max_cqe = hfi1_max_cqes; +- rdi->dparms.props.max_mr = rdi->lkey_table.max; +- rdi->dparms.props.max_fmr = rdi->lkey_table.max; + rdi->dparms.props.max_map_per_fmr = 32767; + rdi->dparms.props.max_pd = hfi1_max_pds; + rdi->dparms.props.max_qp_rd_atom = HFI1_MAX_RDMA_ATOMIC; +diff --git a/drivers/infiniband/hw/hfi1/verbs_txreq.c b/drivers/infiniband/hw/hfi1/verbs_txreq.c +index c4ab2d5b4502..8f766dd3f61c 100644 +--- a/drivers/infiniband/hw/hfi1/verbs_txreq.c ++++ b/drivers/infiniband/hw/hfi1/verbs_txreq.c +@@ -100,7 +100,7 @@ struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev, + if (ib_rvt_state_ops[qp->state] & RVT_PROCESS_RECV_OK) { + struct hfi1_qp_priv *priv; + +- tx = kmem_cache_alloc(dev->verbs_txreq_cache, GFP_ATOMIC); ++ tx = kmem_cache_alloc(dev->verbs_txreq_cache, VERBS_TXREQ_GFP); + if (tx) + goto out; + priv = qp->priv; +diff --git a/drivers/infiniband/hw/hfi1/verbs_txreq.h b/drivers/infiniband/hw/hfi1/verbs_txreq.h +index 1c19bbc764b2..b1a78985b4ec 100644 +--- a/drivers/infiniband/hw/hfi1/verbs_txreq.h ++++ b/drivers/infiniband/hw/hfi1/verbs_txreq.h +@@ -72,6 +72,7 @@ struct hfi1_ibdev; + struct verbs_txreq *__get_txreq(struct hfi1_ibdev *dev, + struct rvt_qp *qp); + ++#define VERBS_TXREQ_GFP (GFP_ATOMIC | __GFP_NOWARN) + static inline struct verbs_txreq *get_txreq(struct hfi1_ibdev *dev, + struct rvt_qp *qp) + __must_hold(&qp->slock) +@@ -79,7 +80,7 @@ static inline struct verbs_txreq *get_txreq(struct hfi1_ibdev *dev, + struct verbs_txreq *tx; + struct hfi1_qp_priv *priv = qp->priv; + +- tx = kmem_cache_alloc(dev->verbs_txreq_cache, GFP_ATOMIC); ++ tx = kmem_cache_alloc(dev->verbs_txreq_cache, VERBS_TXREQ_GFP); + if (unlikely(!tx)) { + /* call slow path to get the lock */ + tx = __get_txreq(dev, qp); +diff --git a/drivers/infiniband/hw/qib/qib_verbs.c b/drivers/infiniband/hw/qib/qib_verbs.c +index 41babbc0db58..803c3544c75b 100644 +--- a/drivers/infiniband/hw/qib/qib_verbs.c ++++ b/drivers/infiniband/hw/qib/qib_verbs.c +@@ -1495,8 +1495,6 @@ static void qib_fill_device_attr(struct qib_devdata *dd) + rdi->dparms.props.max_cq = ib_qib_max_cqs; + rdi->dparms.props.max_cqe = ib_qib_max_cqes; + rdi->dparms.props.max_ah = ib_qib_max_ahs; +- rdi->dparms.props.max_mr = rdi->lkey_table.max; +- rdi->dparms.props.max_fmr = rdi->lkey_table.max; + rdi->dparms.props.max_map_per_fmr = 32767; + rdi->dparms.props.max_qp_rd_atom = QIB_MAX_RDMA_ATOMIC; + rdi->dparms.props.max_qp_init_rd_atom = 255; +diff --git a/drivers/infiniband/sw/rdmavt/mr.c b/drivers/infiniband/sw/rdmavt/mr.c +index 5819c9d6ffdc..39d101df229d 100644 +--- a/drivers/infiniband/sw/rdmavt/mr.c ++++ b/drivers/infiniband/sw/rdmavt/mr.c +@@ -96,6 +96,8 @@ int rvt_driver_mr_init(struct rvt_dev_info *rdi) + for (i = 0; i < rdi->lkey_table.max; i++) + RCU_INIT_POINTER(rdi->lkey_table.table[i], NULL); + ++ rdi->dparms.props.max_mr = rdi->lkey_table.max; ++ rdi->dparms.props.max_fmr = rdi->lkey_table.max; + return 0; + } + +diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c +index 5ce403c6cddb..7d03680afd91 100644 +--- a/drivers/infiniband/sw/rdmavt/qp.c ++++ b/drivers/infiniband/sw/rdmavt/qp.c +@@ -412,7 +412,8 @@ static int alloc_qpn(struct rvt_dev_info *rdi, struct rvt_qpn_table *qpt, + offset = qpt->incr | ((offset & 1) ^ 1); + } + /* there can be no set bits in low-order QoS bits */ +- WARN_ON(offset & (BIT(rdi->dparms.qos_shift) - 1)); ++ WARN_ON(rdi->dparms.qos_shift > 1 && ++ offset & ((BIT(rdi->dparms.qos_shift - 1) - 1) << 1)); + qpn = mk_qpn(qpt, map, offset); + } + +diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c +index 26ec603fe220..83d1499fe021 100644 +--- a/drivers/input/misc/uinput.c ++++ b/drivers/input/misc/uinput.c +@@ -1051,13 +1051,31 @@ static long uinput_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + + #ifdef CONFIG_COMPAT + +-#define UI_SET_PHYS_COMPAT _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t) ++/* ++ * These IOCTLs change their size and thus their numbers between ++ * 32 and 64 bits. ++ */ ++#define UI_SET_PHYS_COMPAT \ ++ _IOW(UINPUT_IOCTL_BASE, 108, compat_uptr_t) ++#define UI_BEGIN_FF_UPLOAD_COMPAT \ ++ _IOWR(UINPUT_IOCTL_BASE, 200, struct uinput_ff_upload_compat) ++#define UI_END_FF_UPLOAD_COMPAT \ ++ _IOW(UINPUT_IOCTL_BASE, 201, struct uinput_ff_upload_compat) + + static long uinput_compat_ioctl(struct file *file, + unsigned int cmd, unsigned long arg) + { +- if (cmd == UI_SET_PHYS_COMPAT) ++ switch (cmd) { ++ case UI_SET_PHYS_COMPAT: + cmd = UI_SET_PHYS; ++ break; ++ case UI_BEGIN_FF_UPLOAD_COMPAT: ++ cmd = UI_BEGIN_FF_UPLOAD; ++ break; ++ case UI_END_FF_UPLOAD_COMPAT: ++ cmd = UI_END_FF_UPLOAD; ++ break; ++ } + + return uinput_ioctl_handler(file, cmd, arg, compat_ptr(arg)); + } +diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c +index b6da0c1267e3..8e6077d8e434 100644 +--- a/drivers/input/mouse/synaptics.c ++++ b/drivers/input/mouse/synaptics.c +@@ -179,6 +179,8 @@ static const char * const smbus_pnp_ids[] = { + "LEN0096", /* X280 */ + "LEN0097", /* X280 -> ALPS trackpoint */ + "LEN200f", /* T450s */ ++ "LEN2054", /* E480 */ ++ "LEN2055", /* E580 */ + "SYN3052", /* HP EliteBook 840 G4 */ + "SYN3221", /* HP 15-ay000 */ + NULL +diff --git a/drivers/input/touchscreen/silead.c b/drivers/input/touchscreen/silead.c +index d196ac3d8b8c..e5c3b066bd2a 100644 +--- a/drivers/input/touchscreen/silead.c ++++ b/drivers/input/touchscreen/silead.c +@@ -604,6 +604,7 @@ static const struct acpi_device_id silead_ts_acpi_match[] = { + { "MSSL1680", 0 }, + { "MSSL0001", 0 }, + { "MSSL0002", 0 }, ++ { "MSSL0017", 0 }, + { } + }; + MODULE_DEVICE_TABLE(acpi, silead_ts_acpi_match); +diff --git a/drivers/mmc/core/core.c b/drivers/mmc/core/core.c +index 6600b3466dfb..0a74785e575b 100644 +--- a/drivers/mmc/core/core.c ++++ b/drivers/mmc/core/core.c +@@ -144,8 +144,9 @@ void mmc_request_done(struct mmc_host *host, struct mmc_request *mrq) + int err = cmd->error; + + /* Flag re-tuning needed on CRC errors */ +- if ((cmd->opcode != MMC_SEND_TUNING_BLOCK && +- cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200) && ++ if (cmd->opcode != MMC_SEND_TUNING_BLOCK && ++ cmd->opcode != MMC_SEND_TUNING_BLOCK_HS200 && ++ !host->retune_crc_disable && + (err == -EILSEQ || (mrq->sbc && mrq->sbc->error == -EILSEQ) || + (mrq->data && mrq->data->error == -EILSEQ) || + (mrq->stop && mrq->stop->error == -EILSEQ))) +diff --git a/drivers/mmc/core/sdio.c b/drivers/mmc/core/sdio.c +index d8e17ea6126d..0aa99694b937 100644 +--- a/drivers/mmc/core/sdio.c ++++ b/drivers/mmc/core/sdio.c +@@ -934,6 +934,10 @@ static int mmc_sdio_pre_suspend(struct mmc_host *host) + */ + static int mmc_sdio_suspend(struct mmc_host *host) + { ++ /* Prevent processing of SDIO IRQs in suspended state. */ ++ mmc_card_set_suspended(host->card); ++ cancel_delayed_work_sync(&host->sdio_irq_work); ++ + mmc_claim_host(host); + + if (mmc_card_keep_power(host) && mmc_card_wake_sdio_irq(host)) +@@ -982,13 +986,20 @@ static int mmc_sdio_resume(struct mmc_host *host) + err = sdio_enable_4bit_bus(host->card); + } + +- if (!err && host->sdio_irqs) { ++ if (err) ++ goto out; ++ ++ /* Allow SDIO IRQs to be processed again. */ ++ mmc_card_clr_suspended(host->card); ++ ++ if (host->sdio_irqs) { + if (!(host->caps2 & MMC_CAP2_SDIO_IRQ_NOTHREAD)) + wake_up_process(host->sdio_irq_thread); + else if (host->caps & MMC_CAP_SDIO_IRQ) + host->ops->enable_sdio_irq(host, 1); + } + ++out: + mmc_release_host(host); + + host->pm_flags &= ~MMC_PM_KEEP_POWER; +diff --git a/drivers/mmc/core/sdio_io.c b/drivers/mmc/core/sdio_io.c +index d40744bbafa9..ed2d8c48ea17 100644 +--- a/drivers/mmc/core/sdio_io.c ++++ b/drivers/mmc/core/sdio_io.c +@@ -18,6 +18,7 @@ + #include "sdio_ops.h" + #include "core.h" + #include "card.h" ++#include "host.h" + + /** + * sdio_claim_host - exclusively claim a bus for a certain SDIO function +@@ -725,3 +726,79 @@ int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags) + return 0; + } + EXPORT_SYMBOL_GPL(sdio_set_host_pm_flags); ++ ++/** ++ * sdio_retune_crc_disable - temporarily disable retuning on CRC errors ++ * @func: SDIO function attached to host ++ * ++ * If the SDIO card is known to be in a state where it might produce ++ * CRC errors on the bus in response to commands (like if we know it is ++ * transitioning between power states), an SDIO function driver can ++ * call this function to temporarily disable the SD/MMC core behavior of ++ * triggering an automatic retuning. ++ * ++ * This function should be called while the host is claimed and the host ++ * should remain claimed until sdio_retune_crc_enable() is called. ++ * Specifically, the expected sequence of calls is: ++ * - sdio_claim_host() ++ * - sdio_retune_crc_disable() ++ * - some number of calls like sdio_writeb() and sdio_readb() ++ * - sdio_retune_crc_enable() ++ * - sdio_release_host() ++ */ ++void sdio_retune_crc_disable(struct sdio_func *func) ++{ ++ func->card->host->retune_crc_disable = true; ++} ++EXPORT_SYMBOL_GPL(sdio_retune_crc_disable); ++ ++/** ++ * sdio_retune_crc_enable - re-enable retuning on CRC errors ++ * @func: SDIO function attached to host ++ * ++ * This is the compement to sdio_retune_crc_disable(). ++ */ ++void sdio_retune_crc_enable(struct sdio_func *func) ++{ ++ func->card->host->retune_crc_disable = false; ++} ++EXPORT_SYMBOL_GPL(sdio_retune_crc_enable); ++ ++/** ++ * sdio_retune_hold_now - start deferring retuning requests till release ++ * @func: SDIO function attached to host ++ * ++ * This function can be called if it's currently a bad time to do ++ * a retune of the SDIO card. Retune requests made during this time ++ * will be held and we'll actually do the retune sometime after the ++ * release. ++ * ++ * This function could be useful if an SDIO card is in a power state ++ * where it can respond to a small subset of commands that doesn't ++ * include the retuning command. Care should be taken when using ++ * this function since (presumably) the retuning request we might be ++ * deferring was made for a good reason. ++ * ++ * This function should be called while the host is claimed. ++ */ ++void sdio_retune_hold_now(struct sdio_func *func) ++{ ++ mmc_retune_hold_now(func->card->host); ++} ++EXPORT_SYMBOL_GPL(sdio_retune_hold_now); ++ ++/** ++ * sdio_retune_release - signal that it's OK to retune now ++ * @func: SDIO function attached to host ++ * ++ * This is the complement to sdio_retune_hold_now(). Calling this ++ * function won't make a retune happen right away but will allow ++ * them to be scheduled normally. ++ * ++ * This function should be called while the host is claimed. ++ */ ++void sdio_retune_release(struct sdio_func *func) ++{ ++ mmc_retune_release(func->card->host); ++} ++EXPORT_SYMBOL_GPL(sdio_retune_release); +diff --git a/drivers/mmc/core/sdio_irq.c b/drivers/mmc/core/sdio_irq.c +index 7ca7b99413f0..b299a24d33f9 100644 +--- a/drivers/mmc/core/sdio_irq.c ++++ b/drivers/mmc/core/sdio_irq.c +@@ -38,6 +38,10 @@ static int process_sdio_pending_irqs(struct mmc_host *host) + unsigned char pending; + struct sdio_func *func; + ++ /* Don't process SDIO IRQs if the card is suspended. */ ++ if (mmc_card_suspended(card)) ++ return 0; ++ + /* + * Optimization, if there is only 1 function interrupt registered + * and we know an IRQ was signaled then call irq handler directly. +diff --git a/drivers/mmc/host/sdhci-pci-o2micro.c b/drivers/mmc/host/sdhci-pci-o2micro.c +index cc3ffeffd7a2..fa8d9da2ab7f 100644 +--- a/drivers/mmc/host/sdhci-pci-o2micro.c ++++ b/drivers/mmc/host/sdhci-pci-o2micro.c +@@ -117,6 +117,7 @@ static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode) + */ + if (mmc->ios.bus_width == MMC_BUS_WIDTH_8) { + current_bus_width = mmc->ios.bus_width; ++ mmc->ios.bus_width = MMC_BUS_WIDTH_4; + sdhci_set_bus_width(host, MMC_BUS_WIDTH_4); + } + +@@ -128,8 +129,10 @@ static int sdhci_o2_execute_tuning(struct mmc_host *mmc, u32 opcode) + + sdhci_end_tuning(host); + +- if (current_bus_width == MMC_BUS_WIDTH_8) ++ if (current_bus_width == MMC_BUS_WIDTH_8) { ++ mmc->ios.bus_width = MMC_BUS_WIDTH_8; + sdhci_set_bus_width(host, current_bus_width); ++ } + + host->flags &= ~SDHCI_HS400_TUNING; + return 0; +diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c +index 2646faffd36e..6f265d2e647b 100644 +--- a/drivers/net/can/flexcan.c ++++ b/drivers/net/can/flexcan.c +@@ -165,7 +165,7 @@ + #define FLEXCAN_MB_CNT_LENGTH(x) (((x) & 0xf) << 16) + #define FLEXCAN_MB_CNT_TIMESTAMP(x) ((x) & 0xffff) + +-#define FLEXCAN_TIMEOUT_US (50) ++#define FLEXCAN_TIMEOUT_US (250) + + /* FLEXCAN hardware feature flags + * +diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c +index 045f0845e665..3df23487487f 100644 +--- a/drivers/net/can/xilinx_can.c ++++ b/drivers/net/can/xilinx_can.c +@@ -1424,7 +1424,7 @@ static const struct xcan_devtype_data xcan_canfd_data = { + XCAN_FLAG_RXMNF | + XCAN_FLAG_TX_MAILBOXES | + XCAN_FLAG_RX_FIFO_MULTI, +- .bittiming_const = &xcan_bittiming_const, ++ .bittiming_const = &xcan_bittiming_const_canfd, + .btr_ts2_shift = XCAN_BTR_TS2_SHIFT_CANFD, + .btr_sjw_shift = XCAN_BTR_SJW_SHIFT_CANFD, + .bus_clk_name = "s_axi_aclk", +diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c +index dfaad1c2c2b8..411cfb806459 100644 +--- a/drivers/net/dsa/mv88e6xxx/chip.c ++++ b/drivers/net/dsa/mv88e6xxx/chip.c +@@ -1484,7 +1484,7 @@ static int mv88e6xxx_vtu_get(struct mv88e6xxx_chip *chip, u16 vid, + int err; + + if (!vid) +- return -EINVAL; ++ return -EOPNOTSUPP; + + entry->vid = vid - 1; + entry->valid = false; +diff --git a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +index e2710ff48fb0..1fa0cd527ead 100644 +--- a/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c ++++ b/drivers/net/ethernet/hisilicon/hns/hns_ethtool.c +@@ -339,6 +339,7 @@ static int __lb_setup(struct net_device *ndev, + static int __lb_up(struct net_device *ndev, + enum hnae_loop loop_mode) + { ++#define NIC_LB_TEST_WAIT_PHY_LINK_TIME 300 + struct hns_nic_priv *priv = netdev_priv(ndev); + struct hnae_handle *h = priv->ae_handle; + int speed, duplex; +@@ -365,6 +366,9 @@ static int __lb_up(struct net_device *ndev, + + h->dev->ops->adjust_link(h, speed, duplex); + ++ /* wait adjust link done and phy ready */ ++ msleep(NIC_LB_TEST_WAIT_PHY_LINK_TIME); ++ + return 0; + } + +diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +index 6e6abdc399de..1d55f014725e 100644 +--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c ++++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c +@@ -1784,6 +1784,7 @@ static void mtk_poll_controller(struct net_device *dev) + + static int mtk_start_dma(struct mtk_eth *eth) + { ++ u32 rx_2b_offset = (NET_IP_ALIGN == 2) ? MTK_RX_2B_OFFSET : 0; + int err; + + err = mtk_dma_init(eth); +@@ -1800,7 +1801,7 @@ static int mtk_start_dma(struct mtk_eth *eth) + MTK_QDMA_GLO_CFG); + + mtk_w32(eth, +- MTK_RX_DMA_EN | MTK_RX_2B_OFFSET | ++ MTK_RX_DMA_EN | rx_2b_offset | + MTK_RX_BT_32DWORDS | MTK_MULTI_EN, + MTK_PDMA_GLO_CFG); + +@@ -2304,13 +2305,13 @@ static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, + + switch (cmd->cmd) { + case ETHTOOL_GRXRINGS: +- if (dev->features & NETIF_F_LRO) { ++ if (dev->hw_features & NETIF_F_LRO) { + cmd->data = MTK_MAX_RX_RING_NUM; + ret = 0; + } + break; + case ETHTOOL_GRXCLSRLCNT: +- if (dev->features & NETIF_F_LRO) { ++ if (dev->hw_features & NETIF_F_LRO) { + struct mtk_mac *mac = netdev_priv(dev); + + cmd->rule_cnt = mac->hwlro_ip_cnt; +@@ -2318,11 +2319,11 @@ static int mtk_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd, + } + break; + case ETHTOOL_GRXCLSRULE: +- if (dev->features & NETIF_F_LRO) ++ if (dev->hw_features & NETIF_F_LRO) + ret = mtk_hwlro_get_fdir_entry(dev, cmd); + break; + case ETHTOOL_GRXCLSRLALL: +- if (dev->features & NETIF_F_LRO) ++ if (dev->hw_features & NETIF_F_LRO) + ret = mtk_hwlro_get_fdir_all(dev, cmd, + rule_locs); + break; +@@ -2339,11 +2340,11 @@ static int mtk_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd) + + switch (cmd->cmd) { + case ETHTOOL_SRXCLSRLINS: +- if (dev->features & NETIF_F_LRO) ++ if (dev->hw_features & NETIF_F_LRO) + ret = mtk_hwlro_add_ipaddr(dev, cmd); + break; + case ETHTOOL_SRXCLSRLDEL: +- if (dev->features & NETIF_F_LRO) ++ if (dev->hw_features & NETIF_F_LRO) + ret = mtk_hwlro_del_ipaddr(dev, cmd); + break; + default: +diff --git a/drivers/net/ipvlan/ipvlan_main.c b/drivers/net/ipvlan/ipvlan_main.c +index 68b8007da82b..0115a2868933 100644 +--- a/drivers/net/ipvlan/ipvlan_main.c ++++ b/drivers/net/ipvlan/ipvlan_main.c +@@ -178,7 +178,7 @@ static void ipvlan_port_destroy(struct net_device *dev) + } + + #define IPVLAN_FEATURES \ +- (NETIF_F_SG | NETIF_F_HW_CSUM | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \ ++ (NETIF_F_SG | NETIF_F_CSUM_MASK | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST | \ + NETIF_F_GSO | NETIF_F_TSO | NETIF_F_GSO_ROBUST | \ + NETIF_F_TSO_ECN | NETIF_F_TSO6 | NETIF_F_GRO | NETIF_F_RXCSUM | \ + NETIF_F_HW_VLAN_CTAG_FILTER | NETIF_F_HW_VLAN_STAG_FILTER) +diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +index a907d7b065fa..53e4962ceb8a 100644 +--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c ++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c +@@ -667,6 +667,12 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) + + brcmf_dbg(TRACE, "Enter: on=%d\n", on); + ++ sdio_retune_crc_disable(bus->sdiodev->func1); ++ ++ /* Cannot re-tune if device is asleep; defer till we're awake */ ++ if (on) ++ sdio_retune_hold_now(bus->sdiodev->func1); ++ + wr_val = (on << SBSDIO_FUNC1_SLEEPCSR_KSO_SHIFT); + /* 1st KSO write goes to AOS wake up core if device is asleep */ + brcmf_sdiod_writeb(bus->sdiodev, SBSDIO_FUNC1_SLEEPCSR, wr_val, &err); +@@ -719,6 +725,11 @@ brcmf_sdio_kso_control(struct brcmf_sdio *bus, bool on) + if (try_cnt > MAX_KSO_ATTEMPTS) + brcmf_err("max tries: rd_val=0x%x err=%d\n", rd_val, err); + ++ if (on) ++ sdio_retune_release(bus->sdiodev->func1); ++ ++ sdio_retune_crc_enable(bus->sdiodev->func1); ++ + return err; + } + +diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c +index a867a139bb35..d8869d978c34 100644 +--- a/drivers/nvme/host/core.c ++++ b/drivers/nvme/host/core.c +@@ -3228,7 +3228,8 @@ static int nvme_scan_ns_list(struct nvme_ctrl *ctrl, unsigned nn) + { + struct nvme_ns *ns; + __le32 *ns_list; +- unsigned i, j, nsid, prev = 0, num_lists = DIV_ROUND_UP(nn, 1024); ++ unsigned i, j, nsid, prev = 0; ++ unsigned num_lists = DIV_ROUND_UP_ULL((u64)nn, 1024); + int ret = 0; + + ns_list = kzalloc(NVME_IDENTIFY_DATA_SIZE, GFP_KERNEL); +diff --git a/drivers/nvme/target/io-cmd-bdev.c b/drivers/nvme/target/io-cmd-bdev.c +index 7bc9f6240432..1096dd01ca22 100644 +--- a/drivers/nvme/target/io-cmd-bdev.c ++++ b/drivers/nvme/target/io-cmd-bdev.c +@@ -239,6 +239,7 @@ u16 nvmet_bdev_parse_io_cmd(struct nvmet_req *req) + return 0; + case nvme_cmd_write_zeroes: + req->execute = nvmet_bdev_execute_write_zeroes; ++ req->data_len = 0; + return 0; + default: + pr_err("unhandled cmd %d on qid %d\n", cmd->common.opcode, +diff --git a/drivers/parport/share.c b/drivers/parport/share.c +index 5dc53d420ca8..7b4ee33c1935 100644 +--- a/drivers/parport/share.c ++++ b/drivers/parport/share.c +@@ -895,6 +895,7 @@ parport_register_dev_model(struct parport *port, const char *name, + par_dev->devmodel = true; + ret = device_register(&par_dev->dev); + if (ret) { ++ kfree(par_dev->state); + put_device(&par_dev->dev); + goto err_put_port; + } +@@ -912,6 +913,7 @@ parport_register_dev_model(struct parport *port, const char *name, + spin_unlock(&port->physport->pardevice_lock); + pr_debug("%s: cannot grant exclusive access for device %s\n", + port->name, name); ++ kfree(par_dev->state); + device_unregister(&par_dev->dev); + goto err_put_port; + } +diff --git a/drivers/s390/net/qeth_l2_main.c b/drivers/s390/net/qeth_l2_main.c +index b7513c5848cf..c1c35eccd5b6 100644 +--- a/drivers/s390/net/qeth_l2_main.c ++++ b/drivers/s390/net/qeth_l2_main.c +@@ -1901,7 +1901,7 @@ static void qeth_bridgeport_an_set_cb(void *priv, + + l2entry = (struct qdio_brinfo_entry_l2 *)entry; + code = IPA_ADDR_CHANGE_CODE_MACADDR; +- if (l2entry->addr_lnid.lnid) ++ if (l2entry->addr_lnid.lnid < VLAN_N_VID) + code |= IPA_ADDR_CHANGE_CODE_VLANID; + qeth_bridge_emit_host_event(card, anev_reg_unreg, code, + (struct net_if_token *)&l2entry->nit, +diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c +index 411d656f2530..98f2d076f938 100644 +--- a/drivers/scsi/smartpqi/smartpqi_init.c ++++ b/drivers/scsi/smartpqi/smartpqi_init.c +@@ -3697,8 +3697,10 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, + return -ETIMEDOUT; + msecs_blocked = + jiffies_to_msecs(jiffies - start_jiffies); +- if (msecs_blocked >= timeout_msecs) +- return -ETIMEDOUT; ++ if (msecs_blocked >= timeout_msecs) { ++ rc = -ETIMEDOUT; ++ goto out; ++ } + timeout_msecs -= msecs_blocked; + } + } +diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c +index 895a9b5ac989..30c22e16b1e3 100644 +--- a/drivers/scsi/ufs/ufshcd-pltfrm.c ++++ b/drivers/scsi/ufs/ufshcd-pltfrm.c +@@ -340,24 +340,21 @@ int ufshcd_pltfrm_init(struct platform_device *pdev, + goto dealloc_host; + } + +- pm_runtime_set_active(&pdev->dev); +- pm_runtime_enable(&pdev->dev); +- + ufshcd_init_lanes_per_dir(hba); + + err = ufshcd_init(hba, mmio_base, irq); + if (err) { + dev_err(dev, "Initialization failed\n"); +- goto out_disable_rpm; ++ goto dealloc_host; + } + + platform_set_drvdata(pdev, hba); + ++ pm_runtime_set_active(&pdev->dev); ++ pm_runtime_enable(&pdev->dev); ++ + return 0; + +-out_disable_rpm: +- pm_runtime_disable(&pdev->dev); +- pm_runtime_set_suspended(&pdev->dev); + dealloc_host: + ufshcd_dealloc_host(hba); + out: +diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c +index 3183fa8c5857..b8b59cfeacd1 100644 +--- a/drivers/scsi/ufs/ufshcd.c ++++ b/drivers/scsi/ufs/ufshcd.c +@@ -1914,7 +1914,8 @@ int ufshcd_copy_query_response(struct ufs_hba *hba, struct ufshcd_lrb *lrbp) + memcpy(&query_res->upiu_res, &lrbp->ucd_rsp_ptr->qr, QUERY_OSF_SIZE); + + /* Get the descriptor */ +- if (lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) { ++ if (hba->dev_cmd.query.descriptor && ++ lrbp->ucd_rsp_ptr->qr.opcode == UPIU_QUERY_OPCODE_READ_DESC) { + u8 *descp = (u8 *)lrbp->ucd_rsp_ptr + + GENERAL_UPIU_REQUEST_SIZE; + u16 resp_len; +diff --git a/drivers/staging/erofs/erofs_fs.h b/drivers/staging/erofs/erofs_fs.h +index 2f8e2bf70941..7677da889f12 100644 +--- a/drivers/staging/erofs/erofs_fs.h ++++ b/drivers/staging/erofs/erofs_fs.h +@@ -17,10 +17,16 @@ + #define EROFS_SUPER_MAGIC_V1 0xE0F5E1E2 + #define EROFS_SUPER_OFFSET 1024 + ++/* ++ * Any bits that aren't in EROFS_ALL_REQUIREMENTS should be ++ * incompatible with this kernel version. ++ */ ++#define EROFS_ALL_REQUIREMENTS 0 ++ + struct erofs_super_block { + /* 0 */__le32 magic; /* in the little endian */ + /* 4 */__le32 checksum; /* crc32c(super_block) */ +-/* 8 */__le32 features; ++/* 8 */__le32 features; /* (aka. feature_compat) */ + /* 12 */__u8 blkszbits; /* support block_size == PAGE_SIZE only */ + /* 13 */__u8 reserved; + +@@ -34,9 +40,10 @@ struct erofs_super_block { + /* 44 */__le32 xattr_blkaddr; + /* 48 */__u8 uuid[16]; /* 128-bit uuid for volume */ + /* 64 */__u8 volume_name[16]; /* volume name */ ++/* 80 */__le32 requirements; /* (aka. feature_incompat) */ + +-/* 80 */__u8 reserved2[48]; /* 128 bytes */ +-} __packed; ++/* 84 */__u8 reserved2[44]; ++} __packed; /* 128 bytes */ + + #define __EROFS_BIT(_prefix, _cur, _pre) enum { \ + _prefix ## _cur ## _BIT = _prefix ## _pre ## _BIT + \ +diff --git a/drivers/staging/erofs/internal.h b/drivers/staging/erofs/internal.h +index 58d8cbc3f921..8ce37091db20 100644 +--- a/drivers/staging/erofs/internal.h ++++ b/drivers/staging/erofs/internal.h +@@ -111,6 +111,8 @@ struct erofs_sb_info { + + u8 uuid[16]; /* 128-bit uuid for volume */ + u8 volume_name[16]; /* volume name */ ++ u32 requirements; ++ + char *dev_name; + + unsigned int mount_opt; +diff --git a/drivers/staging/erofs/super.c b/drivers/staging/erofs/super.c +index b0583cdb079a..b49ebdf6ebda 100644 +--- a/drivers/staging/erofs/super.c ++++ b/drivers/staging/erofs/super.c +@@ -75,6 +75,22 @@ static void destroy_inode(struct inode *inode) + call_rcu(&inode->i_rcu, i_callback); + } + ++static bool check_layout_compatibility(struct super_block *sb, ++ struct erofs_super_block *layout) ++{ ++ const unsigned int requirements = le32_to_cpu(layout->requirements); ++ ++ EROFS_SB(sb)->requirements = requirements; ++ ++ /* check if current kernel meets all mandatory requirements */ ++ if (requirements & (~EROFS_ALL_REQUIREMENTS)) { ++ errln("unidentified requirements %x, please upgrade kernel version", ++ requirements & ~EROFS_ALL_REQUIREMENTS); ++ return false; ++ } ++ return true; ++} ++ + static int superblock_read(struct super_block *sb) + { + struct erofs_sb_info *sbi; +@@ -108,6 +124,9 @@ static int superblock_read(struct super_block *sb) + goto out; + } + ++ if (!check_layout_compatibility(sb, layout)) ++ goto out; ++ + sbi->blocks = le32_to_cpu(layout->blocks); + sbi->meta_blkaddr = le32_to_cpu(layout->meta_blkaddr); + #ifdef CONFIG_EROFS_FS_XATTR +diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c +index 9852ec5e6e01..cc7c856126df 100644 +--- a/drivers/usb/chipidea/udc.c ++++ b/drivers/usb/chipidea/udc.c +@@ -1621,6 +1621,25 @@ static int ci_udc_pullup(struct usb_gadget *_gadget, int is_on) + static int ci_udc_start(struct usb_gadget *gadget, + struct usb_gadget_driver *driver); + static int ci_udc_stop(struct usb_gadget *gadget); ++ ++/* Match ISOC IN from the highest endpoint */ ++static struct usb_ep *ci_udc_match_ep(struct usb_gadget *gadget, ++ struct usb_endpoint_descriptor *desc, ++ struct usb_ss_ep_comp_descriptor *comp_desc) ++{ ++ struct ci_hdrc *ci = container_of(gadget, struct ci_hdrc, gadget); ++ struct usb_ep *ep; ++ ++ if (usb_endpoint_xfer_isoc(desc) && usb_endpoint_dir_in(desc)) { ++ list_for_each_entry_reverse(ep, &ci->gadget.ep_list, ep_list) { ++ if (ep->caps.dir_in && !ep->claimed) ++ return ep; ++ } ++ } ++ ++ return NULL; ++} ++ + /** + * Device operations part of the API to the USB controller hardware, + * which don't involve endpoints (or i/o) +@@ -1634,6 +1653,7 @@ static const struct usb_gadget_ops usb_gadget_ops = { + .vbus_draw = ci_udc_vbus_draw, + .udc_start = ci_udc_start, + .udc_stop = ci_udc_stop, ++ .match_ep = ci_udc_match_ep, + }; + + static int init_eps(struct ci_hdrc *ci) +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c +index b62953ee0fc6..f896a00662ef 100644 +--- a/drivers/usb/host/xhci-ring.c ++++ b/drivers/usb/host/xhci-ring.c +@@ -1604,8 +1604,13 @@ static void handle_port_status(struct xhci_hcd *xhci, + usb_hcd_resume_root_hub(hcd); + } + +- if (hcd->speed >= HCD_USB3 && (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) ++ if (hcd->speed >= HCD_USB3 && ++ (portsc & PORT_PLS_MASK) == XDEV_INACTIVE) { ++ slot_id = xhci_find_slot_id_by_port(hcd, xhci, hcd_portnum + 1); ++ if (slot_id && xhci->devs[slot_id]) ++ xhci->devs[slot_id]->flags |= VDEV_PORT_ERROR; + bus_state->port_remote_wakeup &= ~(1 << hcd_portnum); ++ } + + if ((portsc & PORT_PLC) && (portsc & PORT_PLS_MASK) == XDEV_RESUME) { + xhci_dbg(xhci, "port resume event for port %d\n", port_id); +@@ -1793,6 +1798,14 @@ static void xhci_cleanup_halted_endpoint(struct xhci_hcd *xhci, + { + struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index]; + struct xhci_command *command; ++ ++ /* ++ * Avoid resetting endpoint if link is inactive. Can cause host hang. ++ * Device will be reset soon to recover the link so don't do anything ++ */ ++ if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) ++ return; ++ + command = xhci_alloc_command(xhci, false, GFP_ATOMIC); + if (!command) + return; +diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c +index f30b065095fa..4ffadca2c71a 100644 +--- a/drivers/usb/host/xhci.c ++++ b/drivers/usb/host/xhci.c +@@ -1441,6 +1441,10 @@ static int xhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, gfp_t mem_flag + xhci_dbg(xhci, "urb submitted during PCI suspend\n"); + return -ESHUTDOWN; + } ++ if (xhci->devs[slot_id]->flags & VDEV_PORT_ERROR) { ++ xhci_dbg(xhci, "Can't queue urb, port error, link inactive\n"); ++ return -ENODEV; ++ } + + if (usb_endpoint_xfer_isoc(&urb->ep->desc)) + num_tds = urb->number_of_packets; +@@ -3724,6 +3728,7 @@ static int xhci_discover_or_reset_device(struct usb_hcd *hcd, + } + /* If necessary, update the number of active TTs on this root port */ + xhci_update_tt_active_eps(xhci, virt_dev, old_active_eps); ++ virt_dev->flags = 0; + ret = 0; + + command_cleanup: +@@ -5030,16 +5035,26 @@ int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks) + } else { + /* + * Some 3.1 hosts return sbrn 0x30, use xhci supported protocol +- * minor revision instead of sbrn ++ * minor revision instead of sbrn. Minor revision is a two digit ++ * BCD containing minor and sub-minor numbers, only show minor. + */ +- minor_rev = xhci->usb3_rhub.min_rev; +- if (minor_rev) { ++ minor_rev = xhci->usb3_rhub.min_rev / 0x10; ++ ++ switch (minor_rev) { ++ case 2: ++ hcd->speed = HCD_USB32; ++ hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; ++ hcd->self.root_hub->rx_lanes = 2; ++ hcd->self.root_hub->tx_lanes = 2; ++ break; ++ case 1: + hcd->speed = HCD_USB31; + hcd->self.root_hub->speed = USB_SPEED_SUPER_PLUS; ++ break; + } +- xhci_info(xhci, "Host supports USB 3.%x %s SuperSpeed\n", ++ xhci_info(xhci, "Host supports USB 3.%x %sSuperSpeed\n", + minor_rev, +- minor_rev ? "Enhanced" : ""); ++ minor_rev ? "Enhanced " : ""); + + xhci->usb3_rhub.hcd = hcd; + /* xHCI private pointer was set in xhci_pci_probe for the second +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h +index dc00f59c8e69..761b341d27b0 100644 +--- a/drivers/usb/host/xhci.h ++++ b/drivers/usb/host/xhci.h +@@ -1010,6 +1010,15 @@ struct xhci_virt_device { + u8 real_port; + struct xhci_interval_bw_table *bw_table; + struct xhci_tt_bw_info *tt_info; ++ /* ++ * flags for state tracking based on events and issued commands. ++ * Software can not rely on states from output contexts because of ++ * latency between events and xHC updating output context values. ++ * See xhci 1.1 section 4.8.3 for more details ++ */ ++ unsigned long flags; ++#define VDEV_PORT_ERROR BIT(0) /* Port error, link inactive */ ++ + /* The current max exit latency for the enabled USB3 link states. */ + u16 current_mel; + /* Used for the debugfs interfaces. */ +diff --git a/fs/btrfs/reada.c b/fs/btrfs/reada.c +index dec14b739b10..859274e38417 100644 +--- a/fs/btrfs/reada.c ++++ b/fs/btrfs/reada.c +@@ -745,6 +745,7 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info) + u64 total = 0; + int i; + ++again: + do { + enqueued = 0; + mutex_lock(&fs_devices->device_list_mutex); +@@ -756,6 +757,10 @@ static void __reada_start_machine(struct btrfs_fs_info *fs_info) + mutex_unlock(&fs_devices->device_list_mutex); + total += enqueued; + } while (enqueued && total < 10000); ++ if (fs_devices->seed) { ++ fs_devices = fs_devices->seed; ++ goto again; ++ } + + if (enqueued == 0) + return; +diff --git a/fs/cifs/smb2maperror.c b/fs/cifs/smb2maperror.c +index 18814f1d67d9..3c0bad577859 100644 +--- a/fs/cifs/smb2maperror.c ++++ b/fs/cifs/smb2maperror.c +@@ -457,7 +457,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = { + {STATUS_FILE_INVALID, -EIO, "STATUS_FILE_INVALID"}, + {STATUS_ALLOTTED_SPACE_EXCEEDED, -EIO, + "STATUS_ALLOTTED_SPACE_EXCEEDED"}, +- {STATUS_INSUFFICIENT_RESOURCES, -EREMOTEIO, ++ {STATUS_INSUFFICIENT_RESOURCES, -EAGAIN, + "STATUS_INSUFFICIENT_RESOURCES"}, + {STATUS_DFS_EXIT_PATH_FOUND, -EIO, "STATUS_DFS_EXIT_PATH_FOUND"}, + {STATUS_DEVICE_DATA_ERROR, -EIO, "STATUS_DEVICE_DATA_ERROR"}, +diff --git a/fs/overlayfs/file.c b/fs/overlayfs/file.c +index 00338b828f76..0bd276e4ccbe 100644 +--- a/fs/overlayfs/file.c ++++ b/fs/overlayfs/file.c +@@ -409,36 +409,16 @@ static long ovl_real_ioctl(struct file *file, unsigned int cmd, + return ret; + } + +-static unsigned int ovl_get_inode_flags(struct inode *inode) +-{ +- unsigned int flags = READ_ONCE(inode->i_flags); +- unsigned int ovl_iflags = 0; +- +- if (flags & S_SYNC) +- ovl_iflags |= FS_SYNC_FL; +- if (flags & S_APPEND) +- ovl_iflags |= FS_APPEND_FL; +- if (flags & S_IMMUTABLE) +- ovl_iflags |= FS_IMMUTABLE_FL; +- if (flags & S_NOATIME) +- ovl_iflags |= FS_NOATIME_FL; +- +- return ovl_iflags; +-} +- +-static long ovl_ioctl_set_flags(struct file *file, unsigned long arg) ++static long ovl_ioctl_set_flags(struct file *file, unsigned int cmd, ++ unsigned long arg, unsigned int iflags) + { + long ret; + struct inode *inode = file_inode(file); +- unsigned int flags; +- unsigned int old_flags; ++ unsigned int old_iflags; + + if (!inode_owner_or_capable(inode)) + return -EACCES; + +- if (get_user(flags, (int __user *) arg)) +- return -EFAULT; +- + ret = mnt_want_write_file(file); + if (ret) + return ret; +@@ -447,8 +427,8 @@ static long ovl_ioctl_set_flags(struct file *file, unsigned long arg) + + /* Check the capability before cred override */ + ret = -EPERM; +- old_flags = ovl_get_inode_flags(inode); +- if (((flags ^ old_flags) & (FS_APPEND_FL | FS_IMMUTABLE_FL)) && ++ old_iflags = READ_ONCE(inode->i_flags); ++ if (((iflags ^ old_iflags) & (S_APPEND | S_IMMUTABLE)) && + !capable(CAP_LINUX_IMMUTABLE)) + goto unlock; + +@@ -456,7 +436,7 @@ static long ovl_ioctl_set_flags(struct file *file, unsigned long arg) + if (ret) + goto unlock; + +- ret = ovl_real_ioctl(file, FS_IOC_SETFLAGS, arg); ++ ret = ovl_real_ioctl(file, cmd, arg); + + ovl_copyflags(ovl_inode_real(inode), inode); + unlock: +@@ -468,17 +448,79 @@ unlock: + + } + ++static unsigned int ovl_fsflags_to_iflags(unsigned int flags) ++{ ++ unsigned int iflags = 0; ++ ++ if (flags & FS_SYNC_FL) ++ iflags |= S_SYNC; ++ if (flags & FS_APPEND_FL) ++ iflags |= S_APPEND; ++ if (flags & FS_IMMUTABLE_FL) ++ iflags |= S_IMMUTABLE; ++ if (flags & FS_NOATIME_FL) ++ iflags |= S_NOATIME; ++ ++ return iflags; ++} ++ ++static long ovl_ioctl_set_fsflags(struct file *file, unsigned int cmd, ++ unsigned long arg) ++{ ++ unsigned int flags; ++ ++ if (get_user(flags, (int __user *) arg)) ++ return -EFAULT; ++ ++ return ovl_ioctl_set_flags(file, cmd, arg, ++ ovl_fsflags_to_iflags(flags)); ++} ++ ++static unsigned int ovl_fsxflags_to_iflags(unsigned int xflags) ++{ ++ unsigned int iflags = 0; ++ ++ if (xflags & FS_XFLAG_SYNC) ++ iflags |= S_SYNC; ++ if (xflags & FS_XFLAG_APPEND) ++ iflags |= S_APPEND; ++ if (xflags & FS_XFLAG_IMMUTABLE) ++ iflags |= S_IMMUTABLE; ++ if (xflags & FS_XFLAG_NOATIME) ++ iflags |= S_NOATIME; ++ ++ return iflags; ++} ++ ++static long ovl_ioctl_set_fsxflags(struct file *file, unsigned int cmd, ++ unsigned long arg) ++{ ++ struct fsxattr fa; ++ ++ memset(&fa, 0, sizeof(fa)); ++ if (copy_from_user(&fa, (void __user *) arg, sizeof(fa))) ++ return -EFAULT; ++ ++ return ovl_ioctl_set_flags(file, cmd, arg, ++ ovl_fsxflags_to_iflags(fa.fsx_xflags)); ++} ++ + static long ovl_ioctl(struct file *file, unsigned int cmd, unsigned long arg) + { + long ret; + + switch (cmd) { + case FS_IOC_GETFLAGS: ++ case FS_IOC_FSGETXATTR: + ret = ovl_real_ioctl(file, cmd, arg); + break; + + case FS_IOC_SETFLAGS: +- ret = ovl_ioctl_set_flags(file, arg); ++ ret = ovl_ioctl_set_fsflags(file, cmd, arg); ++ break; ++ ++ case FS_IOC_FSSETXATTR: ++ ret = ovl_ioctl_set_fsxflags(file, cmd, arg); + break; + + default: +diff --git a/fs/overlayfs/inode.c b/fs/overlayfs/inode.c +index b48273e846ad..f0389849fd80 100644 +--- a/fs/overlayfs/inode.c ++++ b/fs/overlayfs/inode.c +@@ -553,15 +553,15 @@ static void ovl_fill_inode(struct inode *inode, umode_t mode, dev_t rdev, + int xinobits = ovl_xino_bits(inode->i_sb); + + /* +- * When NFS export is enabled and d_ino is consistent with st_ino +- * (samefs or i_ino has enough bits to encode layer), set the same +- * value used for d_ino to i_ino, because nfsd readdirplus compares +- * d_ino values to i_ino values of child entries. When called from ++ * When d_ino is consistent with st_ino (samefs or i_ino has enough ++ * bits to encode layer), set the same value used for st_ino to i_ino, ++ * so inode number exposed via /proc/locks and a like will be ++ * consistent with d_ino and st_ino values. An i_ino value inconsistent ++ * with d_ino also causes nfsd readdirplus to fail. When called from + * ovl_new_inode(), ino arg is 0, so i_ino will be updated to real + * upper inode i_ino on ovl_inode_init() or ovl_inode_update(). + */ +- if (inode->i_sb->s_export_op && +- (ovl_same_sb(inode->i_sb) || xinobits)) { ++ if (ovl_same_sb(inode->i_sb) || xinobits) { + inode->i_ino = ino; + if (xinobits && fsid && !(ino >> (64 - xinobits))) + inode->i_ino |= (unsigned long)fsid << (64 - xinobits); +@@ -777,6 +777,54 @@ struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, + return inode; + } + ++bool ovl_lookup_trap_inode(struct super_block *sb, struct dentry *dir) ++{ ++ struct inode *key = d_inode(dir); ++ struct inode *trap; ++ bool res; ++ ++ trap = ilookup5(sb, (unsigned long) key, ovl_inode_test, key); ++ if (!trap) ++ return false; ++ ++ res = IS_DEADDIR(trap) && !ovl_inode_upper(trap) && ++ !ovl_inode_lower(trap); ++ ++ iput(trap); ++ return res; ++} ++ ++/* ++ * Create an inode cache entry for layer root dir, that will intentionally ++ * fail ovl_verify_inode(), so any lookup that will find some layer root ++ * will fail. ++ */ ++struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir) ++{ ++ struct inode *key = d_inode(dir); ++ struct inode *trap; ++ ++ if (!d_is_dir(dir)) ++ return ERR_PTR(-ENOTDIR); ++ ++ trap = iget5_locked(sb, (unsigned long) key, ovl_inode_test, ++ ovl_inode_set, key); ++ if (!trap) ++ return ERR_PTR(-ENOMEM); ++ ++ if (!(trap->i_state & I_NEW)) { ++ /* Conflicting layer roots? */ ++ iput(trap); ++ return ERR_PTR(-ELOOP); ++ } ++ ++ trap->i_mode = S_IFDIR; ++ trap->i_flags = S_DEAD; ++ unlock_new_inode(trap); ++ ++ return trap; ++} ++ + /* + * Does overlay inode need to be hashed by lower inode? + */ +diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c +index efd372312ef1..badf039267a2 100644 +--- a/fs/overlayfs/namei.c ++++ b/fs/overlayfs/namei.c +@@ -18,6 +18,7 @@ + #include "overlayfs.h" + + struct ovl_lookup_data { ++ struct super_block *sb; + struct qstr name; + bool is_dir; + bool opaque; +@@ -244,6 +245,12 @@ static int ovl_lookup_single(struct dentry *base, struct ovl_lookup_data *d, + if (!d->metacopy || d->last) + goto out; + } else { ++ if (ovl_lookup_trap_inode(d->sb, this)) { ++ /* Caught in a trap of overlapping layers */ ++ err = -ELOOP; ++ goto out_err; ++ } ++ + if (last_element) + d->is_dir = true; + if (d->last) +@@ -819,6 +826,7 @@ struct dentry *ovl_lookup(struct inode *dir, struct dentry *dentry, + int err; + bool metacopy = false; + struct ovl_lookup_data d = { ++ .sb = dentry->d_sb, + .name = dentry->d_name, + .is_dir = false, + .opaque = false, +diff --git a/fs/overlayfs/overlayfs.h b/fs/overlayfs/overlayfs.h +index 80fb66426760..265bf9cfde08 100644 +--- a/fs/overlayfs/overlayfs.h ++++ b/fs/overlayfs/overlayfs.h +@@ -270,6 +270,7 @@ void ovl_clear_flag(unsigned long flag, struct inode *inode); + bool ovl_test_flag(unsigned long flag, struct inode *inode); + bool ovl_inuse_trylock(struct dentry *dentry); + void ovl_inuse_unlock(struct dentry *dentry); ++bool ovl_is_inuse(struct dentry *dentry); + bool ovl_need_index(struct dentry *dentry); + int ovl_nlink_start(struct dentry *dentry, bool *locked); + void ovl_nlink_end(struct dentry *dentry, bool locked); +@@ -366,6 +367,8 @@ struct ovl_inode_params { + struct inode *ovl_new_inode(struct super_block *sb, umode_t mode, dev_t rdev); + struct inode *ovl_lookup_inode(struct super_block *sb, struct dentry *real, + bool is_upper); ++bool ovl_lookup_trap_inode(struct super_block *sb, struct dentry *dir); ++struct inode *ovl_get_trap_inode(struct super_block *sb, struct dentry *dir); + struct inode *ovl_get_inode(struct super_block *sb, + struct ovl_inode_params *oip); + static inline void ovl_copyattr(struct inode *from, struct inode *to) +diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h +index ec237035333a..6ed1ace8f8b3 100644 +--- a/fs/overlayfs/ovl_entry.h ++++ b/fs/overlayfs/ovl_entry.h +@@ -29,6 +29,8 @@ struct ovl_sb { + + struct ovl_layer { + struct vfsmount *mnt; ++ /* Trap in ovl inode cache */ ++ struct inode *trap; + struct ovl_sb *fs; + /* Index of this layer in fs root (upper idx == 0) */ + int idx; +@@ -65,6 +67,10 @@ struct ovl_fs { + /* Did we take the inuse lock? */ + bool upperdir_locked; + bool workdir_locked; ++ /* Traps in ovl inode cache */ ++ struct inode *upperdir_trap; ++ struct inode *workdir_trap; ++ struct inode *indexdir_trap; + /* Inode numbers in all layers do not use the high xino_bits */ + unsigned int xino_bits; + }; +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c +index 0fb0a59a5e5c..2d028c02621f 100644 +--- a/fs/overlayfs/super.c ++++ b/fs/overlayfs/super.c +@@ -217,6 +217,9 @@ static void ovl_free_fs(struct ovl_fs *ofs) + { + unsigned i; + ++ iput(ofs->indexdir_trap); ++ iput(ofs->workdir_trap); ++ iput(ofs->upperdir_trap); + dput(ofs->indexdir); + dput(ofs->workdir); + if (ofs->workdir_locked) +@@ -225,8 +228,10 @@ static void ovl_free_fs(struct ovl_fs *ofs) + if (ofs->upperdir_locked) + ovl_inuse_unlock(ofs->upper_mnt->mnt_root); + mntput(ofs->upper_mnt); +- for (i = 0; i < ofs->numlower; i++) ++ for (i = 0; i < ofs->numlower; i++) { ++ iput(ofs->lower_layers[i].trap); + mntput(ofs->lower_layers[i].mnt); ++ } + for (i = 0; i < ofs->numlowerfs; i++) + free_anon_bdev(ofs->lower_fs[i].pseudo_dev); + kfree(ofs->lower_layers); +@@ -984,7 +989,26 @@ static const struct xattr_handler *ovl_xattr_handlers[] = { + NULL + }; + +-static int ovl_get_upper(struct ovl_fs *ofs, struct path *upperpath) ++static int ovl_setup_trap(struct super_block *sb, struct dentry *dir, ++ struct inode **ptrap, const char *name) ++{ ++ struct inode *trap; ++ int err; ++ ++ trap = ovl_get_trap_inode(sb, dir); ++ err = PTR_ERR_OR_ZERO(trap); ++ if (err) { ++ if (err == -ELOOP) ++ pr_err("overlayfs: conflicting %s path\n", name); ++ return err; ++ } ++ ++ *ptrap = trap; ++ return 0; ++} ++ ++static int ovl_get_upper(struct super_block *sb, struct ovl_fs *ofs, ++ struct path *upperpath) + { + struct vfsmount *upper_mnt; + int err; +@@ -1004,6 +1028,11 @@ static int ovl_get_upper(struct ovl_fs *ofs, struct path *upperpath) + if (err) + goto out; + ++ err = ovl_setup_trap(sb, upperpath->dentry, &ofs->upperdir_trap, ++ "upperdir"); ++ if (err) ++ goto out; ++ + upper_mnt = clone_private_mount(upperpath); + err = PTR_ERR(upper_mnt); + if (IS_ERR(upper_mnt)) { +@@ -1030,7 +1059,8 @@ out: + return err; + } + +-static int ovl_make_workdir(struct ovl_fs *ofs, struct path *workpath) ++static int ovl_make_workdir(struct super_block *sb, struct ovl_fs *ofs, ++ struct path *workpath) + { + struct vfsmount *mnt = ofs->upper_mnt; + struct dentry *temp; +@@ -1045,6 +1075,10 @@ static int ovl_make_workdir(struct ovl_fs *ofs, struct path *workpath) + if (!ofs->workdir) + goto out; + ++ err = ovl_setup_trap(sb, ofs->workdir, &ofs->workdir_trap, "workdir"); ++ if (err) ++ goto out; ++ + /* + * Upper should support d_type, else whiteouts are visible. Given + * workdir and upper are on same fs, we can do iterate_dir() on +@@ -1105,7 +1139,8 @@ out: + return err; + } + +-static int ovl_get_workdir(struct ovl_fs *ofs, struct path *upperpath) ++static int ovl_get_workdir(struct super_block *sb, struct ovl_fs *ofs, ++ struct path *upperpath) + { + int err; + struct path workpath = { }; +@@ -1136,19 +1171,16 @@ static int ovl_get_workdir(struct ovl_fs *ofs, struct path *upperpath) + pr_warn("overlayfs: workdir is in-use by another mount, accessing files from both mounts will result in undefined behavior.\n"); + } + +- err = ovl_make_workdir(ofs, &workpath); +- if (err) +- goto out; ++ err = ovl_make_workdir(sb, ofs, &workpath); + +- err = 0; + out: + path_put(&workpath); + + return err; + } + +-static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe, +- struct path *upperpath) ++static int ovl_get_indexdir(struct super_block *sb, struct ovl_fs *ofs, ++ struct ovl_entry *oe, struct path *upperpath) + { + struct vfsmount *mnt = ofs->upper_mnt; + int err; +@@ -1167,6 +1199,11 @@ static int ovl_get_indexdir(struct ovl_fs *ofs, struct ovl_entry *oe, + + ofs->indexdir = ovl_workdir_create(ofs, OVL_INDEXDIR_NAME, true); + if (ofs->indexdir) { ++ err = ovl_setup_trap(sb, ofs->indexdir, &ofs->indexdir_trap, ++ "indexdir"); ++ if (err) ++ goto out; ++ + /* + * Verify upper root is exclusively associated with index dir. + * Older kernels stored upper fh in "trusted.overlay.origin" +@@ -1226,8 +1263,8 @@ static int ovl_get_fsid(struct ovl_fs *ofs, struct super_block *sb) + return ofs->numlowerfs; + } + +-static int ovl_get_lower_layers(struct ovl_fs *ofs, struct path *stack, +- unsigned int numlower) ++static int ovl_get_lower_layers(struct super_block *sb, struct ovl_fs *ofs, ++ struct path *stack, unsigned int numlower) + { + int err; + unsigned int i; +@@ -1245,16 +1282,28 @@ static int ovl_get_lower_layers(struct ovl_fs *ofs, struct path *stack, + + for (i = 0; i < numlower; i++) { + struct vfsmount *mnt; ++ struct inode *trap; + int fsid; + + err = fsid = ovl_get_fsid(ofs, stack[i].mnt->mnt_sb); + if (err < 0) + goto out; + ++ err = -EBUSY; ++ if (ovl_is_inuse(stack[i].dentry)) { ++ pr_err("overlayfs: lowerdir is in-use as upperdir/workdir\n"); ++ goto out; ++ } ++ ++ err = ovl_setup_trap(sb, stack[i].dentry, &trap, "lowerdir"); ++ if (err) ++ goto out; ++ + mnt = clone_private_mount(&stack[i]); + err = PTR_ERR(mnt); + if (IS_ERR(mnt)) { + pr_err("overlayfs: failed to clone lowerpath\n"); ++ iput(trap); + goto out; + } + +@@ -1264,6 +1313,7 @@ static int ovl_get_lower_layers(struct ovl_fs *ofs, struct path *stack, + */ + mnt->mnt_flags |= MNT_READONLY | MNT_NOATIME; + ++ ofs->lower_layers[ofs->numlower].trap = trap; + ofs->lower_layers[ofs->numlower].mnt = mnt; + ofs->lower_layers[ofs->numlower].idx = i + 1; + ofs->lower_layers[ofs->numlower].fsid = fsid; +@@ -1358,7 +1408,7 @@ static struct ovl_entry *ovl_get_lowerstack(struct super_block *sb, + goto out_err; + } + +- err = ovl_get_lower_layers(ofs, stack, numlower); ++ err = ovl_get_lower_layers(sb, ofs, stack, numlower); + if (err) + goto out_err; + +@@ -1390,6 +1440,77 @@ out_err: + goto out; + } + ++/* ++ * Check if this layer root is a descendant of: ++ * - another layer of this overlayfs instance ++ * - upper/work dir of any overlayfs instance ++ */ ++static int ovl_check_layer(struct super_block *sb, struct dentry *dentry, ++ const char *name) ++{ ++ struct dentry *next = dentry, *parent; ++ int err = 0; ++ ++ if (!dentry) ++ return 0; ++ ++ parent = dget_parent(next); ++ ++ /* Walk back ancestors to root (inclusive) looking for traps */ ++ while (!err && parent != next) { ++ if (ovl_is_inuse(parent)) { ++ err = -EBUSY; ++ pr_err("overlayfs: %s path overlapping in-use upperdir/workdir\n", ++ name); ++ } else if (ovl_lookup_trap_inode(sb, parent)) { ++ err = -ELOOP; ++ pr_err("overlayfs: overlapping %s path\n", name); ++ } ++ next = parent; ++ parent = dget_parent(next); ++ dput(next); ++ } ++ ++ dput(parent); ++ ++ return err; ++} ++ ++/* ++ * Check if any of the layers or work dirs overlap. ++ */ ++static int ovl_check_overlapping_layers(struct super_block *sb, ++ struct ovl_fs *ofs) ++{ ++ int i, err; ++ ++ if (ofs->upper_mnt) { ++ err = ovl_check_layer(sb, ofs->upper_mnt->mnt_root, "upperdir"); ++ if (err) ++ return err; ++ ++ /* ++ * Checking workbasedir avoids hitting ovl_is_inuse(parent) of ++ * this instance and covers overlapping work and index dirs, ++ * unless work or index dir have been moved since created inside ++ * workbasedir. In that case, we already have their traps in ++ * inode cache and we will catch that case on lookup. ++ */ ++ err = ovl_check_layer(sb, ofs->workbasedir, "workdir"); ++ if (err) ++ return err; ++ } ++ ++ for (i = 0; i < ofs->numlower; i++) { ++ err = ovl_check_layer(sb, ofs->lower_layers[i].mnt->mnt_root, ++ "lowerdir"); ++ if (err) ++ return err; ++ } ++ ++ return 0; ++} ++ + static int ovl_fill_super(struct super_block *sb, void *data, int silent) + { + struct path upperpath = { }; +@@ -1429,17 +1550,20 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) + if (ofs->config.xino != OVL_XINO_OFF) + ofs->xino_bits = BITS_PER_LONG - 32; + ++ /* alloc/destroy_inode needed for setting up traps in inode cache */ ++ sb->s_op = &ovl_super_operations; ++ + if (ofs->config.upperdir) { + if (!ofs->config.workdir) { + pr_err("overlayfs: missing 'workdir'\n"); + goto out_err; + } + +- err = ovl_get_upper(ofs, &upperpath); ++ err = ovl_get_upper(sb, ofs, &upperpath); + if (err) + goto out_err; + +- err = ovl_get_workdir(ofs, &upperpath); ++ err = ovl_get_workdir(sb, ofs, &upperpath); + if (err) + goto out_err; + +@@ -1460,7 +1584,7 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) + sb->s_flags |= SB_RDONLY; + + if (!(ovl_force_readonly(ofs)) && ofs->config.index) { +- err = ovl_get_indexdir(ofs, oe, &upperpath); ++ err = ovl_get_indexdir(sb, ofs, oe, &upperpath); + if (err) + goto out_free_oe; + +@@ -1473,6 +1597,10 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) + + } + ++ err = ovl_check_overlapping_layers(sb, ofs); ++ if (err) ++ goto out_free_oe; ++ + /* Show index=off in /proc/mounts for forced r/o mount */ + if (!ofs->indexdir) { + ofs->config.index = false; +@@ -1494,7 +1622,6 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) + cap_lower(cred->cap_effective, CAP_SYS_RESOURCE); + + sb->s_magic = OVERLAYFS_SUPER_MAGIC; +- sb->s_op = &ovl_super_operations; + sb->s_xattr = ovl_xattr_handlers; + sb->s_fs_info = ofs; + sb->s_flags |= SB_POSIXACL; +diff --git a/fs/overlayfs/util.c b/fs/overlayfs/util.c +index c9a2e3c6d537..db8bdb29b320 100644 +--- a/fs/overlayfs/util.c ++++ b/fs/overlayfs/util.c +@@ -653,6 +653,18 @@ void ovl_inuse_unlock(struct dentry *dentry) + } + } + ++bool ovl_is_inuse(struct dentry *dentry) ++{ ++ struct inode *inode = d_inode(dentry); ++ bool inuse; ++ ++ spin_lock(&inode->i_lock); ++ inuse = (inode->i_state & I_OVL_INUSE); ++ spin_unlock(&inode->i_lock); ++ ++ return inuse; ++} ++ + /* + * Does this overlay dentry need to be indexed on copy up? + */ +diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h +index beed7121c781..2ff52de1c2b8 100644 +--- a/include/linux/mmc/host.h ++++ b/include/linux/mmc/host.h +@@ -395,6 +395,7 @@ struct mmc_host { + unsigned int retune_now:1; /* do re-tuning at next req */ + unsigned int retune_paused:1; /* re-tuning is temporarily disabled */ + unsigned int use_blk_mq:1; /* use blk-mq */ ++ unsigned int retune_crc_disable:1; /* don't trigger retune upon crc */ + + int rescan_disable; /* disable card detection */ + int rescan_entered; /* used with nonremovable devices */ +diff --git a/include/linux/mmc/sdio_func.h b/include/linux/mmc/sdio_func.h +index 97ca105347a6..6905f3f641cc 100644 +--- a/include/linux/mmc/sdio_func.h ++++ b/include/linux/mmc/sdio_func.h +@@ -159,4 +159,10 @@ extern void sdio_f0_writeb(struct sdio_func *func, unsigned char b, + extern mmc_pm_flag_t sdio_get_host_pm_caps(struct sdio_func *func); + extern int sdio_set_host_pm_flags(struct sdio_func *func, mmc_pm_flag_t flags); + ++extern void sdio_retune_crc_disable(struct sdio_func *func); ++extern void sdio_retune_crc_enable(struct sdio_func *func); ++ ++extern void sdio_retune_hold_now(struct sdio_func *func); ++extern void sdio_retune_release(struct sdio_func *func); ++ + #endif /* LINUX_MMC_SDIO_FUNC_H */ +diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h +index 1dfb75057580..cc2d0c3b475b 100644 +--- a/include/net/bluetooth/hci_core.h ++++ b/include/net/bluetooth/hci_core.h +@@ -182,6 +182,9 @@ struct adv_info { + + #define HCI_MAX_SHORT_NAME_LENGTH 10 + ++/* Min encryption key size to match with SMP */ ++#define HCI_MIN_ENC_KEY_SIZE 7 ++ + /* Default LE RPA expiry time, 15 minutes */ + #define HCI_DEFAULT_RPA_TIMEOUT (15 * 60) + +diff --git a/include/net/cfg80211.h b/include/net/cfg80211.h +index 4de121e24ce5..67e0a990144a 100644 +--- a/include/net/cfg80211.h ++++ b/include/net/cfg80211.h +@@ -3448,7 +3448,8 @@ struct cfg80211_ops { + * on wiphy_new(), but can be changed by the driver if it has a good + * reason to override the default + * @WIPHY_FLAG_4ADDR_AP: supports 4addr mode even on AP (with a single station +- * on a VLAN interface) ++ * on a VLAN interface). This flag also serves an extra purpose of ++ * supporting 4ADDR AP mode on devices which do not support AP/VLAN iftype. + * @WIPHY_FLAG_4ADDR_STATION: supports 4addr mode even as a station + * @WIPHY_FLAG_CONTROL_PORT_PROTOCOL: This device supports setting the + * control port protocol ethertype. The device also honours the +diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c +index 1bd7a758583b..181dba75a203 100644 +--- a/kernel/trace/trace.c ++++ b/kernel/trace/trace.c +@@ -8351,12 +8351,8 @@ void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) + + cnt++; + +- /* reset all but tr, trace, and overruns */ +- memset(&iter.seq, 0, +- sizeof(struct trace_iterator) - +- offsetof(struct trace_iterator, seq)); ++ trace_iterator_reset(&iter); + iter.iter_flags |= TRACE_FILE_LAT_FMT; +- iter.pos = -1; + + if (trace_find_next_entry_inc(&iter) != NULL) { + int ret; +diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h +index 447bd96ee658..d11d7bfc3fa5 100644 +--- a/kernel/trace/trace.h ++++ b/kernel/trace/trace.h +@@ -1895,4 +1895,22 @@ static inline void tracer_hardirqs_off(unsigned long a0, unsigned long a1) { } + + extern struct trace_iterator *tracepoint_print_iter; + ++/* ++ * Reset the state of the trace_iterator so that it can read consumed data. ++ * Normally, the trace_iterator is used for reading the data when it is not ++ * consumed, and must retain state. ++ */ ++static __always_inline void trace_iterator_reset(struct trace_iterator *iter) ++{ ++ const size_t offset = offsetof(struct trace_iterator, seq); ++ ++ /* ++ * Keep gcc from complaining about overwriting more than just one ++ * member in the structure. ++ */ ++ memset((char *)iter + offset, 0, sizeof(struct trace_iterator) - offset); ++ ++ iter->pos = -1; ++} ++ + #endif /* _LINUX_KERNEL_TRACE_H */ +diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c +index 810d78a8d14c..2905a3dd94c1 100644 +--- a/kernel/trace/trace_kdb.c ++++ b/kernel/trace/trace_kdb.c +@@ -41,12 +41,8 @@ static void ftrace_dump_buf(int skip_lines, long cpu_file) + + kdb_printf("Dumping ftrace buffer:\n"); + +- /* reset all but tr, trace, and overruns */ +- memset(&iter.seq, 0, +- sizeof(struct trace_iterator) - +- offsetof(struct trace_iterator, seq)); ++ trace_iterator_reset(&iter); + iter.iter_flags |= TRACE_FILE_LAT_FMT; +- iter.pos = -1; + + if (cpu_file == RING_BUFFER_ALL_CPUS) { + for_each_tracing_cpu(cpu) { +diff --git a/net/bluetooth/hci_conn.c b/net/bluetooth/hci_conn.c +index bd4978ce8c45..15d1cb5aee18 100644 +--- a/net/bluetooth/hci_conn.c ++++ b/net/bluetooth/hci_conn.c +@@ -1392,8 +1392,16 @@ auth: + return 0; + + encrypt: +- if (test_bit(HCI_CONN_ENCRYPT, &conn->flags)) ++ if (test_bit(HCI_CONN_ENCRYPT, &conn->flags)) { ++ /* Ensure that the encryption key size has been read, ++ * otherwise stall the upper layer responses. ++ */ ++ if (!conn->enc_key_size) ++ return 0; ++ ++ /* Nothing else needed, all requirements are met */ + return 1; ++ } + + hci_conn_encrypt(conn); + return 0; +diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c +index 2c6eabf294b3..69e3be51a2c3 100644 +--- a/net/bluetooth/l2cap_core.c ++++ b/net/bluetooth/l2cap_core.c +@@ -1340,6 +1340,21 @@ static void l2cap_request_info(struct l2cap_conn *conn) + sizeof(req), &req); + } + ++static bool l2cap_check_enc_key_size(struct hci_conn *hcon) ++{ ++ /* The minimum encryption key size needs to be enforced by the ++ * host stack before establishing any L2CAP connections. The ++ * specification in theory allows a minimum of 1, but to align ++ * BR/EDR and LE transports, a minimum of 7 is chosen. ++ * ++ * This check might also be called for unencrypted connections ++ * that have no key size requirements. Ensure that the link is ++ * actually encrypted before enforcing a key size. ++ */ ++ return (!test_bit(HCI_CONN_ENCRYPT, &hcon->flags) || ++ hcon->enc_key_size > HCI_MIN_ENC_KEY_SIZE); ++} ++ + static void l2cap_do_start(struct l2cap_chan *chan) + { + struct l2cap_conn *conn = chan->conn; +@@ -1357,9 +1372,14 @@ static void l2cap_do_start(struct l2cap_chan *chan) + if (!(conn->info_state & L2CAP_INFO_FEAT_MASK_REQ_DONE)) + return; + +- if (l2cap_chan_check_security(chan, true) && +- __l2cap_no_conn_pending(chan)) ++ if (!l2cap_chan_check_security(chan, true) || ++ !__l2cap_no_conn_pending(chan)) ++ return; ++ ++ if (l2cap_check_enc_key_size(conn->hcon)) + l2cap_start_connection(chan); ++ else ++ __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); + } + + static inline int l2cap_mode_supported(__u8 mode, __u32 feat_mask) +@@ -1438,7 +1458,10 @@ static void l2cap_conn_start(struct l2cap_conn *conn) + continue; + } + +- l2cap_start_connection(chan); ++ if (l2cap_check_enc_key_size(conn->hcon)) ++ l2cap_start_connection(chan); ++ else ++ l2cap_chan_close(chan, ECONNREFUSED); + + } else if (chan->state == BT_CONNECT2) { + struct l2cap_conn_rsp rsp; +@@ -7455,7 +7478,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) + } + + if (chan->state == BT_CONNECT) { +- if (!status) ++ if (!status && l2cap_check_enc_key_size(hcon)) + l2cap_start_connection(chan); + else + __set_chan_timer(chan, L2CAP_DISC_TIMEOUT); +@@ -7464,7 +7487,7 @@ static void l2cap_security_cfm(struct hci_conn *hcon, u8 status, u8 encrypt) + struct l2cap_conn_rsp rsp; + __u16 res, stat; + +- if (!status) { ++ if (!status && l2cap_check_enc_key_size(hcon)) { + if (test_bit(FLAG_DEFER_SETUP, &chan->flags)) { + res = L2CAP_CR_PEND; + stat = L2CAP_CS_AUTHOR_PEND; +diff --git a/net/can/af_can.c b/net/can/af_can.c +index 1684ba5b51eb..e386d654116d 100644 +--- a/net/can/af_can.c ++++ b/net/can/af_can.c +@@ -105,6 +105,7 @@ EXPORT_SYMBOL(can_ioctl); + static void can_sock_destruct(struct sock *sk) + { + skb_queue_purge(&sk->sk_receive_queue); ++ skb_queue_purge(&sk->sk_error_queue); + } + + static const struct can_proto *can_get_proto(int protocol) +diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h +index 172aeae21ae9..35c6dfa13fa8 100644 +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -2183,6 +2183,9 @@ void ieee80211_tdls_cancel_channel_switch(struct wiphy *wiphy, + const u8 *addr); + void ieee80211_teardown_tdls_peers(struct ieee80211_sub_if_data *sdata); + void ieee80211_tdls_chsw_work(struct work_struct *wk); ++void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata, ++ const u8 *peer, u16 reason); ++const char *ieee80211_get_reason_code_string(u16 reason_code); + + extern const struct ethtool_ops ieee80211_ethtool_ops; + +diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c +index 2ac749c4a6b2..1aaa73fa308e 100644 +--- a/net/mac80211/mlme.c ++++ b/net/mac80211/mlme.c +@@ -2868,7 +2868,7 @@ static void ieee80211_rx_mgmt_auth(struct ieee80211_sub_if_data *sdata, + #define case_WLAN(type) \ + case WLAN_REASON_##type: return #type + +-static const char *ieee80211_get_reason_code_string(u16 reason_code) ++const char *ieee80211_get_reason_code_string(u16 reason_code) + { + switch (reason_code) { + case_WLAN(UNSPECIFIED); +@@ -2933,6 +2933,11 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, + if (len < 24 + 2) + return; + ++ if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { ++ ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); ++ return; ++ } ++ + if (ifmgd->associated && + ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) { + const u8 *bssid = ifmgd->associated->bssid; +@@ -2982,6 +2987,11 @@ static void ieee80211_rx_mgmt_disassoc(struct ieee80211_sub_if_data *sdata, + + reason_code = le16_to_cpu(mgmt->u.disassoc.reason_code); + ++ if (!ether_addr_equal(mgmt->bssid, mgmt->sa)) { ++ ieee80211_tdls_handle_disconnect(sdata, mgmt->sa, reason_code); ++ return; ++ } ++ + sdata_info(sdata, "disassociated from %pM (Reason: %u=%s)\n", + mgmt->sa, reason_code, + ieee80211_get_reason_code_string(reason_code)); +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c +index e946ee4f335b..7523d995ea8a 100644 +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -3752,6 +3752,8 @@ static bool ieee80211_accept_frame(struct ieee80211_rx_data *rx) + case NL80211_IFTYPE_STATION: + if (!bssid && !sdata->u.mgd.use_4addr) + return false; ++ if (ieee80211_is_robust_mgmt_frame(skb) && !rx->sta) ++ return false; + if (multicast) + return true; + return ether_addr_equal(sdata->vif.addr, hdr->addr1); +diff --git a/net/mac80211/tdls.c b/net/mac80211/tdls.c +index 6c647f425e05..67745d1d4c5d 100644 +--- a/net/mac80211/tdls.c ++++ b/net/mac80211/tdls.c +@@ -1992,3 +1992,26 @@ void ieee80211_tdls_chsw_work(struct work_struct *wk) + } + rtnl_unlock(); + } ++ ++void ieee80211_tdls_handle_disconnect(struct ieee80211_sub_if_data *sdata, ++ const u8 *peer, u16 reason) ++{ ++ struct ieee80211_sta *sta; ++ ++ rcu_read_lock(); ++ sta = ieee80211_find_sta(&sdata->vif, peer); ++ if (!sta || !sta->tdls) { ++ rcu_read_unlock(); ++ return; ++ } ++ rcu_read_unlock(); ++ ++ tdls_dbg(sdata, "disconnected from TDLS peer %pM (Reason: %u=%s)\n", ++ peer, reason, ++ ieee80211_get_reason_code_string(reason)); ++ ++ ieee80211_tdls_oper_request(&sdata->vif, peer, ++ NL80211_TDLS_TEARDOWN, ++ WLAN_REASON_TDLS_TEARDOWN_UNREACHABLE, ++ GFP_ATOMIC); ++} +diff --git a/net/mac80211/util.c b/net/mac80211/util.c +index 3deaa01ebee4..2558a34c9df1 100644 +--- a/net/mac80211/util.c ++++ b/net/mac80211/util.c +@@ -3523,7 +3523,9 @@ int ieee80211_check_combinations(struct ieee80211_sub_if_data *sdata, + } + + /* Always allow software iftypes */ +- if (local->hw.wiphy->software_iftypes & BIT(iftype)) { ++ if (local->hw.wiphy->software_iftypes & BIT(iftype) || ++ (iftype == NL80211_IFTYPE_AP_VLAN && ++ local->hw.wiphy->flags & WIPHY_FLAG_4ADDR_AP)) { + if (radar_detect) + return -EINVAL; + return 0; +diff --git a/net/mac80211/wpa.c b/net/mac80211/wpa.c +index 58d0b258b684..5dd48f0a4b1b 100644 +--- a/net/mac80211/wpa.c ++++ b/net/mac80211/wpa.c +@@ -1175,7 +1175,7 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx) + struct ieee80211_rx_status *status = IEEE80211_SKB_RXCB(skb); + struct ieee80211_key *key = rx->key; + struct ieee80211_mmie_16 *mmie; +- u8 aad[GMAC_AAD_LEN], mic[GMAC_MIC_LEN], ipn[6], nonce[GMAC_NONCE_LEN]; ++ u8 aad[GMAC_AAD_LEN], *mic, ipn[6], nonce[GMAC_NONCE_LEN]; + struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; + + if (!ieee80211_is_mgmt(hdr->frame_control)) +@@ -1206,13 +1206,18 @@ ieee80211_crypto_aes_gmac_decrypt(struct ieee80211_rx_data *rx) + memcpy(nonce, hdr->addr2, ETH_ALEN); + memcpy(nonce + ETH_ALEN, ipn, 6); + ++ mic = kmalloc(GMAC_MIC_LEN, GFP_ATOMIC); ++ if (!mic) ++ return RX_DROP_UNUSABLE; + if (ieee80211_aes_gmac(key->u.aes_gmac.tfm, aad, nonce, + skb->data + 24, skb->len - 24, + mic) < 0 || + crypto_memneq(mic, mmie->mic, sizeof(mmie->mic))) { + key->u.aes_gmac.icverrors++; ++ kfree(mic); + return RX_DROP_UNUSABLE; + } ++ kfree(mic); + } + + memcpy(key->u.aes_gmac.rx_pn, ipn, 6); +diff --git a/net/wireless/core.c b/net/wireless/core.c +index a88551f3bc43..2a46ec3cb72c 100644 +--- a/net/wireless/core.c ++++ b/net/wireless/core.c +@@ -498,7 +498,7 @@ use_default_name: + &rdev->rfkill_ops, rdev); + + if (!rdev->rfkill) { +- kfree(rdev); ++ wiphy_free(&rdev->wiphy); + return NULL; + } + +@@ -1335,8 +1335,12 @@ static int cfg80211_netdev_notifier_call(struct notifier_block *nb, + } + break; + case NETDEV_PRE_UP: +- if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype))) ++ if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)) && ++ !(wdev->iftype == NL80211_IFTYPE_AP_VLAN && ++ rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP && ++ wdev->use_4addr)) + return notifier_from_errno(-EOPNOTSUPP); ++ + if (rfkill_blocked(rdev->rfkill)) + return notifier_from_errno(-ERFKILL); + break; +diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c +index c6711ead5e59..8e2f03ab4cc9 100644 +--- a/net/wireless/nl80211.c ++++ b/net/wireless/nl80211.c +@@ -3191,8 +3191,7 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) + return -EINVAL; + } + +- if (!rdev->ops->add_virtual_intf || +- !(rdev->wiphy.interface_modes & (1 << type))) ++ if (!rdev->ops->add_virtual_intf) + return -EOPNOTSUPP; + + if ((type == NL80211_IFTYPE_P2P_DEVICE || type == NL80211_IFTYPE_NAN || +@@ -3211,6 +3210,11 @@ static int nl80211_new_interface(struct sk_buff *skb, struct genl_info *info) + return err; + } + ++ if (!(rdev->wiphy.interface_modes & (1 << type)) && ++ !(type == NL80211_IFTYPE_AP_VLAN && params.use_4addr && ++ rdev->wiphy.flags & WIPHY_FLAG_4ADDR_AP)) ++ return -EOPNOTSUPP; ++ + err = nl80211_parse_mon_options(rdev, type, info, ¶ms); + if (err < 0) + return err; +@@ -4607,8 +4611,10 @@ static int nl80211_send_station(struct sk_buff *msg, u32 cmd, u32 portid, + struct nlattr *sinfoattr, *bss_param; + + hdr = nl80211hdr_put(msg, portid, seq, flags, cmd); +- if (!hdr) ++ if (!hdr) { ++ cfg80211_sinfo_release_content(sinfo); + return -1; ++ } + + if (nla_put_u32(msg, NL80211_ATTR_IFINDEX, dev->ifindex) || + nla_put(msg, NL80211_ATTR_MAC, ETH_ALEN, mac_addr) || +diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl +index 34414c6efad6..a2c9e7f98e06 100755 +--- a/scripts/checkstack.pl ++++ b/scripts/checkstack.pl +@@ -46,7 +46,7 @@ my (@stack, $re, $dre, $x, $xs, $funcre); + $x = "[0-9a-f]"; # hex character + $xs = "[0-9a-f ]"; # hex character or space + $funcre = qr/^$x* <(.*)>:$/; +- if ($arch eq 'aarch64') { ++ if ($arch =~ '^(aarch|arm)64$') { + #ffffffc0006325cc: a9bb7bfd stp x29, x30, [sp, #-80]! + $re = qr/^.*stp.*sp, \#-([0-9]{1,8})\]\!/o; + } elsif ($arch eq 'arm') { +diff --git a/security/apparmor/include/policy.h b/security/apparmor/include/policy.h +index ab64c6b5db5a..28c098fb6208 100644 +--- a/security/apparmor/include/policy.h ++++ b/security/apparmor/include/policy.h +@@ -214,7 +214,16 @@ static inline struct aa_profile *aa_get_newest_profile(struct aa_profile *p) + return labels_profile(aa_get_newest_label(&p->label)); + } + +-#define PROFILE_MEDIATES(P, T) ((P)->policy.start[(unsigned char) (T)]) ++static inline unsigned int PROFILE_MEDIATES(struct aa_profile *profile, ++ unsigned char class) ++{ ++ if (class <= AA_CLASS_LAST) ++ return profile->policy.start[class]; ++ else ++ return aa_dfa_match_len(profile->policy.dfa, ++ profile->policy.start[0], &class, 1); ++} ++ + static inline unsigned int PROFILE_MEDIATES_AF(struct aa_profile *profile, + u16 AF) { + unsigned int state = PROFILE_MEDIATES(profile, AA_CLASS_NET); +diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c +index 21cb384d712a..088ea2ac8570 100644 +--- a/security/apparmor/policy_unpack.c ++++ b/security/apparmor/policy_unpack.c +@@ -276,7 +276,7 @@ static bool unpack_nameX(struct aa_ext *e, enum aa_code code, const char *name) + char *tag = NULL; + size_t size = unpack_u16_chunk(e, &tag); + /* if a name is specified it must match. otherwise skip tag */ +- if (name && (!size || strcmp(name, tag))) ++ if (name && (!size || tag[size-1] != '\0' || strcmp(name, tag))) + goto fail; + } else if (name) { + /* if a name is specified and there is no name tag fail */ +diff --git a/tools/objtool/check.c b/tools/objtool/check.c +index 02a47e365e52..ecf5fc77f50b 100644 +--- a/tools/objtool/check.c ++++ b/tools/objtool/check.c +@@ -839,7 +839,7 @@ static int add_switch_table(struct objtool_file *file, struct instruction *insn, + struct symbol *pfunc = insn->func->pfunc; + unsigned int prev_offset = 0; + +- list_for_each_entry_from(rela, &file->rodata->rela->rela_list, list) { ++ list_for_each_entry_from(rela, &table->rela_sec->rela_list, list) { + if (rela == next_table) + break; + +@@ -929,6 +929,7 @@ static struct rela *find_switch_table(struct objtool_file *file, + { + struct rela *text_rela, *rodata_rela; + struct instruction *orig_insn = insn; ++ struct section *rodata_sec; + unsigned long table_offset; + + /* +@@ -956,10 +957,13 @@ static struct rela *find_switch_table(struct objtool_file *file, + /* look for a relocation which references .rodata */ + text_rela = find_rela_by_dest_range(insn->sec, insn->offset, + insn->len); +- if (!text_rela || text_rela->sym != file->rodata->sym) ++ if (!text_rela || text_rela->sym->type != STT_SECTION || ++ !text_rela->sym->sec->rodata) + continue; + + table_offset = text_rela->addend; ++ rodata_sec = text_rela->sym->sec; ++ + if (text_rela->type == R_X86_64_PC32) + table_offset += 4; + +@@ -967,10 +971,10 @@ static struct rela *find_switch_table(struct objtool_file *file, + * Make sure the .rodata address isn't associated with a + * symbol. gcc jump tables are anonymous data. + */ +- if (find_symbol_containing(file->rodata, table_offset)) ++ if (find_symbol_containing(rodata_sec, table_offset)) + continue; + +- rodata_rela = find_rela_by_dest(file->rodata, table_offset); ++ rodata_rela = find_rela_by_dest(rodata_sec, table_offset); + if (rodata_rela) { + /* + * Use of RIP-relative switch jumps is quite rare, and +@@ -1055,7 +1059,7 @@ static int add_switch_table_alts(struct objtool_file *file) + struct symbol *func; + int ret; + +- if (!file->rodata || !file->rodata->rela) ++ if (!file->rodata) + return 0; + + for_each_sec(file, sec) { +@@ -1201,10 +1205,33 @@ static int read_retpoline_hints(struct objtool_file *file) + return 0; + } + ++static void mark_rodata(struct objtool_file *file) ++{ ++ struct section *sec; ++ bool found = false; ++ ++ /* ++ * This searches for the .rodata section or multiple .rodata.func_name ++ * sections if -fdata-sections is being used. The .str.1.1 and .str.1.8 ++ * rodata sections are ignored as they don't contain jump tables. ++ */ ++ for_each_sec(file, sec) { ++ if (!strncmp(sec->name, ".rodata", 7) && ++ !strstr(sec->name, ".str1.")) { ++ sec->rodata = true; ++ found = true; ++ } ++ } ++ ++ file->rodata = found; ++} ++ + static int decode_sections(struct objtool_file *file) + { + int ret; + ++ mark_rodata(file); ++ + ret = decode_instructions(file); + if (ret) + return ret; +@@ -2176,7 +2203,6 @@ int check(const char *_objname, bool orc) + INIT_LIST_HEAD(&file.insn_list); + hash_init(file.insn_hash); + file.whitelist = find_section_by_name(file.elf, ".discard.func_stack_frame_non_standard"); +- file.rodata = find_section_by_name(file.elf, ".rodata"); + file.c_file = find_section_by_name(file.elf, ".comment"); + file.ignore_unreachables = no_unreachable; + file.hints = false; +diff --git a/tools/objtool/check.h b/tools/objtool/check.h +index 95700a2bcb7c..e6e8a655b556 100644 +--- a/tools/objtool/check.h ++++ b/tools/objtool/check.h +@@ -60,8 +60,8 @@ struct objtool_file { + struct elf *elf; + struct list_head insn_list; + DECLARE_HASHTABLE(insn_hash, 16); +- struct section *rodata, *whitelist; +- bool ignore_unreachables, c_file, hints; ++ struct section *whitelist; ++ bool ignore_unreachables, c_file, hints, rodata; + }; + + int check(const char *objname, bool orc); +diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c +index b75d004f6482..abed594a9653 100644 +--- a/tools/objtool/elf.c ++++ b/tools/objtool/elf.c +@@ -390,6 +390,7 @@ static int read_relas(struct elf *elf) + rela->offset = rela->rela.r_offset; + symndx = GELF_R_SYM(rela->rela.r_info); + rela->sym = find_symbol_by_index(elf, symndx); ++ rela->rela_sec = sec; + if (!rela->sym) { + WARN("can't find rela entry symbol %d for %s", + symndx, sec->name); +diff --git a/tools/objtool/elf.h b/tools/objtool/elf.h +index de5cd2ddded9..bc97ed86b9cd 100644 +--- a/tools/objtool/elf.h ++++ b/tools/objtool/elf.h +@@ -48,7 +48,7 @@ struct section { + char *name; + int idx; + unsigned int len; +- bool changed, text; ++ bool changed, text, rodata; + }; + + struct symbol { +@@ -68,6 +68,7 @@ struct rela { + struct list_head list; + struct hlist_node hash; + GElf_Rela rela; ++ struct section *rela_sec; + struct symbol *sym; + unsigned int type; + unsigned long offset; +diff --git a/tools/testing/selftests/cgroup/test_core.c b/tools/testing/selftests/cgroup/test_core.c +index be59f9c34ea2..79053a4f4783 100644 +--- a/tools/testing/selftests/cgroup/test_core.c ++++ b/tools/testing/selftests/cgroup/test_core.c +@@ -198,7 +198,7 @@ static int test_cgcore_no_internal_process_constraint_on_threads(const char *roo + char *parent = NULL, *child = NULL; + + if (cg_read_strstr(root, "cgroup.controllers", "cpu") || +- cg_read_strstr(root, "cgroup.subtree_control", "cpu")) { ++ cg_write(root, "cgroup.subtree_control", "+cpu")) { + ret = KSFT_SKIP; + goto cleanup; + } +@@ -376,6 +376,11 @@ int main(int argc, char *argv[]) + + if (cg_find_unified_root(root, sizeof(root))) + ksft_exit_skip("cgroup v2 isn't mounted\n"); ++ ++ if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) ++ if (cg_write(root, "cgroup.subtree_control", "+memory")) ++ ksft_exit_skip("Failed to set memory controller\n"); ++ + for (i = 0; i < ARRAY_SIZE(tests); i++) { + switch (tests[i].fn(root)) { + case KSFT_PASS: +diff --git a/tools/testing/selftests/cgroup/test_memcontrol.c b/tools/testing/selftests/cgroup/test_memcontrol.c +index 6f339882a6ca..c19a97dd02d4 100644 +--- a/tools/testing/selftests/cgroup/test_memcontrol.c ++++ b/tools/testing/selftests/cgroup/test_memcontrol.c +@@ -1205,6 +1205,10 @@ int main(int argc, char **argv) + if (cg_read_strstr(root, "cgroup.controllers", "memory")) + ksft_exit_skip("memory controller isn't available\n"); + ++ if (cg_read_strstr(root, "cgroup.subtree_control", "memory")) ++ if (cg_write(root, "cgroup.subtree_control", "+memory")) ++ ksft_exit_skip("Failed to set memory controller\n"); ++ + for (i = 0; i < ARRAY_SIZE(tests); i++) { + switch (tests[i].fn(root)) { + case KSFT_PASS: +diff --git a/tools/testing/selftests/vm/Makefile b/tools/testing/selftests/vm/Makefile +index dc68340a6a96..2cf3dc49bd03 100644 +--- a/tools/testing/selftests/vm/Makefile ++++ b/tools/testing/selftests/vm/Makefile +@@ -24,6 +24,8 @@ TEST_GEN_FILES += virtual_address_range + + TEST_PROGS := run_vmtests + ++TEST_FILES := test_vmalloc.sh ++ + KSFT_KHDR_INSTALL := 1 + include ../lib.mk +