commit:     03f2016758af3bd50343b4ca76cb5d479509e297
Author:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 22 14:44:21 2020 +0000
Commit:     Mike Pagano <mpagano <AT> gentoo <DOT> org>
CommitDate: Mon Jun 22 14:44:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/linux-patches.git/commit/?id=03f20167

Linux patch 4.9.228

Signed-off-by: Mike Pagano <mpagano <AT> gentoo.org>

 0000_README              |    4 +
 1227_linux-4.9.228.patch | 4265 ++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 4269 insertions(+)

diff --git a/0000_README b/0000_README
index 5270d46..f7c5f42 100644
--- a/0000_README
+++ b/0000_README
@@ -951,6 +951,10 @@ Patch:  1226_linux-4.9.227.patch
 From:   http://www.kernel.org
 Desc:   Linux 4.9.227
 
+Patch:  1227_linux-4.9.228.patch
+From:   http://www.kernel.org
+Desc:   Linux 4.9.228
+
 Patch:  1500_XATTR_USER_PREFIX.patch
 From:   https://bugs.gentoo.org/show_bug.cgi?id=470644
 Desc:   Support for namespace user.pax.* on tmpfs.

diff --git a/1227_linux-4.9.228.patch b/1227_linux-4.9.228.patch
new file mode 100644
index 0000000..9d94f31
--- /dev/null
+++ b/1227_linux-4.9.228.patch
@@ -0,0 +1,4265 @@
+diff --git 
a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt 
b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
+index b6a7e7397b8b..b944fe067188 100644
+--- a/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
++++ b/Documentation/devicetree/bindings/display/mediatek/mediatek,dpi.txt
+@@ -16,6 +16,9 @@ Required properties:
+   Documentation/devicetree/bindings/graph.txt. This port should be connected
+   to the input port of an attached HDMI or LVDS encoder chip.
+ 
++Optional properties:
++- pinctrl-names: Contain "default" and "sleep".
++
+ Example:
+ 
+ dpi0: dpi@1401d000 {
+@@ -26,6 +29,9 @@ dpi0: dpi@1401d000 {
+                <&mmsys CLK_MM_DPI_ENGINE>,
+                <&apmixedsys CLK_APMIXED_TVDPLL>;
+       clock-names = "pixel", "engine", "pll";
++      pinctrl-names = "default", "sleep";
++      pinctrl-0 = <&dpi_pin_func>;
++      pinctrl-1 = <&dpi_pin_idle>;
+ 
+       port {
+               dpi0_out: endpoint {
+diff --git a/Documentation/virtual/kvm/api.txt 
b/Documentation/virtual/kvm/api.txt
+index d1908e50b506..b8f5bf2a890a 100644
+--- a/Documentation/virtual/kvm/api.txt
++++ b/Documentation/virtual/kvm/api.txt
+@@ -3534,9 +3534,11 @@ EOI was received.
+ #define KVM_EXIT_HYPERV_SYNIC          1
+ #define KVM_EXIT_HYPERV_HCALL          2
+                       __u32 type;
++                      __u32 pad1;
+                       union {
+                               struct {
+                                       __u32 msr;
++                                      __u32 pad2;
+                                       __u64 control;
+                                       __u64 evt_page;
+                                       __u64 msg_page;
+diff --git a/Makefile b/Makefile
+index 6c3c6e193621..af23d7b67442 100644
+--- a/Makefile
++++ b/Makefile
+@@ -1,6 +1,6 @@
+ VERSION = 4
+ PATCHLEVEL = 9
+-SUBLEVEL = 227
++SUBLEVEL = 228
+ EXTRAVERSION =
+ NAME = Roaring Lionus
+ 
+@@ -313,12 +313,8 @@ KBUILD_MODULES :=
+ KBUILD_BUILTIN := 1
+ 
+ # If we have only "make modules", don't compile built-in objects.
+-# When we're building modules with modversions, we need to consider
+-# the built-in objects during the descend as well, in order to
+-# make sure the checksums are up to date before we record them.
+-
+ ifeq ($(MAKECMDGOALS),modules)
+-  KBUILD_BUILTIN := $(if $(CONFIG_MODVERSIONS),1)
++  KBUILD_BUILTIN :=
+ endif
+ 
+ # If we have "make <whatever> modules", compile modules
+@@ -1237,6 +1233,13 @@ ifdef CONFIG_MODULES
+ 
+ all: modules
+ 
++# When we're building modules with modversions, we need to consider
++# the built-in objects during the descend as well, in order to
++# make sure the checksums are up to date before we record them.
++ifdef CONFIG_MODVERSIONS
++  KBUILD_BUILTIN := 1
++endif
++
+ # Build modules
+ #
+ # A module can be listed more than once in obj-m resulting in
+diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
+index ae738a6319f6..364985c96a92 100644
+--- a/arch/arm/kernel/ptrace.c
++++ b/arch/arm/kernel/ptrace.c
+@@ -227,8 +227,8 @@ static struct undef_hook arm_break_hook = {
+ };
+ 
+ static struct undef_hook thumb_break_hook = {
+-      .instr_mask     = 0xffff,
+-      .instr_val      = 0xde01,
++      .instr_mask     = 0xffffffff,
++      .instr_val      = 0x0000de01,
+       .cpsr_mask      = PSR_T_BIT,
+       .cpsr_val       = PSR_T_BIT,
+       .fn             = break_trap,
+diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c
+index e01cbca196b5..a67fcf7a5643 100644
+--- a/arch/arm/mach-tegra/tegra.c
++++ b/arch/arm/mach-tegra/tegra.c
+@@ -137,8 +137,8 @@ static const char * const tegra_dt_board_compat[] = {
+ };
+ 
+ DT_MACHINE_START(TEGRA_DT, "NVIDIA Tegra SoC (Flattened Device Tree)")
+-      .l2c_aux_val    = 0x3c400001,
+-      .l2c_aux_mask   = 0xc20fc3fe,
++      .l2c_aux_val    = 0x3c400000,
++      .l2c_aux_mask   = 0xc20fc3ff,
+       .smp            = smp_ops(tegra_smp_ops),
+       .map_io         = tegra_map_common_io,
+       .init_early     = tegra_init_early,
+diff --git a/arch/arm/mm/proc-macros.S b/arch/arm/mm/proc-macros.S
+index f8bb65032b79..796e8f675a93 100644
+--- a/arch/arm/mm/proc-macros.S
++++ b/arch/arm/mm/proc-macros.S
+@@ -4,6 +4,7 @@
+  *  VMA_VM_FLAGS
+  *  VM_EXEC
+  */
++#include <linux/const.h>
+ #include <asm/asm-offsets.h>
+ #include <asm/thread_info.h>
+ 
+@@ -34,7 +35,7 @@
+  * act_mm - get current->active_mm
+  */
+       .macro  act_mm, rd
+-      bic     \rd, sp, #8128
++      bic     \rd, sp, #(THREAD_SIZE - 1) & ~63
+       bic     \rd, \rd, #63
+       ldr     \rd, [\rd, #TI_TASK]
+       ldr     \rd, [\rd, #TSK_ACTIVE_MM]
+diff --git a/arch/arm64/include/asm/kvm_host.h 
b/arch/arm64/include/asm/kvm_host.h
+index 4cdfbd01b2de..367ebb48170b 100644
+--- a/arch/arm64/include/asm/kvm_host.h
++++ b/arch/arm64/include/asm/kvm_host.h
+@@ -290,8 +290,10 @@ struct kvm_vcpu_arch {
+  * CP14 and CP15 live in the same array, as they are backed by the
+  * same system registers.
+  */
+-#define vcpu_cp14(v,r)                ((v)->arch.ctxt.copro[(r)])
+-#define vcpu_cp15(v,r)                ((v)->arch.ctxt.copro[(r)])
++#define CPx_BIAS              IS_ENABLED(CONFIG_CPU_BIG_ENDIAN)
++
++#define vcpu_cp14(v,r)                ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
++#define vcpu_cp15(v,r)                ((v)->arch.ctxt.copro[(r) ^ CPx_BIAS])
+ 
+ #ifdef CONFIG_CPU_BIG_ENDIAN
+ #define vcpu_cp15_64_high(v,r)        vcpu_cp15((v),(r))
+diff --git a/arch/m68k/include/asm/mac_via.h b/arch/m68k/include/asm/mac_via.h
+index 53c632c85b03..dff6db19ae4d 100644
+--- a/arch/m68k/include/asm/mac_via.h
++++ b/arch/m68k/include/asm/mac_via.h
+@@ -256,6 +256,7 @@ extern int rbv_present,via_alt_mapping;
+ 
+ struct irq_desc;
+ 
++extern void via_l2_flush(int writeback);
+ extern void via_register_interrupts(void);
+ extern void via_irq_enable(int);
+ extern void via_irq_disable(int);
+diff --git a/arch/m68k/mac/config.c b/arch/m68k/mac/config.c
+index e46895316eb0..dcf18e1ca0bb 100644
+--- a/arch/m68k/mac/config.c
++++ b/arch/m68k/mac/config.c
+@@ -61,7 +61,6 @@ extern void iop_preinit(void);
+ extern void iop_init(void);
+ extern void via_init(void);
+ extern void via_init_clock(irq_handler_t func);
+-extern void via_flush_cache(void);
+ extern void oss_init(void);
+ extern void psc_init(void);
+ extern void baboon_init(void);
+@@ -132,21 +131,6 @@ int __init mac_parse_bootinfo(const struct bi_record 
*record)
+       return unknown;
+ }
+ 
+-/*
+- * Flip into 24bit mode for an instant - flushes the L2 cache card. We
+- * have to disable interrupts for this. Our IRQ handlers will crap
+- * themselves if they take an IRQ in 24bit mode!
+- */
+-
+-static void mac_cache_card_flush(int writeback)
+-{
+-      unsigned long flags;
+-
+-      local_irq_save(flags);
+-      via_flush_cache();
+-      local_irq_restore(flags);
+-}
+-
+ void __init config_mac(void)
+ {
+       if (!MACH_IS_MAC)
+@@ -179,9 +163,8 @@ void __init config_mac(void)
+        * not.
+        */
+ 
+-      if (macintosh_config->ident == MAC_MODEL_IICI
+-          || macintosh_config->ident == MAC_MODEL_IIFX)
+-              mach_l2_flush = mac_cache_card_flush;
++      if (macintosh_config->ident == MAC_MODEL_IICI)
++              mach_l2_flush = via_l2_flush;
+ }
+ 
+ 
+diff --git a/arch/m68k/mac/via.c b/arch/m68k/mac/via.c
+index a435aced6e43..35382c1b563f 100644
+--- a/arch/m68k/mac/via.c
++++ b/arch/m68k/mac/via.c
+@@ -299,10 +299,14 @@ void via_debug_dump(void)
+  * the system into 24-bit mode for an instant.
+  */
+ 
+-void via_flush_cache(void)
++void via_l2_flush(int writeback)
+ {
++      unsigned long flags;
++
++      local_irq_save(flags);
+       via2[gBufB] &= ~VIA2B_vMode32;
+       via2[gBufB] |= VIA2B_vMode32;
++      local_irq_restore(flags);
+ }
+ 
+ /*
+diff --git a/arch/mips/Makefile b/arch/mips/Makefile
+index 1a6bac7b076f..25f3bfef9b39 100644
+--- a/arch/mips/Makefile
++++ b/arch/mips/Makefile
+@@ -256,12 +256,23 @@ ifdef CONFIG_64BIT
+   endif
+ endif
+ 
++# When linking a 32-bit executable the LLVM linker cannot cope with a
++# 32-bit load address that has been sign-extended to 64 bits.  Simply
++# remove the upper 32 bits then, as it is safe to do so with other
++# linkers.
++ifdef CONFIG_64BIT
++      load-ld                 = $(load-y)
++else
++      load-ld                 = $(subst 0xffffffff,0x,$(load-y))
++endif
++
+ KBUILD_AFLAGS += $(cflags-y)
+ KBUILD_CFLAGS += $(cflags-y)
+-KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y)
++KBUILD_CPPFLAGS += -DVMLINUX_LOAD_ADDRESS=$(load-y) 
-DLINKER_LOAD_ADDRESS=$(load-ld)
+ KBUILD_CPPFLAGS += -DDATAOFFSET=$(if $(dataoffset-y),$(dataoffset-y),0)
+ 
+ bootvars-y    = VMLINUX_LOAD_ADDRESS=$(load-y) \
++                LINKER_LOAD_ADDRESS=$(load-ld) \
+                 VMLINUX_ENTRY_ADDRESS=$(entry-y) \
+                 PLATFORM="$(platform-y)"
+ ifdef CONFIG_32BIT
+diff --git a/arch/mips/boot/compressed/Makefile 
b/arch/mips/boot/compressed/Makefile
+index 2f77e250b91d..0fa91c981658 100644
+--- a/arch/mips/boot/compressed/Makefile
++++ b/arch/mips/boot/compressed/Makefile
+@@ -87,7 +87,7 @@ ifneq ($(zload-y),)
+ VMLINUZ_LOAD_ADDRESS := $(zload-y)
+ else
+ VMLINUZ_LOAD_ADDRESS = $(shell $(obj)/calc_vmlinuz_load_addr \
+-              $(obj)/vmlinux.bin $(VMLINUX_LOAD_ADDRESS))
++              $(obj)/vmlinux.bin $(LINKER_LOAD_ADDRESS))
+ endif
+ 
+ vmlinuzobjs-y += $(obj)/piggy.o
+diff --git a/arch/mips/include/asm/kvm_host.h 
b/arch/mips/include/asm/kvm_host.h
+index bebec370324f..22573b4f25b6 100644
+--- a/arch/mips/include/asm/kvm_host.h
++++ b/arch/mips/include/asm/kvm_host.h
+@@ -243,8 +243,12 @@ enum emulation_result {
+ #define MIPS3_PG_SHIFT                6
+ #define MIPS3_PG_FRAME                0x3fffffc0
+ 
++#if defined(CONFIG_64BIT)
++#define VPN2_MASK             GENMASK(cpu_vmbits - 1, 13)
++#else
+ #define VPN2_MASK             0xffffe000
+-#define KVM_ENTRYHI_ASID      MIPS_ENTRYHI_ASID
++#endif
++#define KVM_ENTRYHI_ASID      cpu_asid_mask(&boot_cpu_data)
+ #define TLB_IS_GLOBAL(x)      ((x).tlb_lo[0] & (x).tlb_lo[1] & ENTRYLO_G)
+ #define TLB_VPN2(x)           ((x).tlb_hi & VPN2_MASK)
+ #define TLB_ASID(x)           ((x).tlb_hi & KVM_ENTRYHI_ASID)
+diff --git a/arch/mips/kernel/genex.S b/arch/mips/kernel/genex.S
+index ae810da4d499..59ed811eb32a 100644
+--- a/arch/mips/kernel/genex.S
++++ b/arch/mips/kernel/genex.S
+@@ -429,20 +429,20 @@ NESTED(nmi_handler, PT_SIZE, sp)
+       .endm
+ 
+       .macro  __build_clear_fpe
++      CLI
++      TRACE_IRQS_OFF
+       .set    push
+       /* gas fails to assemble cfc1 for some archs (octeon).*/ \
+       .set    mips1
+       SET_HARDFLOAT
+       cfc1    a1, fcr31
+       .set    pop
+-      CLI
+-      TRACE_IRQS_OFF
+       .endm
+ 
+       .macro  __build_clear_msa_fpe
+-      _cfcmsa a1, MSA_CSR
+       CLI
+       TRACE_IRQS_OFF
++      _cfcmsa a1, MSA_CSR
+       .endm
+ 
+       .macro  __build_clear_ade
+diff --git a/arch/mips/kernel/mips-cm.c b/arch/mips/kernel/mips-cm.c
+index 60177a612cb1..df65516778a2 100644
+--- a/arch/mips/kernel/mips-cm.c
++++ b/arch/mips/kernel/mips-cm.c
+@@ -123,9 +123,9 @@ static char *cm2_causes[32] = {
+       "COH_RD_ERR", "MMIO_WR_ERR", "MMIO_RD_ERR", "0x07",
+       "0x08", "0x09", "0x0a", "0x0b",
+       "0x0c", "0x0d", "0x0e", "0x0f",
+-      "0x10", "0x11", "0x12", "0x13",
+-      "0x14", "0x15", "0x16", "INTVN_WR_ERR",
+-      "INTVN_RD_ERR", "0x19", "0x1a", "0x1b",
++      "0x10", "INTVN_WR_ERR", "INTVN_RD_ERR", "0x13",
++      "0x14", "0x15", "0x16", "0x17",
++      "0x18", "0x19", "0x1a", "0x1b",
+       "0x1c", "0x1d", "0x1e", "0x1f"
+ };
+ 
+diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c
+index 7cc1d29334ee..2c3b89a65317 100644
+--- a/arch/mips/kernel/setup.c
++++ b/arch/mips/kernel/setup.c
+@@ -847,7 +847,17 @@ static void __init arch_mem_init(char **cmdline_p)
+                               BOOTMEM_DEFAULT);
+ #endif
+       device_tree_init();
++
++      /*
++       * In order to reduce the possibility of kernel panic when failed to
++       * get IO TLB memory under CONFIG_SWIOTLB, it is better to allocate
++       * low memory as small as possible before plat_swiotlb_setup(), so
++       * make sparse_init() using top-down allocation.
++       */
++      memblock_set_bottom_up(false);
+       sparse_init();
++      memblock_set_bottom_up(true);
++
+       plat_swiotlb_setup();
+ 
+       dma_contiguous_reserve(PFN_PHYS(max_low_pfn));
+diff --git a/arch/mips/kernel/time.c b/arch/mips/kernel/time.c
+index a7f81261c781..b7f7e08e1ce4 100644
+--- a/arch/mips/kernel/time.c
++++ b/arch/mips/kernel/time.c
+@@ -22,12 +22,82 @@
+ #include <linux/smp.h>
+ #include <linux/spinlock.h>
+ #include <linux/export.h>
++#include <linux/cpufreq.h>
++#include <linux/delay.h>
+ 
+ #include <asm/cpu-features.h>
+ #include <asm/cpu-type.h>
+ #include <asm/div64.h>
+ #include <asm/time.h>
+ 
++#ifdef CONFIG_CPU_FREQ
++
++static DEFINE_PER_CPU(unsigned long, pcp_lpj_ref);
++static DEFINE_PER_CPU(unsigned long, pcp_lpj_ref_freq);
++static unsigned long glb_lpj_ref;
++static unsigned long glb_lpj_ref_freq;
++
++static int cpufreq_callback(struct notifier_block *nb,
++                          unsigned long val, void *data)
++{
++      struct cpufreq_freqs *freq = data;
++      struct cpumask *cpus = freq->policy->cpus;
++      unsigned long lpj;
++      int cpu;
++
++      /*
++       * Skip lpj numbers adjustment if the CPU-freq transition is safe for
++       * the loops delay. (Is this possible?)
++       */
++      if (freq->flags & CPUFREQ_CONST_LOOPS)
++              return NOTIFY_OK;
++
++      /* Save the initial values of the lpjes for future scaling. */
++      if (!glb_lpj_ref) {
++              glb_lpj_ref = boot_cpu_data.udelay_val;
++              glb_lpj_ref_freq = freq->old;
++
++              for_each_online_cpu(cpu) {
++                      per_cpu(pcp_lpj_ref, cpu) =
++                              cpu_data[cpu].udelay_val;
++                      per_cpu(pcp_lpj_ref_freq, cpu) = freq->old;
++              }
++      }
++
++      /*
++       * Adjust global lpj variable and per-CPU udelay_val number in
++       * accordance with the new CPU frequency.
++       */
++      if ((val == CPUFREQ_PRECHANGE  && freq->old < freq->new) ||
++          (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) {
++              loops_per_jiffy = cpufreq_scale(glb_lpj_ref,
++                                              glb_lpj_ref_freq,
++                                              freq->new);
++
++              for_each_cpu(cpu, cpus) {
++                      lpj = cpufreq_scale(per_cpu(pcp_lpj_ref, cpu),
++                                          per_cpu(pcp_lpj_ref_freq, cpu),
++                                          freq->new);
++                      cpu_data[cpu].udelay_val = (unsigned int)lpj;
++              }
++      }
++
++      return NOTIFY_OK;
++}
++
++static struct notifier_block cpufreq_notifier = {
++      .notifier_call  = cpufreq_callback,
++};
++
++static int __init register_cpufreq_notifier(void)
++{
++      return cpufreq_register_notifier(&cpufreq_notifier,
++                                       CPUFREQ_TRANSITION_NOTIFIER);
++}
++core_initcall(register_cpufreq_notifier);
++
++#endif /* CONFIG_CPU_FREQ */
++
+ /*
+  * forward reference
+  */
+diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
+index 2d965d91fee4..612b2b301280 100644
+--- a/arch/mips/kernel/vmlinux.lds.S
++++ b/arch/mips/kernel/vmlinux.lds.S
+@@ -49,7 +49,7 @@ SECTIONS
+       /* . = 0xa800000000300000; */
+       . = 0xffffffff80300000;
+ #endif
+-      . = VMLINUX_LOAD_ADDRESS;
++      . = LINKER_LOAD_ADDRESS;
+       /* read-only */
+       _text = .;      /* Text and read-only data */
+       .text : {
+diff --git a/arch/powerpc/platforms/cell/spufs/file.c 
b/arch/powerpc/platforms/cell/spufs/file.c
+index 06254467e4dd..f12b00a056cb 100644
+--- a/arch/powerpc/platforms/cell/spufs/file.c
++++ b/arch/powerpc/platforms/cell/spufs/file.c
+@@ -2044,8 +2044,9 @@ static ssize_t __spufs_mbox_info_read(struct spu_context 
*ctx,
+ static ssize_t spufs_mbox_info_read(struct file *file, char __user *buf,
+                                  size_t len, loff_t *pos)
+ {
+-      int ret;
+       struct spu_context *ctx = file->private_data;
++      u32 stat, data;
++      int ret;
+ 
+       if (!access_ok(VERIFY_WRITE, buf, len))
+               return -EFAULT;
+@@ -2054,11 +2055,16 @@ static ssize_t spufs_mbox_info_read(struct file *file, 
char __user *buf,
+       if (ret)
+               return ret;
+       spin_lock(&ctx->csa.register_lock);
+-      ret = __spufs_mbox_info_read(ctx, buf, len, pos);
++      stat = ctx->csa.prob.mb_stat_R;
++      data = ctx->csa.prob.pu_mb_R;
+       spin_unlock(&ctx->csa.register_lock);
+       spu_release_saved(ctx);
+ 
+-      return ret;
++      /* EOF if there's no entry in the mbox */
++      if (!(stat & 0x0000ff))
++              return 0;
++
++      return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+ }
+ 
+ static const struct file_operations spufs_mbox_info_fops = {
+@@ -2085,6 +2091,7 @@ static ssize_t spufs_ibox_info_read(struct file *file, 
char __user *buf,
+                                  size_t len, loff_t *pos)
+ {
+       struct spu_context *ctx = file->private_data;
++      u32 stat, data;
+       int ret;
+ 
+       if (!access_ok(VERIFY_WRITE, buf, len))
+@@ -2094,11 +2101,16 @@ static ssize_t spufs_ibox_info_read(struct file *file, 
char __user *buf,
+       if (ret)
+               return ret;
+       spin_lock(&ctx->csa.register_lock);
+-      ret = __spufs_ibox_info_read(ctx, buf, len, pos);
++      stat = ctx->csa.prob.mb_stat_R;
++      data = ctx->csa.priv2.puint_mb_R;
+       spin_unlock(&ctx->csa.register_lock);
+       spu_release_saved(ctx);
+ 
+-      return ret;
++      /* EOF if there's no entry in the ibox */
++      if (!(stat & 0xff0000))
++              return 0;
++
++      return simple_read_from_buffer(buf, len, pos, &data, sizeof(data));
+ }
+ 
+ static const struct file_operations spufs_ibox_info_fops = {
+@@ -2107,6 +2119,11 @@ static const struct file_operations 
spufs_ibox_info_fops = {
+       .llseek  = generic_file_llseek,
+ };
+ 
++static size_t spufs_wbox_info_cnt(struct spu_context *ctx)
++{
++      return (4 - ((ctx->csa.prob.mb_stat_R & 0x00ff00) >> 8)) * sizeof(u32);
++}
++
+ static ssize_t __spufs_wbox_info_read(struct spu_context *ctx,
+                       char __user *buf, size_t len, loff_t *pos)
+ {
+@@ -2115,7 +2132,7 @@ static ssize_t __spufs_wbox_info_read(struct spu_context 
*ctx,
+       u32 wbox_stat;
+ 
+       wbox_stat = ctx->csa.prob.mb_stat_R;
+-      cnt = 4 - ((wbox_stat & 0x00ff00) >> 8);
++      cnt = spufs_wbox_info_cnt(ctx);
+       for (i = 0; i < cnt; i++) {
+               data[i] = ctx->csa.spu_mailbox_data[i];
+       }
+@@ -2128,7 +2145,8 @@ static ssize_t spufs_wbox_info_read(struct file *file, 
char __user *buf,
+                                  size_t len, loff_t *pos)
+ {
+       struct spu_context *ctx = file->private_data;
+-      int ret;
++      u32 data[ARRAY_SIZE(ctx->csa.spu_mailbox_data)];
++      int ret, count;
+ 
+       if (!access_ok(VERIFY_WRITE, buf, len))
+               return -EFAULT;
+@@ -2137,11 +2155,13 @@ static ssize_t spufs_wbox_info_read(struct file *file, 
char __user *buf,
+       if (ret)
+               return ret;
+       spin_lock(&ctx->csa.register_lock);
+-      ret = __spufs_wbox_info_read(ctx, buf, len, pos);
++      count = spufs_wbox_info_cnt(ctx);
++      memcpy(&data, &ctx->csa.spu_mailbox_data, sizeof(data));
+       spin_unlock(&ctx->csa.register_lock);
+       spu_release_saved(ctx);
+ 
+-      return ret;
++      return simple_read_from_buffer(buf, len, pos, &data,
++                              count * sizeof(u32));
+ }
+ 
+ static const struct file_operations spufs_wbox_info_fops = {
+@@ -2150,27 +2170,33 @@ static const struct file_operations 
spufs_wbox_info_fops = {
+       .llseek  = generic_file_llseek,
+ };
+ 
+-static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
+-                      char __user *buf, size_t len, loff_t *pos)
++static void spufs_get_dma_info(struct spu_context *ctx,
++              struct spu_dma_info *info)
+ {
+-      struct spu_dma_info info;
+-      struct mfc_cq_sr *qp, *spuqp;
+       int i;
+ 
+-      info.dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
+-      info.dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
+-      info.dma_info_status = ctx->csa.spu_chnldata_RW[24];
+-      info.dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
+-      info.dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
++      info->dma_info_type = ctx->csa.priv2.spu_tag_status_query_RW;
++      info->dma_info_mask = ctx->csa.lscsa->tag_mask.slot[0];
++      info->dma_info_status = ctx->csa.spu_chnldata_RW[24];
++      info->dma_info_stall_and_notify = ctx->csa.spu_chnldata_RW[25];
++      info->dma_info_atomic_command_status = ctx->csa.spu_chnldata_RW[27];
+       for (i = 0; i < 16; i++) {
+-              qp = &info.dma_info_command_data[i];
+-              spuqp = &ctx->csa.priv2.spuq[i];
++              struct mfc_cq_sr *qp = &info->dma_info_command_data[i];
++              struct mfc_cq_sr *spuqp = &ctx->csa.priv2.spuq[i];
+ 
+               qp->mfc_cq_data0_RW = spuqp->mfc_cq_data0_RW;
+               qp->mfc_cq_data1_RW = spuqp->mfc_cq_data1_RW;
+               qp->mfc_cq_data2_RW = spuqp->mfc_cq_data2_RW;
+               qp->mfc_cq_data3_RW = spuqp->mfc_cq_data3_RW;
+       }
++}
++
++static ssize_t __spufs_dma_info_read(struct spu_context *ctx,
++                      char __user *buf, size_t len, loff_t *pos)
++{
++      struct spu_dma_info info;
++
++      spufs_get_dma_info(ctx, &info);
+ 
+       return simple_read_from_buffer(buf, len, pos, &info,
+                               sizeof info);
+@@ -2180,6 +2206,7 @@ static ssize_t spufs_dma_info_read(struct file *file, 
char __user *buf,
+                             size_t len, loff_t *pos)
+ {
+       struct spu_context *ctx = file->private_data;
++      struct spu_dma_info info;
+       int ret;
+ 
+       if (!access_ok(VERIFY_WRITE, buf, len))
+@@ -2189,11 +2216,12 @@ static ssize_t spufs_dma_info_read(struct file *file, 
char __user *buf,
+       if (ret)
+               return ret;
+       spin_lock(&ctx->csa.register_lock);
+-      ret = __spufs_dma_info_read(ctx, buf, len, pos);
++      spufs_get_dma_info(ctx, &info);
+       spin_unlock(&ctx->csa.register_lock);
+       spu_release_saved(ctx);
+ 
+-      return ret;
++      return simple_read_from_buffer(buf, len, pos, &info,
++                              sizeof(info));
+ }
+ 
+ static const struct file_operations spufs_dma_info_fops = {
+@@ -2202,13 +2230,31 @@ static const struct file_operations 
spufs_dma_info_fops = {
+       .llseek = no_llseek,
+ };
+ 
++static void spufs_get_proxydma_info(struct spu_context *ctx,
++              struct spu_proxydma_info *info)
++{
++      int i;
++
++      info->proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
++      info->proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
++      info->proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
++
++      for (i = 0; i < 8; i++) {
++              struct mfc_cq_sr *qp = &info->proxydma_info_command_data[i];
++              struct mfc_cq_sr *puqp = &ctx->csa.priv2.puq[i];
++
++              qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
++              qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
++              qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
++              qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
++      }
++}
++
+ static ssize_t __spufs_proxydma_info_read(struct spu_context *ctx,
+                       char __user *buf, size_t len, loff_t *pos)
+ {
+       struct spu_proxydma_info info;
+-      struct mfc_cq_sr *qp, *puqp;
+       int ret = sizeof info;
+-      int i;
+ 
+       if (len < ret)
+               return -EINVAL;
+@@ -2216,18 +2262,7 @@ static ssize_t __spufs_proxydma_info_read(struct 
spu_context *ctx,
+       if (!access_ok(VERIFY_WRITE, buf, len))
+               return -EFAULT;
+ 
+-      info.proxydma_info_type = ctx->csa.prob.dma_querytype_RW;
+-      info.proxydma_info_mask = ctx->csa.prob.dma_querymask_RW;
+-      info.proxydma_info_status = ctx->csa.prob.dma_tagstatus_R;
+-      for (i = 0; i < 8; i++) {
+-              qp = &info.proxydma_info_command_data[i];
+-              puqp = &ctx->csa.priv2.puq[i];
+-
+-              qp->mfc_cq_data0_RW = puqp->mfc_cq_data0_RW;
+-              qp->mfc_cq_data1_RW = puqp->mfc_cq_data1_RW;
+-              qp->mfc_cq_data2_RW = puqp->mfc_cq_data2_RW;
+-              qp->mfc_cq_data3_RW = puqp->mfc_cq_data3_RW;
+-      }
++      spufs_get_proxydma_info(ctx, &info);
+ 
+       return simple_read_from_buffer(buf, len, pos, &info,
+                               sizeof info);
+@@ -2237,17 +2272,19 @@ static ssize_t spufs_proxydma_info_read(struct file 
*file, char __user *buf,
+                                  size_t len, loff_t *pos)
+ {
+       struct spu_context *ctx = file->private_data;
++      struct spu_proxydma_info info;
+       int ret;
+ 
+       ret = spu_acquire_saved(ctx);
+       if (ret)
+               return ret;
+       spin_lock(&ctx->csa.register_lock);
+-      ret = __spufs_proxydma_info_read(ctx, buf, len, pos);
++      spufs_get_proxydma_info(ctx, &info);
+       spin_unlock(&ctx->csa.register_lock);
+       spu_release_saved(ctx);
+ 
+-      return ret;
++      return simple_read_from_buffer(buf, len, pos, &info,
++                              sizeof(info));
+ }
+ 
+ static const struct file_operations spufs_proxydma_info_fops = {
+diff --git a/arch/sparc/kernel/ptrace_32.c b/arch/sparc/kernel/ptrace_32.c
+index a331fdc11a2c..396dbdea0cfa 100644
+--- a/arch/sparc/kernel/ptrace_32.c
++++ b/arch/sparc/kernel/ptrace_32.c
+@@ -45,82 +45,79 @@ enum sparc_regset {
+       REGSET_FP,
+ };
+ 
++static int regwindow32_get(struct task_struct *target,
++                         const struct pt_regs *regs,
++                         u32 *uregs)
++{
++      unsigned long reg_window = regs->u_regs[UREG_I6];
++      int size = 16 * sizeof(u32);
++
++      if (target == current) {
++              if (copy_from_user(uregs, (void __user *)reg_window, size))
++                      return -EFAULT;
++      } else {
++              if (access_process_vm(target, reg_window, uregs, size,
++                                    FOLL_FORCE) != size)
++                      return -EFAULT;
++      }
++      return 0;
++}
++
++static int regwindow32_set(struct task_struct *target,
++                         const struct pt_regs *regs,
++                         u32 *uregs)
++{
++      unsigned long reg_window = regs->u_regs[UREG_I6];
++      int size = 16 * sizeof(u32);
++
++      if (target == current) {
++              if (copy_to_user((void __user *)reg_window, uregs, size))
++                      return -EFAULT;
++      } else {
++              if (access_process_vm(target, reg_window, uregs, size,
++                                    FOLL_FORCE | FOLL_WRITE) != size)
++                      return -EFAULT;
++      }
++      return 0;
++}
++
+ static int genregs32_get(struct task_struct *target,
+                        const struct user_regset *regset,
+                        unsigned int pos, unsigned int count,
+                        void *kbuf, void __user *ubuf)
+ {
+       const struct pt_regs *regs = target->thread.kregs;
+-      unsigned long __user *reg_window;
+-      unsigned long *k = kbuf;
+-      unsigned long __user *u = ubuf;
+-      unsigned long reg;
++      u32 uregs[16];
++      int ret;
+ 
+       if (target == current)
+               flush_user_windows();
+ 
+-      pos /= sizeof(reg);
+-      count /= sizeof(reg);
+-
+-      if (kbuf) {
+-              for (; count > 0 && pos < 16; count--)
+-                      *k++ = regs->u_regs[pos++];
+-
+-              reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+-              reg_window -= 16;
+-              for (; count > 0 && pos < 32; count--) {
+-                      if (get_user(*k++, &reg_window[pos++]))
+-                              return -EFAULT;
+-              }
+-      } else {
+-              for (; count > 0 && pos < 16; count--) {
+-                      if (put_user(regs->u_regs[pos++], u++))
+-                              return -EFAULT;
+-              }
+-
+-              reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+-              reg_window -= 16;
+-              for (; count > 0 && pos < 32; count--) {
+-                      if (get_user(reg, &reg_window[pos++]) ||
+-                          put_user(reg, u++))
+-                              return -EFAULT;
+-              }
+-      }
+-      while (count > 0) {
+-              switch (pos) {
+-              case 32: /* PSR */
+-                      reg = regs->psr;
+-                      break;
+-              case 33: /* PC */
+-                      reg = regs->pc;
+-                      break;
+-              case 34: /* NPC */
+-                      reg = regs->npc;
+-                      break;
+-              case 35: /* Y */
+-                      reg = regs->y;
+-                      break;
+-              case 36: /* WIM */
+-              case 37: /* TBR */
+-                      reg = 0;
+-                      break;
+-              default:
+-                      goto finish;
+-              }
++      ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
++                                regs->u_regs,
++                                0, 16 * sizeof(u32));
++      if (ret || !count)
++              return ret;
+ 
+-              if (kbuf)
+-                      *k++ = reg;
+-              else if (put_user(reg, u++))
++      if (pos < 32 * sizeof(u32)) {
++              if (regwindow32_get(target, regs, uregs))
+                       return -EFAULT;
+-              pos++;
+-              count--;
++              ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
++                                        uregs,
++                                        16 * sizeof(u32), 32 * sizeof(u32));
++              if (ret || !count)
++                      return ret;
+       }
+-finish:
+-      pos *= sizeof(reg);
+-      count *= sizeof(reg);
+ 
+-      return user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
+-                                      38 * sizeof(reg), -1);
++      uregs[0] = regs->psr;
++      uregs[1] = regs->pc;
++      uregs[2] = regs->npc;
++      uregs[3] = regs->y;
++      uregs[4] = 0;   /* WIM */
++      uregs[5] = 0;   /* TBR */
++      return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
++                                uregs,
++                                32 * sizeof(u32), 38 * sizeof(u32));
+ }
+ 
+ static int genregs32_set(struct task_struct *target,
+@@ -129,82 +126,53 @@ static int genregs32_set(struct task_struct *target,
+                        const void *kbuf, const void __user *ubuf)
+ {
+       struct pt_regs *regs = target->thread.kregs;
+-      unsigned long __user *reg_window;
+-      const unsigned long *k = kbuf;
+-      const unsigned long __user *u = ubuf;
+-      unsigned long reg;
++      u32 uregs[16];
++      u32 psr;
++      int ret;
+ 
+       if (target == current)
+               flush_user_windows();
+ 
+-      pos /= sizeof(reg);
+-      count /= sizeof(reg);
+-
+-      if (kbuf) {
+-              for (; count > 0 && pos < 16; count--)
+-                      regs->u_regs[pos++] = *k++;
+-
+-              reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+-              reg_window -= 16;
+-              for (; count > 0 && pos < 32; count--) {
+-                      if (put_user(*k++, &reg_window[pos++]))
+-                              return -EFAULT;
+-              }
+-      } else {
+-              for (; count > 0 && pos < 16; count--) {
+-                      if (get_user(reg, u++))
+-                              return -EFAULT;
+-                      regs->u_regs[pos++] = reg;
+-              }
+-
+-              reg_window = (unsigned long __user *) regs->u_regs[UREG_I6];
+-              reg_window -= 16;
+-              for (; count > 0 && pos < 32; count--) {
+-                      if (get_user(reg, u++) ||
+-                          put_user(reg, &reg_window[pos++]))
+-                              return -EFAULT;
+-              }
+-      }
+-      while (count > 0) {
+-              unsigned long psr;
++      ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
++                               regs->u_regs,
++                               0, 16 * sizeof(u32));
++      if (ret || !count)
++              return ret;
+ 
+-              if (kbuf)
+-                      reg = *k++;
+-              else if (get_user(reg, u++))
++      if (pos < 32 * sizeof(u32)) {
++              if (regwindow32_get(target, regs, uregs))
+                       return -EFAULT;
+-
+-              switch (pos) {
+-              case 32: /* PSR */
+-                      psr = regs->psr;
+-                      psr &= ~(PSR_ICC | PSR_SYSCALL);
+-                      psr |= (reg & (PSR_ICC | PSR_SYSCALL));
+-                      regs->psr = psr;
+-                      break;
+-              case 33: /* PC */
+-                      regs->pc = reg;
+-                      break;
+-              case 34: /* NPC */
+-                      regs->npc = reg;
+-                      break;
+-              case 35: /* Y */
+-                      regs->y = reg;
+-                      break;
+-              case 36: /* WIM */
+-              case 37: /* TBR */
+-                      break;
+-              default:
+-                      goto finish;
+-              }
+-
+-              pos++;
+-              count--;
++              ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
++                                       uregs,
++                                       16 * sizeof(u32), 32 * sizeof(u32));
++              if (ret)
++                      return ret;
++              if (regwindow32_set(target, regs, uregs))
++                      return -EFAULT;
++              if (!count)
++                      return 0;
+       }
+-finish:
+-      pos *= sizeof(reg);
+-      count *= sizeof(reg);
+-
++      ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
++                               &psr,
++                               32 * sizeof(u32), 33 * sizeof(u32));
++      if (ret)
++              return ret;
++      regs->psr = (regs->psr & ~(PSR_ICC | PSR_SYSCALL)) |
++                  (psr & (PSR_ICC | PSR_SYSCALL));
++      if (!count)
++              return 0;
++      ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
++                               &regs->pc,
++                               33 * sizeof(u32), 34 * sizeof(u32));
++      if (ret || !count)
++              return ret;
++      ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
++                               &regs->y,
++                               34 * sizeof(u32), 35 * sizeof(u32));
++      if (ret || !count)
++              return ret;
+       return user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
+-                                       38 * sizeof(reg), -1);
++                                       35 * sizeof(u32), 38 * sizeof(u32));
+ }
+ 
+ static int fpregs32_get(struct task_struct *target,
+diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
+index 7037ca3b4328..0a89a0546077 100644
+--- a/arch/sparc/kernel/ptrace_64.c
++++ b/arch/sparc/kernel/ptrace_64.c
+@@ -533,19 +533,13 @@ static int genregs32_get(struct task_struct *target,
+                       for (; count > 0 && pos < 32; count--) {
+                               if (access_process_vm(target,
+                                                     (unsigned long)
+-                                                    &reg_window[pos],
++                                                    &reg_window[pos++],
+                                                     &reg, sizeof(reg),
+                                                     FOLL_FORCE)
+                                   != sizeof(reg))
+                                       return -EFAULT;
+-                              if (access_process_vm(target,
+-                                                    (unsigned long) u,
+-                                                    &reg, sizeof(reg),
+-                                                    FOLL_FORCE | FOLL_WRITE)
+-                                  != sizeof(reg))
++                              if (put_user(reg, u++))
+                                       return -EFAULT;
+-                              pos++;
+-                              u++;
+                       }
+               }
+       }
+@@ -645,12 +639,7 @@ static int genregs32_set(struct task_struct *target,
+                       }
+               } else {
+                       for (; count > 0 && pos < 32; count--) {
+-                              if (access_process_vm(target,
+-                                                    (unsigned long)
+-                                                    u,
+-                                                    &reg, sizeof(reg),
+-                                                    FOLL_FORCE)
+-                                  != sizeof(reg))
++                              if (get_user(reg, u++))
+                                       return -EFAULT;
+                               if (access_process_vm(target,
+                                                     (unsigned long)
+diff --git a/arch/x86/boot/compressed/head_32.S 
b/arch/x86/boot/compressed/head_32.S
+index 7532f6f53677..93f41b4f05ce 100644
+--- a/arch/x86/boot/compressed/head_32.S
++++ b/arch/x86/boot/compressed/head_32.S
+@@ -48,16 +48,17 @@
+  * Position Independent Executable (PIE) so that linker won't optimize
+  * R_386_GOT32X relocation to its fixed symbol address.  Older
+  * linkers generate R_386_32 relocations against locally defined symbols,
+- * _bss, _ebss, _got and _egot, in PIE.  It isn't wrong, just less
++ * _bss, _ebss, _got, _egot and _end, in PIE.  It isn't wrong, just less
+  * optimal than R_386_RELATIVE.  But the x86 kernel fails to properly handle
+  * R_386_32 relocations when relocating the kernel.  To generate
+- * R_386_RELATIVE relocations, we mark _bss, _ebss, _got and _egot as
++ * R_386_RELATIVE relocations, we mark _bss, _ebss, _got, _egot and _end as
+  * hidden:
+  */
+       .hidden _bss
+       .hidden _ebss
+       .hidden _got
+       .hidden _egot
++      .hidden _end
+ 
+       __HEAD
+ ENTRY(startup_32)
+diff --git a/arch/x86/boot/compressed/head_64.S 
b/arch/x86/boot/compressed/head_64.S
+index 3fac2d133e4e..d096bcfcb3f6 100644
+--- a/arch/x86/boot/compressed/head_64.S
++++ b/arch/x86/boot/compressed/head_64.S
+@@ -40,6 +40,7 @@
+       .hidden _ebss
+       .hidden _got
+       .hidden _egot
++      .hidden _end
+ 
+       __HEAD
+       .code32
+diff --git a/arch/x86/include/asm/cpufeatures.h 
b/arch/x86/include/asm/cpufeatures.h
+index 2cd5d12a842c..8ceb7a8a249c 100644
+--- a/arch/x86/include/asm/cpufeatures.h
++++ b/arch/x86/include/asm/cpufeatures.h
+@@ -273,6 +273,7 @@
+ #define X86_FEATURE_AMD_IBPB  (13*32+12) /* "" Indirect Branch Prediction 
Barrier */
+ #define X86_FEATURE_AMD_IBRS  (13*32+14) /* "" Indirect Branch Restricted 
Speculation */
+ #define X86_FEATURE_AMD_STIBP (13*32+15) /* "" Single Thread Indirect Branch 
Predictors */
++#define X86_FEATURE_AMD_STIBP_ALWAYS_ON       (13*32+17) /* "" Single Thread 
Indirect Branch Predictors always-on preferred */
+ #define X86_FEATURE_AMD_SSBD  (13*32+24) /* "" Speculative Store Bypass 
Disable */
+ #define X86_FEATURE_VIRT_SSBD (13*32+25) /* Virtualized Speculative Store 
Bypass Disable */
+ #define X86_FEATURE_AMD_SSB_NO        (13*32+26) /* "" Speculative Store 
Bypass is fixed in hardware. */
+@@ -312,7 +313,6 @@
+ #define X86_FEATURE_SUCCOR    (17*32+1) /* Uncorrectable error containment 
and recovery */
+ #define X86_FEATURE_SMCA      (17*32+3) /* Scalable MCA */
+ 
+-
+ /* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
+ #define X86_FEATURE_AVX512_4VNNIW     (18*32+ 2) /* AVX-512 Neural Network 
Instructions */
+ #define X86_FEATURE_AVX512_4FMAPS     (18*32+ 3) /* AVX-512 Multiply 
Accumulation Single precision */
+diff --git a/arch/x86/include/asm/nospec-branch.h 
b/arch/x86/include/asm/nospec-branch.h
+index 8d56d701b5f7..4af16acc001a 100644
+--- a/arch/x86/include/asm/nospec-branch.h
++++ b/arch/x86/include/asm/nospec-branch.h
+@@ -223,6 +223,7 @@ enum spectre_v2_mitigation {
+ enum spectre_v2_user_mitigation {
+       SPECTRE_V2_USER_NONE,
+       SPECTRE_V2_USER_STRICT,
++      SPECTRE_V2_USER_STRICT_PREFERRED,
+       SPECTRE_V2_USER_PRCTL,
+       SPECTRE_V2_USER_SECCOMP,
+ };
+diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c
+index 5ef0a2b34261..85c1cc0305f3 100644
+--- a/arch/x86/kernel/cpu/bugs.c
++++ b/arch/x86/kernel/cpu/bugs.c
+@@ -60,7 +60,7 @@ static u64 __ro_after_init x86_spec_ctrl_mask = 
SPEC_CTRL_IBRS;
+ u64 __ro_after_init x86_amd_ls_cfg_base;
+ u64 __ro_after_init x86_amd_ls_cfg_ssbd_mask;
+ 
+-/* Control conditional STIPB in switch_to() */
++/* Control conditional STIBP in switch_to() */
+ DEFINE_STATIC_KEY_FALSE(switch_to_cond_stibp);
+ /* Control conditional IBPB in switch_mm() */
+ DEFINE_STATIC_KEY_FALSE(switch_mm_cond_ibpb);
+@@ -580,7 +580,9 @@ early_param("nospectre_v1", nospectre_v1_cmdline);
+ static enum spectre_v2_mitigation spectre_v2_enabled __ro_after_init =
+       SPECTRE_V2_NONE;
+ 
+-static enum spectre_v2_user_mitigation spectre_v2_user __ro_after_init =
++static enum spectre_v2_user_mitigation spectre_v2_user_stibp __ro_after_init =
++      SPECTRE_V2_USER_NONE;
++static enum spectre_v2_user_mitigation spectre_v2_user_ibpb __ro_after_init =
+       SPECTRE_V2_USER_NONE;
+ 
+ #ifdef RETPOLINE
+@@ -632,10 +634,11 @@ enum spectre_v2_user_cmd {
+ };
+ 
+ static const char * const spectre_v2_user_strings[] = {
+-      [SPECTRE_V2_USER_NONE]          = "User space: Vulnerable",
+-      [SPECTRE_V2_USER_STRICT]        = "User space: Mitigation: STIBP 
protection",
+-      [SPECTRE_V2_USER_PRCTL]         = "User space: Mitigation: STIBP via 
prctl",
+-      [SPECTRE_V2_USER_SECCOMP]       = "User space: Mitigation: STIBP via 
seccomp and prctl",
++      [SPECTRE_V2_USER_NONE]                  = "User space: Vulnerable",
++      [SPECTRE_V2_USER_STRICT]                = "User space: Mitigation: 
STIBP protection",
++      [SPECTRE_V2_USER_STRICT_PREFERRED]      = "User space: Mitigation: 
STIBP always-on protection",
++      [SPECTRE_V2_USER_PRCTL]                 = "User space: Mitigation: 
STIBP via prctl",
++      [SPECTRE_V2_USER_SECCOMP]               = "User space: Mitigation: 
STIBP via seccomp and prctl",
+ };
+ 
+ static const struct {
+@@ -747,23 +750,36 @@ spectre_v2_user_select_mitigation(enum 
spectre_v2_mitigation_cmd v2_cmd)
+               pr_info("mitigation: Enabling %s Indirect Branch Prediction 
Barrier\n",
+                       static_key_enabled(&switch_mm_always_ibpb) ?
+                       "always-on" : "conditional");
++
++              spectre_v2_user_ibpb = mode;
+       }
+ 
+-      /* If enhanced IBRS is enabled no STIPB required */
+-      if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
++      /*
++       * If enhanced IBRS is enabled or SMT impossible, STIBP is not
++       * required.
++       */
++      if (!smt_possible || spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
+               return;
+ 
+       /*
+-       * If SMT is not possible or STIBP is not available clear the STIPB
+-       * mode.
++       * At this point, an STIBP mode other than "off" has been set.
++       * If STIBP support is not being forced, check if STIBP always-on
++       * is preferred.
+        */
+-      if (!smt_possible || !boot_cpu_has(X86_FEATURE_STIBP))
++      if (mode != SPECTRE_V2_USER_STRICT &&
++          boot_cpu_has(X86_FEATURE_AMD_STIBP_ALWAYS_ON))
++              mode = SPECTRE_V2_USER_STRICT_PREFERRED;
++
++      /*
++       * If STIBP is not available, clear the STIBP mode.
++       */
++      if (!boot_cpu_has(X86_FEATURE_STIBP))
+               mode = SPECTRE_V2_USER_NONE;
++
++      spectre_v2_user_stibp = mode;
++
+ set_mode:
+-      spectre_v2_user = mode;
+-      /* Only print the STIBP mode when SMT possible */
+-      if (smt_possible)
+-              pr_info("%s\n", spectre_v2_user_strings[mode]);
++      pr_info("%s\n", spectre_v2_user_strings[mode]);
+ }
+ 
+ static const char * const spectre_v2_strings[] = {
+@@ -1003,10 +1019,11 @@ void arch_smt_update(void)
+ {
+       mutex_lock(&spec_ctrl_mutex);
+ 
+-      switch (spectre_v2_user) {
++      switch (spectre_v2_user_stibp) {
+       case SPECTRE_V2_USER_NONE:
+               break;
+       case SPECTRE_V2_USER_STRICT:
++      case SPECTRE_V2_USER_STRICT_PREFERRED:
+               update_stibp_strict();
+               break;
+       case SPECTRE_V2_USER_PRCTL:
+@@ -1235,13 +1252,19 @@ static int ib_prctl_set(struct task_struct *task, 
unsigned long ctrl)
+ {
+       switch (ctrl) {
+       case PR_SPEC_ENABLE:
+-              if (spectre_v2_user == SPECTRE_V2_USER_NONE)
++              if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
+                       return 0;
+               /*
+                * Indirect branch speculation is always disabled in strict
+-               * mode.
++               * mode. It can neither be enabled if it was force-disabled
++               * by a  previous prctl call.
++
+                */
+-              if (spectre_v2_user == SPECTRE_V2_USER_STRICT)
++              if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED ||
++                  task_spec_ib_force_disable(task))
+                       return -EPERM;
+               task_clear_spec_ib_disable(task);
+               task_update_spec_tif(task);
+@@ -1252,9 +1275,12 @@ static int ib_prctl_set(struct task_struct *task, 
unsigned long ctrl)
+                * Indirect branch speculation is always allowed when
+                * mitigation is force disabled.
+                */
+-              if (spectre_v2_user == SPECTRE_V2_USER_NONE)
++              if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
+                       return -EPERM;
+-              if (spectre_v2_user == SPECTRE_V2_USER_STRICT)
++              if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
++                  spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
+                       return 0;
+               task_set_spec_ib_disable(task);
+               if (ctrl == PR_SPEC_FORCE_DISABLE)
+@@ -1285,7 +1311,8 @@ void arch_seccomp_spec_mitigate(struct task_struct *task)
+ {
+       if (ssb_mode == SPEC_STORE_BYPASS_SECCOMP)
+               ssb_prctl_set(task, PR_SPEC_FORCE_DISABLE);
+-      if (spectre_v2_user == SPECTRE_V2_USER_SECCOMP)
++      if (spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||
++          spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP)
+               ib_prctl_set(task, PR_SPEC_FORCE_DISABLE);
+ }
+ #endif
+@@ -1314,21 +1341,24 @@ static int ib_prctl_get(struct task_struct *task)
+       if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
+               return PR_SPEC_NOT_AFFECTED;
+ 
+-      switch (spectre_v2_user) {
+-      case SPECTRE_V2_USER_NONE:
++      if (spectre_v2_user_ibpb == SPECTRE_V2_USER_NONE &&
++          spectre_v2_user_stibp == SPECTRE_V2_USER_NONE)
+               return PR_SPEC_ENABLE;
+-      case SPECTRE_V2_USER_PRCTL:
+-      case SPECTRE_V2_USER_SECCOMP:
++      else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_STRICT ||
++          spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT ||
++          spectre_v2_user_stibp == SPECTRE_V2_USER_STRICT_PREFERRED)
++              return PR_SPEC_DISABLE;
++      else if (spectre_v2_user_ibpb == SPECTRE_V2_USER_PRCTL ||
++          spectre_v2_user_ibpb == SPECTRE_V2_USER_SECCOMP ||
++          spectre_v2_user_stibp == SPECTRE_V2_USER_PRCTL ||
++          spectre_v2_user_stibp == SPECTRE_V2_USER_SECCOMP) {
+               if (task_spec_ib_force_disable(task))
+                       return PR_SPEC_PRCTL | PR_SPEC_FORCE_DISABLE;
+               if (task_spec_ib_disable(task))
+                       return PR_SPEC_PRCTL | PR_SPEC_DISABLE;
+               return PR_SPEC_PRCTL | PR_SPEC_ENABLE;
+-      case SPECTRE_V2_USER_STRICT:
+-              return PR_SPEC_DISABLE;
+-      default:
++      } else
+               return PR_SPEC_NOT_AFFECTED;
+-      }
+ }
+ 
+ int arch_prctl_spec_ctrl_get(struct task_struct *task, unsigned long which)
+@@ -1569,11 +1599,13 @@ static char *stibp_state(void)
+       if (spectre_v2_enabled == SPECTRE_V2_IBRS_ENHANCED)
+               return "";
+ 
+-      switch (spectre_v2_user) {
++      switch (spectre_v2_user_stibp) {
+       case SPECTRE_V2_USER_NONE:
+               return ", STIBP: disabled";
+       case SPECTRE_V2_USER_STRICT:
+               return ", STIBP: forced";
++      case SPECTRE_V2_USER_STRICT_PREFERRED:
++              return ", STIBP: always-on";
+       case SPECTRE_V2_USER_PRCTL:
+       case SPECTRE_V2_USER_SECCOMP:
+               if (static_key_enabled(&switch_to_cond_stibp))
+diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
+index 2e4eab22ca37..f58e4cc20c1c 100644
+--- a/arch/x86/kernel/process.c
++++ b/arch/x86/kernel/process.c
+@@ -337,28 +337,20 @@ static __always_inline void 
__speculation_ctrl_update(unsigned long tifp,
+       u64 msr = x86_spec_ctrl_base;
+       bool updmsr = false;
+ 
+-      /*
+-       * If TIF_SSBD is different, select the proper mitigation
+-       * method. Note that if SSBD mitigation is disabled or permanentely
+-       * enabled this branch can't be taken because nothing can set
+-       * TIF_SSBD.
+-       */
+-      if (tif_diff & _TIF_SSBD) {
+-              if (static_cpu_has(X86_FEATURE_VIRT_SSBD)) {
++      /* Handle change of TIF_SSBD depending on the mitigation method. */
++      if (static_cpu_has(X86_FEATURE_VIRT_SSBD)) {
++              if (tif_diff & _TIF_SSBD)
+                       amd_set_ssb_virt_state(tifn);
+-              } else if (static_cpu_has(X86_FEATURE_LS_CFG_SSBD)) {
++      } else if (static_cpu_has(X86_FEATURE_LS_CFG_SSBD)) {
++              if (tif_diff & _TIF_SSBD)
+                       amd_set_core_ssb_state(tifn);
+-              } else if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
+-                         static_cpu_has(X86_FEATURE_AMD_SSBD)) {
+-                      msr |= ssbd_tif_to_spec_ctrl(tifn);
+-                      updmsr  = true;
+-              }
++      } else if (static_cpu_has(X86_FEATURE_SPEC_CTRL_SSBD) ||
++                 static_cpu_has(X86_FEATURE_AMD_SSBD)) {
++              updmsr |= !!(tif_diff & _TIF_SSBD);
++              msr |= ssbd_tif_to_spec_ctrl(tifn);
+       }
+ 
+-      /*
+-       * Only evaluate TIF_SPEC_IB if conditional STIBP is enabled,
+-       * otherwise avoid the MSR write.
+-       */
++      /* Only evaluate TIF_SPEC_IB if conditional STIBP is enabled. */
+       if (IS_ENABLED(CONFIG_SMP) &&
+           static_branch_unlikely(&switch_to_cond_stibp)) {
+               updmsr |= !!(tif_diff & _TIF_SPEC_IB);
+diff --git a/arch/x86/kernel/process.h b/arch/x86/kernel/process.h
+index 898e97cf6629..320ab978fb1f 100644
+--- a/arch/x86/kernel/process.h
++++ b/arch/x86/kernel/process.h
+@@ -19,7 +19,7 @@ static inline void switch_to_extra(struct task_struct *prev,
+       if (IS_ENABLED(CONFIG_SMP)) {
+               /*
+                * Avoid __switch_to_xtra() invocation when conditional
+-               * STIPB is disabled and the only different bit is
++               * STIBP is disabled and the only different bit is
+                * TIF_SPEC_IB. For CONFIG_SMP=n TIF_SPEC_IB is not
+                * in the TIF_WORK_CTXSW masks.
+                */
+diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
+index c55b11fe8e9f..b427dc73ba27 100644
+--- a/arch/x86/kernel/reboot.c
++++ b/arch/x86/kernel/reboot.c
+@@ -198,6 +198,14 @@ static struct dmi_system_id __initdata reboot_dmi_table[] 
= {
+                       DMI_MATCH(DMI_PRODUCT_NAME, "MacBook5"),
+               },
+       },
++      {       /* Handle problems with rebooting on Apple MacBook6,1 */
++              .callback = set_pci_reboot,
++              .ident = "Apple MacBook6,1",
++              .matches = {
++                      DMI_MATCH(DMI_SYS_VENDOR, "Apple Inc."),
++                      DMI_MATCH(DMI_PRODUCT_NAME, "MacBook6,1"),
++              },
++      },
+       {       /* Handle problems with rebooting on Apple MacBookPro5 */
+               .callback = set_pci_reboot,
+               .ident = "Apple MacBookPro5",
+diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
+index 89d1190b9d94..5e5de7a7f38d 100644
+--- a/arch/x86/kernel/time.c
++++ b/arch/x86/kernel/time.c
+@@ -23,10 +23,6 @@
+ #include <asm/hpet.h>
+ #include <asm/time.h>
+ 
+-#ifdef CONFIG_X86_64
+-__visible volatile unsigned long jiffies __cacheline_aligned_in_smp = 
INITIAL_JIFFIES;
+-#endif
+-
+ unsigned long profile_pc(struct pt_regs *regs)
+ {
+       unsigned long pc = instruction_pointer(regs);
+diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
+index 55f04875293f..097268f85e4e 100644
+--- a/arch/x86/kernel/vmlinux.lds.S
++++ b/arch/x86/kernel/vmlinux.lds.S
+@@ -34,13 +34,13 @@ OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, 
CONFIG_OUTPUT_FORMAT)
+ #ifdef CONFIG_X86_32
+ OUTPUT_ARCH(i386)
+ ENTRY(phys_startup_32)
+-jiffies = jiffies_64;
+ #else
+ OUTPUT_ARCH(i386:x86-64)
+ ENTRY(phys_startup_64)
+-jiffies_64 = jiffies;
+ #endif
+ 
++jiffies = jiffies_64;
++
+ #if defined(CONFIG_X86_64)
+ /*
+  * On 64-bit, align RODATA to 2MB so we retain large page mappings for
+diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
+index 1079228e4fef..29078eaf18c9 100644
+--- a/arch/x86/kvm/svm.c
++++ b/arch/x86/kvm/svm.c
+@@ -2734,7 +2734,7 @@ static inline void copy_vmcb_control_area(struct vmcb 
*dst_vmcb, struct vmcb *fr
+       dst->iopm_base_pa         = from->iopm_base_pa;
+       dst->msrpm_base_pa        = from->msrpm_base_pa;
+       dst->tsc_offset           = from->tsc_offset;
+-      dst->asid                 = from->asid;
++      /* asid not copied, it is handled manually for svm->vmcb.  */
+       dst->tlb_ctl              = from->tlb_ctl;
+       dst->int_ctl              = from->int_ctl;
+       dst->int_vector           = from->int_vector;
+diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
+index b62886f10dc1..e7fe5974c81c 100644
+--- a/arch/x86/kvm/vmx.c
++++ b/arch/x86/kvm/vmx.c
+@@ -8207,7 +8207,7 @@ static bool nested_vmx_exit_handled(struct kvm_vcpu 
*vcpu)
+               return true;
+       }
+ 
+-      switch (exit_reason) {
++      switch ((u16)exit_reason) {
+       case EXIT_REASON_EXCEPTION_NMI:
+               if (is_nmi(intr_info))
+                       return false;
+diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
+index ce092a62fc5d..bc2455c2fcab 100644
+--- a/arch/x86/mm/init.c
++++ b/arch/x86/mm/init.c
+@@ -110,8 +110,6 @@ __ref void *alloc_low_pages(unsigned int num)
+       } else {
+               pfn = pgt_buf_end;
+               pgt_buf_end += num;
+-              printk(KERN_DEBUG "BRK [%#010lx, %#010lx] PGTABLE\n",
+-                      pfn << PAGE_SHIFT, (pgt_buf_end << PAGE_SHIFT) - 1);
+       }
+ 
+       for (i = 0; i < num; i++) {
+diff --git a/arch/x86/pci/fixup.c b/arch/x86/pci/fixup.c
+index 62950ef7f84e..68e86d7cc94d 100644
+--- a/arch/x86/pci/fixup.c
++++ b/arch/x86/pci/fixup.c
+@@ -571,6 +571,10 @@ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x2fc0, 
pci_invalid_bar);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6f60, pci_invalid_bar);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fa0, pci_invalid_bar);
+ DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0x6fc0, pci_invalid_bar);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0xa1ec, pci_invalid_bar);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0xa1ed, pci_invalid_bar);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0xa26c, pci_invalid_bar);
++DECLARE_PCI_FIXUP_EARLY(PCI_VENDOR_ID_INTEL, 0xa26d, pci_invalid_bar);
+ 
+ /*
+  * Device [1022:7914]
+diff --git a/block/blk-mq.c b/block/blk-mq.c
+index 58be2eaa5aaa..e0ed7317e98c 100644
+--- a/block/blk-mq.c
++++ b/block/blk-mq.c
+@@ -2331,6 +2331,10 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set 
*set, int nr_hw_queues)
+ 
+       list_for_each_entry(q, &set->tag_list, tag_set_list)
+               blk_mq_freeze_queue(q);
++      /*
++       * Sync with blk_mq_queue_tag_busy_iter.
++       */
++      synchronize_rcu();
+ 
+       set->nr_hw_queues = nr_hw_queues;
+       list_for_each_entry(q, &set->tag_list, tag_set_list) {
+@@ -2346,10 +2350,6 @@ void blk_mq_update_nr_hw_queues(struct blk_mq_tag_set 
*set, int nr_hw_queues)
+ 
+       list_for_each_entry(q, &set->tag_list, tag_set_list)
+               blk_mq_unfreeze_queue(q);
+-      /*
+-       * Sync with blk_mq_queue_tag_busy_iter.
+-       */
+-      synchronize_rcu();
+ }
+ EXPORT_SYMBOL_GPL(blk_mq_update_nr_hw_queues);
+ 
+diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
+index 9ec4618df533..318bdfb8703c 100644
+--- a/drivers/acpi/cppc_acpi.c
++++ b/drivers/acpi/cppc_acpi.c
+@@ -793,8 +793,10 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr)
+ 
+       ret = kobject_init_and_add(&cpc_ptr->kobj, &cppc_ktype, &cpu_dev->kobj,
+                       "acpi_cppc");
+-      if (ret)
++      if (ret) {
++              kobject_put(&cpc_ptr->kobj);
+               goto out_free;
++      }
+ 
+       kfree(output.pointer);
+       return 0;
+diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c
+index 245bcdb44c64..442aac84ab88 100644
+--- a/drivers/acpi/device_pm.c
++++ b/drivers/acpi/device_pm.c
+@@ -171,7 +171,7 @@ int acpi_device_set_power(struct acpi_device *device, int 
state)
+                * possibly drop references to the power resources in use.
+                */
+               state = ACPI_STATE_D3_HOT;
+-              /* If _PR3 is not available, use D3hot as the target state. */
++              /* If D3cold is not supported, use D3hot as the target state. */
+               if (!device->power.states[ACPI_STATE_D3_COLD].flags.valid)
+                       target_state = state;
+       } else if (!device->power.states[state].flags.valid) {
+diff --git a/drivers/acpi/evged.c b/drivers/acpi/evged.c
+index 46f060356a22..339e6d3dba7c 100644
+--- a/drivers/acpi/evged.c
++++ b/drivers/acpi/evged.c
+@@ -82,6 +82,8 @@ static acpi_status acpi_ged_request_interrupt(struct 
acpi_resource *ares,
+       struct resource r;
+       struct acpi_resource_irq *p = &ares->data.irq;
+       struct acpi_resource_extended_irq *pext = &ares->data.extended_irq;
++      char ev_name[5];
++      u8 trigger;
+ 
+       if (ares->type == ACPI_RESOURCE_TYPE_END_TAG)
+               return AE_OK;
+@@ -90,14 +92,28 @@ static acpi_status acpi_ged_request_interrupt(struct 
acpi_resource *ares,
+               dev_err(dev, "unable to parse IRQ resource\n");
+               return AE_ERROR;
+       }
+-      if (ares->type == ACPI_RESOURCE_TYPE_IRQ)
++      if (ares->type == ACPI_RESOURCE_TYPE_IRQ) {
+               gsi = p->interrupts[0];
+-      else
++              trigger = p->triggering;
++      } else {
+               gsi = pext->interrupts[0];
++              trigger = pext->triggering;
++      }
+ 
+       irq = r.start;
+ 
+-      if (ACPI_FAILURE(acpi_get_handle(handle, "_EVT", &evt_handle))) {
++      switch (gsi) {
++      case 0 ... 255:
++              sprintf(ev_name, "_%c%02hhX",
++                      trigger == ACPI_EDGE_SENSITIVE ? 'E' : 'L', gsi);
++
++              if (ACPI_SUCCESS(acpi_get_handle(handle, ev_name, &evt_handle)))
++                      break;
++              /* fall through */
++      default:
++              if (ACPI_SUCCESS(acpi_get_handle(handle, "_EVT", &evt_handle)))
++                      break;
++
+               dev_err(dev, "cannot locate _EVT method\n");
+               return AE_ERROR;
+       }
+diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
+index 0792ec5a9efc..9a7f017dda47 100644
+--- a/drivers/acpi/scan.c
++++ b/drivers/acpi/scan.c
+@@ -927,12 +927,9 @@ static void acpi_bus_init_power_state(struct acpi_device 
*device, int state)
+ 
+               if (buffer.length && package
+                   && package->type == ACPI_TYPE_PACKAGE
+-                  && package->package.count) {
+-                      int err = acpi_extract_power_resources(package, 0,
+-                                                             &ps->resources);
+-                      if (!err)
+-                              device->power.flags.power_resources = 1;
+-              }
++                  && package->package.count)
++                      acpi_extract_power_resources(package, 0, 
&ps->resources);
++
+               ACPI_FREE(buffer.pointer);
+       }
+ 
+@@ -979,14 +976,27 @@ static void acpi_bus_get_power_flags(struct acpi_device 
*device)
+               acpi_bus_init_power_state(device, i);
+ 
+       INIT_LIST_HEAD(&device->power.states[ACPI_STATE_D3_COLD].resources);
+-      if (!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources))
+-              device->power.states[ACPI_STATE_D3_COLD].flags.valid = 1;
+ 
+-      /* Set defaults for D0 and D3hot states (always valid) */
++      /* Set the defaults for D0 and D3hot (always supported). */
+       device->power.states[ACPI_STATE_D0].flags.valid = 1;
+       device->power.states[ACPI_STATE_D0].power = 100;
+       device->power.states[ACPI_STATE_D3_HOT].flags.valid = 1;
+ 
++      /*
++       * Use power resources only if the D0 list of them is populated, because
++       * some platforms may provide _PR3 only to indicate D3cold support and
++       * in those cases the power resources list returned by it may be bogus.
++       */
++      if (!list_empty(&device->power.states[ACPI_STATE_D0].resources)) {
++              device->power.flags.power_resources = 1;
++              /*
++               * D3cold is supported if the D3hot list of power resources is
++               * not empty.
++               */
++              if 
(!list_empty(&device->power.states[ACPI_STATE_D3_HOT].resources))
++                      device->power.states[ACPI_STATE_D3_COLD].flags.valid = 
1;
++      }
++
+       if (acpi_bus_init_power(device))
+               device->flags.power_manageable = 0;
+ }
+diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
+index a36d0739dbfe..7502441b1400 100644
+--- a/drivers/acpi/sysfs.c
++++ b/drivers/acpi/sysfs.c
+@@ -898,8 +898,10 @@ void acpi_sysfs_add_hotplug_profile(struct 
acpi_hotplug_profile *hotplug,
+ 
+       error = kobject_init_and_add(&hotplug->kobj,
+               &acpi_hotplug_profile_ktype, hotplug_kobj, "%s", name);
+-      if (error)
++      if (error) {
++              kobject_put(&hotplug->kobj);
+               goto err_out;
++      }
+ 
+       kobject_uevent(&hotplug->kobj, KOBJ_ADD);
+       return;
+diff --git a/drivers/char/agp/intel-gtt.c b/drivers/char/agp/intel-gtt.c
+index a7cc5b7be598..871e7f4994e8 100644
+--- a/drivers/char/agp/intel-gtt.c
++++ b/drivers/char/agp/intel-gtt.c
+@@ -845,6 +845,7 @@ void intel_gtt_insert_page(dma_addr_t addr,
+                          unsigned int flags)
+ {
+       intel_private.driver->write_entry(addr, pg, flags);
++      readl(intel_private.gtt + pg);
+       if (intel_private.driver->chipset_flush)
+               intel_private.driver->chipset_flush();
+ }
+@@ -870,7 +871,7 @@ void intel_gtt_insert_sg_entries(struct sg_table *st,
+                       j++;
+               }
+       }
+-      wmb();
++      readl(intel_private.gtt + j - 1);
+       if (intel_private.driver->chipset_flush)
+               intel_private.driver->chipset_flush();
+ }
+@@ -1104,6 +1105,7 @@ static void i9xx_cleanup(void)
+ 
+ static void i9xx_chipset_flush(void)
+ {
++      wmb();
+       if (intel_private.i9xx_flush_page)
+               writel(1, intel_private.i9xx_flush_page);
+ }
+diff --git a/drivers/clocksource/dw_apb_timer_of.c 
b/drivers/clocksource/dw_apb_timer_of.c
+index aee6c0d39a7c..024e6cc5025b 100644
+--- a/drivers/clocksource/dw_apb_timer_of.c
++++ b/drivers/clocksource/dw_apb_timer_of.c
+@@ -146,10 +146,6 @@ static int num_called;
+ static int __init dw_apb_timer_init(struct device_node *timer)
+ {
+       switch (num_called) {
+-      case 0:
+-              pr_debug("%s: found clockevent timer\n", __func__);
+-              add_clockevent(timer);
+-              break;
+       case 1:
+               pr_debug("%s: found clocksource timer\n", __func__);
+               add_clocksource(timer);
+@@ -160,6 +156,8 @@ static int __init dw_apb_timer_init(struct device_node 
*timer)
+ #endif
+               break;
+       default:
++              pr_debug("%s: found clockevent timer\n", __func__);
++              add_clockevent(timer);
+               break;
+       }
+ 
+diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
+index 9e98a5fbbc1d..e7e92ed34f0c 100644
+--- a/drivers/cpuidle/sysfs.c
++++ b/drivers/cpuidle/sysfs.c
+@@ -412,7 +412,7 @@ static int cpuidle_add_state_sysfs(struct cpuidle_device 
*device)
+               ret = kobject_init_and_add(&kobj->kobj, &ktype_state_cpuidle,
+                                          &kdev->kobj, "state%d", i);
+               if (ret) {
+-                      kfree(kobj);
++                      kobject_put(&kobj->kobj);
+                       goto error_state;
+               }
+               kobject_uevent(&kobj->kobj, KOBJ_ADD);
+@@ -542,7 +542,7 @@ static int cpuidle_add_driver_sysfs(struct cpuidle_device 
*dev)
+       ret = kobject_init_and_add(&kdrv->kobj, &ktype_driver_cpuidle,
+                                  &kdev->kobj, "driver");
+       if (ret) {
+-              kfree(kdrv);
++              kobject_put(&kdrv->kobj);
+               return ret;
+       }
+ 
+@@ -636,7 +636,7 @@ int cpuidle_add_sysfs(struct cpuidle_device *dev)
+       error = kobject_init_and_add(&kdev->kobj, &ktype_cpuidle, 
&cpu_dev->kobj,
+                                  "cpuidle");
+       if (error) {
+-              kfree(kdev);
++              kobject_put(&kdev->kobj);
+               return error;
+       }
+ 
+diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
+index 8b383d3d21c2..059c2d4ad18f 100644
+--- a/drivers/crypto/talitos.c
++++ b/drivers/crypto/talitos.c
+@@ -2636,7 +2636,6 @@ static struct talitos_alg_template driver_algs[] = {
+                       .cra_ablkcipher = {
+                               .min_keysize = AES_MIN_KEY_SIZE,
+                               .max_keysize = AES_MAX_KEY_SIZE,
+-                              .ivsize = AES_BLOCK_SIZE,
+                       }
+               },
+               .desc_hdr_template = DESC_HDR_TYPE_COMMON_NONSNOOP_NO_AFEU |
+@@ -2670,6 +2669,7 @@ static struct talitos_alg_template driver_algs[] = {
+                       .cra_ablkcipher = {
+                               .min_keysize = AES_MIN_KEY_SIZE,
+                               .max_keysize = AES_MAX_KEY_SIZE,
++                              .ivsize = AES_BLOCK_SIZE,
+                               .setkey = ablkcipher_aes_setkey,
+                       }
+               },
+diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
+index 1c65f5ac4368..6529addd1e82 100644
+--- a/drivers/firmware/efi/efivars.c
++++ b/drivers/firmware/efi/efivars.c
+@@ -586,8 +586,10 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
+       ret = kobject_init_and_add(&new_var->kobj, &efivar_ktype,
+                                  NULL, "%s", short_name);
+       kfree(short_name);
+-      if (ret)
++      if (ret) {
++              kobject_put(&new_var->kobj);
+               return ret;
++      }
+ 
+       kobject_uevent(&new_var->kobj, KOBJ_ADD);
+       if (efivar_entry_add(new_var, &efivar_sysfs_list)) {
+diff --git a/drivers/macintosh/windfarm_pm112.c 
b/drivers/macintosh/windfarm_pm112.c
+index 96d16fca68b2..24e7152cd2bf 100644
+--- a/drivers/macintosh/windfarm_pm112.c
++++ b/drivers/macintosh/windfarm_pm112.c
+@@ -13,6 +13,7 @@
+ #include <linux/device.h>
+ #include <linux/platform_device.h>
+ #include <linux/reboot.h>
++#include <linux/slab.h>
+ #include <asm/prom.h>
+ #include <asm/smu.h>
+ 
+@@ -133,14 +134,6 @@ static int create_cpu_loop(int cpu)
+       s32 tmax;
+       int fmin;
+ 
+-      /* Get PID params from the appropriate SAT */
+-      hdr = smu_sat_get_sdb_partition(chip, 0xC8 + core, NULL);
+-      if (hdr == NULL) {
+-              printk(KERN_WARNING"windfarm: can't get CPU PID fan config\n");
+-              return -EINVAL;
+-      }
+-      piddata = (struct smu_sdbp_cpupiddata *)&hdr[1];
+-
+       /* Get FVT params to get Tmax; if not found, assume default */
+       hdr = smu_sat_get_sdb_partition(chip, 0xC4 + core, NULL);
+       if (hdr) {
+@@ -153,6 +146,16 @@ static int create_cpu_loop(int cpu)
+       if (tmax < cpu_all_tmax)
+               cpu_all_tmax = tmax;
+ 
++      kfree(hdr);
++
++      /* Get PID params from the appropriate SAT */
++      hdr = smu_sat_get_sdb_partition(chip, 0xC8 + core, NULL);
++      if (hdr == NULL) {
++              printk(KERN_WARNING"windfarm: can't get CPU PID fan config\n");
++              return -EINVAL;
++      }
++      piddata = (struct smu_sdbp_cpupiddata *)&hdr[1];
++
+       /*
+        * Darwin has a minimum fan speed of 1000 rpm for the 4-way and
+        * 515 for the 2-way.  That appears to be overkill, so for now,
+@@ -175,6 +178,9 @@ static int create_cpu_loop(int cpu)
+               pid.min = fmin;
+ 
+       wf_cpu_pid_init(&cpu_pid[cpu], &pid);
++
++      kfree(hdr);
++
+       return 0;
+ }
+ 
+diff --git a/drivers/md/md.c b/drivers/md/md.c
+index da8708b65356..3485d2a79600 100644
+--- a/drivers/md/md.c
++++ b/drivers/md/md.c
+@@ -7101,7 +7101,8 @@ static int md_open(struct block_device *bdev, fmode_t 
mode)
+                */
+               mddev_put(mddev);
+               /* Wait until bdev->bd_disk is definitely gone */
+-              flush_workqueue(md_misc_wq);
++              if (work_pending(&mddev->del_work))
++                      flush_workqueue(md_misc_wq);
+               /* Then retry the open from the top */
+               return -ERESTARTSYS;
+       }
+diff --git a/drivers/media/dvb-core/dvb_frontend.c 
b/drivers/media/dvb-core/dvb_frontend.c
+index 2f054db8807b..372057cabea4 100644
+--- a/drivers/media/dvb-core/dvb_frontend.c
++++ b/drivers/media/dvb-core/dvb_frontend.c
+@@ -629,7 +629,7 @@ static int dvb_frontend_thread(void *data)
+       struct dvb_frontend *fe = data;
+       struct dtv_frontend_properties *c = &fe->dtv_property_cache;
+       struct dvb_frontend_private *fepriv = fe->frontend_priv;
+-      enum fe_status s;
++      enum fe_status s = FE_NONE;
+       enum dvbfe_algo algo;
+       bool re_tune = false;
+       bool semheld = false;
+diff --git a/drivers/media/platform/rcar-fcp.c 
b/drivers/media/platform/rcar-fcp.c
+index f3a3f31cdfa9..8e9c3bd36d03 100644
+--- a/drivers/media/platform/rcar-fcp.c
++++ b/drivers/media/platform/rcar-fcp.c
+@@ -12,6 +12,7 @@
+  */
+ 
+ #include <linux/device.h>
++#include <linux/dma-mapping.h>
+ #include <linux/list.h>
+ #include <linux/module.h>
+ #include <linux/mutex.h>
+@@ -24,6 +25,7 @@
+ struct rcar_fcp_device {
+       struct list_head list;
+       struct device *dev;
++      struct device_dma_parameters dma_parms;
+ };
+ 
+ static LIST_HEAD(fcp_devices);
+@@ -140,6 +142,9 @@ static int rcar_fcp_probe(struct platform_device *pdev)
+ 
+       fcp->dev = &pdev->dev;
+ 
++      fcp->dev->dma_parms = &fcp->dma_parms;
++      dma_set_max_seg_size(fcp->dev, DMA_BIT_MASK(32));
++
+       pm_runtime_enable(&pdev->dev);
+ 
+       mutex_lock(&fcp_lock);
+diff --git a/drivers/media/tuners/si2157.c b/drivers/media/tuners/si2157.c
+index 57b250847cd3..72a47da0db2a 100644
+--- a/drivers/media/tuners/si2157.c
++++ b/drivers/media/tuners/si2157.c
+@@ -84,24 +84,23 @@ static int si2157_init(struct dvb_frontend *fe)
+       struct si2157_cmd cmd;
+       const struct firmware *fw;
+       const char *fw_name;
+-      unsigned int uitmp, chip_id;
++      unsigned int chip_id, xtal_trim;
+ 
+       dev_dbg(&client->dev, "\n");
+ 
+-      /* Returned IF frequency is garbage when firmware is not running */
+-      memcpy(cmd.args, "\x15\x00\x06\x07", 4);
++      /* Try to get Xtal trim property, to verify tuner still running */
++      memcpy(cmd.args, "\x15\x00\x04\x02", 4);
+       cmd.wlen = 4;
+       cmd.rlen = 4;
+       ret = si2157_cmd_execute(client, &cmd);
+-      if (ret)
+-              goto err;
+ 
+-      uitmp = cmd.args[2] << 0 | cmd.args[3] << 8;
+-      dev_dbg(&client->dev, "if_frequency kHz=%u\n", uitmp);
++      xtal_trim = cmd.args[2] | (cmd.args[3] << 8);
+ 
+-      if (uitmp == dev->if_frequency / 1000)
++      if (ret == 0 && xtal_trim < 16)
+               goto warm;
+ 
++      dev->if_frequency = 0; /* we no longer know current tuner state */
++
+       /* power up */
+       if (dev->chiptype == SI2157_CHIPTYPE_SI2146) {
+               memcpy(cmd.args, "\xc0\x05\x01\x00\x00\x0b\x00\x00\x01", 9);
+diff --git a/drivers/media/usb/dvb-usb/dibusb-mb.c 
b/drivers/media/usb/dvb-usb/dibusb-mb.c
+index a0057641cc86..c55180912c3a 100644
+--- a/drivers/media/usb/dvb-usb/dibusb-mb.c
++++ b/drivers/media/usb/dvb-usb/dibusb-mb.c
+@@ -84,7 +84,7 @@ static int dibusb_tuner_probe_and_attach(struct 
dvb_usb_adapter *adap)
+ 
+       if (i2c_transfer(&adap->dev->i2c_adap, msg, 2) != 2) {
+               err("tuner i2c write failed.");
+-              ret = -EREMOTEIO;
++              return -EREMOTEIO;
+       }
+ 
+       if (adap->fe_adap[0].fe->ops.i2c_gate_ctrl)
+diff --git a/drivers/media/usb/go7007/snd-go7007.c 
b/drivers/media/usb/go7007/snd-go7007.c
+index 070871fb1fc4..6e1a85ff3fff 100644
+--- a/drivers/media/usb/go7007/snd-go7007.c
++++ b/drivers/media/usb/go7007/snd-go7007.c
+@@ -243,22 +243,18 @@ int go7007_snd_init(struct go7007 *go)
+       gosnd->capturing = 0;
+       ret = snd_card_new(go->dev, index[dev], id[dev], THIS_MODULE, 0,
+                          &gosnd->card);
+-      if (ret < 0) {
+-              kfree(gosnd);
+-              return ret;
+-      }
++      if (ret < 0)
++              goto free_snd;
++
+       ret = snd_device_new(gosnd->card, SNDRV_DEV_LOWLEVEL, go,
+                       &go7007_snd_device_ops);
+-      if (ret < 0) {
+-              kfree(gosnd);
+-              return ret;
+-      }
++      if (ret < 0)
++              goto free_card;
++
+       ret = snd_pcm_new(gosnd->card, "go7007", 0, 0, 1, &gosnd->pcm);
+-      if (ret < 0) {
+-              snd_card_free(gosnd->card);
+-              kfree(gosnd);
+-              return ret;
+-      }
++      if (ret < 0)
++              goto free_card;
++
+       strlcpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver));
+       strlcpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver));
+       strlcpy(gosnd->card->longname, gosnd->card->shortname,
+@@ -269,11 +265,8 @@ int go7007_snd_init(struct go7007 *go)
+                       &go7007_snd_capture_ops);
+ 
+       ret = snd_card_register(gosnd->card);
+-      if (ret < 0) {
+-              snd_card_free(gosnd->card);
+-              kfree(gosnd);
+-              return ret;
+-      }
++      if (ret < 0)
++              goto free_card;
+ 
+       gosnd->substream = NULL;
+       go->snd_context = gosnd;
+@@ -281,6 +274,12 @@ int go7007_snd_init(struct go7007 *go)
+       ++dev;
+ 
+       return 0;
++
++free_card:
++      snd_card_free(gosnd->card);
++free_snd:
++      kfree(gosnd);
++      return ret;
+ }
+ EXPORT_SYMBOL(go7007_snd_init);
+ 
+diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c 
b/drivers/mmc/host/sdhci-esdhc-imx.c
+index 445fc47dc3e7..b4336534f628 100644
+--- a/drivers/mmc/host/sdhci-esdhc-imx.c
++++ b/drivers/mmc/host/sdhci-esdhc-imx.c
+@@ -79,7 +79,7 @@
+ #define ESDHC_STD_TUNING_EN           (1 << 24)
+ /* NOTE: the minimum valid tuning start tap for mx6sl is 1 */
+ #define ESDHC_TUNING_START_TAP_DEFAULT        0x1
+-#define ESDHC_TUNING_START_TAP_MASK   0xff
++#define ESDHC_TUNING_START_TAP_MASK   0x7f
+ #define ESDHC_TUNING_STEP_MASK                0x00070000
+ #define ESDHC_TUNING_STEP_SHIFT               16
+ 
+diff --git a/drivers/mtd/nand/brcmnand/brcmnand.c 
b/drivers/mtd/nand/brcmnand/brcmnand.c
+index ef9a6b22c9fa..1291492a1cef 100644
+--- a/drivers/mtd/nand/brcmnand/brcmnand.c
++++ b/drivers/mtd/nand/brcmnand/brcmnand.c
+@@ -911,11 +911,14 @@ static int brcmnand_hamming_ooblayout_free(struct 
mtd_info *mtd, int section,
+               if (!section) {
+                       /*
+                        * Small-page NAND use byte 6 for BBI while large-page
+-                       * NAND use byte 0.
++                       * NAND use bytes 0 and 1.
+                        */
+-                      if (cfg->page_size > 512)
+-                              oobregion->offset++;
+-                      oobregion->length--;
++                      if (cfg->page_size > 512) {
++                              oobregion->offset += 2;
++                              oobregion->length -= 2;
++                      } else {
++                              oobregion->length--;
++                      }
+               }
+       }
+ 
+diff --git a/drivers/mtd/nand/pasemi_nand.c b/drivers/mtd/nand/pasemi_nand.c
+index 5de7591b0510..80c98eef44d9 100644
+--- a/drivers/mtd/nand/pasemi_nand.c
++++ b/drivers/mtd/nand/pasemi_nand.c
+@@ -164,7 +164,7 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
+       if (mtd_device_register(pasemi_nand_mtd, NULL, 0)) {
+               dev_err(dev, "Unable to register MTD device\n");
+               err = -ENODEV;
+-              goto out_lpc;
++              goto out_cleanup_nand;
+       }
+ 
+       dev_info(dev, "PA Semi NAND flash at %pR, control at I/O %x\n", &res,
+@@ -172,6 +172,8 @@ static int pasemi_nand_probe(struct platform_device *ofdev)
+ 
+       return 0;
+ 
++ out_cleanup_nand:
++      nand_cleanup(chip);
+  out_lpc:
+       release_region(lpcctl, 4);
+  out_ior:
+diff --git a/drivers/net/can/usb/kvaser_usb.c 
b/drivers/net/can/usb/kvaser_usb.c
+index 3a75352f632b..792a1afabf5d 100644
+--- a/drivers/net/can/usb/kvaser_usb.c
++++ b/drivers/net/can/usb/kvaser_usb.c
+@@ -791,7 +791,7 @@ static int kvaser_usb_simple_msg_async(struct 
kvaser_usb_net_priv *priv,
+       if (!urb)
+               return -ENOMEM;
+ 
+-      buf = kmalloc(sizeof(struct kvaser_msg), GFP_ATOMIC);
++      buf = kzalloc(sizeof(struct kvaser_msg), GFP_ATOMIC);
+       if (!buf) {
+               usb_free_urb(urb);
+               return -ENOMEM;
+@@ -1459,7 +1459,7 @@ static int kvaser_usb_set_opt_mode(const struct 
kvaser_usb_net_priv *priv)
+       struct kvaser_msg *msg;
+       int rc;
+ 
+-      msg = kmalloc(sizeof(*msg), GFP_KERNEL);
++      msg = kzalloc(sizeof(*msg), GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+ 
+@@ -1592,7 +1592,7 @@ static int kvaser_usb_flush_queue(struct 
kvaser_usb_net_priv *priv)
+       struct kvaser_msg *msg;
+       int rc;
+ 
+-      msg = kmalloc(sizeof(*msg), GFP_KERNEL);
++      msg = kzalloc(sizeof(*msg), GFP_KERNEL);
+       if (!msg)
+               return -ENOMEM;
+ 
+diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c 
b/drivers/net/ethernet/allwinner/sun4i-emac.c
+index 6ffdff68bfc4..672a8212c8d9 100644
+--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
++++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
+@@ -412,7 +412,7 @@ static void emac_timeout(struct net_device *dev)
+ /* Hardware start transmission.
+  * Send a packet to media from the upper layer.
+  */
+-static int emac_start_xmit(struct sk_buff *skb, struct net_device *dev)
++static netdev_tx_t emac_start_xmit(struct sk_buff *skb, struct net_device 
*dev)
+ {
+       struct emac_board_info *db = netdev_priv(dev);
+       unsigned long channel;
+@@ -420,7 +420,7 @@ static int emac_start_xmit(struct sk_buff *skb, struct 
net_device *dev)
+ 
+       channel = db->tx_fifo_stat & 3;
+       if (channel == 3)
+-              return 1;
++              return NETDEV_TX_BUSY;
+ 
+       channel = (channel == 1 ? 1 : 0);
+ 
+diff --git a/drivers/net/ethernet/amazon/ena/ena_com.c 
b/drivers/net/ethernet/amazon/ena/ena_com.c
+index 905911f78693..e95f19e573a7 100644
+--- a/drivers/net/ethernet/amazon/ena/ena_com.c
++++ b/drivers/net/ethernet/amazon/ena/ena_com.c
+@@ -2096,6 +2096,9 @@ int ena_com_get_hash_function(struct ena_com_dev 
*ena_dev,
+               rss->hash_key;
+       int rc;
+ 
++      if (unlikely(!func))
++              return -EINVAL;
++
+       rc = ena_com_get_feature_ex(ena_dev, &get_resp,
+                                   ENA_ADMIN_RSS_HASH_FUNCTION,
+                                   rss->hash_key_dma_addr,
+@@ -2108,8 +2111,7 @@ int ena_com_get_hash_function(struct ena_com_dev 
*ena_dev,
+       if (rss->hash_func)
+               rss->hash_func--;
+ 
+-      if (func)
+-              *func = rss->hash_func;
++      *func = rss->hash_func;
+ 
+       if (key)
+               memcpy(key, hash_key->key, (size_t)(hash_key->keys_num) << 2);
+diff --git a/drivers/net/ethernet/ibm/ibmvnic.c 
b/drivers/net/ethernet/ibm/ibmvnic.c
+index 897a87ae8655..20f7ab4aa2f1 100644
+--- a/drivers/net/ethernet/ibm/ibmvnic.c
++++ b/drivers/net/ethernet/ibm/ibmvnic.c
+@@ -3362,12 +3362,10 @@ static void ibmvnic_handle_crq(union ibmvnic_crq *crq,
+                       dev_err(dev, "Error %ld in VERSION_EXCHG_RSP\n", rc);
+                       break;
+               }
+-              dev_info(dev, "Partner protocol version is %d\n",
+-                       crq->version_exchange_rsp.version);
+-              if (be16_to_cpu(crq->version_exchange_rsp.version) <
+-                  ibmvnic_version)
+-                      ibmvnic_version =
++              ibmvnic_version =
+                           be16_to_cpu(crq->version_exchange_rsp.version);
++              dev_info(dev, "Partner protocol version is %d\n",
++                       ibmvnic_version);
+               send_cap_queries(adapter);
+               break;
+       case QUERY_CAPABILITY_RSP:
+diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c 
b/drivers/net/ethernet/intel/e1000/e1000_main.c
+index 39a09e18c1b7..3b16ee0de246 100644
+--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
++++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
+@@ -3167,8 +3167,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
+               hdr_len = skb_transport_offset(skb) + tcp_hdrlen(skb);
+               if (skb->data_len && hdr_len == len) {
+                       switch (hw->mac_type) {
++                      case e1000_82544: {
+                               unsigned int pull_size;
+-                      case e1000_82544:
++
+                               /* Make sure we have room to chop off 4 bytes,
+                                * and that the end alignment will work out to
+                                * this hardware's requirements
+@@ -3189,6 +3190,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
+                               }
+                               len = skb_headlen(skb);
+                               break;
++                      }
+                       default:
+                               /* do nothing */
+                               break;
+diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h 
b/drivers/net/ethernet/intel/e1000e/e1000.h
+index 879cca47b021..62675938cb59 100644
+--- a/drivers/net/ethernet/intel/e1000e/e1000.h
++++ b/drivers/net/ethernet/intel/e1000e/e1000.h
+@@ -589,7 +589,6 @@ static inline u32 __er32(struct e1000_hw *hw, unsigned 
long reg)
+ 
+ #define er32(reg)     __er32(hw, E1000_##reg)
+ 
+-s32 __ew32_prepare(struct e1000_hw *hw);
+ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val);
+ 
+ #define ew32(reg, val)        __ew32(hw, E1000_##reg, (val))
+diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c 
b/drivers/net/ethernet/intel/e1000e/netdev.c
+index a0f97c5ab6ef..be324b4761eb 100644
+--- a/drivers/net/ethernet/intel/e1000e/netdev.c
++++ b/drivers/net/ethernet/intel/e1000e/netdev.c
+@@ -136,14 +136,12 @@ static const struct e1000_reg_info e1000_reg_info_tbl[] 
= {
+  * has bit 24 set while ME is accessing MAC CSR registers, wait if it is set
+  * and try again a number of times.
+  **/
+-s32 __ew32_prepare(struct e1000_hw *hw)
++static void __ew32_prepare(struct e1000_hw *hw)
+ {
+       s32 i = E1000_ICH_FWSM_PCIM2PCI_COUNT;
+ 
+       while ((er32(FWSM) & E1000_ICH_FWSM_PCIM2PCI) && --i)
+               udelay(50);
+-
+-      return i;
+ }
+ 
+ void __ew32(struct e1000_hw *hw, unsigned long reg, u32 val)
+@@ -624,11 +622,11 @@ static void e1000e_update_rdt_wa(struct e1000_ring 
*rx_ring, unsigned int i)
+ {
+       struct e1000_adapter *adapter = rx_ring->adapter;
+       struct e1000_hw *hw = &adapter->hw;
+-      s32 ret_val = __ew32_prepare(hw);
+ 
++      __ew32_prepare(hw);
+       writel(i, rx_ring->tail);
+ 
+-      if (unlikely(!ret_val && (i != readl(rx_ring->tail)))) {
++      if (unlikely(i != readl(rx_ring->tail))) {
+               u32 rctl = er32(RCTL);
+ 
+               ew32(RCTL, rctl & ~E1000_RCTL_EN);
+@@ -641,11 +639,11 @@ static void e1000e_update_tdt_wa(struct e1000_ring 
*tx_ring, unsigned int i)
+ {
+       struct e1000_adapter *adapter = tx_ring->adapter;
+       struct e1000_hw *hw = &adapter->hw;
+-      s32 ret_val = __ew32_prepare(hw);
+ 
++      __ew32_prepare(hw);
+       writel(i, tx_ring->tail);
+ 
+-      if (unlikely(!ret_val && (i != readl(tx_ring->tail)))) {
++      if (unlikely(i != readl(tx_ring->tail))) {
+               u32 tctl = er32(TCTL);
+ 
+               ew32(TCTL, tctl & ~E1000_TCTL_EN);
+diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c 
b/drivers/net/ethernet/intel/igb/igb_ethtool.c
+index 737b664d004c..b02e262ed76a 100644
+--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
++++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
+@@ -153,7 +153,8 @@ static int igb_get_settings(struct net_device *netdev, 
struct ethtool_cmd *ecmd)
+       u32 status;
+       u32 speed;
+ 
+-      status = rd32(E1000_STATUS);
++      status = pm_runtime_suspended(&adapter->pdev->dev) ?
++               0 : rd32(E1000_STATUS);
+       if (hw->phy.media_type == e1000_media_type_copper) {
+ 
+               ecmd->supported = (SUPPORTED_10baseT_Half |
+diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c 
b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+index 0d2baec546e1..c17135b7fca7 100644
+--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
++++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c
+@@ -2219,7 +2219,7 @@ s32 ixgbe_fc_enable_generic(struct ixgbe_hw *hw)
+       }
+ 
+       /* Configure pause time (2 TCs per register) */
+-      reg = hw->fc.pause_time * 0x00010001;
++      reg = hw->fc.pause_time * 0x00010001U;
+       for (i = 0; i < (MAX_TRAFFIC_CLASS / 2); i++)
+               IXGBE_WRITE_REG(hw, IXGBE_FCTTV(i), reg);
+ 
+diff --git a/drivers/net/ethernet/nxp/lpc_eth.c 
b/drivers/net/ethernet/nxp/lpc_eth.c
+index 9fcaf1910633..9b98ec3dcb82 100644
+--- a/drivers/net/ethernet/nxp/lpc_eth.c
++++ b/drivers/net/ethernet/nxp/lpc_eth.c
+@@ -845,7 +845,8 @@ static int lpc_mii_init(struct netdata_local *pldat)
+       if (mdiobus_register(pldat->mii_bus))
+               goto err_out_unregister_bus;
+ 
+-      if (lpc_mii_probe(pldat->ndev) != 0)
++      err = lpc_mii_probe(pldat->ndev);
++      if (err)
+               goto err_out_unregister_bus;
+ 
+       return 0;
+diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
+index 4f582ce929f2..9dda2dc6b5e7 100644
+--- a/drivers/net/macvlan.c
++++ b/drivers/net/macvlan.c
+@@ -421,6 +421,10 @@ static rx_handler_result_t macvlan_handle_frame(struct 
sk_buff **pskb)
+       int ret;
+       rx_handler_result_t handle_res;
+ 
++      /* Packets from dev_loopback_xmit() do not have L2 header, bail out */
++      if (unlikely(skb->pkt_type == PACKET_LOOPBACK))
++              return RX_HANDLER_PASS;
++
+       port = macvlan_port_get_rcu(skb->dev);
+       if (is_multicast_ether_addr(eth->h_dest)) {
+               unsigned int hash;
+diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c 
b/drivers/net/vmxnet3/vmxnet3_ethtool.c
+index aabc6ef366b4..d63b83605748 100644
+--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
++++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
+@@ -691,6 +691,8 @@ vmxnet3_get_rss(struct net_device *netdev, u32 *p, u8 
*key, u8 *hfunc)
+               *hfunc = ETH_RSS_HASH_TOP;
+       if (!p)
+               return 0;
++      if (n > UPT1_RSS_MAX_IND_TABLE_SIZE)
++              return 0;
+       while (n--)
+               p[n] = rssConf->indTable[n];
+       return 0;
+diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
+index 58ddb6c90418..b1470d30d079 100644
+--- a/drivers/net/vxlan.c
++++ b/drivers/net/vxlan.c
+@@ -1521,6 +1521,10 @@ static struct sk_buff *vxlan_na_create(struct sk_buff 
*request,
+       daddr = eth_hdr(request)->h_source;
+       ns_olen = request->len - skb_transport_offset(request) - sizeof(*ns);
+       for (i = 0; i < ns_olen-1; i += (ns->opt[i+1]<<3)) {
++              if (!ns->opt[i + 1]) {
++                      kfree_skb(reply);
++                      return NULL;
++              }
+               if (ns->opt[i] == ND_OPT_SOURCE_LL_ADDR) {
+                       daddr = ns->opt + i + sizeof(struct nd_opt_hdr);
+                       break;
+diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.c 
b/drivers/net/wireless/ath/ath9k/hif_usb.c
+index b5e12be73f2b..e27acccc3678 100644
+--- a/drivers/net/wireless/ath/ath9k/hif_usb.c
++++ b/drivers/net/wireless/ath/ath9k/hif_usb.c
+@@ -610,6 +610,11 @@ static void ath9k_hif_usb_rx_stream(struct hif_device_usb 
*hif_dev,
+                       hif_dev->remain_skb = nskb;
+                       spin_unlock(&hif_dev->rx_lock);
+               } else {
++                      if (pool_index == MAX_PKT_NUM_IN_TRANSFER) {
++                              dev_err(&hif_dev->udev->dev,
++                                      "ath9k_htc: over RX MAX_PKT_NUM\n");
++                              goto err;
++                      }
+                       nskb = __dev_alloc_skb(pkt_len + 32, GFP_ATOMIC);
+                       if (!nskb) {
+                               dev_err(&hif_dev->udev->dev,
+@@ -636,9 +641,9 @@ err:
+ 
+ static void ath9k_hif_usb_rx_cb(struct urb *urb)
+ {
+-      struct sk_buff *skb = (struct sk_buff *) urb->context;
+-      struct hif_device_usb *hif_dev =
+-              usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
++      struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
++      struct hif_device_usb *hif_dev = rx_buf->hif_dev;
++      struct sk_buff *skb = rx_buf->skb;
+       int ret;
+ 
+       if (!skb)
+@@ -678,14 +683,15 @@ resubmit:
+       return;
+ free:
+       kfree_skb(skb);
++      kfree(rx_buf);
+ }
+ 
+ static void ath9k_hif_usb_reg_in_cb(struct urb *urb)
+ {
+-      struct sk_buff *skb = (struct sk_buff *) urb->context;
++      struct rx_buf *rx_buf = (struct rx_buf *)urb->context;
++      struct hif_device_usb *hif_dev = rx_buf->hif_dev;
++      struct sk_buff *skb = rx_buf->skb;
+       struct sk_buff *nskb;
+-      struct hif_device_usb *hif_dev =
+-              usb_get_intfdata(usb_ifnum_to_if(urb->dev, 0));
+       int ret;
+ 
+       if (!skb)
+@@ -743,6 +749,7 @@ resubmit:
+       return;
+ free:
+       kfree_skb(skb);
++      kfree(rx_buf);
+       urb->context = NULL;
+ }
+ 
+@@ -788,7 +795,7 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct 
hif_device_usb *hif_dev)
+       init_usb_anchor(&hif_dev->mgmt_submitted);
+ 
+       for (i = 0; i < MAX_TX_URB_NUM; i++) {
+-              tx_buf = kzalloc(sizeof(struct tx_buf), GFP_KERNEL);
++              tx_buf = kzalloc(sizeof(*tx_buf), GFP_KERNEL);
+               if (!tx_buf)
+                       goto err;
+ 
+@@ -825,8 +832,9 @@ static void ath9k_hif_usb_dealloc_rx_urbs(struct 
hif_device_usb *hif_dev)
+ 
+ static int ath9k_hif_usb_alloc_rx_urbs(struct hif_device_usb *hif_dev)
+ {
+-      struct urb *urb = NULL;
++      struct rx_buf *rx_buf = NULL;
+       struct sk_buff *skb = NULL;
++      struct urb *urb = NULL;
+       int i, ret;
+ 
+       init_usb_anchor(&hif_dev->rx_submitted);
+@@ -834,6 +842,12 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct 
hif_device_usb *hif_dev)
+ 
+       for (i = 0; i < MAX_RX_URB_NUM; i++) {
+ 
++              rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
++              if (!rx_buf) {
++                      ret = -ENOMEM;
++                      goto err_rxb;
++              }
++
+               /* Allocate URB */
+               urb = usb_alloc_urb(0, GFP_KERNEL);
+               if (urb == NULL) {
+@@ -848,11 +862,14 @@ static int ath9k_hif_usb_alloc_rx_urbs(struct 
hif_device_usb *hif_dev)
+                       goto err_skb;
+               }
+ 
++              rx_buf->hif_dev = hif_dev;
++              rx_buf->skb = skb;
++
+               usb_fill_bulk_urb(urb, hif_dev->udev,
+                                 usb_rcvbulkpipe(hif_dev->udev,
+                                                 USB_WLAN_RX_PIPE),
+                                 skb->data, MAX_RX_BUF_SIZE,
+-                                ath9k_hif_usb_rx_cb, skb);
++                                ath9k_hif_usb_rx_cb, rx_buf);
+ 
+               /* Anchor URB */
+               usb_anchor_urb(urb, &hif_dev->rx_submitted);
+@@ -878,6 +895,8 @@ err_submit:
+ err_skb:
+       usb_free_urb(urb);
+ err_urb:
++      kfree(rx_buf);
++err_rxb:
+       ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
+       return ret;
+ }
+@@ -889,14 +908,21 @@ static void ath9k_hif_usb_dealloc_reg_in_urbs(struct 
hif_device_usb *hif_dev)
+ 
+ static int ath9k_hif_usb_alloc_reg_in_urbs(struct hif_device_usb *hif_dev)
+ {
+-      struct urb *urb = NULL;
++      struct rx_buf *rx_buf = NULL;
+       struct sk_buff *skb = NULL;
++      struct urb *urb = NULL;
+       int i, ret;
+ 
+       init_usb_anchor(&hif_dev->reg_in_submitted);
+ 
+       for (i = 0; i < MAX_REG_IN_URB_NUM; i++) {
+ 
++              rx_buf = kzalloc(sizeof(*rx_buf), GFP_KERNEL);
++              if (!rx_buf) {
++                      ret = -ENOMEM;
++                      goto err_rxb;
++              }
++
+               /* Allocate URB */
+               urb = usb_alloc_urb(0, GFP_KERNEL);
+               if (urb == NULL) {
+@@ -911,11 +937,14 @@ static int ath9k_hif_usb_alloc_reg_in_urbs(struct 
hif_device_usb *hif_dev)
+                       goto err_skb;
+               }
+ 
++              rx_buf->hif_dev = hif_dev;
++              rx_buf->skb = skb;
++
+               usb_fill_int_urb(urb, hif_dev->udev,
+                                 usb_rcvintpipe(hif_dev->udev,
+                                                 USB_REG_IN_PIPE),
+                                 skb->data, MAX_REG_IN_BUF_SIZE,
+-                                ath9k_hif_usb_reg_in_cb, skb, 1);
++                                ath9k_hif_usb_reg_in_cb, rx_buf, 1);
+ 
+               /* Anchor URB */
+               usb_anchor_urb(urb, &hif_dev->reg_in_submitted);
+@@ -941,6 +970,8 @@ err_submit:
+ err_skb:
+       usb_free_urb(urb);
+ err_urb:
++      kfree(rx_buf);
++err_rxb:
+       ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
+       return ret;
+ }
+@@ -971,7 +1002,7 @@ err:
+       return -ENOMEM;
+ }
+ 
+-static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
++void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
+ {
+       usb_kill_anchored_urbs(&hif_dev->regout_submitted);
+       ath9k_hif_usb_dealloc_reg_in_urbs(hif_dev);
+@@ -1338,8 +1369,9 @@ static void ath9k_hif_usb_disconnect(struct 
usb_interface *interface)
+ 
+       if (hif_dev->flags & HIF_USB_READY) {
+               ath9k_htc_hw_deinit(hif_dev->htc_handle, unplugged);
+-              ath9k_htc_hw_free(hif_dev->htc_handle);
+               ath9k_hif_usb_dev_deinit(hif_dev);
++              ath9k_destoy_wmi(hif_dev->htc_handle->drv_priv);
++              ath9k_htc_hw_free(hif_dev->htc_handle);
+       }
+ 
+       usb_set_intfdata(interface, NULL);
+diff --git a/drivers/net/wireless/ath/ath9k/hif_usb.h 
b/drivers/net/wireless/ath/ath9k/hif_usb.h
+index 7c2ef7ecd98b..835264c36595 100644
+--- a/drivers/net/wireless/ath/ath9k/hif_usb.h
++++ b/drivers/net/wireless/ath/ath9k/hif_usb.h
+@@ -84,6 +84,11 @@ struct tx_buf {
+       struct list_head list;
+ };
+ 
++struct rx_buf {
++      struct sk_buff *skb;
++      struct hif_device_usb *hif_dev;
++};
++
+ #define HIF_USB_TX_STOP  BIT(0)
+ #define HIF_USB_TX_FLUSH BIT(1)
+ 
+@@ -131,5 +136,6 @@ struct hif_device_usb {
+ 
+ int ath9k_hif_usb_init(void);
+ void ath9k_hif_usb_exit(void);
++void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev);
+ 
+ #endif /* HTC_USB_H */
+diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c 
b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+index b65c1b661ade..15a0036dcc6e 100644
+--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
++++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+@@ -931,8 +931,9 @@ err_init:
+ int ath9k_htc_probe_device(struct htc_target *htc_handle, struct device *dev,
+                          u16 devid, char *product, u32 drv_info)
+ {
+-      struct ieee80211_hw *hw;
++      struct hif_device_usb *hif_dev;
+       struct ath9k_htc_priv *priv;
++      struct ieee80211_hw *hw;
+       int ret;
+ 
+       hw = ieee80211_alloc_hw(sizeof(struct ath9k_htc_priv), &ath9k_htc_ops);
+@@ -967,7 +968,10 @@ int ath9k_htc_probe_device(struct htc_target *htc_handle, 
struct device *dev,
+       return 0;
+ 
+ err_init:
+-      ath9k_deinit_wmi(priv);
++      ath9k_stop_wmi(priv);
++      hif_dev = (struct hif_device_usb *)htc_handle->hif_dev;
++      ath9k_hif_usb_dealloc_urbs(hif_dev);
++      ath9k_destoy_wmi(priv);
+ err_free:
+       ieee80211_free_hw(hw);
+       return ret;
+@@ -982,7 +986,7 @@ void ath9k_htc_disconnect_device(struct htc_target 
*htc_handle, bool hotunplug)
+                       htc_handle->drv_priv->ah->ah_flags |= AH_UNPLUGGED;
+ 
+               ath9k_deinit_device(htc_handle->drv_priv);
+-              ath9k_deinit_wmi(htc_handle->drv_priv);
++              ath9k_stop_wmi(htc_handle->drv_priv);
+               ieee80211_free_hw(htc_handle->drv_priv->hw);
+       }
+ }
+diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c 
b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+index 52b42ecee621..2eb169b204f8 100644
+--- a/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
++++ b/drivers/net/wireless/ath/ath9k/htc_drv_txrx.c
+@@ -998,9 +998,9 @@ static bool ath9k_rx_prepare(struct ath9k_htc_priv *priv,
+        * which are not PHY_ERROR (short radar pulses have a length of 3)
+        */
+       if (unlikely(!rs_datalen || (rs_datalen < 10 && !is_phyerr))) {
+-              ath_warn(common,
+-                       "Short RX data len, dropping (dlen: %d)\n",
+-                       rs_datalen);
++              ath_dbg(common, ANY,
++                      "Short RX data len, dropping (dlen: %d)\n",
++                      rs_datalen);
+               goto rx_next;
+       }
+ 
+diff --git a/drivers/net/wireless/ath/ath9k/htc_hst.c 
b/drivers/net/wireless/ath/ath9k/htc_hst.c
+index fd85f996c554..257b6ee51e54 100644
+--- a/drivers/net/wireless/ath/ath9k/htc_hst.c
++++ b/drivers/net/wireless/ath/ath9k/htc_hst.c
+@@ -114,6 +114,9 @@ static void htc_process_conn_rsp(struct htc_target *target,
+ 
+       if (svc_rspmsg->status == HTC_SERVICE_SUCCESS) {
+               epid = svc_rspmsg->endpoint_id;
++              if (epid < 0 || epid >= ENDPOINT_MAX)
++                      return;
++
+               service_id = be16_to_cpu(svc_rspmsg->service_id);
+               max_msglen = be16_to_cpu(svc_rspmsg->max_msg_len);
+               endpoint = &target->endpoint[epid];
+diff --git a/drivers/net/wireless/ath/ath9k/wmi.c 
b/drivers/net/wireless/ath/ath9k/wmi.c
+index 9c16e2a6d185..8f14897ae5a3 100644
+--- a/drivers/net/wireless/ath/ath9k/wmi.c
++++ b/drivers/net/wireless/ath/ath9k/wmi.c
+@@ -112,14 +112,17 @@ struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv)
+       return wmi;
+ }
+ 
+-void ath9k_deinit_wmi(struct ath9k_htc_priv *priv)
++void ath9k_stop_wmi(struct ath9k_htc_priv *priv)
+ {
+       struct wmi *wmi = priv->wmi;
+ 
+       mutex_lock(&wmi->op_mutex);
+       wmi->stopped = true;
+       mutex_unlock(&wmi->op_mutex);
++}
+ 
++void ath9k_destoy_wmi(struct ath9k_htc_priv *priv)
++{
+       kfree(priv->wmi);
+ }
+ 
+diff --git a/drivers/net/wireless/ath/ath9k/wmi.h 
b/drivers/net/wireless/ath/ath9k/wmi.h
+index 380175d5ecd7..d8b912206232 100644
+--- a/drivers/net/wireless/ath/ath9k/wmi.h
++++ b/drivers/net/wireless/ath/ath9k/wmi.h
+@@ -179,7 +179,6 @@ struct wmi {
+ };
+ 
+ struct wmi *ath9k_init_wmi(struct ath9k_htc_priv *priv);
+-void ath9k_deinit_wmi(struct ath9k_htc_priv *priv);
+ int ath9k_wmi_connect(struct htc_target *htc, struct wmi *wmi,
+                     enum htc_endpoint_id *wmi_ctrl_epid);
+ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
+@@ -189,6 +188,8 @@ int ath9k_wmi_cmd(struct wmi *wmi, enum wmi_cmd_id cmd_id,
+ void ath9k_wmi_event_tasklet(unsigned long data);
+ void ath9k_fatal_work(struct work_struct *work);
+ void ath9k_wmi_event_drain(struct ath9k_htc_priv *priv);
++void ath9k_stop_wmi(struct ath9k_htc_priv *priv);
++void ath9k_destoy_wmi(struct ath9k_htc_priv *priv);
+ 
+ #define WMI_CMD(_wmi_cmd)                                             \
+       do {                                                            \
+diff --git a/drivers/net/wireless/ath/carl9170/fw.c 
b/drivers/net/wireless/ath/carl9170/fw.c
+index 88045f93a76c..62ed0977f32c 100644
+--- a/drivers/net/wireless/ath/carl9170/fw.c
++++ b/drivers/net/wireless/ath/carl9170/fw.c
+@@ -351,9 +351,7 @@ static int carl9170_fw(struct ar9170 *ar, const __u8 
*data, size_t len)
+               ar->hw->wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC);
+ 
+               if (SUPP(CARL9170FW_WLANTX_CAB)) {
+-                      if_comb_types |=
+-                              BIT(NL80211_IFTYPE_AP) |
+-                              BIT(NL80211_IFTYPE_P2P_GO);
++                      if_comb_types |= BIT(NL80211_IFTYPE_AP);
+ 
+ #ifdef CONFIG_MAC80211_MESH
+                       if_comb_types |=
+diff --git a/drivers/net/wireless/ath/carl9170/main.c 
b/drivers/net/wireless/ath/carl9170/main.c
+index ffb22a04beeb..202f421e0e37 100644
+--- a/drivers/net/wireless/ath/carl9170/main.c
++++ b/drivers/net/wireless/ath/carl9170/main.c
+@@ -582,11 +582,10 @@ static int carl9170_init_interface(struct ar9170 *ar,
+       ar->disable_offload |= ((vif->type != NL80211_IFTYPE_STATION) &&
+           (vif->type != NL80211_IFTYPE_AP));
+ 
+-      /* While the driver supports HW offload in a single
+-       * P2P client configuration, it doesn't support HW
+-       * offload in the favourit, concurrent P2P GO+CLIENT
+-       * configuration. Hence, HW offload will always be
+-       * disabled for P2P.
++      /* The driver used to have P2P GO+CLIENT support,
++       * but since this was dropped and we don't know if
++       * there are any gremlins lurking in the shadows,
++       * so best we keep HW offload disabled for P2P.
+        */
+       ar->disable_offload |= vif->p2p;
+ 
+@@ -639,18 +638,6 @@ static int carl9170_op_add_interface(struct ieee80211_hw 
*hw,
+                       if (vif->type == NL80211_IFTYPE_STATION)
+                               break;
+ 
+-                      /* P2P GO [master] use-case
+-                       * Because the P2P GO station is selected dynamically
+-                       * by all participating peers of a WIFI Direct network,
+-                       * the driver has be able to change the main interface
+-                       * operating mode on the fly.
+-                       */
+-                      if (main_vif->p2p && vif->p2p &&
+-                          vif->type == NL80211_IFTYPE_AP) {
+-                              old_main = main_vif;
+-                              break;
+-                      }
+-
+                       err = -EBUSY;
+                       rcu_read_unlock();
+ 
+diff --git a/drivers/net/wireless/broadcom/b43/main.c 
b/drivers/net/wireless/broadcom/b43/main.c
+index a635fc6b1722..e57a50cc1d87 100644
+--- a/drivers/net/wireless/broadcom/b43/main.c
++++ b/drivers/net/wireless/broadcom/b43/main.c
+@@ -5596,7 +5596,7 @@ static struct b43_wl *b43_wireless_init(struct 
b43_bus_dev *dev)
+       /* fill hw info */
+       ieee80211_hw_set(hw, RX_INCLUDES_FCS);
+       ieee80211_hw_set(hw, SIGNAL_DBM);
+-
++      ieee80211_hw_set(hw, MFP_CAPABLE);
+       hw->wiphy->interface_modes =
+               BIT(NL80211_IFTYPE_AP) |
+               BIT(NL80211_IFTYPE_MESH_POINT) |
+diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c 
b/drivers/net/wireless/broadcom/b43legacy/main.c
+index 9da8bd792702..fe658a9b53cb 100644
+--- a/drivers/net/wireless/broadcom/b43legacy/main.c
++++ b/drivers/net/wireless/broadcom/b43legacy/main.c
+@@ -3835,6 +3835,7 @@ static int b43legacy_wireless_init(struct ssb_device 
*dev)
+       /* fill hw info */
+       ieee80211_hw_set(hw, RX_INCLUDES_FCS);
+       ieee80211_hw_set(hw, SIGNAL_DBM);
++      ieee80211_hw_set(hw, MFP_CAPABLE); /* Allow WPA3 in software */
+ 
+       hw->wiphy->interface_modes =
+               BIT(NL80211_IFTYPE_AP) |
+diff --git a/drivers/net/wireless/broadcom/b43legacy/xmit.c 
b/drivers/net/wireless/broadcom/b43legacy/xmit.c
+index 35ccf400b02c..87045e30e585 100644
+--- a/drivers/net/wireless/broadcom/b43legacy/xmit.c
++++ b/drivers/net/wireless/broadcom/b43legacy/xmit.c
+@@ -571,6 +571,7 @@ void b43legacy_rx(struct b43legacy_wldev *dev,
+       default:
+               b43legacywarn(dev->wl, "Unexpected value for chanstat (0x%X)\n",
+                      chanstat);
++              goto drop;
+       }
+ 
+       memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status));
+diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c 
b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+index 94901b0041ce..c597af69f48f 100644
+--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
++++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+@@ -1446,7 +1446,8 @@ mwifiex_cfg80211_dump_station(struct wiphy *wiphy, 
struct net_device *dev,
+                             int idx, u8 *mac, struct station_info *sinfo)
+ {
+       struct mwifiex_private *priv = mwifiex_netdev_get_priv(dev);
+-      static struct mwifiex_sta_node *node;
++      struct mwifiex_sta_node *node;
++      int i;
+ 
+       if ((GET_BSS_ROLE(priv) == MWIFIEX_BSS_ROLE_STA) &&
+           priv->media_connected && idx == 0) {
+@@ -1456,13 +1457,10 @@ mwifiex_cfg80211_dump_station(struct wiphy *wiphy, 
struct net_device *dev,
+               mwifiex_send_cmd(priv, HOST_CMD_APCMD_STA_LIST,
+                                HostCmd_ACT_GEN_GET, 0, NULL, true);
+ 
+-              if (node && (&node->list == &priv->sta_list)) {
+-                      node = NULL;
+-                      return -ENOENT;
+-              }
+-
+-              node = list_prepare_entry(node, &priv->sta_list, list);
+-              list_for_each_entry_continue(node, &priv->sta_list, list) {
++              i = 0;
++              list_for_each_entry(node, &priv->sta_list, list) {
++                      if (i++ != idx)
++                              continue;
+                       ether_addr_copy(mac, node->mac_addr);
+                       return mwifiex_dump_station_info(priv, node, sinfo);
+               }
+diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c 
b/drivers/net/wireless/realtek/rtlwifi/usb.c
+index 1f02461de261..93b22a5b6878 100644
+--- a/drivers/net/wireless/realtek/rtlwifi/usb.c
++++ b/drivers/net/wireless/realtek/rtlwifi/usb.c
+@@ -927,10 +927,8 @@ static struct urb *_rtl_usb_tx_urb_setup(struct 
ieee80211_hw *hw,
+ 
+       WARN_ON(NULL == skb);
+       _urb = usb_alloc_urb(0, GFP_ATOMIC);
+-      if (!_urb) {
+-              kfree_skb(skb);
++      if (!_urb)
+               return NULL;
+-      }
+       _rtl_install_trx_info(rtlusb, skb, ep_num);
+       usb_fill_bulk_urb(_urb, rtlusb->udev, usb_sndbulkpipe(rtlusb->udev,
+                         ep_num), skb->data, skb->len, _rtl_tx_complete, skb);
+@@ -945,7 +943,6 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, 
struct sk_buff *skb,
+       struct rtl_usb *rtlusb = rtl_usbdev(rtl_usbpriv(hw));
+       u32 ep_num;
+       struct urb *_urb = NULL;
+-      struct sk_buff *_skb = NULL;
+ 
+       WARN_ON(NULL == rtlusb->usb_tx_aggregate_hdl);
+       if (unlikely(IS_USB_STOP(rtlusb))) {
+@@ -955,8 +952,7 @@ static void _rtl_usb_transmit(struct ieee80211_hw *hw, 
struct sk_buff *skb,
+               return;
+       }
+       ep_num = rtlusb->ep_map.ep_mapping[qnum];
+-      _skb = skb;
+-      _urb = _rtl_usb_tx_urb_setup(hw, _skb, ep_num);
++      _urb = _rtl_usb_tx_urb_setup(hw, skb, ep_num);
+       if (unlikely(!_urb)) {
+               RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
+                        "Can't allocate urb. Drop skb!\n");
+diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
+index 16611cf3aba4..19658873b4c1 100644
+--- a/drivers/pci/probe.c
++++ b/drivers/pci/probe.c
+@@ -1251,7 +1251,7 @@ int pci_setup_device(struct pci_dev *dev)
+       /* device class may be changed after fixup */
+       class = dev->class >> 8;
+ 
+-      if (dev->non_compliant_bars) {
++      if (dev->non_compliant_bars && !dev->mmio_always_on) {
+               pci_read_config_word(dev, PCI_COMMAND, &cmd);
+               if (cmd & (PCI_COMMAND_IO | PCI_COMMAND_MEMORY)) {
+                       dev_info(&dev->dev, "device has non-compliant BARs; 
disabling IO/MEM decoding\n");
+@@ -1360,13 +1360,33 @@ static void pci_configure_mps(struct pci_dev *dev)
+       struct pci_dev *bridge = pci_upstream_bridge(dev);
+       int mps, p_mps, rc;
+ 
+-      if (!pci_is_pcie(dev) || !bridge || !pci_is_pcie(bridge))
++      if (!pci_is_pcie(dev))
+               return;
+ 
+       /* MPS and MRRS fields are of type 'RsvdP' for VFs, short-circuit out */
+       if (dev->is_virtfn)
+               return;
+ 
++      /*
++       * For Root Complex Integrated Endpoints, program the maximum
++       * supported value unless limited by the PCIE_BUS_PEER2PEER case.
++       */
++      if (pci_pcie_type(dev) == PCI_EXP_TYPE_RC_END) {
++              if (pcie_bus_config == PCIE_BUS_PEER2PEER)
++                      mps = 128;
++              else
++                      mps = 128 << dev->pcie_mpss;
++              rc = pcie_set_mps(dev, mps);
++              if (rc) {
++                      pci_warn(dev, "can't set Max Payload Size to %d; if 
necessary, use \"pci=pcie_bus_safe\" and report a bug\n",
++                               mps);
++              }
++              return;
++      }
++
++      if (!bridge || !pci_is_pcie(bridge))
++              return;
++
+       mps = pcie_get_mps(dev);
+       p_mps = pcie_get_mps(bridge);
+ 
+diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c 
b/drivers/pinctrl/samsung/pinctrl-exynos.c
+index e8aee6d88a40..6a23136bc813 100644
+--- a/drivers/pinctrl/samsung/pinctrl-exynos.c
++++ b/drivers/pinctrl/samsung/pinctrl-exynos.c
+@@ -289,6 +289,7 @@ struct exynos_eint_gpio_save {
+       u32 eint_con;
+       u32 eint_fltcon0;
+       u32 eint_fltcon1;
++      u32 eint_mask;
+ };
+ 
+ /*
+@@ -585,10 +586,13 @@ static void exynos_pinctrl_suspend_bank(
+                                               + 2 * bank->eint_offset);
+       save->eint_fltcon1 = readl(regs + EXYNOS_GPIO_EFLTCON_OFFSET
+                                               + 2 * bank->eint_offset + 4);
++      save->eint_mask = readl(regs + bank->irq_chip->eint_mask
++                                              + bank->eint_offset);
+ 
+       pr_debug("%s: save     con %#010x\n", bank->name, save->eint_con);
+       pr_debug("%s: save fltcon0 %#010x\n", bank->name, save->eint_fltcon0);
+       pr_debug("%s: save fltcon1 %#010x\n", bank->name, save->eint_fltcon1);
++      pr_debug("%s: save    mask %#010x\n", bank->name, save->eint_mask);
+ }
+ 
+ static void exynos_pinctrl_suspend(struct samsung_pinctrl_drv_data *drvdata)
+@@ -617,6 +621,9 @@ static void exynos_pinctrl_resume_bank(
+       pr_debug("%s: fltcon1 %#010x => %#010x\n", bank->name,
+                       readl(regs + EXYNOS_GPIO_EFLTCON_OFFSET
+                       + 2 * bank->eint_offset + 4), save->eint_fltcon1);
++      pr_debug("%s:    mask %#010x => %#010x\n", bank->name,
++                      readl(regs + bank->irq_chip->eint_mask
++                      + bank->eint_offset), save->eint_mask);
+ 
+       writel(save->eint_con, regs + EXYNOS_GPIO_ECON_OFFSET
+                                               + bank->eint_offset);
+@@ -624,6 +631,8 @@ static void exynos_pinctrl_resume_bank(
+                                               + 2 * bank->eint_offset);
+       writel(save->eint_fltcon1, regs + EXYNOS_GPIO_EFLTCON_OFFSET
+                                               + 2 * bank->eint_offset + 4);
++      writel(save->eint_mask, regs + bank->irq_chip->eint_mask
++                                              + bank->eint_offset);
+ }
+ 
+ static void exynos_pinctrl_resume(struct samsung_pinctrl_drv_data *drvdata)
+diff --git a/drivers/power/reset/vexpress-poweroff.c 
b/drivers/power/reset/vexpress-poweroff.c
+index e9e749f87517..8fb43c4438e6 100644
+--- a/drivers/power/reset/vexpress-poweroff.c
++++ b/drivers/power/reset/vexpress-poweroff.c
+@@ -150,6 +150,7 @@ static struct platform_driver vexpress_reset_driver = {
+       .driver = {
+               .name = "vexpress-reset",
+               .of_match_table = vexpress_reset_of_match,
++              .suppress_bind_attrs = true,
+       },
+ };
+ 
+diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
+index c7b770075caa..80341863caa5 100644
+--- a/drivers/scsi/scsi_lib.c
++++ b/drivers/scsi/scsi_lib.c
+@@ -1029,10 +1029,10 @@ int scsi_init_io(struct scsi_cmnd *cmd)
+       struct scsi_device *sdev = cmd->device;
+       struct request *rq = cmd->request;
+       bool is_mq = (rq->mq_ctx != NULL);
+-      int error;
++      int error = BLKPREP_KILL;
+ 
+       if (WARN_ON_ONCE(!rq->nr_phys_segments))
+-              return -EINVAL;
++              goto err_exit;
+ 
+       error = scsi_init_sgtable(rq, &cmd->sdb);
+       if (error)
+diff --git a/drivers/spi/spi-bcm-qspi.c b/drivers/spi/spi-bcm-qspi.c
+index 63231760facc..1906b2319e5b 100644
+--- a/drivers/spi/spi-bcm-qspi.c
++++ b/drivers/spi/spi-bcm-qspi.c
+@@ -698,7 +698,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots)
+                       if (buf)
+                               buf[tp.byte] = read_rxram_slot_u8(qspi, slot);
+                       dev_dbg(&qspi->pdev->dev, "RD %02x\n",
+-                              buf ? buf[tp.byte] : 0xff);
++                              buf ? buf[tp.byte] : 0x0);
+               } else {
+                       u16 *buf = tp.trans->rx_buf;
+ 
+@@ -706,7 +706,7 @@ static void read_from_hw(struct bcm_qspi *qspi, int slots)
+                               buf[tp.byte / 2] = read_rxram_slot_u16(qspi,
+                                                                     slot);
+                       dev_dbg(&qspi->pdev->dev, "RD %04x\n",
+-                              buf ? buf[tp.byte] : 0xffff);
++                              buf ? buf[tp.byte / 2] : 0x0);
+               }
+ 
+               update_qspi_trans_byte_count(qspi, &tp,
+@@ -761,13 +761,13 @@ static int write_to_hw(struct bcm_qspi *qspi, struct 
spi_device *spi)
+       while (!tstatus && slot < MSPI_NUM_CDRAM) {
+               if (tp.trans->bits_per_word <= 8) {
+                       const u8 *buf = tp.trans->tx_buf;
+-                      u8 val = buf ? buf[tp.byte] : 0xff;
++                      u8 val = buf ? buf[tp.byte] : 0x00;
+ 
+                       write_txram_slot_u8(qspi, slot, val);
+                       dev_dbg(&qspi->pdev->dev, "WR %02x\n", val);
+               } else {
+                       const u16 *buf = tp.trans->tx_buf;
+-                      u16 val = buf ? buf[tp.byte / 2] : 0xffff;
++                      u16 val = buf ? buf[tp.byte / 2] : 0x0000;
+ 
+                       write_txram_slot_u16(qspi, slot, val);
+                       dev_dbg(&qspi->pdev->dev, "WR %04x\n", val);
+diff --git a/drivers/spi/spi-bcm2835.c b/drivers/spi/spi-bcm2835.c
+index eab27d41ba83..df6abc75bc16 100644
+--- a/drivers/spi/spi-bcm2835.c
++++ b/drivers/spi/spi-bcm2835.c
+@@ -793,7 +793,7 @@ static int bcm2835_spi_probe(struct platform_device *pdev)
+               goto out_clk_disable;
+       }
+ 
+-      err = devm_spi_register_master(&pdev->dev, master);
++      err = spi_register_master(master);
+       if (err) {
+               dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
+               goto out_clk_disable;
+@@ -813,6 +813,8 @@ static int bcm2835_spi_remove(struct platform_device *pdev)
+       struct spi_master *master = platform_get_drvdata(pdev);
+       struct bcm2835_spi *bs = spi_master_get_devdata(master);
+ 
++      spi_unregister_master(master);
++
+       /* Clear FIFOs, and disable the HW block */
+       bcm2835_wr(bs, BCM2835_SPI_CS,
+                  BCM2835_SPI_CS_CLEAR_RX | BCM2835_SPI_CS_CLEAR_TX);
+diff --git a/drivers/spi/spi-bcm2835aux.c b/drivers/spi/spi-bcm2835aux.c
+index e075712c501e..b7f78e6d9bec 100644
+--- a/drivers/spi/spi-bcm2835aux.c
++++ b/drivers/spi/spi-bcm2835aux.c
+@@ -485,7 +485,7 @@ static int bcm2835aux_spi_probe(struct platform_device 
*pdev)
+               goto out_clk_disable;
+       }
+ 
+-      err = devm_spi_register_master(&pdev->dev, master);
++      err = spi_register_master(master);
+       if (err) {
+               dev_err(&pdev->dev, "could not register SPI master: %d\n", err);
+               goto out_clk_disable;
+@@ -505,6 +505,8 @@ static int bcm2835aux_spi_remove(struct platform_device 
*pdev)
+       struct spi_master *master = platform_get_drvdata(pdev);
+       struct bcm2835aux_spi *bs = spi_master_get_devdata(master);
+ 
++      spi_unregister_master(master);
++
+       bcm2835aux_spi_reset_hw(bs);
+ 
+       /* disable the HW block by releasing the clock */
+diff --git a/drivers/spi/spi-dw-mid.c b/drivers/spi/spi-dw-mid.c
+index e31971f91475..c079ab36275f 100644
+--- a/drivers/spi/spi-dw-mid.c
++++ b/drivers/spi/spi-dw-mid.c
+@@ -155,6 +155,7 @@ static struct dma_async_tx_descriptor 
*dw_spi_dma_prepare_tx(struct dw_spi *dws,
+       if (!xfer->tx_buf)
+               return NULL;
+ 
++      memset(&txconf, 0, sizeof(txconf));
+       txconf.direction = DMA_MEM_TO_DEV;
+       txconf.dst_addr = dws->dma_addr;
+       txconf.dst_maxburst = 16;
+@@ -201,6 +202,7 @@ static struct dma_async_tx_descriptor 
*dw_spi_dma_prepare_rx(struct dw_spi *dws,
+       if (!xfer->rx_buf)
+               return NULL;
+ 
++      memset(&rxconf, 0, sizeof(rxconf));
+       rxconf.direction = DMA_DEV_TO_MEM;
+       rxconf.src_addr = dws->dma_addr;
+       rxconf.src_maxburst = 16;
+@@ -226,19 +228,23 @@ static struct dma_async_tx_descriptor 
*dw_spi_dma_prepare_rx(struct dw_spi *dws,
+ 
+ static int mid_spi_dma_setup(struct dw_spi *dws, struct spi_transfer *xfer)
+ {
+-      u16 dma_ctrl = 0;
++      u16 imr = 0, dma_ctrl = 0;
+ 
+       dw_writel(dws, DW_SPI_DMARDLR, 0xf);
+       dw_writel(dws, DW_SPI_DMATDLR, 0x10);
+ 
+-      if (xfer->tx_buf)
++      if (xfer->tx_buf) {
+               dma_ctrl |= SPI_DMA_TDMAE;
+-      if (xfer->rx_buf)
++              imr |= SPI_INT_TXOI;
++      }
++      if (xfer->rx_buf) {
+               dma_ctrl |= SPI_DMA_RDMAE;
++              imr |= SPI_INT_RXUI | SPI_INT_RXOI;
++      }
+       dw_writel(dws, DW_SPI_DMACR, dma_ctrl);
+ 
+       /* Set the interrupt mask */
+-      spi_umask_intr(dws, SPI_INT_TXOI | SPI_INT_RXUI | SPI_INT_RXOI);
++      spi_umask_intr(dws, imr);
+ 
+       dws->transfer_handler = dma_transfer;
+ 
+@@ -268,7 +274,7 @@ static int mid_spi_dma_transfer(struct dw_spi *dws, struct 
spi_transfer *xfer)
+               dma_async_issue_pending(dws->txchan);
+       }
+ 
+-      return 0;
++      return 1;
+ }
+ 
+ static void mid_spi_dma_stop(struct dw_spi *dws)
+diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c
+index babf0a337e96..91f44e3e1930 100644
+--- a/drivers/spi/spi-dw.c
++++ b/drivers/spi/spi-dw.c
+@@ -384,11 +384,8 @@ static int dw_spi_transfer_one(struct spi_master *master,
+ 
+       spi_enable_chip(dws, 1);
+ 
+-      if (dws->dma_mapped) {
+-              ret = dws->dma_ops->dma_transfer(dws, transfer);
+-              if (ret < 0)
+-                      return ret;
+-      }
++      if (dws->dma_mapped)
++              return dws->dma_ops->dma_transfer(dws, transfer);
+ 
+       if (chip->poll_mode)
+               return poll_transfer(dws);
+@@ -500,6 +497,8 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
+       snprintf(dws->name, sizeof(dws->name), "dw_spi%d", dws->bus_num);
+       spin_lock_init(&dws->buf_lock);
+ 
++      spi_master_set_devdata(master, dws);
++
+       ret = request_irq(dws->irq, dw_spi_irq, IRQF_SHARED, dws->name, master);
+       if (ret < 0) {
+               dev_err(dev, "can not get IRQ\n");
+@@ -531,8 +530,7 @@ int dw_spi_add_host(struct device *dev, struct dw_spi *dws)
+               }
+       }
+ 
+-      spi_master_set_devdata(master, dws);
+-      ret = devm_spi_register_master(dev, master);
++      ret = spi_register_master(master);
+       if (ret) {
+               dev_err(&master->dev, "problem registering spi master\n");
+               goto err_dma_exit;
+@@ -556,6 +554,8 @@ void dw_spi_remove_host(struct dw_spi *dws)
+ {
+       dw_spi_debugfs_remove(dws);
+ 
++      spi_unregister_master(dws->master);
++
+       if (dws->dma_ops && dws->dma_ops->dma_exit)
+               dws->dma_ops->dma_exit(dws);
+ 
+diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
+index 2f84d7653afd..da3834fe5e57 100644
+--- a/drivers/spi/spi-pxa2xx.c
++++ b/drivers/spi/spi-pxa2xx.c
+@@ -1774,7 +1774,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
+ 
+       /* Register with the SPI framework */
+       platform_set_drvdata(pdev, drv_data);
+-      status = devm_spi_register_master(&pdev->dev, master);
++      status = spi_register_master(master);
+       if (status != 0) {
+               dev_err(&pdev->dev, "problem registering spi master\n");
+               goto out_error_clock_enabled;
+@@ -1804,6 +1804,8 @@ static int pxa2xx_spi_remove(struct platform_device 
*pdev)
+ 
+       pm_runtime_get_sync(&pdev->dev);
+ 
++      spi_unregister_master(drv_data->master);
++
+       /* Disable the SSP at the peripheral and SOC level */
+       pxa2xx_spi_write(drv_data, SSCR0, 0);
+       clk_disable_unprepare(ssp->clk);
+diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
+index d74d341f9890..3fadc564d781 100644
+--- a/drivers/spi/spi.c
++++ b/drivers/spi/spi.c
+@@ -2025,18 +2025,17 @@ static int __unregister(struct device *dev, void *null)
+  */
+ void spi_unregister_master(struct spi_master *master)
+ {
+-      int dummy;
+-
+       if (master->queued) {
+               if (spi_destroy_queue(master))
+                       dev_err(&master->dev, "queue remove failed\n");
+       }
+ 
++      device_for_each_child(&master->dev, NULL, __unregister);
++
+       mutex_lock(&board_lock);
+       list_del(&master->list);
+       mutex_unlock(&board_lock);
+ 
+-      dummy = device_for_each_child(&master->dev, NULL, __unregister);
+       device_unregister(&master->dev);
+ }
+ EXPORT_SYMBOL_GPL(spi_unregister_master);
+diff --git a/drivers/staging/android/ion/ion_heap.c 
b/drivers/staging/android/ion/ion_heap.c
+index c2a7cb95725b..4fc5de13582d 100644
+--- a/drivers/staging/android/ion/ion_heap.c
++++ b/drivers/staging/android/ion/ion_heap.c
+@@ -105,12 +105,12 @@ int ion_heap_map_user(struct ion_heap *heap, struct 
ion_buffer *buffer,
+ 
+ static int ion_heap_clear_pages(struct page **pages, int num, pgprot_t pgprot)
+ {
+-      void *addr = vm_map_ram(pages, num, -1, pgprot);
++      void *addr = vmap(pages, num, VM_MAP, pgprot);
+ 
+       if (!addr)
+               return -ENOMEM;
+       memset(addr, 0, PAGE_SIZE * num);
+-      vm_unmap_ram(addr, num);
++      vunmap(addr);
+ 
+       return 0;
+ }
+diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c
+index 5649ef1e379d..82a1c2cf6687 100644
+--- a/drivers/staging/greybus/sdio.c
++++ b/drivers/staging/greybus/sdio.c
+@@ -413,6 +413,7 @@ static int gb_sdio_command(struct gb_sdio_host *host, 
struct mmc_command *cmd)
+       struct gb_sdio_command_request request = {0};
+       struct gb_sdio_command_response response;
+       struct mmc_data *data = host->mrq->data;
++      unsigned int timeout_ms;
+       u8 cmd_flags;
+       u8 cmd_type;
+       int i;
+@@ -471,9 +472,12 @@ static int gb_sdio_command(struct gb_sdio_host *host, 
struct mmc_command *cmd)
+               request.data_blksz = cpu_to_le16(data->blksz);
+       }
+ 
+-      ret = gb_operation_sync(host->connection, GB_SDIO_TYPE_COMMAND,
+-                              &request, sizeof(request), &response,
+-                              sizeof(response));
++      timeout_ms = cmd->busy_timeout ? cmd->busy_timeout :
++              GB_OPERATION_TIMEOUT_DEFAULT;
++
++      ret = gb_operation_sync_timeout(host->connection, GB_SDIO_TYPE_COMMAND,
++                                      &request, sizeof(request), &response,
++                                      sizeof(response), timeout_ms);
+       if (ret < 0)
+               goto out;
+ 
+diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c
+index 10951c82f6ed..7bd4c27cfb14 100644
+--- a/drivers/video/fbdev/w100fb.c
++++ b/drivers/video/fbdev/w100fb.c
+@@ -583,6 +583,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
+               memsize=par->mach->mem->size;
+               memcpy_toio(remapped_fbuf + (W100_FB_BASE-MEM_WINDOW_BASE), 
par->saved_extmem, memsize);
+               vfree(par->saved_extmem);
++              par->saved_extmem = NULL;
+       }
+       if (par->saved_intmem) {
+               memsize=MEM_INT_SIZE;
+@@ -591,6 +592,7 @@ static void w100fb_restore_vidmem(struct w100fb_par *par)
+               else
+                       memcpy_toio(remapped_fbuf + 
(W100_FB_BASE-MEM_WINDOW_BASE), par->saved_intmem, memsize);
+               vfree(par->saved_intmem);
++              par->saved_intmem = NULL;
+       }
+ }
+ 
+diff --git a/drivers/w1/masters/omap_hdq.c b/drivers/w1/masters/omap_hdq.c
+index 86637fec4eaa..6bc6823f81fa 100644
+--- a/drivers/w1/masters/omap_hdq.c
++++ b/drivers/w1/masters/omap_hdq.c
+@@ -204,7 +204,7 @@ static int hdq_write_byte(struct hdq_data *hdq_data, u8 
val, u8 *status)
+       /* check irqstatus */
+       if (!(*status & OMAP_HDQ_INT_STATUS_TXCOMPLETE)) {
+               dev_dbg(hdq_data->dev, "timeout waiting for"
+-                      " TXCOMPLETE/RXCOMPLETE, %x", *status);
++                      " TXCOMPLETE/RXCOMPLETE, %x\n", *status);
+               ret = -ETIMEDOUT;
+               goto out;
+       }
+@@ -215,7 +215,7 @@ static int hdq_write_byte(struct hdq_data *hdq_data, u8 
val, u8 *status)
+                       OMAP_HDQ_FLAG_CLEAR, &tmp_status);
+       if (ret) {
+               dev_dbg(hdq_data->dev, "timeout waiting GO bit"
+-                      " return to zero, %x", tmp_status);
++                      " return to zero, %x\n", tmp_status);
+       }
+ 
+ out:
+@@ -231,7 +231,7 @@ static irqreturn_t hdq_isr(int irq, void *_hdq)
+       spin_lock_irqsave(&hdq_data->hdq_spinlock, irqflags);
+       hdq_data->hdq_irqstatus = hdq_reg_in(hdq_data, OMAP_HDQ_INT_STATUS);
+       spin_unlock_irqrestore(&hdq_data->hdq_spinlock, irqflags);
+-      dev_dbg(hdq_data->dev, "hdq_isr: %x", hdq_data->hdq_irqstatus);
++      dev_dbg(hdq_data->dev, "hdq_isr: %x\n", hdq_data->hdq_irqstatus);
+ 
+       if (hdq_data->hdq_irqstatus &
+               (OMAP_HDQ_INT_STATUS_TXCOMPLETE | OMAP_HDQ_INT_STATUS_RXCOMPLETE
+@@ -339,7 +339,7 @@ static int omap_hdq_break(struct hdq_data *hdq_data)
+       tmp_status = hdq_data->hdq_irqstatus;
+       /* check irqstatus */
+       if (!(tmp_status & OMAP_HDQ_INT_STATUS_TIMEOUT)) {
+-              dev_dbg(hdq_data->dev, "timeout waiting for TIMEOUT, %x",
++              dev_dbg(hdq_data->dev, "timeout waiting for TIMEOUT, %x\n",
+                               tmp_status);
+               ret = -ETIMEDOUT;
+               goto out;
+@@ -366,7 +366,7 @@ static int omap_hdq_break(struct hdq_data *hdq_data)
+                       &tmp_status);
+       if (ret)
+               dev_dbg(hdq_data->dev, "timeout waiting INIT&GO bits"
+-                      " return to zero, %x", tmp_status);
++                      " return to zero, %x\n", tmp_status);
+ 
+ out:
+       mutex_unlock(&hdq_data->hdq_mutex);
+diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c
+index d0d571c47d33..4f919628137c 100644
+--- a/fs/btrfs/file-item.c
++++ b/fs/btrfs/file-item.c
+@@ -779,10 +779,12 @@ again:
+               nritems = btrfs_header_nritems(path->nodes[0]);
+               if (!nritems || (path->slots[0] >= nritems - 1)) {
+                       ret = btrfs_next_leaf(root, path);
+-                      if (ret == 1)
++                      if (ret < 0) {
++                              goto out;
++                      } else if (ret > 0) {
+                               found_next = 1;
+-                      if (ret != 0)
+                               goto insert;
++                      }
+                       slot = path->slots[0];
+               }
+               btrfs_item_key_to_cpu(path->nodes[0], &found_key, slot);
+diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c
+index 250c8403ec67..c425443c31fe 100644
+--- a/fs/btrfs/inode.c
++++ b/fs/btrfs/inode.c
+@@ -8494,7 +8494,6 @@ static int btrfs_submit_direct_hook(struct 
btrfs_dio_private *dip,
+       bio->bi_private = dip;
+       bio->bi_end_io = btrfs_end_dio_bio;
+       btrfs_io_bio(bio)->logical = file_offset;
+-      atomic_inc(&dip->pending_bios);
+ 
+       while (bvec <= (orig_bio->bi_io_vec + orig_bio->bi_vcnt - 1)) {
+               nr_sectors = BTRFS_BYTES_TO_BLKS(root->fs_info, bvec->bv_len);
+@@ -8560,7 +8559,8 @@ submit:
+       if (!ret)
+               return 0;
+ 
+-      bio_put(bio);
++      if (bio != orig_bio)
++              bio_put(bio);
+ out_err:
+       dip->errors = 1;
+       /*
+@@ -8607,7 +8607,7 @@ static void btrfs_submit_direct(struct bio *dio_bio, 
struct inode *inode,
+       io_bio->bi_private = dip;
+       dip->orig_bio = io_bio;
+       dip->dio_bio = dio_bio;
+-      atomic_set(&dip->pending_bios, 0);
++      atomic_set(&dip->pending_bios, 1);
+       btrfs_bio = btrfs_io_bio(io_bio);
+       btrfs_bio->logical = file_offset;
+ 
+diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c
+index edfc7ba38b33..080b12d65b0c 100644
+--- a/fs/btrfs/send.c
++++ b/fs/btrfs/send.c
+@@ -35,6 +35,7 @@
+ #include "btrfs_inode.h"
+ #include "transaction.h"
+ #include "compression.h"
++#include "xattr.h"
+ 
+ /*
+  * Maximum number of references an extent can have in order for us to attempt 
to
+@@ -4368,6 +4369,10 @@ static int __process_new_xattr(int num, struct 
btrfs_key *di_key,
+       struct fs_path *p;
+       struct posix_acl_xattr_header dummy_acl;
+ 
++      /* Capabilities are emitted by finish_inode_if_needed */
++      if (!strncmp(name, XATTR_NAME_CAPS, name_len))
++              return 0;
++
+       p = fs_path_alloc();
+       if (!p)
+               return -ENOMEM;
+@@ -4904,6 +4909,64 @@ static int send_extent_data(struct send_ctx *sctx,
+       return 0;
+ }
+ 
++/*
++ * Search for a capability xattr related to sctx->cur_ino. If the capability 
is
++ * found, call send_set_xattr function to emit it.
++ *
++ * Return 0 if there isn't a capability, or when the capability was emitted
++ * successfully, or < 0 if an error occurred.
++ */
++static int send_capabilities(struct send_ctx *sctx)
++{
++      struct fs_path *fspath = NULL;
++      struct btrfs_path *path;
++      struct btrfs_dir_item *di;
++      struct extent_buffer *leaf;
++      unsigned long data_ptr;
++      char *buf = NULL;
++      int buf_len;
++      int ret = 0;
++
++      path = alloc_path_for_send();
++      if (!path)
++              return -ENOMEM;
++
++      di = btrfs_lookup_xattr(NULL, sctx->send_root, path, sctx->cur_ino,
++                              XATTR_NAME_CAPS, strlen(XATTR_NAME_CAPS), 0);
++      if (!di) {
++              /* There is no xattr for this inode */
++              goto out;
++      } else if (IS_ERR(di)) {
++              ret = PTR_ERR(di);
++              goto out;
++      }
++
++      leaf = path->nodes[0];
++      buf_len = btrfs_dir_data_len(leaf, di);
++
++      fspath = fs_path_alloc();
++      buf = kmalloc(buf_len, GFP_KERNEL);
++      if (!fspath || !buf) {
++              ret = -ENOMEM;
++              goto out;
++      }
++
++      ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, fspath);
++      if (ret < 0)
++              goto out;
++
++      data_ptr = (unsigned long)(di + 1) + btrfs_dir_name_len(leaf, di);
++      read_extent_buffer(leaf, buf, data_ptr, buf_len);
++
++      ret = send_set_xattr(sctx, fspath, XATTR_NAME_CAPS,
++                      strlen(XATTR_NAME_CAPS), buf, buf_len);
++out:
++      kfree(buf);
++      fs_path_free(fspath);
++      btrfs_free_path(path);
++      return ret;
++}
++
+ static int clone_range(struct send_ctx *sctx,
+                      struct clone_root *clone_root,
+                      const u64 disk_byte,
+@@ -5615,6 +5678,10 @@ static int finish_inode_if_needed(struct send_ctx 
*sctx, int at_end)
+                       goto out;
+       }
+ 
++      ret = send_capabilities(sctx);
++      if (ret < 0)
++              goto out;
++
+       /*
+        * If other directory inodes depended on our current directory
+        * inode's move/rename, now do their move/rename operations.
+diff --git a/fs/ext4/ext4_extents.h b/fs/ext4/ext4_extents.h
+index a284fb28944b..63291c265aa0 100644
+--- a/fs/ext4/ext4_extents.h
++++ b/fs/ext4/ext4_extents.h
+@@ -169,10 +169,13 @@ struct ext4_ext_path {
+       (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
+ #define EXT_LAST_INDEX(__hdr__) \
+       (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_entries) - 1)
+-#define EXT_MAX_EXTENT(__hdr__) \
+-      (EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
++#define EXT_MAX_EXTENT(__hdr__)       \
++      ((le16_to_cpu((__hdr__)->eh_max)) ? \
++      ((EXT_FIRST_EXTENT((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) \
++                                      : 0)
+ #define EXT_MAX_INDEX(__hdr__) \
+-      (EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)
++      ((le16_to_cpu((__hdr__)->eh_max)) ? \
++      ((EXT_FIRST_INDEX((__hdr__)) + le16_to_cpu((__hdr__)->eh_max) - 1)) : 0)
+ 
+ static inline struct ext4_extent_header *ext_inode_hdr(struct inode *inode)
+ {
+diff --git a/fs/ext4/fsync.c b/fs/ext4/fsync.c
+index 88effb1053c7..6dc0b89c7b55 100644
+--- a/fs/ext4/fsync.c
++++ b/fs/ext4/fsync.c
+@@ -43,30 +43,28 @@
+  */
+ static int ext4_sync_parent(struct inode *inode)
+ {
+-      struct dentry *dentry = NULL;
+-      struct inode *next;
++      struct dentry *dentry, *next;
+       int ret = 0;
+ 
+       if (!ext4_test_inode_state(inode, EXT4_STATE_NEWENTRY))
+               return 0;
+-      inode = igrab(inode);
++      dentry = d_find_any_alias(inode);
++      if (!dentry)
++              return 0;
+       while (ext4_test_inode_state(inode, EXT4_STATE_NEWENTRY)) {
+               ext4_clear_inode_state(inode, EXT4_STATE_NEWENTRY);
+-              dentry = d_find_any_alias(inode);
+-              if (!dentry)
+-                      break;
+-              next = igrab(d_inode(dentry->d_parent));
++
++              next = dget_parent(dentry);
+               dput(dentry);
+-              if (!next)
+-                      break;
+-              iput(inode);
+-              inode = next;
++              dentry = next;
++              inode = dentry->d_inode;
++
+               /*
+                * The directory inode may have gone through rmdir by now. But
+                * the inode itself and its blocks are still allocated (we hold
+-               * a reference to the inode so it didn't go through
+-               * ext4_evict_inode()) and so we are safe to flush metadata
+-               * blocks and the inode.
++               * a reference to the inode via its dentry), so it didn't go
++               * through ext4_evict_inode()) and so we are safe to flush
++               * metadata blocks and the inode.
+                */
+               ret = sync_mapping_buffers(inode->i_mapping);
+               if (ret)
+@@ -75,7 +73,7 @@ static int ext4_sync_parent(struct inode *inode)
+               if (ret)
+                       break;
+       }
+-      iput(inode);
++      dput(dentry);
+       return ret;
+ }
+ 
+diff --git a/fs/fat/inode.c b/fs/fat/inode.c
+index f0387d040331..9af410142f78 100644
+--- a/fs/fat/inode.c
++++ b/fs/fat/inode.c
+@@ -1512,6 +1512,12 @@ static int fat_read_bpb(struct super_block *sb, struct 
fat_boot_sector *b,
+               goto out;
+       }
+ 
++      if (bpb->fat_fat_length == 0 && bpb->fat32_length == 0) {
++              if (!silent)
++                      fat_msg(sb, KERN_ERR, "bogus number of FAT sectors");
++              goto out;
++      }
++
+       error = 0;
+ 
+ out:
+diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
+index 882e9d6830df..5a1a6dbbc55f 100644
+--- a/fs/fs-writeback.c
++++ b/fs/fs-writeback.c
+@@ -269,6 +269,7 @@ void __inode_attach_wb(struct inode *inode, struct page 
*page)
+       if (unlikely(cmpxchg(&inode->i_wb, NULL, wb)))
+               wb_put(wb);
+ }
++EXPORT_SYMBOL_GPL(__inode_attach_wb);
+ 
+ /**
+  * locked_inode_to_wb_and_lock_list - determine a locked inode's wb and lock 
it
+diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c
+index 36362d4bc344..a92af0ed0e28 100644
+--- a/fs/nilfs2/segment.c
++++ b/fs/nilfs2/segment.c
+@@ -2793,6 +2793,8 @@ int nilfs_attach_log_writer(struct super_block *sb, 
struct nilfs_root *root)
+       if (!nilfs->ns_writer)
+               return -ENOMEM;
+ 
++      inode_attach_wb(nilfs->ns_bdev->bd_inode, NULL);
++
+       err = nilfs_segctor_start_thread(nilfs->ns_writer);
+       if (err) {
+               kfree(nilfs->ns_writer);
+diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c
+index 36795eed40b0..299dbf59f28f 100644
+--- a/fs/overlayfs/copy_up.c
++++ b/fs/overlayfs/copy_up.c
+@@ -56,7 +56,7 @@ int ovl_copy_xattr(struct dentry *old, struct dentry *new)
+ {
+       ssize_t list_size, size, value_size = 0;
+       char *buf, *name, *value = NULL;
+-      int uninitialized_var(error);
++      int error = 0;
+       size_t slen;
+ 
+       if (!(old->d_inode->i_opflags & IOP_XATTR) ||
+diff --git a/fs/proc/inode.c b/fs/proc/inode.c
+index c2afe39f0b9e..a28934912530 100644
+--- a/fs/proc/inode.c
++++ b/fs/proc/inode.c
+@@ -417,7 +417,7 @@ const struct inode_operations proc_link_inode_operations = 
{
+ 
+ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry 
*de)
+ {
+-      struct inode *inode = new_inode_pseudo(sb);
++      struct inode *inode = new_inode(sb);
+ 
+       if (inode) {
+               inode->i_ino = de->low_ino;
+diff --git a/fs/proc/self.c b/fs/proc/self.c
+index 40245954c450..c8bbc1c84a39 100644
+--- a/fs/proc/self.c
++++ b/fs/proc/self.c
+@@ -53,7 +53,7 @@ int proc_setup_self(struct super_block *s)
+       inode_lock(root_inode);
+       self = d_alloc_name(s->s_root, "self");
+       if (self) {
+-              struct inode *inode = new_inode_pseudo(s);
++              struct inode *inode = new_inode(s);
+               if (inode) {
+                       inode->i_ino = self_inum;
+                       inode->i_mtime = inode->i_atime = inode->i_ctime = 
current_time(inode);
+diff --git a/fs/proc/thread_self.c b/fs/proc/thread_self.c
+index 595b90a9766c..02d1db8e9723 100644
+--- a/fs/proc/thread_self.c
++++ b/fs/proc/thread_self.c
+@@ -55,7 +55,7 @@ int proc_setup_thread_self(struct super_block *s)
+       inode_lock(root_inode);
+       thread_self = d_alloc_name(s->s_root, "thread-self");
+       if (thread_self) {
+-              struct inode *inode = new_inode_pseudo(s);
++              struct inode *inode = new_inode(s);
+               if (inode) {
+                       inode->i_ino = thread_self_inum;
+                       inode->i_mtime = inode->i_atime = inode->i_ctime = 
current_time(inode);
+diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
+index e465bb15912d..6be5545d3584 100644
+--- a/include/linux/kgdb.h
++++ b/include/linux/kgdb.h
+@@ -317,7 +317,7 @@ extern void gdbstub_exit(int status);
+ extern int                    kgdb_single_step;
+ extern atomic_t                       kgdb_active;
+ #define in_dbg_master() \
+-      (raw_smp_processor_id() == atomic_read(&kgdb_active))
++      (irqs_disabled() && (smp_processor_id() == atomic_read(&kgdb_active)))
+ extern bool dbg_is_early;
+ extern void __init dbg_late_init(void);
+ #else /* ! CONFIG_KGDB */
+diff --git a/include/linux/sunrpc/gss_api.h b/include/linux/sunrpc/gss_api.h
+index 68ec78c1aa48..bd8480ae82e9 100644
+--- a/include/linux/sunrpc/gss_api.h
++++ b/include/linux/sunrpc/gss_api.h
+@@ -82,6 +82,7 @@ struct pf_desc {
+       u32     service;
+       char    *name;
+       char    *auth_domain_name;
++      struct auth_domain *domain;
+       bool    datatouch;
+ };
+ 
+diff --git a/include/linux/sunrpc/svcauth_gss.h 
b/include/linux/sunrpc/svcauth_gss.h
+index 726aff1a5201..213fa12f56fc 100644
+--- a/include/linux/sunrpc/svcauth_gss.h
++++ b/include/linux/sunrpc/svcauth_gss.h
+@@ -20,7 +20,8 @@ int gss_svc_init(void);
+ void gss_svc_shutdown(void);
+ int gss_svc_init_net(struct net *net);
+ void gss_svc_shutdown_net(struct net *net);
+-int svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name);
++struct auth_domain *svcauth_gss_register_pseudoflavor(u32 pseudoflavor,
++                                                    char *name);
+ u32 svcauth_gss_flavor(struct auth_domain *dom);
+ 
+ #endif /* __KERNEL__ */
+diff --git a/include/uapi/linux/dvb/frontend.h 
b/include/uapi/linux/dvb/frontend.h
+index 00a20cd21ee2..afc3972b0879 100644
+--- a/include/uapi/linux/dvb/frontend.h
++++ b/include/uapi/linux/dvb/frontend.h
+@@ -127,6 +127,7 @@ enum fe_sec_mini_cmd {
+  *                    to reset DiSEqC, tone and parameters
+  */
+ enum fe_status {
++      FE_NONE                 = 0x00,
+       FE_HAS_SIGNAL           = 0x01,
+       FE_HAS_CARRIER          = 0x02,
+       FE_HAS_VITERBI          = 0x04,
+diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h
+index a0a365cbf3c9..0c02441d2cc9 100644
+--- a/include/uapi/linux/kvm.h
++++ b/include/uapi/linux/kvm.h
+@@ -159,9 +159,11 @@ struct kvm_hyperv_exit {
+ #define KVM_EXIT_HYPERV_SYNIC          1
+ #define KVM_EXIT_HYPERV_HCALL          2
+       __u32 type;
++      __u32 pad1;
+       union {
+               struct {
+                       __u32 msr;
++                      __u32 pad2;
+                       __u64 control;
+                       __u64 evt_page;
+                       __u64 msg_page;
+diff --git a/kernel/cpu_pm.c b/kernel/cpu_pm.c
+index 009cc9a17d95..f1042d639eee 100644
+--- a/kernel/cpu_pm.c
++++ b/kernel/cpu_pm.c
+@@ -97,7 +97,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_unregister_notifier);
+  */
+ int cpu_pm_enter(void)
+ {
+-      int nr_calls;
++      int nr_calls = 0;
+       int ret = 0;
+ 
+       read_lock(&cpu_pm_notifier_lock);
+@@ -156,7 +156,7 @@ EXPORT_SYMBOL_GPL(cpu_pm_exit);
+  */
+ int cpu_cluster_pm_enter(void)
+ {
+-      int nr_calls;
++      int nr_calls = 0;
+       int ret = 0;
+ 
+       read_lock(&cpu_pm_notifier_lock);
+diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
+index 79517e5549f1..9c939c6bf21c 100644
+--- a/kernel/debug/debug_core.c
++++ b/kernel/debug/debug_core.c
+@@ -443,6 +443,7 @@ static int kgdb_reenter_check(struct kgdb_state *ks)
+ 
+       if (exception_level > 1) {
+               dump_stack();
++              kgdb_io_module_registered = false;
+               panic("Recursive entry to debugger");
+       }
+ 
+diff --git a/kernel/events/core.c b/kernel/events/core.c
+index 1f27b73bd7d4..b562467d2d49 100644
+--- a/kernel/events/core.c
++++ b/kernel/events/core.c
+@@ -90,11 +90,11 @@ static void remote_function(void *data)
+  * @info:     the function call argument
+  *
+  * Calls the function @func when the task is currently running. This might
+- * be on the current CPU, which just calls the function directly
++ * be on the current CPU, which just calls the function directly.  This will
++ * retry due to any failures in smp_call_function_single(), such as if the
++ * task_cpu() goes offline concurrently.
+  *
+- * returns: @func return value, or
+- *        -ESRCH  - when the process isn't running
+- *        -EAGAIN - when the process moved away
++ * returns @func return value or -ESRCH when the process isn't running
+  */
+ static int
+ task_function_call(struct task_struct *p, remote_function_f func, void *info)
+@@ -107,11 +107,16 @@ task_function_call(struct task_struct *p, 
remote_function_f func, void *info)
+       };
+       int ret;
+ 
+-      do {
+-              ret = smp_call_function_single(task_cpu(p), remote_function, 
&data, 1);
+-              if (!ret)
+-                      ret = data.ret;
+-      } while (ret == -EAGAIN);
++      for (;;) {
++              ret = smp_call_function_single(task_cpu(p), remote_function,
++                                             &data, 1);
++              ret = !ret ? data.ret : -EAGAIN;
++
++              if (ret != -EAGAIN)
++                      break;
++
++              cond_resched();
++      }
+ 
+       return ret;
+ }
+diff --git a/kernel/exit.c b/kernel/exit.c
+index d9394fcd0e2c..27f4168eaeb1 100644
+--- a/kernel/exit.c
++++ b/kernel/exit.c
+@@ -739,8 +739,12 @@ void __noreturn do_exit(long code)
+       int group_dead;
+       TASKS_RCU(int tasks_rcu_i);
+ 
+-      profile_task_exit(tsk);
+-      kcov_task_exit(tsk);
++      /*
++       * We can get here from a kernel oops, sometimes with preemption off.
++       * Start by checking for critical errors.
++       * Then fix up important state like USER_DS and preemption.
++       * Then do everything else.
++       */
+ 
+       WARN_ON(blk_needs_flush_plug(tsk));
+ 
+@@ -758,6 +762,16 @@ void __noreturn do_exit(long code)
+        */
+       set_fs(USER_DS);
+ 
++      if (unlikely(in_atomic())) {
++              pr_info("note: %s[%d] exited with preempt_count %d\n",
++                      current->comm, task_pid_nr(current),
++                      preempt_count());
++              preempt_count_set(PREEMPT_ENABLED);
++      }
++
++      profile_task_exit(tsk);
++      kcov_task_exit(tsk);
++
+       ptrace_event(PTRACE_EVENT_EXIT, code);
+ 
+       validate_creds_for_do_exit(tsk);
+@@ -794,13 +808,6 @@ void __noreturn do_exit(long code)
+        */
+       raw_spin_unlock_wait(&tsk->pi_lock);
+ 
+-      if (unlikely(in_atomic())) {
+-              pr_info("note: %s[%d] exited with preempt_count %d\n",
+-                      current->comm, task_pid_nr(current),
+-                      preempt_count());
+-              preempt_count_set(PREEMPT_ENABLED);
+-      }
+-
+       /* sync mm's RSS info before statistics gathering */
+       if (tsk->mm)
+               sync_mm_rss(tsk->mm);
+diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
+index 5e65c7eea872..8233032a2f01 100644
+--- a/kernel/sched/fair.c
++++ b/kernel/sched/fair.c
+@@ -2542,7 +2542,7 @@ void task_tick_numa(struct rq *rq, struct task_struct 
*curr)
+       /*
+        * We don't care about NUMA placement if we don't have memory.
+        */
+-      if (!curr->mm || (curr->flags & PF_EXITING) || work->next != work)
++      if ((curr->flags & (PF_EXITING | PF_KTHREAD)) || work->next != work)
+               return;
+ 
+       /*
+diff --git a/lib/mpi/longlong.h b/lib/mpi/longlong.h
+index 8f383cca6bb1..623440d3d365 100644
+--- a/lib/mpi/longlong.h
++++ b/lib/mpi/longlong.h
+@@ -671,7 +671,7 @@ do {                                               \
+       **************  MIPS/64  **************
+       ***************************************/
+ #if (defined(__mips) && __mips >= 3) && W_TYPE_SIZE == 64
+-#if defined(__mips_isa_rev) && __mips_isa_rev >= 6
++#if defined(__mips_isa_rev) && __mips_isa_rev >= 6 && 
defined(CONFIG_CC_IS_GCC)
+ /*
+  * GCC ends up emitting a __multi3 intrinsic call for MIPS64r6 with the plain 
C
+  * code below, so we special case MIPS64r6 until the compiler can do better.
+diff --git a/mm/huge_memory.c b/mm/huge_memory.c
+index 5fbd77d52602..cf4c0a61b370 100644
+--- a/mm/huge_memory.c
++++ b/mm/huge_memory.c
+@@ -1755,6 +1755,8 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t 
*pmd,
+       spinlock_t *ptl;
+       struct mm_struct *mm = vma->vm_mm;
+       unsigned long haddr = address & HPAGE_PMD_MASK;
++      bool was_locked = false;
++      pmd_t _pmd;
+ 
+       mmu_notifier_invalidate_range_start(mm, haddr, haddr + HPAGE_PMD_SIZE);
+       ptl = pmd_lock(mm, pmd);
+@@ -1764,11 +1766,32 @@ void __split_huge_pmd(struct vm_area_struct *vma, 
pmd_t *pmd,
+        * pmd against. Otherwise we can end up replacing wrong page.
+        */
+       VM_BUG_ON(freeze && !page);
+-      if (page && page != pmd_page(*pmd))
+-              goto out;
++      if (page) {
++              VM_WARN_ON_ONCE(!PageLocked(page));
++              was_locked = true;
++              if (page != pmd_page(*pmd))
++                      goto out;
++      }
+ 
++repeat:
+       if (pmd_trans_huge(*pmd)) {
+-              page = pmd_page(*pmd);
++              if (!page) {
++                      page = pmd_page(*pmd);
++                      if (unlikely(!trylock_page(page))) {
++                              get_page(page);
++                              _pmd = *pmd;
++                              spin_unlock(ptl);
++                              lock_page(page);
++                              spin_lock(ptl);
++                              if (unlikely(!pmd_same(*pmd, _pmd))) {
++                                      unlock_page(page);
++                                      put_page(page);
++                                      page = NULL;
++                                      goto repeat;
++                              }
++                              put_page(page);
++                      }
++              }
+               if (PageMlocked(page))
+                       clear_page_mlock(page);
+       } else if (!pmd_devmap(*pmd))
+@@ -1776,6 +1799,8 @@ void __split_huge_pmd(struct vm_area_struct *vma, pmd_t 
*pmd,
+       __split_huge_pmd_locked(vma, pmd, haddr, freeze);
+ out:
+       spin_unlock(ptl);
++      if (!was_locked && page)
++              unlock_page(page);
+       mmu_notifier_invalidate_range_end(mm, haddr, haddr + HPAGE_PMD_SIZE);
+ }
+ 
+diff --git a/mm/slub.c b/mm/slub.c
+index 9b44423f1cf0..3d45713187a4 100644
+--- a/mm/slub.c
++++ b/mm/slub.c
+@@ -5620,8 +5620,10 @@ static int sysfs_slab_add(struct kmem_cache *s)
+ 
+       s->kobj.kset = cache_kset(s);
+       err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
+-      if (err)
++      if (err) {
++              kobject_put(&s->kobj);
+               goto out;
++      }
+ 
+       err = sysfs_create_group(&s->kobj, &slab_attr_group);
+       if (err)
+diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c
+index 6f78489fdb13..a8aa3f29f2d6 100644
+--- a/net/bluetooth/hci_event.c
++++ b/net/bluetooth/hci_event.c
+@@ -3775,6 +3775,7 @@ static void hci_sync_conn_complete_evt(struct hci_dev 
*hdev,
+       case 0x11:      /* Unsupported Feature or Parameter Value */
+       case 0x1c:      /* SCO interval rejected */
+       case 0x1a:      /* Unsupported Remote Feature */
++      case 0x1e:      /* Invalid LMP Parameters */
+       case 0x1f:      /* Unspecified error */
+       case 0x20:      /* Unsupported LMP Parameter value */
+               if (conn->out) {
+diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
+index 455fa4a30353..2c770bba212c 100644
+--- a/net/ipv6/ipv6_sockglue.c
++++ b/net/ipv6/ipv6_sockglue.c
+@@ -184,14 +184,15 @@ static int do_ipv6_setsockopt(struct sock *sk, int 
level, int optname,
+                                       retv = -EBUSY;
+                                       break;
+                               }
+-                      }
+-                      if (sk->sk_protocol == IPPROTO_TCP &&
+-                          sk->sk_prot != &tcpv6_prot) {
+-                              retv = -EBUSY;
++                      } else if (sk->sk_protocol == IPPROTO_TCP) {
++                              if (sk->sk_prot != &tcpv6_prot) {
++                                      retv = -EBUSY;
++                                      break;
++                              }
++                      } else {
+                               break;
+                       }
+-                      if (sk->sk_protocol != IPPROTO_TCP)
+-                              break;
++
+                       if (sk->sk_state != TCP_ESTABLISHED) {
+                               retv = -ENOTCONN;
+                               break;
+diff --git a/net/netfilter/nft_nat.c b/net/netfilter/nft_nat.c
+index 4c48e9bb21e2..d2510e432c18 100644
+--- a/net/netfilter/nft_nat.c
++++ b/net/netfilter/nft_nat.c
+@@ -135,7 +135,7 @@ static int nft_nat_init(const struct nft_ctx *ctx, const 
struct nft_expr *expr,
+               priv->type = NF_NAT_MANIP_DST;
+               break;
+       default:
+-              return -EINVAL;
++              return -EOPNOTSUPP;
+       }
+ 
+       err = nft_nat_validate(ctx, expr, NULL);
+@@ -206,7 +206,7 @@ static int nft_nat_init(const struct nft_ctx *ctx, const 
struct nft_expr *expr,
+       if (tb[NFTA_NAT_FLAGS]) {
+               priv->flags = ntohl(nla_get_be32(tb[NFTA_NAT_FLAGS]));
+               if (priv->flags & ~NF_NAT_RANGE_MASK)
+-                      return -EINVAL;
++                      return -EOPNOTSUPP;
+       }
+ 
+       return 0;
+diff --git a/net/sunrpc/auth_gss/gss_mech_switch.c 
b/net/sunrpc/auth_gss/gss_mech_switch.c
+index 5fec3abbe19b..c7d88f979c56 100644
+--- a/net/sunrpc/auth_gss/gss_mech_switch.c
++++ b/net/sunrpc/auth_gss/gss_mech_switch.c
+@@ -61,6 +61,8 @@ gss_mech_free(struct gss_api_mech *gm)
+ 
+       for (i = 0; i < gm->gm_pf_num; i++) {
+               pf = &gm->gm_pfs[i];
++              if (pf->domain)
++                      auth_domain_put(pf->domain);
+               kfree(pf->auth_domain_name);
+               pf->auth_domain_name = NULL;
+       }
+@@ -83,6 +85,7 @@ make_auth_domain_name(char *name)
+ static int
+ gss_mech_svc_setup(struct gss_api_mech *gm)
+ {
++      struct auth_domain *dom;
+       struct pf_desc *pf;
+       int i, status;
+ 
+@@ -92,10 +95,13 @@ gss_mech_svc_setup(struct gss_api_mech *gm)
+               status = -ENOMEM;
+               if (pf->auth_domain_name == NULL)
+                       goto out;
+-              status = svcauth_gss_register_pseudoflavor(pf->pseudoflavor,
+-                                                      pf->auth_domain_name);
+-              if (status)
++              dom = svcauth_gss_register_pseudoflavor(
++                      pf->pseudoflavor, pf->auth_domain_name);
++              if (IS_ERR(dom)) {
++                      status = PTR_ERR(dom);
+                       goto out;
++              }
++              pf->domain = dom;
+       }
+       return 0;
+ out:
+diff --git a/net/sunrpc/auth_gss/svcauth_gss.c 
b/net/sunrpc/auth_gss/svcauth_gss.c
+index d7775ca2fbb9..fd897d900d12 100644
+--- a/net/sunrpc/auth_gss/svcauth_gss.c
++++ b/net/sunrpc/auth_gss/svcauth_gss.c
+@@ -779,7 +779,7 @@ u32 svcauth_gss_flavor(struct auth_domain *dom)
+ 
+ EXPORT_SYMBOL_GPL(svcauth_gss_flavor);
+ 
+-int
++struct auth_domain *
+ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char * name)
+ {
+       struct gss_domain       *new;
+@@ -796,21 +796,23 @@ svcauth_gss_register_pseudoflavor(u32 pseudoflavor, char 
* name)
+       new->h.flavour = &svcauthops_gss;
+       new->pseudoflavor = pseudoflavor;
+ 
+-      stat = 0;
+       test = auth_domain_lookup(name, &new->h);
+-      if (test != &new->h) { /* Duplicate registration */
++      if (test != &new->h) {
++              pr_warn("svc: duplicate registration of gss pseudo flavour 
%s.\n",
++                      name);
++              stat = -EADDRINUSE;
+               auth_domain_put(test);
+-              kfree(new->h.name);
+-              goto out_free_dom;
++              goto out_free_name;
+       }
+-      return 0;
++      return test;
+ 
++out_free_name:
++      kfree(new->h.name);
+ out_free_dom:
+       kfree(new);
+ out:
+-      return stat;
++      return ERR_PTR(stat);
+ }
+-
+ EXPORT_SYMBOL_GPL(svcauth_gss_register_pseudoflavor);
+ 
+ static inline int
+diff --git a/security/integrity/evm/evm_crypto.c 
b/security/integrity/evm/evm_crypto.c
+index e034dc21421e..b0440cf34970 100644
+--- a/security/integrity/evm/evm_crypto.c
++++ b/security/integrity/evm/evm_crypto.c
+@@ -240,7 +240,7 @@ static int evm_calc_hmac_or_hash(struct dentry *dentry,
+ 
+       /* Portable EVM signatures must include an IMA hash */
+       if (type == EVM_XATTR_PORTABLE_DIGSIG && !ima_present)
+-              return -EPERM;
++              error = -EPERM;
+ out:
+       kfree(xattr_value);
+       kfree(desc);
+diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
+index df7834aa1b8f..5f2a0a07ceac 100644
+--- a/security/integrity/ima/ima.h
++++ b/security/integrity/ima/ima.h
+@@ -36,7 +36,7 @@ enum tpm_pcrs { TPM_PCR0 = 0, TPM_PCR8 = 8 };
+ #define IMA_DIGEST_SIZE               SHA1_DIGEST_SIZE
+ #define IMA_EVENT_NAME_LEN_MAX        255
+ 
+-#define IMA_HASH_BITS 9
++#define IMA_HASH_BITS 10
+ #define IMA_MEASURE_HTABLE_SIZE (1 << IMA_HASH_BITS)
+ 
+ #define IMA_TEMPLATE_FIELD_ID_MAX_LEN 16
+@@ -136,9 +136,10 @@ struct ima_h_table {
+ };
+ extern struct ima_h_table ima_htable;
+ 
+-static inline unsigned long ima_hash_key(u8 *digest)
++static inline unsigned int ima_hash_key(u8 *digest)
+ {
+-      return hash_long(*digest, IMA_HASH_BITS);
++      /* there is no point in taking a hash of part of a digest */
++      return (digest[0] | digest[1] << 8) % IMA_MEASURE_HTABLE_SIZE;
+ }
+ 
+ enum ima_hooks {
+diff --git a/security/integrity/ima/ima_policy.c 
b/security/integrity/ima/ima_policy.c
+index aed47b777a57..4926a5a1bc94 100644
+--- a/security/integrity/ima/ima_policy.c
++++ b/security/integrity/ima/ima_policy.c
+@@ -150,7 +150,7 @@ static struct ima_rule_entry default_appraise_rules[] = {
+ static LIST_HEAD(ima_default_rules);
+ static LIST_HEAD(ima_policy_rules);
+ static LIST_HEAD(ima_temp_rules);
+-static struct list_head *ima_rules;
++static struct list_head *ima_rules = &ima_default_rules;
+ 
+ static int ima_policy __initdata;
+ 
+@@ -429,7 +429,6 @@ void __init ima_init_policy(void)
+                       temp_ima_appraise |= IMA_APPRAISE_POLICY;
+       }
+ 
+-      ima_rules = &ima_default_rules;
+       ima_update_policy_flag();
+ }
+ 
+diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c
+index 6492fe96cae4..3397b216bc6c 100644
+--- a/security/smack/smackfs.c
++++ b/security/smack/smackfs.c
+@@ -901,11 +901,21 @@ static ssize_t smk_set_cipso(struct file *file, const 
char __user *buf,
+       else
+               rule += strlen(skp->smk_known) + 1;
+ 
++      if (rule > data + count) {
++              rc = -EOVERFLOW;
++              goto out;
++      }
++
+       ret = sscanf(rule, "%d", &maplevel);
+       if (ret != 1 || maplevel > SMACK_CIPSO_MAXLEVEL)
+               goto out;
+ 
+       rule += SMK_DIGITLEN;
++      if (rule > data + count) {
++              rc = -EOVERFLOW;
++              goto out;
++      }
++
+       ret = sscanf(rule, "%d", &catlen);
+       if (ret != 1 || catlen > SMACK_CIPSO_MAXCATNUM)
+               goto out;
+diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
+index 23e17a58651b..5c07c5be3142 100644
+--- a/sound/core/pcm_native.c
++++ b/sound/core/pcm_native.c
+@@ -1836,6 +1836,11 @@ static int snd_pcm_link(struct snd_pcm_substream 
*substream, int fd)
+       }
+       pcm_file = f.file->private_data;
+       substream1 = pcm_file->substream;
++      if (substream == substream1) {
++              res = -EINVAL;
++              goto _badf;
++      }
++
+       group = kmalloc(sizeof(*group), GFP_KERNEL);
+       if (!group) {
+               res = -ENOMEM;
+diff --git a/sound/isa/es1688/es1688.c b/sound/isa/es1688/es1688.c
+index 1901c2bb6c3b..a36e2121ef09 100644
+--- a/sound/isa/es1688/es1688.c
++++ b/sound/isa/es1688/es1688.c
+@@ -284,8 +284,10 @@ static int snd_es968_pnp_detect(struct pnp_card_link 
*pcard,
+               return error;
+       }
+       error = snd_es1688_probe(card, dev);
+-      if (error < 0)
++      if (error < 0) {
++              snd_card_free(card);
+               return error;
++      }
+       pnp_set_card_drvdata(pcard, card);
+       snd_es968_pnp_is_probed = 1;
+       return 0;
+diff --git a/sound/usb/card.c b/sound/usb/card.c
+index 549b9b061694..023a36a4922b 100644
+--- a/sound/usb/card.c
++++ b/sound/usb/card.c
+@@ -768,9 +768,6 @@ static int usb_audio_suspend(struct usb_interface *intf, 
pm_message_t message)
+       if (chip == (void *)-1L)
+               return 0;
+ 
+-      chip->autosuspended = !!PMSG_IS_AUTO(message);
+-      if (!chip->autosuspended)
+-              snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
+       if (!chip->num_suspended_intf++) {
+               list_for_each_entry(as, &chip->pcm_list, list) {
+                       snd_pcm_suspend_all(as->pcm);
+@@ -783,6 +780,11 @@ static int usb_audio_suspend(struct usb_interface *intf, 
pm_message_t message)
+                       snd_usb_mixer_suspend(mixer);
+       }
+ 
++      if (!PMSG_IS_AUTO(message) && !chip->system_suspend) {
++              snd_power_change_state(chip->card, SNDRV_CTL_POWER_D3hot);
++              chip->system_suspend = chip->num_suspended_intf;
++      }
++
+       return 0;
+ }
+ 
+@@ -795,10 +797,11 @@ static int __usb_audio_resume(struct usb_interface 
*intf, bool reset_resume)
+ 
+       if (chip == (void *)-1L)
+               return 0;
+-      if (--chip->num_suspended_intf)
+-              return 0;
+ 
+       atomic_inc(&chip->active); /* avoid autopm */
++      if (chip->num_suspended_intf > 1)
++              goto out;
++
+       /*
+        * ALSA leaves material resumption to user space
+        * we just notify and restart the mixers
+@@ -813,9 +816,12 @@ static int __usb_audio_resume(struct usb_interface *intf, 
bool reset_resume)
+               snd_usbmidi_resume(p);
+       }
+ 
+-      if (!chip->autosuspended)
++ out:
++      if (chip->num_suspended_intf == chip->system_suspend) {
+               snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0);
+-      chip->autosuspended = 0;
++              chip->system_suspend = 0;
++      }
++      chip->num_suspended_intf--;
+ 
+ err_out:
+       atomic_dec(&chip->active); /* allow autopm after this point */
+diff --git a/sound/usb/usbaudio.h b/sound/usb/usbaudio.h
+index 4d5c89a7ba2b..f4ee83c8e0b2 100644
+--- a/sound/usb/usbaudio.h
++++ b/sound/usb/usbaudio.h
+@@ -37,7 +37,7 @@ struct snd_usb_audio {
+       struct usb_interface *pm_intf;
+       u32 usb_id;
+       struct mutex mutex;
+-      unsigned int autosuspended:1;   
++      unsigned int system_suspend;
+       atomic_t active;
+       atomic_t shutdown;
+       atomic_t usage_count;
+diff --git a/tools/objtool/check.c b/tools/objtool/check.c
+index b0b8ba9b800c..c7399d7f4bc7 100644
+--- a/tools/objtool/check.c
++++ b/tools/objtool/check.c
+@@ -778,6 +778,12 @@ static int add_special_section_alts(struct objtool_file 
*file)
+               }
+ 
+               if (special_alt->group) {
++                      if (!special_alt->orig_len) {
++                              WARN_FUNC("empty alternative entry",
++                                        orig_insn->sec, orig_insn->offset);
++                              continue;
++                      }
++
+                       ret = handle_group_alt(file, special_alt, orig_insn,
+                                              &new_insn);
+                       if (ret)
+diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
+index 2b420e7a92c0..929f0d0ea9da 100644
+--- a/tools/perf/builtin-probe.c
++++ b/tools/perf/builtin-probe.c
+@@ -344,6 +344,9 @@ static int perf_add_probe_events(struct perf_probe_event 
*pevs, int npevs)
+ 
+               for (k = 0; k < pev->ntevs; k++) {
+                       struct probe_trace_event *tev = &pev->tevs[k];
++                      /* Skipped events have no event name */
++                      if (!tev->event)
++                              continue;
+ 
+                       /* We use tev's name for showing new events */
+                       show_perf_probe_event(tev->group, tev->event, pev,
+diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c
+index 8bec05365aae..9be7c95bd1e1 100644
+--- a/tools/perf/util/dso.c
++++ b/tools/perf/util/dso.c
+@@ -19,6 +19,7 @@ char dso__symtab_origin(const struct dso *dso)
+               [DSO_BINARY_TYPE__BUILD_ID_CACHE]               = 'B',
+               [DSO_BINARY_TYPE__FEDORA_DEBUGINFO]             = 'f',
+               [DSO_BINARY_TYPE__UBUNTU_DEBUGINFO]             = 'u',
++              [DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO]     = 'x',
+               [DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO]       = 'o',
+               [DSO_BINARY_TYPE__BUILDID_DEBUGINFO]            = 'b',
+               [DSO_BINARY_TYPE__SYSTEM_PATH_DSO]              = 'd',
+@@ -77,6 +78,21 @@ int dso__read_binary_type_filename(const struct dso *dso,
+               snprintf(filename + len, size - len, "%s", dso->long_name);
+               break;
+ 
++      case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO:
++              /*
++               * Ubuntu can mixup /usr/lib with /lib, putting debuginfo in
++               * /usr/lib/debug/lib when it is expected to be in
++               * /usr/lib/debug/usr/lib
++               */
++              if (strlen(dso->long_name) < 9 ||
++                  strncmp(dso->long_name, "/usr/lib/", 9)) {
++                      ret = -1;
++                      break;
++              }
++              len = __symbol__join_symfs(filename, size, "/usr/lib/debug");
++              snprintf(filename + len, size - len, "%s", dso->long_name + 4);
++              break;
++
+       case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
+       {
+               const char *last_slash;
+diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h
+index ecc4bbd3f82e..b886720ffea0 100644
+--- a/tools/perf/util/dso.h
++++ b/tools/perf/util/dso.h
+@@ -22,6 +22,7 @@ enum dso_binary_type {
+       DSO_BINARY_TYPE__BUILD_ID_CACHE,
+       DSO_BINARY_TYPE__FEDORA_DEBUGINFO,
+       DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
++      DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
+       DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
+       DSO_BINARY_TYPE__SYSTEM_PATH_DSO,
+       DSO_BINARY_TYPE__GUEST_KMODULE,
+diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
+index 82e4f158c88e..7d0d44b4f3d5 100644
+--- a/tools/perf/util/probe-finder.c
++++ b/tools/perf/util/probe-finder.c
+@@ -111,6 +111,7 @@ enum dso_binary_type distro_dwarf_types[] = {
+       DSO_BINARY_TYPE__UBUNTU_DEBUGINFO,
+       DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
+       DSO_BINARY_TYPE__BUILDID_DEBUGINFO,
++      DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
+       DSO_BINARY_TYPE__NOT_FOUND,
+ };
+ 
+diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
+index acde8e489352..4e27b868f774 100644
+--- a/tools/perf/util/symbol.c
++++ b/tools/perf/util/symbol.c
+@@ -58,6 +58,7 @@ static enum dso_binary_type binary_type_symtab[] = {
+       DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE,
+       DSO_BINARY_TYPE__SYSTEM_PATH_KMODULE_COMP,
+       DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO,
++      DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO,
+       DSO_BINARY_TYPE__NOT_FOUND,
+ };
+ 
+@@ -1361,6 +1362,7 @@ static bool dso__is_compatible_symtab_type(struct dso 
*dso, bool kmod,
+       case DSO_BINARY_TYPE__SYSTEM_PATH_DSO:
+       case DSO_BINARY_TYPE__FEDORA_DEBUGINFO:
+       case DSO_BINARY_TYPE__UBUNTU_DEBUGINFO:
++      case DSO_BINARY_TYPE__MIXEDUP_UBUNTU_DEBUGINFO:
+       case DSO_BINARY_TYPE__BUILDID_DEBUGINFO:
+       case DSO_BINARY_TYPE__OPENEMBEDDED_DEBUGINFO:
+               return !kmod && dso->kernel == DSO_TYPE_USER;

Reply via email to