diff options
author | 2015-06-06 18:03:54 -0400 | |
---|---|---|
committer | 2015-06-06 18:03:54 -0400 | |
commit | b80f0b1fd45f663435ca84e9a9694c636e502613 (patch) | |
tree | 1689e91e2d4100a37e023902df583b06b55e1b53 | |
parent | Linux patch 4.0.4 (diff) | |
download | linux-patches-b80f0b1fd45f663435ca84e9a9694c636e502613.tar.gz linux-patches-b80f0b1fd45f663435ca84e9a9694c636e502613.tar.bz2 linux-patches-b80f0b1fd45f663435ca84e9a9694c636e502613.zip |
Linux patch 4.0.54.0-7
-rw-r--r-- | 0000_README | 4 | ||||
-rw-r--r-- | 1004_linux-4.0.5.patch | 4937 |
2 files changed, 4941 insertions, 0 deletions
diff --git a/0000_README b/0000_README index 3bcb0f89..0f635597 100644 --- a/0000_README +++ b/0000_README @@ -59,6 +59,10 @@ Patch: 1003_linux-4.0.4.patch From: http://www.kernel.org Desc: Linux 4.0.4 +Patch: 1004_linux-4.0.5.patch +From: http://www.kernel.org +Desc: Linux 4.0.5 + 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/1004_linux-4.0.5.patch b/1004_linux-4.0.5.patch new file mode 100644 index 00000000..84509c00 --- /dev/null +++ b/1004_linux-4.0.5.patch @@ -0,0 +1,4937 @@ +diff --git a/Documentation/hwmon/tmp401 b/Documentation/hwmon/tmp401 +index 8eb88e974055..711f75e189eb 100644 +--- a/Documentation/hwmon/tmp401 ++++ b/Documentation/hwmon/tmp401 +@@ -20,7 +20,7 @@ Supported chips: + Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp432.html + * Texas Instruments TMP435 + Prefix: 'tmp435' +- Addresses scanned: I2C 0x37, 0x48 - 0x4f ++ Addresses scanned: I2C 0x48 - 0x4f + Datasheet: http://focus.ti.com/docs/prod/folders/print/tmp435.html + + Authors: +diff --git a/Documentation/serial/tty.txt b/Documentation/serial/tty.txt +index 1e52d67d0abf..dbe6623fed1c 100644 +--- a/Documentation/serial/tty.txt ++++ b/Documentation/serial/tty.txt +@@ -198,6 +198,9 @@ TTY_IO_ERROR If set, causes all subsequent userspace read/write + + TTY_OTHER_CLOSED Device is a pty and the other side has closed. + ++TTY_OTHER_DONE Device is a pty and the other side has closed and ++ all pending input processing has been completed. ++ + TTY_NO_WRITE_SPLIT Prevent driver from splitting up writes into + smaller chunks. + +diff --git a/Documentation/virtual/kvm/mmu.txt b/Documentation/virtual/kvm/mmu.txt +index 53838d9c6295..c59bd9bc41ef 100644 +--- a/Documentation/virtual/kvm/mmu.txt ++++ b/Documentation/virtual/kvm/mmu.txt +@@ -169,6 +169,10 @@ Shadow pages contain the following information: + Contains the value of cr4.smep && !cr0.wp for which the page is valid + (pages for which this is true are different from other pages; see the + treatment of cr0.wp=0 below). ++ role.smap_andnot_wp: ++ Contains the value of cr4.smap && !cr0.wp for which the page is valid ++ (pages for which this is true are different from other pages; see the ++ treatment of cr0.wp=0 below). + gfn: + Either the guest page table containing the translations shadowed by this + page, or the base page frame for linear translations. See role.direct. +@@ -344,10 +348,16 @@ on fault type: + + (user write faults generate a #PF) + +-In the first case there is an additional complication if CR4.SMEP is +-enabled: since we've turned the page into a kernel page, the kernel may now +-execute it. We handle this by also setting spte.nx. If we get a user +-fetch or read fault, we'll change spte.u=1 and spte.nx=gpte.nx back. ++In the first case there are two additional complications: ++- if CR4.SMEP is enabled: since we've turned the page into a kernel page, ++ the kernel may now execute it. We handle this by also setting spte.nx. ++ If we get a user fetch or read fault, we'll change spte.u=1 and ++ spte.nx=gpte.nx back. ++- if CR4.SMAP is disabled: since the page has been changed to a kernel ++ page, it can not be reused when CR4.SMAP is enabled. We set ++ CR4.SMAP && !CR0.WP into shadow page's role to avoid this case. Note, ++ here we do not care the case that CR4.SMAP is enabled since KVM will ++ directly inject #PF to guest due to failed permission check. + + To prevent an spte that was converted into a kernel page with cr0.wp=0 + from being written by the kernel after cr0.wp has changed to 1, we make +diff --git a/Makefile b/Makefile +index 3d16bcc87585..1880cf77059b 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,6 @@ + VERSION = 4 + PATCHLEVEL = 0 +-SUBLEVEL = 4 ++SUBLEVEL = 5 + EXTRAVERSION = + NAME = Hurr durr I'ma sheep + +diff --git a/arch/arc/include/asm/atomic.h b/arch/arc/include/asm/atomic.h +index 067551b6920a..9917a45fc430 100644 +--- a/arch/arc/include/asm/atomic.h ++++ b/arch/arc/include/asm/atomic.h +@@ -99,7 +99,7 @@ static inline void atomic_##op(int i, atomic_t *v) \ + atomic_ops_unlock(flags); \ + } + +-#define ATOMIC_OP_RETURN(op, c_op) \ ++#define ATOMIC_OP_RETURN(op, c_op, asm_op) \ + static inline int atomic_##op##_return(int i, atomic_t *v) \ + { \ + unsigned long flags; \ +diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile +index a1c776b8dcec..992ea0b063d5 100644 +--- a/arch/arm/boot/dts/Makefile ++++ b/arch/arm/boot/dts/Makefile +@@ -215,7 +215,7 @@ dtb-$(CONFIG_SOC_IMX25) += \ + imx25-eukrea-mbimxsd25-baseboard-dvi-vga.dtb \ + imx25-karo-tx25.dtb \ + imx25-pdk.dtb +-dtb-$(CONFIG_SOC_IMX31) += \ ++dtb-$(CONFIG_SOC_IMX27) += \ + imx27-apf27.dtb \ + imx27-apf27dev.dtb \ + imx27-eukrea-mbimxsd27-baseboard.dtb \ +diff --git a/arch/arm/boot/dts/exynos4412-trats2.dts b/arch/arm/boot/dts/exynos4412-trats2.dts +index 173ffa479ad3..792394dd0f2a 100644 +--- a/arch/arm/boot/dts/exynos4412-trats2.dts ++++ b/arch/arm/boot/dts/exynos4412-trats2.dts +@@ -736,7 +736,7 @@ + + display-timings { + timing-0 { +- clock-frequency = <0>; ++ clock-frequency = <57153600>; + hactive = <720>; + vactive = <1280>; + hfront-porch = <5>; +diff --git a/arch/arm/boot/dts/imx27.dtsi b/arch/arm/boot/dts/imx27.dtsi +index 4b063b68db44..9ce1d2128749 100644 +--- a/arch/arm/boot/dts/imx27.dtsi ++++ b/arch/arm/boot/dts/imx27.dtsi +@@ -531,7 +531,7 @@ + + fec: ethernet@1002b000 { + compatible = "fsl,imx27-fec"; +- reg = <0x1002b000 0x4000>; ++ reg = <0x1002b000 0x1000>; + interrupts = <50>; + clocks = <&clks IMX27_CLK_FEC_IPG_GATE>, + <&clks IMX27_CLK_FEC_AHB_GATE>; +diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S +index f8ccc21fa032..4e7f40c577e6 100644 +--- a/arch/arm/kernel/entry-common.S ++++ b/arch/arm/kernel/entry-common.S +@@ -33,7 +33,9 @@ ret_fast_syscall: + UNWIND(.fnstart ) + UNWIND(.cantunwind ) + disable_irq @ disable interrupts +- ldr r1, [tsk, #TI_FLAGS] ++ ldr r1, [tsk, #TI_FLAGS] @ re-check for syscall tracing ++ tst r1, #_TIF_SYSCALL_WORK ++ bne __sys_trace_return + tst r1, #_TIF_WORK_MASK + bne fast_work_pending + asm_trace_hardirqs_on +diff --git a/arch/arm/mach-exynos/pm_domains.c b/arch/arm/mach-exynos/pm_domains.c +index 37266a826437..1f02bcb350e5 100644 +--- a/arch/arm/mach-exynos/pm_domains.c ++++ b/arch/arm/mach-exynos/pm_domains.c +@@ -169,7 +169,7 @@ no_clk: + args.np = np; + args.args_count = 0; + child_domain = of_genpd_get_from_provider(&args); +- if (!child_domain) ++ if (IS_ERR(child_domain)) + continue; + + if (of_parse_phandle_with_args(np, "power-domains", +@@ -177,7 +177,7 @@ no_clk: + continue; + + parent_domain = of_genpd_get_from_provider(&args); +- if (!parent_domain) ++ if (IS_ERR(parent_domain)) + continue; + + if (pm_genpd_add_subdomain(parent_domain, child_domain)) +diff --git a/arch/arm/mach-exynos/sleep.S b/arch/arm/mach-exynos/sleep.S +index 31d25834b9c4..cf950790fbdc 100644 +--- a/arch/arm/mach-exynos/sleep.S ++++ b/arch/arm/mach-exynos/sleep.S +@@ -23,14 +23,7 @@ + #define CPU_MASK 0xff0ffff0 + #define CPU_CORTEX_A9 0x410fc090 + +- /* +- * The following code is located into the .data section. This is to +- * allow l2x0_regs_phys to be accessed with a relative load while we +- * can't rely on any MMU translation. We could have put l2x0_regs_phys +- * in the .text section as well, but some setups might insist on it to +- * be truly read-only. (Reference from: arch/arm/kernel/sleep.S) +- */ +- .data ++ .text + .align + + /* +@@ -69,10 +62,12 @@ ENTRY(exynos_cpu_resume_ns) + cmp r0, r1 + bne skip_cp15 + +- adr r0, cp15_save_power ++ adr r0, _cp15_save_power + ldr r1, [r0] +- adr r0, cp15_save_diag ++ ldr r1, [r0, r1] ++ adr r0, _cp15_save_diag + ldr r2, [r0] ++ ldr r2, [r0, r2] + mov r0, #SMC_CMD_C15RESUME + dsb + smc #0 +@@ -118,14 +113,20 @@ skip_l2x0: + skip_cp15: + b cpu_resume + ENDPROC(exynos_cpu_resume_ns) ++ ++ .align ++_cp15_save_power: ++ .long cp15_save_power - . ++_cp15_save_diag: ++ .long cp15_save_diag - . ++#ifdef CONFIG_CACHE_L2X0 ++1: .long l2x0_saved_regs - . ++#endif /* CONFIG_CACHE_L2X0 */ ++ ++ .data + .globl cp15_save_diag + cp15_save_diag: + .long 0 @ cp15 diagnostic + .globl cp15_save_power + cp15_save_power: + .long 0 @ cp15 power control +- +-#ifdef CONFIG_CACHE_L2X0 +- .align +-1: .long l2x0_saved_regs - . +-#endif /* CONFIG_CACHE_L2X0 */ +diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c +index 4e6ef896c619..7186382672b5 100644 +--- a/arch/arm/mm/mmu.c ++++ b/arch/arm/mm/mmu.c +@@ -1112,22 +1112,22 @@ void __init sanity_check_meminfo(void) + } + + /* +- * Find the first non-section-aligned page, and point ++ * Find the first non-pmd-aligned page, and point + * memblock_limit at it. This relies on rounding the +- * limit down to be section-aligned, which happens at +- * the end of this function. ++ * limit down to be pmd-aligned, which happens at the ++ * end of this function. + * + * With this algorithm, the start or end of almost any +- * bank can be non-section-aligned. The only exception +- * is that the start of the bank 0 must be section- ++ * bank can be non-pmd-aligned. The only exception is ++ * that the start of the bank 0 must be section- + * aligned, since otherwise memory would need to be + * allocated when mapping the start of bank 0, which + * occurs before any free memory is mapped. + */ + if (!memblock_limit) { +- if (!IS_ALIGNED(block_start, SECTION_SIZE)) ++ if (!IS_ALIGNED(block_start, PMD_SIZE)) + memblock_limit = block_start; +- else if (!IS_ALIGNED(block_end, SECTION_SIZE)) ++ else if (!IS_ALIGNED(block_end, PMD_SIZE)) + memblock_limit = arm_lowmem_limit; + } + +@@ -1137,12 +1137,12 @@ void __init sanity_check_meminfo(void) + high_memory = __va(arm_lowmem_limit - 1) + 1; + + /* +- * Round the memblock limit down to a section size. This ++ * Round the memblock limit down to a pmd size. This + * helps to ensure that we will allocate memory from the +- * last full section, which should be mapped. ++ * last full pmd, which should be mapped. + */ + if (memblock_limit) +- memblock_limit = round_down(memblock_limit, SECTION_SIZE); ++ memblock_limit = round_down(memblock_limit, PMD_SIZE); + if (!memblock_limit) + memblock_limit = arm_lowmem_limit; + +diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c +index edba042b2325..dc6a4842683a 100644 +--- a/arch/arm64/net/bpf_jit_comp.c ++++ b/arch/arm64/net/bpf_jit_comp.c +@@ -487,7 +487,7 @@ emit_cond_jmp: + return -EINVAL; + } + +- imm64 = (u64)insn1.imm << 32 | imm; ++ imm64 = (u64)insn1.imm << 32 | (u32)imm; + emit_a64_mov_i64(dst, imm64, ctx); + + return 1; +diff --git a/arch/mips/kernel/elf.c b/arch/mips/kernel/elf.c +index d2c09f6475c5..f20cedcb50f1 100644 +--- a/arch/mips/kernel/elf.c ++++ b/arch/mips/kernel/elf.c +@@ -76,14 +76,6 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, + + /* Lets see if this is an O32 ELF */ + if (ehdr32->e_ident[EI_CLASS] == ELFCLASS32) { +- /* FR = 1 for N32 */ +- if (ehdr32->e_flags & EF_MIPS_ABI2) +- state->overall_fp_mode = FP_FR1; +- else +- /* Set a good default FPU mode for O32 */ +- state->overall_fp_mode = cpu_has_mips_r6 ? +- FP_FRE : FP_FR0; +- + if (ehdr32->e_flags & EF_MIPS_FP64) { + /* + * Set MIPS_ABI_FP_OLD_64 for EF_MIPS_FP64. We will override it +@@ -104,9 +96,6 @@ int arch_elf_pt_proc(void *_ehdr, void *_phdr, struct file *elf, + (char *)&abiflags, + sizeof(abiflags)); + } else { +- /* FR=1 is really the only option for 64-bit */ +- state->overall_fp_mode = FP_FR1; +- + if (phdr64->p_type != PT_MIPS_ABIFLAGS) + return 0; + if (phdr64->p_filesz < sizeof(abiflags)) +@@ -147,6 +136,7 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, + struct elf32_hdr *ehdr = _ehdr; + struct mode_req prog_req, interp_req; + int fp_abi, interp_fp_abi, abi0, abi1, max_abi; ++ bool is_mips64; + + if (!config_enabled(CONFIG_MIPS_O32_FP64_SUPPORT)) + return 0; +@@ -162,10 +152,22 @@ int arch_check_elf(void *_ehdr, bool has_interpreter, + abi0 = abi1 = fp_abi; + } + +- /* ABI limits. O32 = FP_64A, N32/N64 = FP_SOFT */ +- max_abi = ((ehdr->e_ident[EI_CLASS] == ELFCLASS32) && +- (!(ehdr->e_flags & EF_MIPS_ABI2))) ? +- MIPS_ABI_FP_64A : MIPS_ABI_FP_SOFT; ++ is_mips64 = (ehdr->e_ident[EI_CLASS] == ELFCLASS64) || ++ (ehdr->e_flags & EF_MIPS_ABI2); ++ ++ if (is_mips64) { ++ /* MIPS64 code always uses FR=1, thus the default is easy */ ++ state->overall_fp_mode = FP_FR1; ++ ++ /* Disallow access to the various FPXX & FP64 ABIs */ ++ max_abi = MIPS_ABI_FP_SOFT; ++ } else { ++ /* Default to a mode capable of running code expecting FR=0 */ ++ state->overall_fp_mode = cpu_has_mips_r6 ? FP_FRE : FP_FR0; ++ ++ /* Allow all ABIs we know about */ ++ max_abi = MIPS_ABI_FP_64A; ++ } + + if ((abi0 > max_abi && abi0 != MIPS_ABI_FP_UNKNOWN) || + (abi1 > max_abi && abi1 != MIPS_ABI_FP_UNKNOWN)) +diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h +index 3391d061eccc..78c9fd32c554 100644 +--- a/arch/parisc/include/asm/elf.h ++++ b/arch/parisc/include/asm/elf.h +@@ -348,6 +348,10 @@ struct pt_regs; /* forward declaration... */ + + #define ELF_HWCAP 0 + ++#define STACK_RND_MASK (is_32bit_task() ? \ ++ 0x7ff >> (PAGE_SHIFT - 12) : \ ++ 0x3ffff >> (PAGE_SHIFT - 12)) ++ + struct mm_struct; + extern unsigned long arch_randomize_brk(struct mm_struct *); + #define arch_randomize_brk arch_randomize_brk +diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c +index e1ffea2f9a0b..5aba01ac457f 100644 +--- a/arch/parisc/kernel/sys_parisc.c ++++ b/arch/parisc/kernel/sys_parisc.c +@@ -77,6 +77,9 @@ static unsigned long mmap_upper_limit(void) + if (stack_base > STACK_SIZE_MAX) + stack_base = STACK_SIZE_MAX; + ++ /* Add space for stack randomization. */ ++ stack_base += (STACK_RND_MASK << PAGE_SHIFT); ++ + return PAGE_ALIGN(STACK_TOP - stack_base); + } + +diff --git a/arch/powerpc/kernel/mce.c b/arch/powerpc/kernel/mce.c +index 15c99b649b04..b2eb4686bd8f 100644 +--- a/arch/powerpc/kernel/mce.c ++++ b/arch/powerpc/kernel/mce.c +@@ -73,7 +73,7 @@ void save_mce_event(struct pt_regs *regs, long handled, + uint64_t nip, uint64_t addr) + { + uint64_t srr1; +- int index = __this_cpu_inc_return(mce_nest_count); ++ int index = __this_cpu_inc_return(mce_nest_count) - 1; + struct machine_check_event *mce = this_cpu_ptr(&mce_event[index]); + + /* +@@ -184,7 +184,7 @@ void machine_check_queue_event(void) + if (!get_mce_event(&evt, MCE_EVENT_RELEASE)) + return; + +- index = __this_cpu_inc_return(mce_queue_count); ++ index = __this_cpu_inc_return(mce_queue_count) - 1; + /* If queue is full, just return for now. */ + if (index >= MAX_MC_EVT) { + __this_cpu_dec(mce_queue_count); +diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S +index f096e72262f4..1db685104ffc 100644 +--- a/arch/powerpc/kernel/vmlinux.lds.S ++++ b/arch/powerpc/kernel/vmlinux.lds.S +@@ -213,6 +213,7 @@ SECTIONS + *(.opd) + } + ++ . = ALIGN(256); + .got : AT(ADDR(.got) - LOAD_OFFSET) { + __toc_start = .; + #ifndef CONFIG_RELOCATABLE +diff --git a/arch/s390/crypto/ghash_s390.c b/arch/s390/crypto/ghash_s390.c +index 7940dc90e80b..b258110da952 100644 +--- a/arch/s390/crypto/ghash_s390.c ++++ b/arch/s390/crypto/ghash_s390.c +@@ -16,11 +16,12 @@ + #define GHASH_DIGEST_SIZE 16 + + struct ghash_ctx { +- u8 icv[16]; +- u8 key[16]; ++ u8 key[GHASH_BLOCK_SIZE]; + }; + + struct ghash_desc_ctx { ++ u8 icv[GHASH_BLOCK_SIZE]; ++ u8 key[GHASH_BLOCK_SIZE]; + u8 buffer[GHASH_BLOCK_SIZE]; + u32 bytes; + }; +@@ -28,8 +29,10 @@ struct ghash_desc_ctx { + static int ghash_init(struct shash_desc *desc) + { + struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); ++ struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); + + memset(dctx, 0, sizeof(*dctx)); ++ memcpy(dctx->key, ctx->key, GHASH_BLOCK_SIZE); + + return 0; + } +@@ -45,7 +48,6 @@ static int ghash_setkey(struct crypto_shash *tfm, + } + + memcpy(ctx->key, key, GHASH_BLOCK_SIZE); +- memset(ctx->icv, 0, GHASH_BLOCK_SIZE); + + return 0; + } +@@ -54,7 +56,6 @@ static int ghash_update(struct shash_desc *desc, + const u8 *src, unsigned int srclen) + { + struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); +- struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); + unsigned int n; + u8 *buf = dctx->buffer; + int ret; +@@ -70,7 +71,7 @@ static int ghash_update(struct shash_desc *desc, + src += n; + + if (!dctx->bytes) { +- ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, ++ ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf, + GHASH_BLOCK_SIZE); + if (ret != GHASH_BLOCK_SIZE) + return -EIO; +@@ -79,7 +80,7 @@ static int ghash_update(struct shash_desc *desc, + + n = srclen & ~(GHASH_BLOCK_SIZE - 1); + if (n) { +- ret = crypt_s390_kimd(KIMD_GHASH, ctx, src, n); ++ ret = crypt_s390_kimd(KIMD_GHASH, dctx, src, n); + if (ret != n) + return -EIO; + src += n; +@@ -94,7 +95,7 @@ static int ghash_update(struct shash_desc *desc, + return 0; + } + +-static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx) ++static int ghash_flush(struct ghash_desc_ctx *dctx) + { + u8 *buf = dctx->buffer; + int ret; +@@ -104,24 +105,24 @@ static int ghash_flush(struct ghash_ctx *ctx, struct ghash_desc_ctx *dctx) + + memset(pos, 0, dctx->bytes); + +- ret = crypt_s390_kimd(KIMD_GHASH, ctx, buf, GHASH_BLOCK_SIZE); ++ ret = crypt_s390_kimd(KIMD_GHASH, dctx, buf, GHASH_BLOCK_SIZE); + if (ret != GHASH_BLOCK_SIZE) + return -EIO; ++ ++ dctx->bytes = 0; + } + +- dctx->bytes = 0; + return 0; + } + + static int ghash_final(struct shash_desc *desc, u8 *dst) + { + struct ghash_desc_ctx *dctx = shash_desc_ctx(desc); +- struct ghash_ctx *ctx = crypto_shash_ctx(desc->tfm); + int ret; + +- ret = ghash_flush(ctx, dctx); ++ ret = ghash_flush(dctx); + if (!ret) +- memcpy(dst, ctx->icv, GHASH_BLOCK_SIZE); ++ memcpy(dst, dctx->icv, GHASH_BLOCK_SIZE); + return ret; + } + +diff --git a/arch/s390/include/asm/pgtable.h b/arch/s390/include/asm/pgtable.h +index e08ec38f8c6e..e10112da008d 100644 +--- a/arch/s390/include/asm/pgtable.h ++++ b/arch/s390/include/asm/pgtable.h +@@ -600,7 +600,7 @@ static inline int pmd_large(pmd_t pmd) + return (pmd_val(pmd) & _SEGMENT_ENTRY_LARGE) != 0; + } + +-static inline int pmd_pfn(pmd_t pmd) ++static inline unsigned long pmd_pfn(pmd_t pmd) + { + unsigned long origin_mask; + +diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h +index a236e39cc385..1c0fb570b5c2 100644 +--- a/arch/x86/include/asm/kvm_host.h ++++ b/arch/x86/include/asm/kvm_host.h +@@ -212,6 +212,7 @@ union kvm_mmu_page_role { + unsigned nxe:1; + unsigned cr0_wp:1; + unsigned smep_andnot_wp:1; ++ unsigned smap_andnot_wp:1; + }; + }; + +@@ -404,6 +405,7 @@ struct kvm_vcpu_arch { + struct kvm_mmu_memory_cache mmu_page_header_cache; + + struct fpu guest_fpu; ++ bool eager_fpu; + u64 xcr0; + u64 guest_supported_xcr0; + u32 guest_xstate_size; +@@ -735,6 +737,7 @@ struct kvm_x86_ops { + void (*cache_reg)(struct kvm_vcpu *vcpu, enum kvm_reg reg); + unsigned long (*get_rflags)(struct kvm_vcpu *vcpu); + void (*set_rflags)(struct kvm_vcpu *vcpu, unsigned long rflags); ++ void (*fpu_activate)(struct kvm_vcpu *vcpu); + void (*fpu_deactivate)(struct kvm_vcpu *vcpu); + + void (*tlb_flush)(struct kvm_vcpu *vcpu); +diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c +index 3c036cb4a370..11dd8f23fcea 100644 +--- a/arch/x86/kernel/cpu/mcheck/mce.c ++++ b/arch/x86/kernel/cpu/mcheck/mce.c +@@ -705,6 +705,7 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, + struct pt_regs *regs) + { + int i, ret = 0; ++ char *tmp; + + for (i = 0; i < mca_cfg.banks; i++) { + m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i)); +@@ -713,9 +714,11 @@ static int mce_no_way_out(struct mce *m, char **msg, unsigned long *validp, + if (quirk_no_way_out) + quirk_no_way_out(i, m, regs); + } +- if (mce_severity(m, mca_cfg.tolerant, msg, true) >= +- MCE_PANIC_SEVERITY) ++ ++ if (mce_severity(m, mca_cfg.tolerant, &tmp, true) >= MCE_PANIC_SEVERITY) { ++ *msg = tmp; + ret = 1; ++ } + } + return ret; + } +diff --git a/arch/x86/kernel/cpu/perf_event_intel_rapl.c b/arch/x86/kernel/cpu/perf_event_intel_rapl.c +index c4bb8b8e5017..76d8cbe5a10f 100644 +--- a/arch/x86/kernel/cpu/perf_event_intel_rapl.c ++++ b/arch/x86/kernel/cpu/perf_event_intel_rapl.c +@@ -680,6 +680,7 @@ static int __init rapl_pmu_init(void) + break; + case 60: /* Haswell */ + case 69: /* Haswell-Celeron */ ++ case 61: /* Broadwell */ + rapl_cntr_mask = RAPL_IDX_HSW; + rapl_pmu_events_group.attrs = rapl_events_hsw_attr; + break; +diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c +index d5651fce0b71..f341d56b7883 100644 +--- a/arch/x86/kernel/i387.c ++++ b/arch/x86/kernel/i387.c +@@ -169,6 +169,21 @@ static void init_thread_xstate(void) + xstate_size = sizeof(struct i387_fxsave_struct); + else + xstate_size = sizeof(struct i387_fsave_struct); ++ ++ /* ++ * Quirk: we don't yet handle the XSAVES* instructions ++ * correctly, as we don't correctly convert between ++ * standard and compacted format when interfacing ++ * with user-space - so disable it for now. ++ * ++ * The difference is small: with recent CPUs the ++ * compacted format is only marginally smaller than ++ * the standard FPU state format. ++ * ++ * ( This is easy to backport while we are fixing ++ * XSAVES* support. ) ++ */ ++ setup_clear_cpu_cap(X86_FEATURE_XSAVES); + } + + /* +diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c +index 8a80737ee6e6..307f9ec28e08 100644 +--- a/arch/x86/kvm/cpuid.c ++++ b/arch/x86/kvm/cpuid.c +@@ -16,6 +16,8 @@ + #include <linux/module.h> + #include <linux/vmalloc.h> + #include <linux/uaccess.h> ++#include <asm/i387.h> /* For use_eager_fpu. Ugh! */ ++#include <asm/fpu-internal.h> /* For use_eager_fpu. Ugh! */ + #include <asm/user.h> + #include <asm/xsave.h> + #include "cpuid.h" +@@ -95,6 +97,8 @@ int kvm_update_cpuid(struct kvm_vcpu *vcpu) + if (best && (best->eax & (F(XSAVES) | F(XSAVEC)))) + best->ebx = xstate_required_size(vcpu->arch.xcr0, true); + ++ vcpu->arch.eager_fpu = guest_cpuid_has_mpx(vcpu); ++ + /* + * The existing code assumes virtual address is 48-bit in the canonical + * address checks; exit if it is ever changed. +diff --git a/arch/x86/kvm/cpuid.h b/arch/x86/kvm/cpuid.h +index 4452eedfaedd..9bec2b8cdced 100644 +--- a/arch/x86/kvm/cpuid.h ++++ b/arch/x86/kvm/cpuid.h +@@ -111,4 +111,12 @@ static inline bool guest_cpuid_has_rtm(struct kvm_vcpu *vcpu) + best = kvm_find_cpuid_entry(vcpu, 7, 0); + return best && (best->ebx & bit(X86_FEATURE_RTM)); + } ++ ++static inline bool guest_cpuid_has_mpx(struct kvm_vcpu *vcpu) ++{ ++ struct kvm_cpuid_entry2 *best; ++ ++ best = kvm_find_cpuid_entry(vcpu, 7, 0); ++ return best && (best->ebx & bit(X86_FEATURE_MPX)); ++} + #endif +diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c +index cee759299a35..88ee9282a57e 100644 +--- a/arch/x86/kvm/mmu.c ++++ b/arch/x86/kvm/mmu.c +@@ -3736,8 +3736,8 @@ static void reset_rsvds_bits_mask_ept(struct kvm_vcpu *vcpu, + } + } + +-void update_permission_bitmask(struct kvm_vcpu *vcpu, +- struct kvm_mmu *mmu, bool ept) ++static void update_permission_bitmask(struct kvm_vcpu *vcpu, ++ struct kvm_mmu *mmu, bool ept) + { + unsigned bit, byte, pfec; + u8 map; +@@ -3918,6 +3918,7 @@ static void init_kvm_tdp_mmu(struct kvm_vcpu *vcpu) + void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu) + { + bool smep = kvm_read_cr4_bits(vcpu, X86_CR4_SMEP); ++ bool smap = kvm_read_cr4_bits(vcpu, X86_CR4_SMAP); + struct kvm_mmu *context = &vcpu->arch.mmu; + + MMU_WARN_ON(VALID_PAGE(context->root_hpa)); +@@ -3936,6 +3937,8 @@ void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu) + context->base_role.cr0_wp = is_write_protection(vcpu); + context->base_role.smep_andnot_wp + = smep && !is_write_protection(vcpu); ++ context->base_role.smap_andnot_wp ++ = smap && !is_write_protection(vcpu); + } + EXPORT_SYMBOL_GPL(kvm_init_shadow_mmu); + +@@ -4207,12 +4210,18 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, + const u8 *new, int bytes) + { + gfn_t gfn = gpa >> PAGE_SHIFT; +- union kvm_mmu_page_role mask = { .word = 0 }; + struct kvm_mmu_page *sp; + LIST_HEAD(invalid_list); + u64 entry, gentry, *spte; + int npte; + bool remote_flush, local_flush, zap_page; ++ union kvm_mmu_page_role mask = (union kvm_mmu_page_role) { ++ .cr0_wp = 1, ++ .cr4_pae = 1, ++ .nxe = 1, ++ .smep_andnot_wp = 1, ++ .smap_andnot_wp = 1, ++ }; + + /* + * If we don't have indirect shadow pages, it means no page is +@@ -4238,7 +4247,6 @@ void kvm_mmu_pte_write(struct kvm_vcpu *vcpu, gpa_t gpa, + ++vcpu->kvm->stat.mmu_pte_write; + kvm_mmu_audit(vcpu, AUDIT_PRE_PTE_WRITE); + +- mask.cr0_wp = mask.cr4_pae = mask.nxe = 1; + for_each_gfn_indirect_valid_sp(vcpu->kvm, sp, gfn) { + if (detect_write_misaligned(sp, gpa, bytes) || + detect_write_flooding(sp)) { +diff --git a/arch/x86/kvm/mmu.h b/arch/x86/kvm/mmu.h +index c7d65637c851..0ada65ecddcf 100644 +--- a/arch/x86/kvm/mmu.h ++++ b/arch/x86/kvm/mmu.h +@@ -71,8 +71,6 @@ enum { + int handle_mmio_page_fault_common(struct kvm_vcpu *vcpu, u64 addr, bool direct); + void kvm_init_shadow_mmu(struct kvm_vcpu *vcpu); + void kvm_init_shadow_ept_mmu(struct kvm_vcpu *vcpu, bool execonly); +-void update_permission_bitmask(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, +- bool ept); + + static inline unsigned int kvm_mmu_available_pages(struct kvm *kvm) + { +@@ -166,6 +164,8 @@ static inline bool permission_fault(struct kvm_vcpu *vcpu, struct kvm_mmu *mmu, + int index = (pfec >> 1) + + (smap >> (X86_EFLAGS_AC_BIT - PFERR_RSVD_BIT + 1)); + ++ WARN_ON(pfec & PFERR_RSVD_MASK); ++ + return (mmu->permissions[index] >> pte_access) & 1; + } + +diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h +index fd49c867b25a..6e6d115fe9b5 100644 +--- a/arch/x86/kvm/paging_tmpl.h ++++ b/arch/x86/kvm/paging_tmpl.h +@@ -718,6 +718,13 @@ static int FNAME(page_fault)(struct kvm_vcpu *vcpu, gva_t addr, u32 error_code, + mmu_is_nested(vcpu)); + if (likely(r != RET_MMIO_PF_INVALID)) + return r; ++ ++ /* ++ * page fault with PFEC.RSVD = 1 is caused by shadow ++ * page fault, should not be used to walk guest page ++ * table. ++ */ ++ error_code &= ~PFERR_RSVD_MASK; + }; + + r = mmu_topup_memory_caches(vcpu); +diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c +index cc618c882f90..a4e62fcfabcb 100644 +--- a/arch/x86/kvm/svm.c ++++ b/arch/x86/kvm/svm.c +@@ -4374,6 +4374,7 @@ static struct kvm_x86_ops svm_x86_ops = { + .cache_reg = svm_cache_reg, + .get_rflags = svm_get_rflags, + .set_rflags = svm_set_rflags, ++ .fpu_activate = svm_fpu_activate, + .fpu_deactivate = svm_fpu_deactivate, + + .tlb_flush = svm_flush_tlb, +diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c +index a60bd3aa0965..5318d64674b0 100644 +--- a/arch/x86/kvm/vmx.c ++++ b/arch/x86/kvm/vmx.c +@@ -10179,6 +10179,7 @@ static struct kvm_x86_ops vmx_x86_ops = { + .cache_reg = vmx_cache_reg, + .get_rflags = vmx_get_rflags, + .set_rflags = vmx_set_rflags, ++ .fpu_activate = vmx_fpu_activate, + .fpu_deactivate = vmx_fpu_deactivate, + + .tlb_flush = vmx_flush_tlb, +diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c +index e222ba5d2beb..8838057da9c3 100644 +--- a/arch/x86/kvm/x86.c ++++ b/arch/x86/kvm/x86.c +@@ -702,8 +702,9 @@ EXPORT_SYMBOL_GPL(kvm_set_xcr); + int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) + { + unsigned long old_cr4 = kvm_read_cr4(vcpu); +- unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | +- X86_CR4_PAE | X86_CR4_SMEP; ++ unsigned long pdptr_bits = X86_CR4_PGE | X86_CR4_PSE | X86_CR4_PAE | ++ X86_CR4_SMEP | X86_CR4_SMAP; ++ + if (cr4 & CR4_RESERVED_BITS) + return 1; + +@@ -744,9 +745,6 @@ int kvm_set_cr4(struct kvm_vcpu *vcpu, unsigned long cr4) + (!(cr4 & X86_CR4_PCIDE) && (old_cr4 & X86_CR4_PCIDE))) + kvm_mmu_reset_context(vcpu); + +- if ((cr4 ^ old_cr4) & X86_CR4_SMAP) +- update_permission_bitmask(vcpu, vcpu->arch.walk_mmu, false); +- + if ((cr4 ^ old_cr4) & X86_CR4_OSXSAVE) + kvm_update_cpuid(vcpu); + +@@ -6141,6 +6139,8 @@ void kvm_vcpu_reload_apic_access_page(struct kvm_vcpu *vcpu) + return; + + page = gfn_to_page(vcpu->kvm, APIC_DEFAULT_PHYS_BASE >> PAGE_SHIFT); ++ if (is_error_page(page)) ++ return; + kvm_x86_ops->set_apic_access_page_addr(vcpu, page_to_phys(page)); + + /* +@@ -6996,7 +6996,9 @@ void kvm_put_guest_fpu(struct kvm_vcpu *vcpu) + fpu_save_init(&vcpu->arch.guest_fpu); + __kernel_fpu_end(); + ++vcpu->stat.fpu_reload; +- kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu); ++ if (!vcpu->arch.eager_fpu) ++ kvm_make_request(KVM_REQ_DEACTIVATE_FPU, vcpu); ++ + trace_kvm_fpu(0); + } + +@@ -7012,11 +7014,21 @@ void kvm_arch_vcpu_free(struct kvm_vcpu *vcpu) + struct kvm_vcpu *kvm_arch_vcpu_create(struct kvm *kvm, + unsigned int id) + { ++ struct kvm_vcpu *vcpu; ++ + if (check_tsc_unstable() && atomic_read(&kvm->online_vcpus) != 0) + printk_once(KERN_WARNING + "kvm: SMP vm created on host with unstable TSC; " + "guest TSC will not be reliable\n"); +- return kvm_x86_ops->vcpu_create(kvm, id); ++ ++ vcpu = kvm_x86_ops->vcpu_create(kvm, id); ++ ++ /* ++ * Activate fpu unconditionally in case the guest needs eager FPU. It will be ++ * deactivated soon if it doesn't. ++ */ ++ kvm_x86_ops->fpu_activate(vcpu); ++ return vcpu; + } + + int kvm_arch_vcpu_setup(struct kvm_vcpu *vcpu) +diff --git a/drivers/acpi/osl.c b/drivers/acpi/osl.c +index f9eeae871593..5aa1f6e281d2 100644 +--- a/drivers/acpi/osl.c ++++ b/drivers/acpi/osl.c +@@ -182,7 +182,7 @@ static void __init acpi_request_region (struct acpi_generic_address *gas, + request_mem_region(addr, length, desc); + } + +-static int __init acpi_reserve_resources(void) ++static void __init acpi_reserve_resources(void) + { + acpi_request_region(&acpi_gbl_FADT.xpm1a_event_block, acpi_gbl_FADT.pm1_event_length, + "ACPI PM1a_EVT_BLK"); +@@ -211,10 +211,7 @@ static int __init acpi_reserve_resources(void) + if (!(acpi_gbl_FADT.gpe1_block_length & 0x1)) + acpi_request_region(&acpi_gbl_FADT.xgpe1_block, + acpi_gbl_FADT.gpe1_block_length, "ACPI GPE1_BLK"); +- +- return 0; + } +-device_initcall(acpi_reserve_resources); + + void acpi_os_printf(const char *fmt, ...) + { +@@ -1845,6 +1842,7 @@ acpi_status __init acpi_os_initialize(void) + + acpi_status __init acpi_os_initialize1(void) + { ++ acpi_reserve_resources(); + kacpid_wq = alloc_workqueue("kacpid", 0, 1); + kacpi_notify_wq = alloc_workqueue("kacpi_notify", 0, 1); + kacpi_hotplug_wq = alloc_ordered_workqueue("kacpi_hotplug", 0); +diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c +index 33bb06e006c9..adce56fa9cef 100644 +--- a/drivers/ata/ahci.c ++++ b/drivers/ata/ahci.c +@@ -66,6 +66,7 @@ enum board_ids { + board_ahci_yes_fbs, + + /* board IDs for specific chipsets in alphabetical order */ ++ board_ahci_avn, + board_ahci_mcp65, + board_ahci_mcp77, + board_ahci_mcp89, +@@ -84,6 +85,8 @@ enum board_ids { + static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent); + static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class, + unsigned long deadline); ++static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, ++ unsigned long deadline); + static void ahci_mcp89_apple_enable(struct pci_dev *pdev); + static bool is_mcp89_apple(struct pci_dev *pdev); + static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, +@@ -107,6 +110,11 @@ static struct ata_port_operations ahci_p5wdh_ops = { + .hardreset = ahci_p5wdh_hardreset, + }; + ++static struct ata_port_operations ahci_avn_ops = { ++ .inherits = &ahci_ops, ++ .hardreset = ahci_avn_hardreset, ++}; ++ + static const struct ata_port_info ahci_port_info[] = { + /* by features */ + [board_ahci] = { +@@ -151,6 +159,12 @@ static const struct ata_port_info ahci_port_info[] = { + .port_ops = &ahci_ops, + }, + /* by chipsets */ ++ [board_ahci_avn] = { ++ .flags = AHCI_FLAG_COMMON, ++ .pio_mask = ATA_PIO4, ++ .udma_mask = ATA_UDMA6, ++ .port_ops = &ahci_avn_ops, ++ }, + [board_ahci_mcp65] = { + AHCI_HFLAGS (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP | + AHCI_HFLAG_YES_NCQ), +@@ -290,14 +304,14 @@ static const struct pci_device_id ahci_pci_tbl[] = { + { PCI_VDEVICE(INTEL, 0x1f27), board_ahci }, /* Avoton RAID */ + { PCI_VDEVICE(INTEL, 0x1f2e), board_ahci }, /* Avoton RAID */ + { PCI_VDEVICE(INTEL, 0x1f2f), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f32), board_ahci }, /* Avoton AHCI */ +- { PCI_VDEVICE(INTEL, 0x1f33), board_ahci }, /* Avoton AHCI */ +- { PCI_VDEVICE(INTEL, 0x1f34), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f35), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f36), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f37), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci }, /* Avoton RAID */ +- { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f32), board_ahci_avn }, /* Avoton AHCI */ ++ { PCI_VDEVICE(INTEL, 0x1f33), board_ahci_avn }, /* Avoton AHCI */ ++ { PCI_VDEVICE(INTEL, 0x1f34), board_ahci_avn }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f35), board_ahci_avn }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f36), board_ahci_avn }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */ ++ { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */ + { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */ + { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */ + { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */ +@@ -670,6 +684,79 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class, + return rc; + } + ++/* ++ * ahci_avn_hardreset - attempt more aggressive recovery of Avoton ports. ++ * ++ * It has been observed with some SSDs that the timing of events in the ++ * link synchronization phase can leave the port in a state that can not ++ * be recovered by a SATA-hard-reset alone. The failing signature is ++ * SStatus.DET stuck at 1 ("Device presence detected but Phy ++ * communication not established"). It was found that unloading and ++ * reloading the driver when this problem occurs allows the drive ++ * connection to be recovered (DET advanced to 0x3). The critical ++ * component of reloading the driver is that the port state machines are ++ * reset by bouncing "port enable" in the AHCI PCS configuration ++ * register. So, reproduce that effect by bouncing a port whenever we ++ * see DET==1 after a reset. ++ */ ++static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class, ++ unsigned long deadline) ++{ ++ const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context); ++ struct ata_port *ap = link->ap; ++ struct ahci_port_priv *pp = ap->private_data; ++ struct ahci_host_priv *hpriv = ap->host->private_data; ++ u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG; ++ unsigned long tmo = deadline - jiffies; ++ struct ata_taskfile tf; ++ bool online; ++ int rc, i; ++ ++ DPRINTK("ENTER\n"); ++ ++ ahci_stop_engine(ap); ++ ++ for (i = 0; i < 2; i++) { ++ u16 val; ++ u32 sstatus; ++ int port = ap->port_no; ++ struct ata_host *host = ap->host; ++ struct pci_dev *pdev = to_pci_dev(host->dev); ++ ++ /* clear D2H reception area to properly wait for D2H FIS */ ++ ata_tf_init(link->device, &tf); ++ tf.command = ATA_BUSY; ++ ata_tf_to_fis(&tf, 0, 0, d2h_fis); ++ ++ rc = sata_link_hardreset(link, timing, deadline, &online, ++ ahci_check_ready); ++ ++ if (sata_scr_read(link, SCR_STATUS, &sstatus) != 0 || ++ (sstatus & 0xf) != 1) ++ break; ++ ++ ata_link_printk(link, KERN_INFO, "avn bounce port%d\n", ++ port); ++ ++ pci_read_config_word(pdev, 0x92, &val); ++ val &= ~(1 << port); ++ pci_write_config_word(pdev, 0x92, val); ++ ata_msleep(ap, 1000); ++ val |= 1 << port; ++ pci_write_config_word(pdev, 0x92, val); ++ deadline += tmo; ++ } ++ ++ hpriv->start_engine(ap); ++ ++ if (online) ++ *class = ahci_dev_classify(ap); ++ ++ DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class); ++ return rc; ++} ++ ++ + #ifdef CONFIG_PM + static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg) + { +diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c +index 61a9c07e0dff..287c4ba0219f 100644 +--- a/drivers/ata/libahci.c ++++ b/drivers/ata/libahci.c +@@ -1707,8 +1707,7 @@ static void ahci_handle_port_interrupt(struct ata_port *ap, + if (unlikely(resetting)) + status &= ~PORT_IRQ_BAD_PMP; + +- /* if LPM is enabled, PHYRDY doesn't mean anything */ +- if (ap->link.lpm_policy > ATA_LPM_MAX_POWER) { ++ if (sata_lpm_ignore_phy_events(&ap->link)) { + status &= ~PORT_IRQ_PHYRDY; + ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG); + } +diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c +index 23dac3babfe3..87b4b7f9fdc6 100644 +--- a/drivers/ata/libata-core.c ++++ b/drivers/ata/libata-core.c +@@ -4214,7 +4214,7 @@ static const struct ata_blacklist_entry ata_device_blacklist [] = { + ATA_HORKAGE_ZERO_AFTER_TRIM, }, + { "Crucial_CT*MX100*", "MU01", ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, +- { "Samsung SSD 850 PRO*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | ++ { "Samsung SSD 8*", NULL, ATA_HORKAGE_NO_NCQ_TRIM | + ATA_HORKAGE_ZERO_AFTER_TRIM, }, + + /* +@@ -6728,6 +6728,38 @@ u32 ata_wait_register(struct ata_port *ap, void __iomem *reg, u32 mask, u32 val, + return tmp; + } + ++/** ++ * sata_lpm_ignore_phy_events - test if PHY event should be ignored ++ * @link: Link receiving the event ++ * ++ * Test whether the received PHY event has to be ignored or not. ++ * ++ * LOCKING: ++ * None: ++ * ++ * RETURNS: ++ * True if the event has to be ignored. ++ */ ++bool sata_lpm_ignore_phy_events(struct ata_link *link) ++{ ++ unsigned long lpm_timeout = link->last_lpm_change + ++ msecs_to_jiffies(ATA_TMOUT_SPURIOUS_PHY); ++ ++ /* if LPM is enabled, PHYRDY doesn't mean anything */ ++ if (link->lpm_policy > ATA_LPM_MAX_POWER) ++ return true; ++ ++ /* ignore the first PHY event after the LPM policy changed ++ * as it is might be spurious ++ */ ++ if ((link->flags & ATA_LFLAG_CHANGED) && ++ time_before(jiffies, lpm_timeout)) ++ return true; ++ ++ return false; ++} ++EXPORT_SYMBOL_GPL(sata_lpm_ignore_phy_events); ++ + /* + * Dummy port_ops + */ +diff --git a/drivers/ata/libata-eh.c b/drivers/ata/libata-eh.c +index d2029a462e2c..89c3d83e1ca7 100644 +--- a/drivers/ata/libata-eh.c ++++ b/drivers/ata/libata-eh.c +@@ -3489,6 +3489,9 @@ static int ata_eh_set_lpm(struct ata_link *link, enum ata_lpm_policy policy, + } + } + ++ link->last_lpm_change = jiffies; ++ link->flags |= ATA_LFLAG_CHANGED; ++ + return 0; + + fail: +diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c +index 237f23f68bfc..1daa0ea2f1ac 100644 +--- a/drivers/clk/clk.c ++++ b/drivers/clk/clk.c +@@ -1443,8 +1443,10 @@ static struct clk_core *__clk_set_parent_before(struct clk_core *clk, + */ + if (clk->prepare_count) { + clk_core_prepare(parent); ++ flags = clk_enable_lock(); + clk_core_enable(parent); + clk_core_enable(clk); ++ clk_enable_unlock(flags); + } + + /* update the clk tree topology */ +@@ -1459,13 +1461,17 @@ static void __clk_set_parent_after(struct clk_core *core, + struct clk_core *parent, + struct clk_core *old_parent) + { ++ unsigned long flags; ++ + /* + * Finish the migration of prepare state and undo the changes done + * for preventing a race with clk_enable(). + */ + if (core->prepare_count) { ++ flags = clk_enable_lock(); + clk_core_disable(core); + clk_core_disable(old_parent); ++ clk_enable_unlock(flags); + clk_core_unprepare(old_parent); + } + } +@@ -1489,8 +1495,10 @@ static int __clk_set_parent(struct clk_core *clk, struct clk_core *parent, + clk_enable_unlock(flags); + + if (clk->prepare_count) { ++ flags = clk_enable_lock(); + clk_core_disable(clk); + clk_core_disable(parent); ++ clk_enable_unlock(flags); + clk_core_unprepare(parent); + } + return ret; +diff --git a/drivers/clk/samsung/clk-exynos5420.c b/drivers/clk/samsung/clk-exynos5420.c +index 07d666cc6a29..bea4a173eef5 100644 +--- a/drivers/clk/samsung/clk-exynos5420.c ++++ b/drivers/clk/samsung/clk-exynos5420.c +@@ -271,6 +271,7 @@ static const struct samsung_clk_reg_dump exynos5420_set_clksrc[] = { + { .offset = SRC_MASK_PERIC0, .value = 0x11111110, }, + { .offset = SRC_MASK_PERIC1, .value = 0x11111100, }, + { .offset = SRC_MASK_ISP, .value = 0x11111000, }, ++ { .offset = GATE_BUS_TOP, .value = 0xffffffff, }, + { .offset = GATE_BUS_DISP1, .value = 0xffffffff, }, + { .offset = GATE_IP_PERIC, .value = 0xffffffff, }, + }; +diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c +index 2eebd28b4c40..ccc20188f00c 100644 +--- a/drivers/firmware/dmi_scan.c ++++ b/drivers/firmware/dmi_scan.c +@@ -499,18 +499,19 @@ static int __init dmi_present(const u8 *buf) + buf += 16; + + if (memcmp(buf, "_DMI_", 5) == 0 && dmi_checksum(buf, 15)) { ++ if (smbios_ver) ++ dmi_ver = smbios_ver; ++ else ++ dmi_ver = (buf[14] & 0xF0) << 4 | (buf[14] & 0x0F); + dmi_num = get_unaligned_le16(buf + 12); + dmi_len = get_unaligned_le16(buf + 6); + dmi_base = get_unaligned_le32(buf + 8); + + if (dmi_walk_early(dmi_decode) == 0) { + if (smbios_ver) { +- dmi_ver = smbios_ver; + pr_info("SMBIOS %d.%d present.\n", + dmi_ver >> 8, dmi_ver & 0xFF); + } else { +- dmi_ver = (buf[14] & 0xF0) << 4 | +- (buf[14] & 0x0F); + pr_info("Legacy DMI %d.%d present.\n", + dmi_ver >> 8, dmi_ver & 0xFF); + } +diff --git a/drivers/gpio/gpio-kempld.c b/drivers/gpio/gpio-kempld.c +index 443518f63f15..a6b0def4bd7b 100644 +--- a/drivers/gpio/gpio-kempld.c ++++ b/drivers/gpio/gpio-kempld.c +@@ -117,7 +117,7 @@ static int kempld_gpio_get_direction(struct gpio_chip *chip, unsigned offset) + = container_of(chip, struct kempld_gpio_data, chip); + struct kempld_device_data *pld = gpio->pld; + +- return kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset); ++ return !kempld_gpio_get_bit(pld, KEMPLD_GPIO_DIR_NUM(offset), offset); + } + + static int kempld_gpio_pincount(struct kempld_device_data *pld) +diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +index 498399323a8c..406624a0b201 100644 +--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c ++++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c +@@ -729,7 +729,7 @@ static ssize_t node_show(struct kobject *kobj, struct attribute *attr, + kfd2kgd->get_max_engine_clock_in_mhz( + dev->gpu->kgd)); + sysfs_show_64bit_prop(buffer, "local_mem_size", +- kfd2kgd->get_vmem_size(dev->gpu->kgd)); ++ (unsigned long long int) 0); + + sysfs_show_32bit_prop(buffer, "fw_version", + kfd2kgd->get_fw_version( +diff --git a/drivers/gpu/drm/drm_plane_helper.c b/drivers/gpu/drm/drm_plane_helper.c +index 5ba5792bfdba..98b125763ecd 100644 +--- a/drivers/gpu/drm/drm_plane_helper.c ++++ b/drivers/gpu/drm/drm_plane_helper.c +@@ -476,6 +476,9 @@ int drm_plane_helper_commit(struct drm_plane *plane, + if (!crtc[i]) + continue; + ++ if (crtc[i]->cursor == plane) ++ continue; ++ + /* There's no other way to figure out whether the crtc is running. */ + ret = drm_crtc_vblank_get(crtc[i]); + if (ret == 0) { +diff --git a/drivers/gpu/drm/radeon/atombios_crtc.c b/drivers/gpu/drm/radeon/atombios_crtc.c +index 1afc0b419da2..965a45619f6b 100644 +--- a/drivers/gpu/drm/radeon/atombios_crtc.c ++++ b/drivers/gpu/drm/radeon/atombios_crtc.c +@@ -1789,7 +1789,9 @@ static int radeon_get_shared_nondp_ppll(struct drm_crtc *crtc) + if ((crtc->mode.clock == test_crtc->mode.clock) && + (adjusted_clock == test_adjusted_clock) && + (radeon_crtc->ss_enabled == test_radeon_crtc->ss_enabled) && +- (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID)) ++ (test_radeon_crtc->pll_id != ATOM_PPLL_INVALID) && ++ (drm_detect_monitor_audio(radeon_connector_edid(test_radeon_crtc->connector)) == ++ drm_detect_monitor_audio(radeon_connector_edid(radeon_crtc->connector)))) + return test_radeon_crtc->pll_id; + } + } +diff --git a/drivers/gpu/drm/radeon/atombios_dp.c b/drivers/gpu/drm/radeon/atombios_dp.c +index 8d74de82456e..8b2c4c890507 100644 +--- a/drivers/gpu/drm/radeon/atombios_dp.c ++++ b/drivers/gpu/drm/radeon/atombios_dp.c +@@ -412,19 +412,21 @@ bool radeon_dp_getdpcd(struct radeon_connector *radeon_connector) + { + struct radeon_connector_atom_dig *dig_connector = radeon_connector->con_priv; + u8 msg[DP_DPCD_SIZE]; +- int ret; ++ int ret, i; + +- ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg, +- DP_DPCD_SIZE); +- if (ret > 0) { +- memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); ++ for (i = 0; i < 7; i++) { ++ ret = drm_dp_dpcd_read(&radeon_connector->ddc_bus->aux, DP_DPCD_REV, msg, ++ DP_DPCD_SIZE); ++ if (ret == DP_DPCD_SIZE) { ++ memcpy(dig_connector->dpcd, msg, DP_DPCD_SIZE); + +- DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd), +- dig_connector->dpcd); ++ DRM_DEBUG_KMS("DPCD: %*ph\n", (int)sizeof(dig_connector->dpcd), ++ dig_connector->dpcd); + +- radeon_dp_probe_oui(radeon_connector); ++ radeon_dp_probe_oui(radeon_connector); + +- return true; ++ return true; ++ } + } + dig_connector->dpcd[0] = 0; + return false; +diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c +index 3e670d344a20..19aafb71fd8e 100644 +--- a/drivers/gpu/drm/radeon/cik.c ++++ b/drivers/gpu/drm/radeon/cik.c +@@ -5804,7 +5804,7 @@ static int cik_pcie_gart_enable(struct radeon_device *rdev) + /* restore context1-15 */ + /* set vm size, must be a multiple of 4 */ + WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); +- WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); ++ WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1); + for (i = 1; i < 16; i++) { + if (i < 8) + WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), +diff --git a/drivers/gpu/drm/radeon/evergreen_hdmi.c b/drivers/gpu/drm/radeon/evergreen_hdmi.c +index 0926739c9fa7..9953356fe263 100644 +--- a/drivers/gpu/drm/radeon/evergreen_hdmi.c ++++ b/drivers/gpu/drm/radeon/evergreen_hdmi.c +@@ -400,7 +400,7 @@ void evergreen_hdmi_enable(struct drm_encoder *encoder, bool enable) + if (enable) { + struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); + +- if (drm_detect_monitor_audio(radeon_connector_edid(connector))) { ++ if (connector && drm_detect_monitor_audio(radeon_connector_edid(connector))) { + WREG32(HDMI_INFOFRAME_CONTROL0 + dig->afmt->offset, + HDMI_AVI_INFO_SEND | /* enable AVI info frames */ + HDMI_AVI_INFO_CONT | /* required for audio info values to be updated */ +@@ -438,7 +438,8 @@ void evergreen_dp_enable(struct drm_encoder *encoder, bool enable) + if (!dig || !dig->afmt) + return; + +- if (enable && drm_detect_monitor_audio(radeon_connector_edid(connector))) { ++ if (enable && connector && ++ drm_detect_monitor_audio(radeon_connector_edid(connector))) { + struct drm_connector *connector = radeon_get_connector_for_encoder(encoder); + struct radeon_connector *radeon_connector = to_radeon_connector(connector); + struct radeon_connector_atom_dig *dig_connector; +diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c +index dab00812abaa..02d585455f49 100644 +--- a/drivers/gpu/drm/radeon/ni.c ++++ b/drivers/gpu/drm/radeon/ni.c +@@ -1272,7 +1272,8 @@ static int cayman_pcie_gart_enable(struct radeon_device *rdev) + */ + for (i = 1; i < 8; i++) { + WREG32(VM_CONTEXT0_PAGE_TABLE_START_ADDR + (i << 2), 0); +- WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), rdev->vm_manager.max_pfn); ++ WREG32(VM_CONTEXT0_PAGE_TABLE_END_ADDR + (i << 2), ++ rdev->vm_manager.max_pfn - 1); + WREG32(VM_CONTEXT0_PAGE_TABLE_BASE_ADDR + (i << 2), + rdev->vm_manager.saved_table_addr[i]); + } +diff --git a/drivers/gpu/drm/radeon/radeon_audio.c b/drivers/gpu/drm/radeon/radeon_audio.c +index b7c6bb69f3c7..88c04bc0a7f6 100644 +--- a/drivers/gpu/drm/radeon/radeon_audio.c ++++ b/drivers/gpu/drm/radeon/radeon_audio.c +@@ -460,9 +460,6 @@ void radeon_audio_detect(struct drm_connector *connector, + if (!connector || !connector->encoder) + return; + +- if (!radeon_encoder_is_digital(connector->encoder)) +- return; +- + rdev = connector->encoder->dev->dev_private; + + if (!radeon_audio_chipset_supported(rdev)) +@@ -471,26 +468,26 @@ void radeon_audio_detect(struct drm_connector *connector, + radeon_encoder = to_radeon_encoder(connector->encoder); + dig = radeon_encoder->enc_priv; + +- if (!dig->afmt) +- return; +- + if (status == connector_status_connected) { +- struct radeon_connector *radeon_connector = to_radeon_connector(connector); ++ struct radeon_connector *radeon_connector; ++ int sink_type; ++ ++ if (!drm_detect_monitor_audio(radeon_connector_edid(connector))) { ++ radeon_encoder->audio = NULL; ++ return; ++ } ++ ++ radeon_connector = to_radeon_connector(connector); ++ sink_type = radeon_dp_getsinktype(radeon_connector); + + if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort && +- radeon_dp_getsinktype(radeon_connector) == +- CONNECTOR_OBJECT_ID_DISPLAYPORT) ++ sink_type == CONNECTOR_OBJECT_ID_DISPLAYPORT) + radeon_encoder->audio = rdev->audio.dp_funcs; + else + radeon_encoder->audio = rdev->audio.hdmi_funcs; + + dig->afmt->pin = radeon_audio_get_pin(connector->encoder); +- if (drm_detect_monitor_audio(radeon_connector_edid(connector))) { +- radeon_audio_enable(rdev, dig->afmt->pin, 0xf); +- } else { +- radeon_audio_enable(rdev, dig->afmt->pin, 0); +- dig->afmt->pin = NULL; +- } ++ radeon_audio_enable(rdev, dig->afmt->pin, 0xf); + } else { + radeon_audio_enable(rdev, dig->afmt->pin, 0); + dig->afmt->pin = NULL; +diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c +index 27973e3faf0e..27def67cb6be 100644 +--- a/drivers/gpu/drm/radeon/radeon_connectors.c ++++ b/drivers/gpu/drm/radeon/radeon_connectors.c +@@ -1333,10 +1333,8 @@ out: + /* updated in get modes as well since we need to know if it's analog or digital */ + radeon_connector_update_scratch_regs(connector, ret); + +- if (radeon_audio != 0) { +- radeon_connector_get_edid(connector); ++ if (radeon_audio != 0) + radeon_audio_detect(connector, ret); +- } + + exit: + pm_runtime_mark_last_busy(connector->dev->dev); +@@ -1661,10 +1659,8 @@ radeon_dp_detect(struct drm_connector *connector, bool force) + + radeon_connector_update_scratch_regs(connector, ret); + +- if (radeon_audio != 0) { +- radeon_connector_get_edid(connector); ++ if (radeon_audio != 0) + radeon_audio_detect(connector, ret); +- } + + out: + pm_runtime_mark_last_busy(connector->dev->dev); +diff --git a/drivers/gpu/drm/radeon/si.c b/drivers/gpu/drm/radeon/si.c +index a7fb2735d4a9..f433491fab6f 100644 +--- a/drivers/gpu/drm/radeon/si.c ++++ b/drivers/gpu/drm/radeon/si.c +@@ -4288,7 +4288,7 @@ static int si_pcie_gart_enable(struct radeon_device *rdev) + /* empty context1-15 */ + /* set vm size, must be a multiple of 4 */ + WREG32(VM_CONTEXT1_PAGE_TABLE_START_ADDR, 0); +- WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn); ++ WREG32(VM_CONTEXT1_PAGE_TABLE_END_ADDR, rdev->vm_manager.max_pfn - 1); + /* Assign the pt base to something valid for now; the pts used for + * the VMs are determined by the application and setup and assigned + * on the fly in the vm part of radeon_gart.c +diff --git a/drivers/hid/hid-logitech-hidpp.c b/drivers/hid/hid-logitech-hidpp.c +index e77658cd037c..2caf5b2f3446 100644 +--- a/drivers/hid/hid-logitech-hidpp.c ++++ b/drivers/hid/hid-logitech-hidpp.c +@@ -39,7 +39,6 @@ MODULE_AUTHOR("Nestor Lopez Casado <nlopezcasad@logitech.com>"); + /* bits 1..20 are reserved for classes */ + #define HIDPP_QUIRK_DELAYED_INIT BIT(21) + #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS BIT(22) +-#define HIDPP_QUIRK_MULTI_INPUT BIT(23) + + /* + * There are two hidpp protocols in use, the first version hidpp10 is known +@@ -701,12 +700,6 @@ static int wtp_input_mapping(struct hid_device *hdev, struct hid_input *hi, + struct hid_field *field, struct hid_usage *usage, + unsigned long **bit, int *max) + { +- struct hidpp_device *hidpp = hid_get_drvdata(hdev); +- +- if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) && +- (field->application == HID_GD_KEYBOARD)) +- return 0; +- + return -1; + } + +@@ -715,10 +708,6 @@ static void wtp_populate_input(struct hidpp_device *hidpp, + { + struct wtp_data *wd = hidpp->private_data; + +- if ((hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) && origin_is_hid_core) +- /* this is the generic hid-input call */ +- return; +- + __set_bit(EV_ABS, input_dev->evbit); + __set_bit(EV_KEY, input_dev->evbit); + __clear_bit(EV_REL, input_dev->evbit); +@@ -1234,10 +1223,6 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id) + if (hidpp->quirks & HIDPP_QUIRK_DELAYED_INIT) + connect_mask &= ~HID_CONNECT_HIDINPUT; + +- /* Re-enable hidinput for multi-input devices */ +- if (hidpp->quirks & HIDPP_QUIRK_MULTI_INPUT) +- connect_mask |= HID_CONNECT_HIDINPUT; +- + ret = hid_hw_start(hdev, connect_mask); + if (ret) { + hid_err(hdev, "%s:hid_hw_start returned error\n", __func__); +@@ -1285,11 +1270,6 @@ static const struct hid_device_id hidpp_devices[] = { + HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, + USB_DEVICE_ID_LOGITECH_T651), + .driver_data = HIDPP_QUIRK_CLASS_WTP }, +- { /* Keyboard TK820 */ +- HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, +- USB_VENDOR_ID_LOGITECH, 0x4102), +- .driver_data = HIDPP_QUIRK_DELAYED_INIT | HIDPP_QUIRK_MULTI_INPUT | +- HIDPP_QUIRK_CLASS_WTP }, + + { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE, + USB_VENDOR_ID_LOGITECH, HID_ANY_ID)}, +diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c +index f3830db02d46..37f01702d081 100644 +--- a/drivers/hwmon/nct6683.c ++++ b/drivers/hwmon/nct6683.c +@@ -439,6 +439,7 @@ nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg, + (*t)->dev_attr.attr.name, tg->base + i); + if ((*t)->s2) { + a2 = &su->u.a2; ++ sysfs_attr_init(&a2->dev_attr.attr); + a2->dev_attr.attr.name = su->name; + a2->nr = (*t)->u.s.nr + i; + a2->index = (*t)->u.s.index; +@@ -449,6 +450,7 @@ nct6683_create_attr_group(struct device *dev, struct sensor_template_group *tg, + *attrs = &a2->dev_attr.attr; + } else { + a = &su->u.a1; ++ sysfs_attr_init(&a->dev_attr.attr); + a->dev_attr.attr.name = su->name; + a->index = (*t)->u.index + i; + a->dev_attr.attr.mode = +diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c +index 1be41177b620..0773930c110e 100644 +--- a/drivers/hwmon/nct6775.c ++++ b/drivers/hwmon/nct6775.c +@@ -994,6 +994,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg, + (*t)->dev_attr.attr.name, tg->base + i); + if ((*t)->s2) { + a2 = &su->u.a2; ++ sysfs_attr_init(&a2->dev_attr.attr); + a2->dev_attr.attr.name = su->name; + a2->nr = (*t)->u.s.nr + i; + a2->index = (*t)->u.s.index; +@@ -1004,6 +1005,7 @@ nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg, + *attrs = &a2->dev_attr.attr; + } else { + a = &su->u.a1; ++ sysfs_attr_init(&a->dev_attr.attr); + a->dev_attr.attr.name = su->name; + a->index = (*t)->u.index + i; + a->dev_attr.attr.mode = +diff --git a/drivers/hwmon/ntc_thermistor.c b/drivers/hwmon/ntc_thermistor.c +index 112e4d45e4a0..68800115876b 100644 +--- a/drivers/hwmon/ntc_thermistor.c ++++ b/drivers/hwmon/ntc_thermistor.c +@@ -239,8 +239,10 @@ static struct ntc_thermistor_platform_data * + ntc_thermistor_parse_dt(struct platform_device *pdev) + { + struct iio_channel *chan; ++ enum iio_chan_type type; + struct device_node *np = pdev->dev.of_node; + struct ntc_thermistor_platform_data *pdata; ++ int ret; + + if (!np) + return NULL; +@@ -253,6 +255,13 @@ ntc_thermistor_parse_dt(struct platform_device *pdev) + if (IS_ERR(chan)) + return ERR_CAST(chan); + ++ ret = iio_get_channel_type(chan, &type); ++ if (ret < 0) ++ return ERR_PTR(ret); ++ ++ if (type != IIO_VOLTAGE) ++ return ERR_PTR(-EINVAL); ++ + if (of_property_read_u32(np, "pullup-uv", &pdata->pullup_uv)) + return ERR_PTR(-ENODEV); + if (of_property_read_u32(np, "pullup-ohm", &pdata->pullup_ohm)) +diff --git a/drivers/hwmon/tmp401.c b/drivers/hwmon/tmp401.c +index 99664ebc738d..ccf4cffe0ee1 100644 +--- a/drivers/hwmon/tmp401.c ++++ b/drivers/hwmon/tmp401.c +@@ -44,7 +44,7 @@ + #include <linux/sysfs.h> + + /* Addresses to scan */ +-static const unsigned short normal_i2c[] = { 0x37, 0x48, 0x49, 0x4a, 0x4c, 0x4d, ++static const unsigned short normal_i2c[] = { 0x48, 0x49, 0x4a, 0x4c, 0x4d, + 0x4e, 0x4f, I2C_CLIENT_END }; + + enum chips { tmp401, tmp411, tmp431, tmp432, tmp435 }; +diff --git a/drivers/iio/accel/st_accel_core.c b/drivers/iio/accel/st_accel_core.c +index 53f32629283a..6805db0e4f07 100644 +--- a/drivers/iio/accel/st_accel_core.c ++++ b/drivers/iio/accel/st_accel_core.c +@@ -465,6 +465,7 @@ int st_accel_common_probe(struct iio_dev *indio_dev) + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &accel_info; ++ mutex_init(&adata->tb.buf_lock); + + st_sensors_power_enable(indio_dev); + +diff --git a/drivers/iio/adc/axp288_adc.c b/drivers/iio/adc/axp288_adc.c +index 08bcfb061ca5..56008a86b78f 100644 +--- a/drivers/iio/adc/axp288_adc.c ++++ b/drivers/iio/adc/axp288_adc.c +@@ -53,39 +53,42 @@ static const struct iio_chan_spec const axp288_adc_channels[] = { + .channel = 0, + .address = AXP288_TS_ADC_H, + .datasheet_name = "TS_PIN", ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, { + .indexed = 1, + .type = IIO_TEMP, + .channel = 1, + .address = AXP288_PMIC_ADC_H, + .datasheet_name = "PMIC_TEMP", ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, { + .indexed = 1, + .type = IIO_TEMP, + .channel = 2, + .address = AXP288_GP_ADC_H, + .datasheet_name = "GPADC", ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, { + .indexed = 1, + .type = IIO_CURRENT, + .channel = 3, + .address = AXP20X_BATT_CHRG_I_H, + .datasheet_name = "BATT_CHG_I", +- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, { + .indexed = 1, + .type = IIO_CURRENT, + .channel = 4, + .address = AXP20X_BATT_DISCHRG_I_H, + .datasheet_name = "BATT_DISCHRG_I", +- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, { + .indexed = 1, + .type = IIO_VOLTAGE, + .channel = 5, + .address = AXP20X_BATT_V_H, + .datasheet_name = "BATT_V", +- .info_mask_separate = BIT(IIO_CHAN_INFO_PROCESSED), ++ .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + }, + }; + +@@ -151,9 +154,6 @@ static int axp288_adc_read_raw(struct iio_dev *indio_dev, + chan->address)) + dev_err(&indio_dev->dev, "TS pin restore\n"); + break; +- case IIO_CHAN_INFO_PROCESSED: +- ret = axp288_adc_read_channel(val, chan->address, info->regmap); +- break; + default: + ret = -EINVAL; + } +diff --git a/drivers/iio/adc/cc10001_adc.c b/drivers/iio/adc/cc10001_adc.c +index 51e2a83c9404..115f6e99a7fa 100644 +--- a/drivers/iio/adc/cc10001_adc.c ++++ b/drivers/iio/adc/cc10001_adc.c +@@ -35,8 +35,9 @@ + #define CC10001_ADC_EOC_SET BIT(0) + + #define CC10001_ADC_CHSEL_SAMPLED 0x0c +-#define CC10001_ADC_POWER_UP 0x10 +-#define CC10001_ADC_POWER_UP_SET BIT(0) ++#define CC10001_ADC_POWER_DOWN 0x10 ++#define CC10001_ADC_POWER_DOWN_SET BIT(0) ++ + #define CC10001_ADC_DEBUG 0x14 + #define CC10001_ADC_DATA_COUNT 0x20 + +@@ -62,7 +63,6 @@ struct cc10001_adc_device { + u16 *buf; + + struct mutex lock; +- unsigned long channel_map; + unsigned int start_delay_ns; + unsigned int eoc_delay_ns; + }; +@@ -79,6 +79,18 @@ static inline u32 cc10001_adc_read_reg(struct cc10001_adc_device *adc_dev, + return readl(adc_dev->reg_base + reg); + } + ++static void cc10001_adc_power_up(struct cc10001_adc_device *adc_dev) ++{ ++ cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN, 0); ++ ndelay(adc_dev->start_delay_ns); ++} ++ ++static void cc10001_adc_power_down(struct cc10001_adc_device *adc_dev) ++{ ++ cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_DOWN, ++ CC10001_ADC_POWER_DOWN_SET); ++} ++ + static void cc10001_adc_start(struct cc10001_adc_device *adc_dev, + unsigned int channel) + { +@@ -88,6 +100,7 @@ static void cc10001_adc_start(struct cc10001_adc_device *adc_dev, + val = (channel & CC10001_ADC_CH_MASK) | CC10001_ADC_MODE_SINGLE_CONV; + cc10001_adc_write_reg(adc_dev, CC10001_ADC_CONFIG, val); + ++ udelay(1); + val = cc10001_adc_read_reg(adc_dev, CC10001_ADC_CONFIG); + val = val | CC10001_ADC_START_CONV; + cc10001_adc_write_reg(adc_dev, CC10001_ADC_CONFIG, val); +@@ -129,6 +142,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p) + struct iio_dev *indio_dev; + unsigned int delay_ns; + unsigned int channel; ++ unsigned int scan_idx; + bool sample_invalid; + u16 *data; + int i; +@@ -139,20 +153,17 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p) + + mutex_lock(&adc_dev->lock); + +- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, +- CC10001_ADC_POWER_UP_SET); +- +- /* Wait for 8 (6+2) clock cycles before activating START */ +- ndelay(adc_dev->start_delay_ns); ++ cc10001_adc_power_up(adc_dev); + + /* Calculate delay step for eoc and sampled data */ + delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT; + + i = 0; + sample_invalid = false; +- for_each_set_bit(channel, indio_dev->active_scan_mask, ++ for_each_set_bit(scan_idx, indio_dev->active_scan_mask, + indio_dev->masklength) { + ++ channel = indio_dev->channels[scan_idx].channel; + cc10001_adc_start(adc_dev, channel); + + data[i] = cc10001_adc_poll_done(indio_dev, channel, delay_ns); +@@ -166,7 +177,7 @@ static irqreturn_t cc10001_adc_trigger_h(int irq, void *p) + } + + done: +- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0); ++ cc10001_adc_power_down(adc_dev); + + mutex_unlock(&adc_dev->lock); + +@@ -185,11 +196,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev, + unsigned int delay_ns; + u16 val; + +- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, +- CC10001_ADC_POWER_UP_SET); +- +- /* Wait for 8 (6+2) clock cycles before activating START */ +- ndelay(adc_dev->start_delay_ns); ++ cc10001_adc_power_up(adc_dev); + + /* Calculate delay step for eoc and sampled data */ + delay_ns = adc_dev->eoc_delay_ns / CC10001_MAX_POLL_COUNT; +@@ -198,7 +205,7 @@ static u16 cc10001_adc_read_raw_voltage(struct iio_dev *indio_dev, + + val = cc10001_adc_poll_done(indio_dev, chan->channel, delay_ns); + +- cc10001_adc_write_reg(adc_dev, CC10001_ADC_POWER_UP, 0); ++ cc10001_adc_power_down(adc_dev); + + return val; + } +@@ -224,7 +231,7 @@ static int cc10001_adc_read_raw(struct iio_dev *indio_dev, + + case IIO_CHAN_INFO_SCALE: + ret = regulator_get_voltage(adc_dev->reg); +- if (ret) ++ if (ret < 0) + return ret; + + *val = ret / 1000; +@@ -255,22 +262,22 @@ static const struct iio_info cc10001_adc_info = { + .update_scan_mode = &cc10001_update_scan_mode, + }; + +-static int cc10001_adc_channel_init(struct iio_dev *indio_dev) ++static int cc10001_adc_channel_init(struct iio_dev *indio_dev, ++ unsigned long channel_map) + { +- struct cc10001_adc_device *adc_dev = iio_priv(indio_dev); + struct iio_chan_spec *chan_array, *timestamp; + unsigned int bit, idx = 0; + +- indio_dev->num_channels = bitmap_weight(&adc_dev->channel_map, +- CC10001_ADC_NUM_CHANNELS); ++ indio_dev->num_channels = bitmap_weight(&channel_map, ++ CC10001_ADC_NUM_CHANNELS) + 1; + +- chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels + 1, ++ chan_array = devm_kcalloc(&indio_dev->dev, indio_dev->num_channels, + sizeof(struct iio_chan_spec), + GFP_KERNEL); + if (!chan_array) + return -ENOMEM; + +- for_each_set_bit(bit, &adc_dev->channel_map, CC10001_ADC_NUM_CHANNELS) { ++ for_each_set_bit(bit, &channel_map, CC10001_ADC_NUM_CHANNELS) { + struct iio_chan_spec *chan = &chan_array[idx]; + + chan->type = IIO_VOLTAGE; +@@ -305,6 +312,7 @@ static int cc10001_adc_probe(struct platform_device *pdev) + unsigned long adc_clk_rate; + struct resource *res; + struct iio_dev *indio_dev; ++ unsigned long channel_map; + int ret; + + indio_dev = devm_iio_device_alloc(&pdev->dev, sizeof(*adc_dev)); +@@ -313,9 +321,9 @@ static int cc10001_adc_probe(struct platform_device *pdev) + + adc_dev = iio_priv(indio_dev); + +- adc_dev->channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0); ++ channel_map = GENMASK(CC10001_ADC_NUM_CHANNELS - 1, 0); + if (!of_property_read_u32(node, "adc-reserved-channels", &ret)) +- adc_dev->channel_map &= ~ret; ++ channel_map &= ~ret; + + adc_dev->reg = devm_regulator_get(&pdev->dev, "vref"); + if (IS_ERR(adc_dev->reg)) +@@ -361,7 +369,7 @@ static int cc10001_adc_probe(struct platform_device *pdev) + adc_dev->start_delay_ns = adc_dev->eoc_delay_ns * CC10001_WAIT_CYCLES; + + /* Setup the ADC channels available on the device */ +- ret = cc10001_adc_channel_init(indio_dev); ++ ret = cc10001_adc_channel_init(indio_dev, channel_map); + if (ret < 0) + goto err_disable_clk; + +diff --git a/drivers/iio/adc/qcom-spmi-vadc.c b/drivers/iio/adc/qcom-spmi-vadc.c +index 3211729bcb0b..0c4618b4d515 100644 +--- a/drivers/iio/adc/qcom-spmi-vadc.c ++++ b/drivers/iio/adc/qcom-spmi-vadc.c +@@ -18,6 +18,7 @@ + #include <linux/iio/iio.h> + #include <linux/interrupt.h> + #include <linux/kernel.h> ++#include <linux/math64.h> + #include <linux/module.h> + #include <linux/of.h> + #include <linux/platform_device.h> +@@ -471,11 +472,11 @@ static s32 vadc_calibrate(struct vadc_priv *vadc, + const struct vadc_channel_prop *prop, u16 adc_code) + { + const struct vadc_prescale_ratio *prescale; +- s32 voltage; ++ s64 voltage; + + voltage = adc_code - vadc->graph[prop->calibration].gnd; + voltage *= vadc->graph[prop->calibration].dx; +- voltage = voltage / vadc->graph[prop->calibration].dy; ++ voltage = div64_s64(voltage, vadc->graph[prop->calibration].dy); + + if (prop->calibration == VADC_CALIB_ABSOLUTE) + voltage += vadc->graph[prop->calibration].dx; +@@ -487,7 +488,7 @@ static s32 vadc_calibrate(struct vadc_priv *vadc, + + voltage = voltage * prescale->den; + +- return voltage / prescale->num; ++ return div64_s64(voltage, prescale->num); + } + + static int vadc_decimation_from_dt(u32 value) +diff --git a/drivers/iio/adc/xilinx-xadc-core.c b/drivers/iio/adc/xilinx-xadc-core.c +index a221f7329b79..ce93bd8e3f68 100644 +--- a/drivers/iio/adc/xilinx-xadc-core.c ++++ b/drivers/iio/adc/xilinx-xadc-core.c +@@ -856,6 +856,7 @@ static int xadc_read_raw(struct iio_dev *indio_dev, + switch (chan->address) { + case XADC_REG_VCCINT: + case XADC_REG_VCCAUX: ++ case XADC_REG_VREFP: + case XADC_REG_VCCBRAM: + case XADC_REG_VCCPINT: + case XADC_REG_VCCPAUX: +@@ -996,7 +997,7 @@ static const struct iio_event_spec xadc_voltage_events[] = { + .num_event_specs = (_alarm) ? ARRAY_SIZE(xadc_voltage_events) : 0, \ + .scan_index = (_scan_index), \ + .scan_type = { \ +- .sign = 'u', \ ++ .sign = ((_addr) == XADC_REG_VREFN) ? 's' : 'u', \ + .realbits = 12, \ + .storagebits = 16, \ + .shift = 4, \ +@@ -1008,7 +1009,7 @@ static const struct iio_event_spec xadc_voltage_events[] = { + static const struct iio_chan_spec xadc_channels[] = { + XADC_CHAN_TEMP(0, 8, XADC_REG_TEMP), + XADC_CHAN_VOLTAGE(0, 9, XADC_REG_VCCINT, "vccint", true), +- XADC_CHAN_VOLTAGE(1, 10, XADC_REG_VCCINT, "vccaux", true), ++ XADC_CHAN_VOLTAGE(1, 10, XADC_REG_VCCAUX, "vccaux", true), + XADC_CHAN_VOLTAGE(2, 14, XADC_REG_VCCBRAM, "vccbram", true), + XADC_CHAN_VOLTAGE(3, 5, XADC_REG_VCCPINT, "vccpint", true), + XADC_CHAN_VOLTAGE(4, 6, XADC_REG_VCCPAUX, "vccpaux", true), +diff --git a/drivers/iio/adc/xilinx-xadc.h b/drivers/iio/adc/xilinx-xadc.h +index c7487e8d7f80..54adc5087210 100644 +--- a/drivers/iio/adc/xilinx-xadc.h ++++ b/drivers/iio/adc/xilinx-xadc.h +@@ -145,9 +145,9 @@ static inline int xadc_write_adc_reg(struct xadc *xadc, unsigned int reg, + #define XADC_REG_MAX_VCCPINT 0x28 + #define XADC_REG_MAX_VCCPAUX 0x29 + #define XADC_REG_MAX_VCCO_DDR 0x2a +-#define XADC_REG_MIN_VCCPINT 0x2b +-#define XADC_REG_MIN_VCCPAUX 0x2c +-#define XADC_REG_MIN_VCCO_DDR 0x2d ++#define XADC_REG_MIN_VCCPINT 0x2c ++#define XADC_REG_MIN_VCCPAUX 0x2d ++#define XADC_REG_MIN_VCCO_DDR 0x2e + + #define XADC_REG_CONF0 0x40 + #define XADC_REG_CONF1 0x41 +diff --git a/drivers/iio/common/st_sensors/st_sensors_core.c b/drivers/iio/common/st_sensors/st_sensors_core.c +index edd13d2b4121..8dd0477e201c 100644 +--- a/drivers/iio/common/st_sensors/st_sensors_core.c ++++ b/drivers/iio/common/st_sensors/st_sensors_core.c +@@ -304,8 +304,6 @@ int st_sensors_init_sensor(struct iio_dev *indio_dev, + struct st_sensors_platform_data *of_pdata; + int err = 0; + +- mutex_init(&sdata->tb.buf_lock); +- + /* If OF/DT pdata exists, it will take precedence of anything else */ + of_pdata = st_sensors_of_probe(indio_dev->dev.parent, pdata); + if (of_pdata) +diff --git a/drivers/iio/gyro/st_gyro_core.c b/drivers/iio/gyro/st_gyro_core.c +index f07a2336f7dc..566f7d2df031 100644 +--- a/drivers/iio/gyro/st_gyro_core.c ++++ b/drivers/iio/gyro/st_gyro_core.c +@@ -317,6 +317,7 @@ int st_gyro_common_probe(struct iio_dev *indio_dev) + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &gyro_info; ++ mutex_init(&gdata->tb.buf_lock); + + st_sensors_power_enable(indio_dev); + +diff --git a/drivers/iio/light/hid-sensor-prox.c b/drivers/iio/light/hid-sensor-prox.c +index 3ecf79ed08ac..88f21bbe947c 100644 +--- a/drivers/iio/light/hid-sensor-prox.c ++++ b/drivers/iio/light/hid-sensor-prox.c +@@ -43,8 +43,6 @@ struct prox_state { + static const struct iio_chan_spec prox_channels[] = { + { + .type = IIO_PROXIMITY, +- .modified = 1, +- .channel2 = IIO_NO_MOD, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | +diff --git a/drivers/iio/magnetometer/st_magn_core.c b/drivers/iio/magnetometer/st_magn_core.c +index 8ade473f99fe..2e56f812a644 100644 +--- a/drivers/iio/magnetometer/st_magn_core.c ++++ b/drivers/iio/magnetometer/st_magn_core.c +@@ -369,6 +369,7 @@ int st_magn_common_probe(struct iio_dev *indio_dev) + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &magn_info; ++ mutex_init(&mdata->tb.buf_lock); + + st_sensors_power_enable(indio_dev); + +diff --git a/drivers/iio/pressure/hid-sensor-press.c b/drivers/iio/pressure/hid-sensor-press.c +index 1af314926ebd..476a7d03d2ce 100644 +--- a/drivers/iio/pressure/hid-sensor-press.c ++++ b/drivers/iio/pressure/hid-sensor-press.c +@@ -47,8 +47,6 @@ struct press_state { + static const struct iio_chan_spec press_channels[] = { + { + .type = IIO_PRESSURE, +- .modified = 1, +- .channel2 = IIO_NO_MOD, + .info_mask_separate = BIT(IIO_CHAN_INFO_RAW), + .info_mask_shared_by_type = BIT(IIO_CHAN_INFO_OFFSET) | + BIT(IIO_CHAN_INFO_SCALE) | +diff --git a/drivers/iio/pressure/st_pressure_core.c b/drivers/iio/pressure/st_pressure_core.c +index 97baf40d424b..e881fa6291e9 100644 +--- a/drivers/iio/pressure/st_pressure_core.c ++++ b/drivers/iio/pressure/st_pressure_core.c +@@ -417,6 +417,7 @@ int st_press_common_probe(struct iio_dev *indio_dev) + + indio_dev->modes = INDIO_DIRECT_MODE; + indio_dev->info = &press_info; ++ mutex_init(&press_data->tb.buf_lock); + + st_sensors_power_enable(indio_dev); + +diff --git a/drivers/infiniband/core/iwpm_msg.c b/drivers/infiniband/core/iwpm_msg.c +index b85ddbc979e0..e5558b2660f2 100644 +--- a/drivers/infiniband/core/iwpm_msg.c ++++ b/drivers/infiniband/core/iwpm_msg.c +@@ -33,7 +33,7 @@ + + #include "iwpm_util.h" + +-static const char iwpm_ulib_name[] = "iWarpPortMapperUser"; ++static const char iwpm_ulib_name[IWPM_ULIBNAME_SIZE] = "iWarpPortMapperUser"; + static int iwpm_ulib_version = 3; + static int iwpm_user_pid = IWPM_PID_UNDEFINED; + static atomic_t echo_nlmsg_seq; +diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c +index 991dc6b20a58..79363b687195 100644 +--- a/drivers/input/mouse/elantech.c ++++ b/drivers/input/mouse/elantech.c +@@ -315,7 +315,7 @@ static void elantech_report_semi_mt_data(struct input_dev *dev, + unsigned int x2, unsigned int y2) + { + elantech_set_slot(dev, 0, num_fingers != 0, x1, y1); +- elantech_set_slot(dev, 1, num_fingers == 2, x2, y2); ++ elantech_set_slot(dev, 1, num_fingers >= 2, x2, y2); + } + + /* +diff --git a/drivers/iommu/amd_iommu_v2.c b/drivers/iommu/amd_iommu_v2.c +index 6d5a5c44453b..173e70dbf61b 100644 +--- a/drivers/iommu/amd_iommu_v2.c ++++ b/drivers/iommu/amd_iommu_v2.c +@@ -266,6 +266,7 @@ static void put_pasid_state(struct pasid_state *pasid_state) + + static void put_pasid_state_wait(struct pasid_state *pasid_state) + { ++ atomic_dec(&pasid_state->count); + wait_event(pasid_state->wq, !atomic_read(&pasid_state->count)); + free_pasid_state(pasid_state); + } +diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c +index a3adde6519f0..bd6252b01510 100644 +--- a/drivers/iommu/arm-smmu.c ++++ b/drivers/iommu/arm-smmu.c +@@ -224,14 +224,7 @@ + #define RESUME_TERMINATE (1 << 0) + + #define TTBCR2_SEP_SHIFT 15 +-#define TTBCR2_SEP_MASK 0x7 +- +-#define TTBCR2_ADDR_32 0 +-#define TTBCR2_ADDR_36 1 +-#define TTBCR2_ADDR_40 2 +-#define TTBCR2_ADDR_42 3 +-#define TTBCR2_ADDR_44 4 +-#define TTBCR2_ADDR_48 5 ++#define TTBCR2_SEP_UPSTREAM (0x7 << TTBCR2_SEP_SHIFT) + + #define TTBRn_HI_ASID_SHIFT 16 + +@@ -783,26 +776,7 @@ static void arm_smmu_init_context_bank(struct arm_smmu_domain *smmu_domain, + writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR); + if (smmu->version > ARM_SMMU_V1) { + reg = pgtbl_cfg->arm_lpae_s1_cfg.tcr >> 32; +- switch (smmu->va_size) { +- case 32: +- reg |= (TTBCR2_ADDR_32 << TTBCR2_SEP_SHIFT); +- break; +- case 36: +- reg |= (TTBCR2_ADDR_36 << TTBCR2_SEP_SHIFT); +- break; +- case 40: +- reg |= (TTBCR2_ADDR_40 << TTBCR2_SEP_SHIFT); +- break; +- case 42: +- reg |= (TTBCR2_ADDR_42 << TTBCR2_SEP_SHIFT); +- break; +- case 44: +- reg |= (TTBCR2_ADDR_44 << TTBCR2_SEP_SHIFT); +- break; +- case 48: +- reg |= (TTBCR2_ADDR_48 << TTBCR2_SEP_SHIFT); +- break; +- } ++ reg |= TTBCR2_SEP_UPSTREAM; + writel_relaxed(reg, cb_base + ARM_SMMU_CB_TTBCR2); + } + } else { +diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c +index 7dc93aa004c8..312ffd3d0017 100644 +--- a/drivers/lguest/core.c ++++ b/drivers/lguest/core.c +@@ -173,7 +173,7 @@ static void unmap_switcher(void) + bool lguest_address_ok(const struct lguest *lg, + unsigned long addr, unsigned long len) + { +- return (addr+len) / PAGE_SIZE < lg->pfn_limit && (addr+len >= addr); ++ return addr+len <= lg->pfn_limit * PAGE_SIZE && (addr+len >= addr); + } + + /* +diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c +index 6554d9148927..757f1ba34c4d 100644 +--- a/drivers/md/dm-table.c ++++ b/drivers/md/dm-table.c +@@ -823,6 +823,12 @@ void dm_consume_args(struct dm_arg_set *as, unsigned num_args) + } + EXPORT_SYMBOL(dm_consume_args); + ++static bool __table_type_request_based(unsigned table_type) ++{ ++ return (table_type == DM_TYPE_REQUEST_BASED || ++ table_type == DM_TYPE_MQ_REQUEST_BASED); ++} ++ + static int dm_table_set_type(struct dm_table *t) + { + unsigned i; +@@ -855,8 +861,7 @@ static int dm_table_set_type(struct dm_table *t) + * Determine the type from the live device. + * Default to bio-based if device is new. + */ +- if (live_md_type == DM_TYPE_REQUEST_BASED || +- live_md_type == DM_TYPE_MQ_REQUEST_BASED) ++ if (__table_type_request_based(live_md_type)) + request_based = 1; + else + bio_based = 1; +@@ -906,7 +911,7 @@ static int dm_table_set_type(struct dm_table *t) + } + t->type = DM_TYPE_MQ_REQUEST_BASED; + +- } else if (hybrid && list_empty(devices) && live_md_type != DM_TYPE_NONE) { ++ } else if (list_empty(devices) && __table_type_request_based(live_md_type)) { + /* inherit live MD type */ + t->type = live_md_type; + +@@ -928,10 +933,7 @@ struct target_type *dm_table_get_immutable_target_type(struct dm_table *t) + + bool dm_table_request_based(struct dm_table *t) + { +- unsigned table_type = dm_table_get_type(t); +- +- return (table_type == DM_TYPE_REQUEST_BASED || +- table_type == DM_TYPE_MQ_REQUEST_BASED); ++ return __table_type_request_based(dm_table_get_type(t)); + } + + bool dm_table_mq_request_based(struct dm_table *t) +diff --git a/drivers/md/dm.c b/drivers/md/dm.c +index 8001fe9e3434..9b4e30a82e4a 100644 +--- a/drivers/md/dm.c ++++ b/drivers/md/dm.c +@@ -1642,8 +1642,7 @@ static int dm_merge_bvec(struct request_queue *q, + struct mapped_device *md = q->queuedata; + struct dm_table *map = dm_get_live_table_fast(md); + struct dm_target *ti; +- sector_t max_sectors; +- int max_size = 0; ++ sector_t max_sectors, max_size = 0; + + if (unlikely(!map)) + goto out; +@@ -1658,8 +1657,16 @@ static int dm_merge_bvec(struct request_queue *q, + max_sectors = min(max_io_len(bvm->bi_sector, ti), + (sector_t) queue_max_sectors(q)); + max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size; +- if (unlikely(max_size < 0)) /* this shouldn't _ever_ happen */ +- max_size = 0; ++ ++ /* ++ * FIXME: this stop-gap fix _must_ be cleaned up (by passing a sector_t ++ * to the targets' merge function since it holds sectors not bytes). ++ * Just doing this as an interim fix for stable@ because the more ++ * comprehensive cleanup of switching to sector_t will impact every ++ * DM target that implements a ->merge hook. ++ */ ++ if (max_size > INT_MAX) ++ max_size = INT_MAX; + + /* + * merge_bvec_fn() returns number of bytes +@@ -1667,7 +1674,7 @@ static int dm_merge_bvec(struct request_queue *q, + * max is precomputed maximal io size + */ + if (max_size && ti->type->merge) +- max_size = ti->type->merge(ti, bvm, biovec, max_size); ++ max_size = ti->type->merge(ti, bvm, biovec, (int) max_size); + /* + * If the target doesn't support merge method and some of the devices + * provided their merge_bvec method (we know this by looking for the +diff --git a/drivers/md/md.c b/drivers/md/md.c +index e47d1dd046da..907534b7f40d 100644 +--- a/drivers/md/md.c ++++ b/drivers/md/md.c +@@ -4138,12 +4138,12 @@ action_store(struct mddev *mddev, const char *page, size_t len) + if (!mddev->pers || !mddev->pers->sync_request) + return -EINVAL; + +- if (cmd_match(page, "frozen")) +- set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); +- else +- clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + + if (cmd_match(page, "idle") || cmd_match(page, "frozen")) { ++ if (cmd_match(page, "frozen")) ++ set_bit(MD_RECOVERY_FROZEN, &mddev->recovery); ++ else ++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + flush_workqueue(md_misc_wq); + if (mddev->sync_thread) { + set_bit(MD_RECOVERY_INTR, &mddev->recovery); +@@ -4156,16 +4156,17 @@ action_store(struct mddev *mddev, const char *page, size_t len) + test_bit(MD_RECOVERY_NEEDED, &mddev->recovery)) + return -EBUSY; + else if (cmd_match(page, "resync")) +- set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); ++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + else if (cmd_match(page, "recover")) { ++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + set_bit(MD_RECOVERY_RECOVER, &mddev->recovery); +- set_bit(MD_RECOVERY_NEEDED, &mddev->recovery); + } else if (cmd_match(page, "reshape")) { + int err; + if (mddev->pers->start_reshape == NULL) + return -EINVAL; + err = mddev_lock(mddev); + if (!err) { ++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + err = mddev->pers->start_reshape(mddev); + mddev_unlock(mddev); + } +@@ -4177,6 +4178,7 @@ action_store(struct mddev *mddev, const char *page, size_t len) + set_bit(MD_RECOVERY_CHECK, &mddev->recovery); + else if (!cmd_match(page, "repair")) + return -EINVAL; ++ clear_bit(MD_RECOVERY_FROZEN, &mddev->recovery); + set_bit(MD_RECOVERY_REQUESTED, &mddev->recovery); + set_bit(MD_RECOVERY_SYNC, &mddev->recovery); + } +diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c +index 3b5d7f704aa3..903391ce9353 100644 +--- a/drivers/md/raid0.c ++++ b/drivers/md/raid0.c +@@ -517,6 +517,9 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio) + ? (sector & (chunk_sects-1)) + : sector_div(sector, chunk_sects)); + ++ /* Restore due to sector_div */ ++ sector = bio->bi_iter.bi_sector; ++ + if (sectors < bio_sectors(bio)) { + split = bio_split(bio, sectors, GFP_NOIO, fs_bio_set); + bio_chain(split, bio); +@@ -524,7 +527,6 @@ static void raid0_make_request(struct mddev *mddev, struct bio *bio) + split = bio; + } + +- sector = bio->bi_iter.bi_sector; + zone = find_zone(mddev->private, §or); + tmp_dev = map_sector(mddev, zone, sector, §or); + split->bi_bdev = tmp_dev->bdev; +diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c +index cd2f96b2c572..007ab861eca0 100644 +--- a/drivers/md/raid5.c ++++ b/drivers/md/raid5.c +@@ -1933,7 +1933,8 @@ static int resize_stripes(struct r5conf *conf, int newsize) + + conf->slab_cache = sc; + conf->active_name = 1-conf->active_name; +- conf->pool_size = newsize; ++ if (!err) ++ conf->pool_size = newsize; + return err; + } + +diff --git a/drivers/mfd/da9052-core.c b/drivers/mfd/da9052-core.c +index ae498b53ee40..46e3840c7a37 100644 +--- a/drivers/mfd/da9052-core.c ++++ b/drivers/mfd/da9052-core.c +@@ -433,6 +433,10 @@ EXPORT_SYMBOL_GPL(da9052_adc_read_temp); + static const struct mfd_cell da9052_subdev_info[] = { + { + .name = "da9052-regulator", ++ .id = 0, ++ }, ++ { ++ .name = "da9052-regulator", + .id = 1, + }, + { +@@ -484,10 +488,6 @@ static const struct mfd_cell da9052_subdev_info[] = { + .id = 13, + }, + { +- .name = "da9052-regulator", +- .id = 14, +- }, +- { + .name = "da9052-onkey", + }, + { +diff --git a/drivers/mmc/host/atmel-mci.c b/drivers/mmc/host/atmel-mci.c +index 03d7c7521d97..9a39e0b7e583 100644 +--- a/drivers/mmc/host/atmel-mci.c ++++ b/drivers/mmc/host/atmel-mci.c +@@ -1304,7 +1304,7 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) + + if (ios->clock) { + unsigned int clock_min = ~0U; +- u32 clkdiv; ++ int clkdiv; + + spin_lock_bh(&host->lock); + if (!host->mode_reg) { +@@ -1328,7 +1328,12 @@ static void atmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) + /* Calculate clock divider */ + if (host->caps.has_odd_clk_div) { + clkdiv = DIV_ROUND_UP(host->bus_hz, clock_min) - 2; +- if (clkdiv > 511) { ++ if (clkdiv < 0) { ++ dev_warn(&mmc->class_dev, ++ "clock %u too fast; using %lu\n", ++ clock_min, host->bus_hz / 2); ++ clkdiv = 0; ++ } else if (clkdiv > 511) { + dev_warn(&mmc->class_dev, + "clock %u too slow; using %lu\n", + clock_min, host->bus_hz / (511 + 2)); +diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c +index db2c05b6fe7f..c9eb78f10a0d 100644 +--- a/drivers/mtd/ubi/block.c ++++ b/drivers/mtd/ubi/block.c +@@ -310,6 +310,8 @@ static void ubiblock_do_work(struct work_struct *work) + blk_rq_map_sg(req->q, req, pdu->usgl.sg); + + ret = ubiblock_read(pdu); ++ rq_flush_dcache_pages(req); ++ + blk_mq_end_request(req, ret); + } + +diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +index 6262612dec45..7a3231d8b933 100644 +--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c ++++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c +@@ -512,11 +512,9 @@ static int brcmf_msgbuf_query_dcmd(struct brcmf_pub *drvr, int ifidx, + msgbuf->rx_pktids, + msgbuf->ioctl_resp_pktid); + if (msgbuf->ioctl_resp_ret_len != 0) { +- if (!skb) { +- brcmf_err("Invalid packet id idx recv'd %d\n", +- msgbuf->ioctl_resp_pktid); ++ if (!skb) + return -EBADF; +- } ++ + memcpy(buf, skb->data, (len < msgbuf->ioctl_resp_ret_len) ? + len : msgbuf->ioctl_resp_ret_len); + } +@@ -875,10 +873,8 @@ brcmf_msgbuf_process_txstatus(struct brcmf_msgbuf *msgbuf, void *buf) + flowid -= BRCMF_NROF_H2D_COMMON_MSGRINGS; + skb = brcmf_msgbuf_get_pktid(msgbuf->drvr->bus_if->dev, + msgbuf->tx_pktids, idx); +- if (!skb) { +- brcmf_err("Invalid packet id idx recv'd %d\n", idx); ++ if (!skb) + return; +- } + + set_bit(flowid, msgbuf->txstatus_done_map); + commonring = msgbuf->flowrings[flowid]; +@@ -1157,6 +1153,8 @@ brcmf_msgbuf_process_rx_complete(struct brcmf_msgbuf *msgbuf, void *buf) + + skb = brcmf_msgbuf_get_pktid(msgbuf->drvr->bus_if->dev, + msgbuf->rx_pktids, idx); ++ if (!skb) ++ return; + + if (data_offset) + skb_pull(skb, data_offset); +diff --git a/drivers/net/wireless/iwlwifi/mvm/d3.c b/drivers/net/wireless/iwlwifi/mvm/d3.c +index 14e8fd661889..fd5a0bb1493f 100644 +--- a/drivers/net/wireless/iwlwifi/mvm/d3.c ++++ b/drivers/net/wireless/iwlwifi/mvm/d3.c +@@ -1742,8 +1742,10 @@ static void iwl_mvm_query_netdetect_reasons(struct iwl_mvm *mvm, + int i, j, n_matches, ret; + + fw_status = iwl_mvm_get_wakeup_status(mvm, vif); +- if (!IS_ERR_OR_NULL(fw_status)) ++ if (!IS_ERR_OR_NULL(fw_status)) { + reasons = le32_to_cpu(fw_status->wakeup_reasons); ++ kfree(fw_status); ++ } + + if (reasons & IWL_WOWLAN_WAKEUP_BY_RFKILL_DEASSERTED) + wakeup.rfkill_release = true; +@@ -1860,15 +1862,15 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) + /* get the BSS vif pointer again */ + vif = iwl_mvm_get_bss_vif(mvm); + if (IS_ERR_OR_NULL(vif)) +- goto out_unlock; ++ goto err; + + ret = iwl_trans_d3_resume(mvm->trans, &d3_status, test); + if (ret) +- goto out_unlock; ++ goto err; + + if (d3_status != IWL_D3_STATUS_ALIVE) { + IWL_INFO(mvm, "Device was reset during suspend\n"); +- goto out_unlock; ++ goto err; + } + + /* query SRAM first in case we want event logging */ +@@ -1886,7 +1888,8 @@ static int __iwl_mvm_resume(struct iwl_mvm *mvm, bool test) + /* has unlocked the mutex, so skip that */ + goto out; + +- out_unlock: ++err: ++ iwl_mvm_free_nd(mvm); + mutex_unlock(&mvm->mutex); + + out: +diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c +index 69935aa5a1b3..cb72edb3d16a 100644 +--- a/drivers/net/wireless/iwlwifi/pcie/trans.c ++++ b/drivers/net/wireless/iwlwifi/pcie/trans.c +@@ -5,8 +5,8 @@ + * + * GPL LICENSE SUMMARY + * +- * Copyright(c) 2007 - 2014 Intel Corporation. All rights reserved. +- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH ++ * Copyright(c) 2007 - 2015 Intel Corporation. All rights reserved. ++ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as +@@ -31,8 +31,8 @@ + * + * BSD LICENSE + * +- * Copyright(c) 2005 - 2014 Intel Corporation. All rights reserved. +- * Copyright(c) 2013 - 2014 Intel Mobile Communications GmbH ++ * Copyright(c) 2005 - 2015 Intel Corporation. All rights reserved. ++ * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without +@@ -104,7 +104,7 @@ static void iwl_pcie_free_fw_monitor(struct iwl_trans *trans) + static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans) + { + struct iwl_trans_pcie *trans_pcie = IWL_TRANS_GET_PCIE_TRANS(trans); +- struct page *page; ++ struct page *page = NULL; + dma_addr_t phys; + u32 size; + u8 power; +@@ -131,6 +131,7 @@ static void iwl_pcie_alloc_fw_monitor(struct iwl_trans *trans) + DMA_FROM_DEVICE); + if (dma_mapping_error(trans->dev, phys)) { + __free_pages(page, order); ++ page = NULL; + continue; + } + IWL_INFO(trans, +diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c +index 8444313eabe2..8694dddcce9a 100644 +--- a/drivers/net/wireless/rt2x00/rt2800usb.c ++++ b/drivers/net/wireless/rt2x00/rt2800usb.c +@@ -1040,6 +1040,7 @@ static struct usb_device_id rt2800usb_device_table[] = { + { USB_DEVICE(0x07d1, 0x3c17) }, + { USB_DEVICE(0x2001, 0x3317) }, + { USB_DEVICE(0x2001, 0x3c1b) }, ++ { USB_DEVICE(0x2001, 0x3c25) }, + /* Draytek */ + { USB_DEVICE(0x07fa, 0x7712) }, + /* DVICO */ +diff --git a/drivers/net/wireless/rtlwifi/usb.c b/drivers/net/wireless/rtlwifi/usb.c +index 46ee956d0235..27cd6cabf6c5 100644 +--- a/drivers/net/wireless/rtlwifi/usb.c ++++ b/drivers/net/wireless/rtlwifi/usb.c +@@ -126,7 +126,7 @@ static int _usbctrl_vendorreq_sync_read(struct usb_device *udev, u8 request, + + do { + status = usb_control_msg(udev, pipe, request, reqtype, value, +- index, pdata, len, 0); /*max. timeout*/ ++ index, pdata, len, 1000); + if (status < 0) { + /* firmware download is checksumed, don't retry */ + if ((value >= FW_8192C_START_ADDRESS && +diff --git a/drivers/power/reset/at91-reset.c b/drivers/power/reset/at91-reset.c +index 13584e24736a..4d7d60e593b8 100644 +--- a/drivers/power/reset/at91-reset.c ++++ b/drivers/power/reset/at91-reset.c +@@ -212,9 +212,9 @@ static int at91_reset_platform_probe(struct platform_device *pdev) + res = platform_get_resource(pdev, IORESOURCE_MEM, idx + 1 ); + at91_ramc_base[idx] = devm_ioremap(&pdev->dev, res->start, + resource_size(res)); +- if (IS_ERR(at91_ramc_base[idx])) { ++ if (!at91_ramc_base[idx]) { + dev_err(&pdev->dev, "Could not map ram controller address\n"); +- return PTR_ERR(at91_ramc_base[idx]); ++ return -ENOMEM; + } + } + +diff --git a/drivers/pwm/pwm-img.c b/drivers/pwm/pwm-img.c +index 476171a768d6..8a029f9bc18c 100644 +--- a/drivers/pwm/pwm-img.c ++++ b/drivers/pwm/pwm-img.c +@@ -16,6 +16,7 @@ + #include <linux/mfd/syscon.h> + #include <linux/module.h> + #include <linux/of.h> ++#include <linux/of_device.h> + #include <linux/platform_device.h> + #include <linux/pwm.h> + #include <linux/regmap.h> +@@ -38,7 +39,22 @@ + #define PERIP_PWM_PDM_CONTROL_CH_MASK 0x1 + #define PERIP_PWM_PDM_CONTROL_CH_SHIFT(ch) ((ch) * 4) + +-#define MAX_TMBASE_STEPS 65536 ++/* ++ * PWM period is specified with a timebase register, ++ * in number of step periods. The PWM duty cycle is also ++ * specified in step periods, in the [0, $timebase] range. ++ * In other words, the timebase imposes the duty cycle ++ * resolution. Therefore, let's constraint the timebase to ++ * a minimum value to allow a sane range of duty cycle values. ++ * Imposing a minimum timebase, will impose a maximum PWM frequency. ++ * ++ * The value chosen is completely arbitrary. ++ */ ++#define MIN_TMBASE_STEPS 16 ++ ++struct img_pwm_soc_data { ++ u32 max_timebase; ++}; + + struct img_pwm_chip { + struct device *dev; +@@ -47,6 +63,9 @@ struct img_pwm_chip { + struct clk *sys_clk; + void __iomem *base; + struct regmap *periph_regs; ++ int max_period_ns; ++ int min_period_ns; ++ const struct img_pwm_soc_data *data; + }; + + static inline struct img_pwm_chip *to_img_pwm_chip(struct pwm_chip *chip) +@@ -72,24 +91,31 @@ static int img_pwm_config(struct pwm_chip *chip, struct pwm_device *pwm, + u32 val, div, duty, timebase; + unsigned long mul, output_clk_hz, input_clk_hz; + struct img_pwm_chip *pwm_chip = to_img_pwm_chip(chip); ++ unsigned int max_timebase = pwm_chip->data->max_timebase; ++ ++ if (period_ns < pwm_chip->min_period_ns || ++ period_ns > pwm_chip->max_period_ns) { ++ dev_err(chip->dev, "configured period not in range\n"); ++ return -ERANGE; ++ } + + input_clk_hz = clk_get_rate(pwm_chip->pwm_clk); + output_clk_hz = DIV_ROUND_UP(NSEC_PER_SEC, period_ns); + + mul = DIV_ROUND_UP(input_clk_hz, output_clk_hz); +- if (mul <= MAX_TMBASE_STEPS) { ++ if (mul <= max_timebase) { + div = PWM_CTRL_CFG_NO_SUB_DIV; + timebase = DIV_ROUND_UP(mul, 1); +- } else if (mul <= MAX_TMBASE_STEPS * 8) { ++ } else if (mul <= max_timebase * 8) { + div = PWM_CTRL_CFG_SUB_DIV0; + timebase = DIV_ROUND_UP(mul, 8); +- } else if (mul <= MAX_TMBASE_STEPS * 64) { ++ } else if (mul <= max_timebase * 64) { + div = PWM_CTRL_CFG_SUB_DIV1; + timebase = DIV_ROUND_UP(mul, 64); +- } else if (mul <= MAX_TMBASE_STEPS * 512) { ++ } else if (mul <= max_timebase * 512) { + div = PWM_CTRL_CFG_SUB_DIV0_DIV1; + timebase = DIV_ROUND_UP(mul, 512); +- } else if (mul > MAX_TMBASE_STEPS * 512) { ++ } else if (mul > max_timebase * 512) { + dev_err(chip->dev, + "failed to configure timebase steps/divider value\n"); + return -EINVAL; +@@ -143,11 +169,27 @@ static const struct pwm_ops img_pwm_ops = { + .owner = THIS_MODULE, + }; + ++static const struct img_pwm_soc_data pistachio_pwm = { ++ .max_timebase = 255, ++}; ++ ++static const struct of_device_id img_pwm_of_match[] = { ++ { ++ .compatible = "img,pistachio-pwm", ++ .data = &pistachio_pwm, ++ }, ++ { } ++}; ++MODULE_DEVICE_TABLE(of, img_pwm_of_match); ++ + static int img_pwm_probe(struct platform_device *pdev) + { + int ret; ++ u64 val; ++ unsigned long clk_rate; + struct resource *res; + struct img_pwm_chip *pwm; ++ const struct of_device_id *of_dev_id; + + pwm = devm_kzalloc(&pdev->dev, sizeof(*pwm), GFP_KERNEL); + if (!pwm) +@@ -160,6 +202,11 @@ static int img_pwm_probe(struct platform_device *pdev) + if (IS_ERR(pwm->base)) + return PTR_ERR(pwm->base); + ++ of_dev_id = of_match_device(img_pwm_of_match, &pdev->dev); ++ if (!of_dev_id) ++ return -ENODEV; ++ pwm->data = of_dev_id->data; ++ + pwm->periph_regs = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, + "img,cr-periph"); + if (IS_ERR(pwm->periph_regs)) +@@ -189,6 +236,17 @@ static int img_pwm_probe(struct platform_device *pdev) + goto disable_sysclk; + } + ++ clk_rate = clk_get_rate(pwm->pwm_clk); ++ ++ /* The maximum input clock divider is 512 */ ++ val = (u64)NSEC_PER_SEC * 512 * pwm->data->max_timebase; ++ do_div(val, clk_rate); ++ pwm->max_period_ns = val; ++ ++ val = (u64)NSEC_PER_SEC * MIN_TMBASE_STEPS; ++ do_div(val, clk_rate); ++ pwm->min_period_ns = val; ++ + pwm->chip.dev = &pdev->dev; + pwm->chip.ops = &img_pwm_ops; + pwm->chip.base = -1; +@@ -228,12 +286,6 @@ static int img_pwm_remove(struct platform_device *pdev) + return pwmchip_remove(&pwm_chip->chip); + } + +-static const struct of_device_id img_pwm_of_match[] = { +- { .compatible = "img,pistachio-pwm", }, +- { } +-}; +-MODULE_DEVICE_TABLE(of, img_pwm_of_match); +- + static struct platform_driver img_pwm_driver = { + .driver = { + .name = "img-pwm", +diff --git a/drivers/regulator/da9052-regulator.c b/drivers/regulator/da9052-regulator.c +index 8a4df7a1f2ee..e628d4c2f2ae 100644 +--- a/drivers/regulator/da9052-regulator.c ++++ b/drivers/regulator/da9052-regulator.c +@@ -394,6 +394,7 @@ static inline struct da9052_regulator_info *find_regulator_info(u8 chip_id, + + static int da9052_regulator_probe(struct platform_device *pdev) + { ++ const struct mfd_cell *cell = mfd_get_cell(pdev); + struct regulator_config config = { }; + struct da9052_regulator *regulator; + struct da9052 *da9052; +@@ -409,7 +410,7 @@ static int da9052_regulator_probe(struct platform_device *pdev) + regulator->da9052 = da9052; + + regulator->info = find_regulator_info(regulator->da9052->chip_id, +- pdev->id); ++ cell->id); + if (regulator->info == NULL) { + dev_err(&pdev->dev, "invalid regulator ID specified\n"); + return -EINVAL; +@@ -419,7 +420,7 @@ static int da9052_regulator_probe(struct platform_device *pdev) + config.driver_data = regulator; + config.regmap = da9052->regmap; + if (pdata && pdata->regulators) { +- config.init_data = pdata->regulators[pdev->id]; ++ config.init_data = pdata->regulators[cell->id]; + } else { + #ifdef CONFIG_OF + struct device_node *nproot = da9052->dev->of_node; +diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c +index 3290a3ed5b31..a661d339adf7 100644 +--- a/drivers/scsi/sd.c ++++ b/drivers/scsi/sd.c +@@ -1624,6 +1624,7 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) + { + u64 start_lba = blk_rq_pos(scmd->request); + u64 end_lba = blk_rq_pos(scmd->request) + (scsi_bufflen(scmd) / 512); ++ u64 factor = scmd->device->sector_size / 512; + u64 bad_lba; + int info_valid; + /* +@@ -1645,16 +1646,9 @@ static unsigned int sd_completed_bytes(struct scsi_cmnd *scmd) + if (scsi_bufflen(scmd) <= scmd->device->sector_size) + return 0; + +- if (scmd->device->sector_size < 512) { +- /* only legitimate sector_size here is 256 */ +- start_lba <<= 1; +- end_lba <<= 1; +- } else { +- /* be careful ... don't want any overflows */ +- unsigned int factor = scmd->device->sector_size / 512; +- do_div(start_lba, factor); +- do_div(end_lba, factor); +- } ++ /* be careful ... don't want any overflows */ ++ do_div(start_lba, factor); ++ do_div(end_lba, factor); + + /* The bad lba was reported incorrectly, we have no idea where + * the error is. +@@ -2212,8 +2206,7 @@ got_data: + if (sector_size != 512 && + sector_size != 1024 && + sector_size != 2048 && +- sector_size != 4096 && +- sector_size != 256) { ++ sector_size != 4096) { + sd_printk(KERN_NOTICE, sdkp, "Unsupported sector size %d.\n", + sector_size); + /* +@@ -2268,8 +2261,6 @@ got_data: + sdkp->capacity <<= 2; + else if (sector_size == 1024) + sdkp->capacity <<= 1; +- else if (sector_size == 256) +- sdkp->capacity >>= 1; + + blk_queue_physical_block_size(sdp->request_queue, + sdkp->physical_block_size); +diff --git a/drivers/scsi/storvsc_drv.c b/drivers/scsi/storvsc_drv.c +index bf8c5c1e254e..75efaaeb0eca 100644 +--- a/drivers/scsi/storvsc_drv.c ++++ b/drivers/scsi/storvsc_drv.c +@@ -1565,8 +1565,7 @@ static int storvsc_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *scmnd) + break; + default: + vm_srb->data_in = UNKNOWN_TYPE; +- vm_srb->win8_extension.srb_flags |= (SRB_FLAGS_DATA_IN | +- SRB_FLAGS_DATA_OUT); ++ vm_srb->win8_extension.srb_flags |= SRB_FLAGS_NO_DATA_TRANSFER; + break; + } + +diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c +index d1ab996b3305..a21a51efaad0 100644 +--- a/drivers/staging/gdm724x/gdm_mux.c ++++ b/drivers/staging/gdm724x/gdm_mux.c +@@ -158,7 +158,7 @@ static int up_to_host(struct mux_rx *r) + unsigned int start_flag; + unsigned int payload_size; + unsigned short packet_type; +- int dummy_cnt; ++ int total_len; + u32 packet_size_sum = r->offset; + int index; + int ret = TO_HOST_INVALID_PACKET; +@@ -176,10 +176,10 @@ static int up_to_host(struct mux_rx *r) + break; + } + +- dummy_cnt = ALIGN(MUX_HEADER_SIZE + payload_size, 4); ++ total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4); + + if (len - packet_size_sum < +- MUX_HEADER_SIZE + payload_size + dummy_cnt) { ++ total_len) { + pr_err("invalid payload : %d %d %04x\n", + payload_size, len, packet_type); + break; +@@ -202,7 +202,7 @@ static int up_to_host(struct mux_rx *r) + break; + } + +- packet_size_sum += MUX_HEADER_SIZE + payload_size + dummy_cnt; ++ packet_size_sum += total_len; + if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { + ret = r->callback(NULL, + 0, +@@ -361,7 +361,6 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, + struct mux_pkt_header *mux_header; + struct mux_tx *t = NULL; + static u32 seq_num = 1; +- int dummy_cnt; + int total_len; + int ret; + unsigned long flags; +@@ -374,9 +373,7 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, + + spin_lock_irqsave(&mux_dev->write_lock, flags); + +- dummy_cnt = ALIGN(MUX_HEADER_SIZE + len, 4); +- +- total_len = len + MUX_HEADER_SIZE + dummy_cnt; ++ total_len = ALIGN(MUX_HEADER_SIZE + len, 4); + + t = alloc_mux_tx(total_len); + if (!t) { +@@ -392,7 +389,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, + mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); + + memcpy(t->buf+MUX_HEADER_SIZE, data, len); +- memset(t->buf+MUX_HEADER_SIZE+len, 0, dummy_cnt); ++ memset(t->buf+MUX_HEADER_SIZE+len, 0, total_len - MUX_HEADER_SIZE - ++ len); + + t->len = total_len; + t->callback = cb; +diff --git a/drivers/staging/vt6655/device_main.c b/drivers/staging/vt6655/device_main.c +index 03b2a90b9ac0..992236f605d8 100644 +--- a/drivers/staging/vt6655/device_main.c ++++ b/drivers/staging/vt6655/device_main.c +@@ -911,7 +911,11 @@ static int vnt_int_report_rate(struct vnt_private *priv, + + if (!(tsr1 & TSR1_TERR)) { + info->status.rates[0].idx = idx; +- info->flags |= IEEE80211_TX_STAT_ACK; ++ ++ if (info->flags & IEEE80211_TX_CTL_NO_ACK) ++ info->flags |= IEEE80211_TX_STAT_NOACK_TRANSMITTED; ++ else ++ info->flags |= IEEE80211_TX_STAT_ACK; + } + + return 0; +@@ -936,9 +940,6 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) + //Only the status of first TD in the chain is correct + if (pTD->m_td1TD1.byTCR & TCR_STP) { + if ((pTD->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) != 0) { +- +- vnt_int_report_rate(pDevice, pTD->pTDInfo, byTsr0, byTsr1); +- + if (!(byTsr1 & TSR1_TERR)) { + if (byTsr0 != 0) { + pr_debug(" Tx[%d] OK but has error. tsr1[%02X] tsr0[%02X]\n", +@@ -957,6 +958,9 @@ static int device_tx_srv(struct vnt_private *pDevice, unsigned int uIdx) + (int)uIdx, byTsr1, byTsr0); + } + } ++ ++ vnt_int_report_rate(pDevice, pTD->pTDInfo, byTsr0, byTsr1); ++ + device_free_tx_buf(pDevice, pTD); + pDevice->iTDUsed[uIdx]--; + } +@@ -988,10 +992,8 @@ static void device_free_tx_buf(struct vnt_private *pDevice, PSTxDesc pDesc) + PCI_DMA_TODEVICE); + } + +- if (pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) ++ if (skb) + ieee80211_tx_status_irqsafe(pDevice->hw, skb); +- else +- dev_kfree_skb_irq(skb); + + pTDInfo->skb_dma = 0; + pTDInfo->skb = NULL; +@@ -1201,14 +1203,6 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) + if (dma_idx == TYPE_AC0DMA) + head_td->pTDInfo->byFlags = TD_FLAGS_NETIF_SKB; + +- priv->iTDUsed[dma_idx]++; +- +- /* Take ownership */ +- wmb(); +- head_td->m_td0TD0.f1Owner = OWNED_BY_NIC; +- +- /* get Next */ +- wmb(); + priv->apCurrTD[dma_idx] = head_td->next; + + spin_unlock_irqrestore(&priv->lock, flags); +@@ -1229,11 +1223,18 @@ static int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) + + head_td->buff_addr = cpu_to_le32(head_td->pTDInfo->skb_dma); + ++ /* Poll Transmit the adapter */ ++ wmb(); ++ head_td->m_td0TD0.f1Owner = OWNED_BY_NIC; ++ wmb(); /* second memory barrier */ ++ + if (head_td->pTDInfo->byFlags & TD_FLAGS_NETIF_SKB) + MACvTransmitAC0(priv->PortOffset); + else + MACvTransmit0(priv->PortOffset); + ++ priv->iTDUsed[dma_idx]++; ++ + spin_unlock_irqrestore(&priv->lock, flags); + + return 0; +@@ -1413,9 +1414,16 @@ static void vnt_bss_info_changed(struct ieee80211_hw *hw, + + priv->current_aid = conf->aid; + +- if (changed & BSS_CHANGED_BSSID) ++ if (changed & BSS_CHANGED_BSSID) { ++ unsigned long flags; ++ ++ spin_lock_irqsave(&priv->lock, flags); ++ + MACvWriteBSSIDAddress(priv->PortOffset, (u8 *)conf->bssid); + ++ spin_unlock_irqrestore(&priv->lock, flags); ++ } ++ + if (changed & BSS_CHANGED_BASIC_RATES) { + priv->basic_rates = conf->basic_rates; + +diff --git a/drivers/staging/vt6656/rxtx.c b/drivers/staging/vt6656/rxtx.c +index 33baf26de4b5..ee9ce165dcde 100644 +--- a/drivers/staging/vt6656/rxtx.c ++++ b/drivers/staging/vt6656/rxtx.c +@@ -805,10 +805,18 @@ int vnt_tx_packet(struct vnt_private *priv, struct sk_buff *skb) + vnt_schedule_command(priv, WLAN_CMD_SETPOWER); + } + +- if (current_rate > RATE_11M) +- pkt_type = priv->packet_type; +- else ++ if (current_rate > RATE_11M) { ++ if (info->band == IEEE80211_BAND_5GHZ) { ++ pkt_type = PK_TYPE_11A; ++ } else { ++ if (tx_rate->flags & IEEE80211_TX_RC_USE_CTS_PROTECT) ++ pkt_type = PK_TYPE_11GB; ++ else ++ pkt_type = PK_TYPE_11GA; ++ } ++ } else { + pkt_type = PK_TYPE_11B; ++ } + + spin_lock_irqsave(&priv->lock, flags); + +diff --git a/drivers/target/target_core_pscsi.c b/drivers/target/target_core_pscsi.c +index f6c954c4635f..4073869d2090 100644 +--- a/drivers/target/target_core_pscsi.c ++++ b/drivers/target/target_core_pscsi.c +@@ -521,6 +521,7 @@ static int pscsi_configure_device(struct se_device *dev) + " pdv_host_id: %d\n", pdv->pdv_host_id); + return -EINVAL; + } ++ pdv->pdv_lld_host = sh; + } + } else { + if (phv->phv_mode == PHV_VIRTUAL_HOST_ID) { +@@ -603,6 +604,8 @@ static void pscsi_free_device(struct se_device *dev) + if ((phv->phv_mode == PHV_LLD_SCSI_HOST_NO) && + (phv->phv_lld_host != NULL)) + scsi_host_put(phv->phv_lld_host); ++ else if (pdv->pdv_lld_host) ++ scsi_host_put(pdv->pdv_lld_host); + + if ((sd->type == TYPE_DISK) || (sd->type == TYPE_ROM)) + scsi_device_put(sd); +diff --git a/drivers/target/target_core_pscsi.h b/drivers/target/target_core_pscsi.h +index 1bd757dff8ee..820d3052b775 100644 +--- a/drivers/target/target_core_pscsi.h ++++ b/drivers/target/target_core_pscsi.h +@@ -45,6 +45,7 @@ struct pscsi_dev_virt { + int pdv_lun_id; + struct block_device *pdv_bd; + struct scsi_device *pdv_sd; ++ struct Scsi_Host *pdv_lld_host; + } ____cacheline_aligned; + + typedef enum phv_modes { +diff --git a/drivers/thermal/armada_thermal.c b/drivers/thermal/armada_thermal.c +index c2556cf5186b..01255fd65135 100644 +--- a/drivers/thermal/armada_thermal.c ++++ b/drivers/thermal/armada_thermal.c +@@ -224,9 +224,9 @@ static const struct armada_thermal_data armada380_data = { + .is_valid_shift = 10, + .temp_shift = 0, + .temp_mask = 0x3ff, +- .coef_b = 1169498786UL, +- .coef_m = 2000000UL, +- .coef_div = 4289, ++ .coef_b = 2931108200UL, ++ .coef_m = 5000000UL, ++ .coef_div = 10502, + .inverted = true, + }; + +diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c +index 5bab1c684bb1..7a3d146a5f0e 100644 +--- a/drivers/tty/hvc/hvc_xen.c ++++ b/drivers/tty/hvc/hvc_xen.c +@@ -289,7 +289,7 @@ static int xen_initial_domain_console_init(void) + return -ENOMEM; + } + +- info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0); ++ info->irq = bind_virq_to_irq(VIRQ_CONSOLE, 0, false); + info->vtermno = HVC_COOKIE; + + spin_lock(&xencons_lock); +diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c +index c4343764cc5b..bce16e405d59 100644 +--- a/drivers/tty/n_gsm.c ++++ b/drivers/tty/n_gsm.c +@@ -3170,7 +3170,7 @@ static int gsmtty_break_ctl(struct tty_struct *tty, int state) + return gsmtty_modem_update(dlci, encode); + } + +-static void gsmtty_remove(struct tty_driver *driver, struct tty_struct *tty) ++static void gsmtty_cleanup(struct tty_struct *tty) + { + struct gsm_dlci *dlci = tty->driver_data; + struct gsm_mux *gsm = dlci->gsm; +@@ -3178,7 +3178,6 @@ static void gsmtty_remove(struct tty_driver *driver, struct tty_struct *tty) + dlci_put(dlci); + dlci_put(gsm->dlci[0]); + mux_put(gsm); +- driver->ttys[tty->index] = NULL; + } + + /* Virtual ttys for the demux */ +@@ -3199,7 +3198,7 @@ static const struct tty_operations gsmtty_ops = { + .tiocmget = gsmtty_tiocmget, + .tiocmset = gsmtty_tiocmset, + .break_ctl = gsmtty_break_ctl, +- .remove = gsmtty_remove, ++ .cleanup = gsmtty_cleanup, + }; + + +diff --git a/drivers/tty/n_hdlc.c b/drivers/tty/n_hdlc.c +index 644ddb841d9f..bbc4ce66c2c1 100644 +--- a/drivers/tty/n_hdlc.c ++++ b/drivers/tty/n_hdlc.c +@@ -600,7 +600,7 @@ static ssize_t n_hdlc_tty_read(struct tty_struct *tty, struct file *file, + add_wait_queue(&tty->read_wait, &wait); + + for (;;) { +- if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { ++ if (test_bit(TTY_OTHER_DONE, &tty->flags)) { + ret = -EIO; + break; + } +@@ -828,7 +828,7 @@ static unsigned int n_hdlc_tty_poll(struct tty_struct *tty, struct file *filp, + /* set bits for operations that won't block */ + if (n_hdlc->rx_buf_list.head) + mask |= POLLIN | POLLRDNORM; /* readable */ +- if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) ++ if (test_bit(TTY_OTHER_DONE, &tty->flags)) + mask |= POLLHUP; + if (tty_hung_up_p(filp)) + mask |= POLLHUP; +diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c +index cf6e0f2e1331..cc57a3a6b02b 100644 +--- a/drivers/tty/n_tty.c ++++ b/drivers/tty/n_tty.c +@@ -1949,6 +1949,18 @@ static inline int input_available_p(struct tty_struct *tty, int poll) + return ldata->commit_head - ldata->read_tail >= amt; + } + ++static inline int check_other_done(struct tty_struct *tty) ++{ ++ int done = test_bit(TTY_OTHER_DONE, &tty->flags); ++ if (done) { ++ /* paired with cmpxchg() in check_other_closed(); ensures ++ * read buffer head index is not stale ++ */ ++ smp_mb__after_atomic(); ++ } ++ return done; ++} ++ + /** + * copy_from_read_buf - copy read data directly + * @tty: terminal device +@@ -2167,7 +2179,7 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, + struct n_tty_data *ldata = tty->disc_data; + unsigned char __user *b = buf; + DEFINE_WAIT_FUNC(wait, woken_wake_function); +- int c; ++ int c, done; + int minimum, time; + ssize_t retval = 0; + long timeout; +@@ -2235,8 +2247,10 @@ static ssize_t n_tty_read(struct tty_struct *tty, struct file *file, + ((minimum - (b - buf)) >= 1)) + ldata->minimum_to_wake = (minimum - (b - buf)); + ++ done = check_other_done(tty); ++ + if (!input_available_p(tty, 0)) { +- if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) { ++ if (done) { + retval = -EIO; + break; + } +@@ -2443,12 +2457,12 @@ static unsigned int n_tty_poll(struct tty_struct *tty, struct file *file, + + poll_wait(file, &tty->read_wait, wait); + poll_wait(file, &tty->write_wait, wait); ++ if (check_other_done(tty)) ++ mask |= POLLHUP; + if (input_available_p(tty, 1)) + mask |= POLLIN | POLLRDNORM; + if (tty->packet && tty->link->ctrl_status) + mask |= POLLPRI | POLLIN | POLLRDNORM; +- if (test_bit(TTY_OTHER_CLOSED, &tty->flags)) +- mask |= POLLHUP; + if (tty_hung_up_p(file)) + mask |= POLLHUP; + if (!(mask & (POLLHUP | POLLIN | POLLRDNORM))) { +diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c +index e72ee629cead..4d5e8409769c 100644 +--- a/drivers/tty/pty.c ++++ b/drivers/tty/pty.c +@@ -53,9 +53,8 @@ static void pty_close(struct tty_struct *tty, struct file *filp) + /* Review - krefs on tty_link ?? */ + if (!tty->link) + return; +- tty_flush_to_ldisc(tty->link); + set_bit(TTY_OTHER_CLOSED, &tty->link->flags); +- wake_up_interruptible(&tty->link->read_wait); ++ tty_flip_buffer_push(tty->link->port); + wake_up_interruptible(&tty->link->write_wait); + if (tty->driver->subtype == PTY_TYPE_MASTER) { + set_bit(TTY_OTHER_CLOSED, &tty->flags); +@@ -243,7 +242,9 @@ static int pty_open(struct tty_struct *tty, struct file *filp) + goto out; + + clear_bit(TTY_IO_ERROR, &tty->flags); ++ /* TTY_OTHER_CLOSED must be cleared before TTY_OTHER_DONE */ + clear_bit(TTY_OTHER_CLOSED, &tty->link->flags); ++ clear_bit(TTY_OTHER_DONE, &tty->link->flags); + set_bit(TTY_THROTTLED, &tty->flags); + return 0; + +diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c +index 75661641f5fe..2f78b77f0f81 100644 +--- a/drivers/tty/tty_buffer.c ++++ b/drivers/tty/tty_buffer.c +@@ -37,6 +37,28 @@ + + #define TTY_BUFFER_PAGE (((PAGE_SIZE - sizeof(struct tty_buffer)) / 2) & ~0xFF) + ++/* ++ * If all tty flip buffers have been processed by flush_to_ldisc() or ++ * dropped by tty_buffer_flush(), check if the linked pty has been closed. ++ * If so, wake the reader/poll to process ++ */ ++static inline void check_other_closed(struct tty_struct *tty) ++{ ++ unsigned long flags, old; ++ ++ /* transition from TTY_OTHER_CLOSED => TTY_OTHER_DONE must be atomic */ ++ for (flags = ACCESS_ONCE(tty->flags); ++ test_bit(TTY_OTHER_CLOSED, &flags); ++ ) { ++ old = flags; ++ __set_bit(TTY_OTHER_DONE, &flags); ++ flags = cmpxchg(&tty->flags, old, flags); ++ if (old == flags) { ++ wake_up_interruptible(&tty->read_wait); ++ break; ++ } ++ } ++} + + /** + * tty_buffer_lock_exclusive - gain exclusive access to buffer +@@ -229,6 +251,8 @@ void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld) + if (ld && ld->ops->flush_buffer) + ld->ops->flush_buffer(tty); + ++ check_other_closed(tty); ++ + atomic_dec(&buf->priority); + mutex_unlock(&buf->lock); + } +@@ -471,8 +495,10 @@ static void flush_to_ldisc(struct work_struct *work) + smp_rmb(); + count = head->commit - head->read; + if (!count) { +- if (next == NULL) ++ if (next == NULL) { ++ check_other_closed(tty); + break; ++ } + buf->head = next; + tty_buffer_free(port, head); + continue; +@@ -489,19 +515,6 @@ static void flush_to_ldisc(struct work_struct *work) + } + + /** +- * tty_flush_to_ldisc +- * @tty: tty to push +- * +- * Push the terminal flip buffers to the line discipline. +- * +- * Must not be called from IRQ context. +- */ +-void tty_flush_to_ldisc(struct tty_struct *tty) +-{ +- flush_work(&tty->port->buf.work); +-} +- +-/** + * tty_flip_buffer_push - terminal + * @port: tty port to push + * +diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c +index c42765b3a060..0495c94a23d7 100644 +--- a/drivers/usb/gadget/configfs.c ++++ b/drivers/usb/gadget/configfs.c +@@ -1295,6 +1295,7 @@ static void purge_configs_funcs(struct gadget_info *gi) + } + } + c->next_interface_id = 0; ++ memset(c->interface, 0, sizeof(c->interface)); + c->superspeed = 0; + c->highspeed = 0; + c->fullspeed = 0; +diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c +index eeedde8c435a..6994c99e58a6 100644 +--- a/drivers/usb/host/xhci-ring.c ++++ b/drivers/usb/host/xhci-ring.c +@@ -2026,8 +2026,13 @@ static int process_isoc_td(struct xhci_hcd *xhci, struct xhci_td *td, + break; + case COMP_DEV_ERR: + case COMP_STALL: ++ frame->status = -EPROTO; ++ skip_td = true; ++ break; + case COMP_TX_ERR: + frame->status = -EPROTO; ++ if (event_trb != td->last_trb) ++ return 0; + skip_td = true; + break; + case COMP_STOP: +@@ -2640,7 +2645,7 @@ irqreturn_t xhci_irq(struct usb_hcd *hcd) + xhci_halt(xhci); + hw_died: + spin_unlock(&xhci->lock); +- return -ESHUTDOWN; ++ return IRQ_HANDLED; + } + + /* +diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h +index 8e421b89632d..ea75e8ccd3c1 100644 +--- a/drivers/usb/host/xhci.h ++++ b/drivers/usb/host/xhci.h +@@ -1267,7 +1267,7 @@ union xhci_trb { + * since the command ring is 64-byte aligned. + * It must also be greater than 16. + */ +-#define TRBS_PER_SEGMENT 64 ++#define TRBS_PER_SEGMENT 256 + /* Allow two commands + a link TRB, along with any reserved command TRBs */ + #define MAX_RSVD_CMD_TRBS (TRBS_PER_SEGMENT - 3) + #define TRB_SEGMENT_SIZE (TRBS_PER_SEGMENT*16) +diff --git a/drivers/usb/serial/cp210x.c b/drivers/usb/serial/cp210x.c +index 84ce2d74894c..9031750e7404 100644 +--- a/drivers/usb/serial/cp210x.c ++++ b/drivers/usb/serial/cp210x.c +@@ -127,6 +127,7 @@ static const struct usb_device_id id_table[] = { + { USB_DEVICE(0x10C4, 0x88A5) }, /* Planet Innovation Ingeni ZigBee USB Device */ + { USB_DEVICE(0x10C4, 0x8946) }, /* Ketra N1 Wireless Interface */ + { USB_DEVICE(0x10C4, 0x8977) }, /* CEL MeshWorks DevKit Device */ ++ { USB_DEVICE(0x10C4, 0x8998) }, /* KCF Technologies PRN */ + { USB_DEVICE(0x10C4, 0xEA60) }, /* Silicon Labs factory default */ + { USB_DEVICE(0x10C4, 0xEA61) }, /* Silicon Labs factory default */ + { USB_DEVICE(0x10C4, 0xEA70) }, /* Silicon Labs factory default */ +diff --git a/drivers/usb/serial/pl2303.c b/drivers/usb/serial/pl2303.c +index 829604d11f3f..f5257af33ecf 100644 +--- a/drivers/usb/serial/pl2303.c ++++ b/drivers/usb/serial/pl2303.c +@@ -61,7 +61,6 @@ static const struct usb_device_id id_table[] = { + { USB_DEVICE(DCU10_VENDOR_ID, DCU10_PRODUCT_ID) }, + { USB_DEVICE(SITECOM_VENDOR_ID, SITECOM_PRODUCT_ID) }, + { USB_DEVICE(ALCATEL_VENDOR_ID, ALCATEL_PRODUCT_ID) }, +- { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_PRODUCT_ID) }, + { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_SX1), + .driver_info = PL2303_QUIRK_UART_STATE_IDX0 }, + { USB_DEVICE(SIEMENS_VENDOR_ID, SIEMENS_PRODUCT_ID_X65), +diff --git a/drivers/usb/serial/pl2303.h b/drivers/usb/serial/pl2303.h +index 71fd9da1d6e7..e3b7af8adfb7 100644 +--- a/drivers/usb/serial/pl2303.h ++++ b/drivers/usb/serial/pl2303.h +@@ -62,10 +62,6 @@ + #define ALCATEL_VENDOR_ID 0x11f7 + #define ALCATEL_PRODUCT_ID 0x02df + +-/* Samsung I330 phone cradle */ +-#define SAMSUNG_VENDOR_ID 0x04e8 +-#define SAMSUNG_PRODUCT_ID 0x8001 +- + #define SIEMENS_VENDOR_ID 0x11f5 + #define SIEMENS_PRODUCT_ID_SX1 0x0001 + #define SIEMENS_PRODUCT_ID_X65 0x0003 +diff --git a/drivers/usb/serial/visor.c b/drivers/usb/serial/visor.c +index bf2bd40e5f2a..60afb39eb73c 100644 +--- a/drivers/usb/serial/visor.c ++++ b/drivers/usb/serial/visor.c +@@ -95,7 +95,7 @@ static const struct usb_device_id id_table[] = { + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, + { USB_DEVICE(ACER_VENDOR_ID, ACER_S10_ID), + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, +- { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID), ++ { USB_DEVICE_INTERFACE_CLASS(SAMSUNG_VENDOR_ID, SAMSUNG_SCH_I330_ID, 0xff), + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, + { USB_DEVICE(SAMSUNG_VENDOR_ID, SAMSUNG_SPH_I500_ID), + .driver_info = (kernel_ulong_t)&palm_os_4_probe }, +diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h +index d684b4b8108f..caf188800c67 100644 +--- a/drivers/usb/storage/unusual_devs.h ++++ b/drivers/usb/storage/unusual_devs.h +@@ -766,6 +766,13 @@ UNUSUAL_DEV( 0x059f, 0x0643, 0x0000, 0x0000, + USB_SC_DEVICE, USB_PR_DEVICE, NULL, + US_FL_GO_SLOW ), + ++/* Reported by Christian Schaller <cschalle@redhat.com> */ ++UNUSUAL_DEV( 0x059f, 0x0651, 0x0000, 0x0000, ++ "LaCie", ++ "External HDD", ++ USB_SC_DEVICE, USB_PR_DEVICE, NULL, ++ US_FL_NO_WP_DETECT ), ++ + /* Submitted by Joel Bourquard <numlock@freesurf.ch> + * Some versions of this device need the SubClass and Protocol overrides + * while others don't. +diff --git a/drivers/xen/events/events_base.c b/drivers/xen/events/events_base.c +index 2b8553bd8715..38387950490e 100644 +--- a/drivers/xen/events/events_base.c ++++ b/drivers/xen/events/events_base.c +@@ -957,7 +957,7 @@ unsigned xen_evtchn_nr_channels(void) + } + EXPORT_SYMBOL_GPL(xen_evtchn_nr_channels); + +-int bind_virq_to_irq(unsigned int virq, unsigned int cpu) ++int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu) + { + struct evtchn_bind_virq bind_virq; + int evtchn, irq, ret; +@@ -971,8 +971,12 @@ int bind_virq_to_irq(unsigned int virq, unsigned int cpu) + if (irq < 0) + goto out; + +- irq_set_chip_and_handler_name(irq, &xen_percpu_chip, +- handle_percpu_irq, "virq"); ++ if (percpu) ++ irq_set_chip_and_handler_name(irq, &xen_percpu_chip, ++ handle_percpu_irq, "virq"); ++ else ++ irq_set_chip_and_handler_name(irq, &xen_dynamic_chip, ++ handle_edge_irq, "virq"); + + bind_virq.virq = virq; + bind_virq.vcpu = cpu; +@@ -1062,7 +1066,7 @@ int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, + { + int irq, retval; + +- irq = bind_virq_to_irq(virq, cpu); ++ irq = bind_virq_to_irq(virq, cpu, irqflags & IRQF_PERCPU); + if (irq < 0) + return irq; + retval = request_irq(irq, handler, irqflags, devname, dev_id); +diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c +index d925f55e4857..8081aba116a7 100644 +--- a/fs/binfmt_elf.c ++++ b/fs/binfmt_elf.c +@@ -928,7 +928,7 @@ static int load_elf_binary(struct linux_binprm *bprm) + total_size = total_mapping_size(elf_phdata, + loc->elf_ex.e_phnum); + if (!total_size) { +- error = -EINVAL; ++ retval = -EINVAL; + goto out_free_dentry; + } + } +diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c +index 0a795c969c78..8b33da6ec3dd 100644 +--- a/fs/btrfs/extent-tree.c ++++ b/fs/btrfs/extent-tree.c +@@ -8548,7 +8548,9 @@ int btrfs_set_block_group_ro(struct btrfs_root *root, + out: + if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) { + alloc_flags = update_block_group_flags(root, cache->flags); ++ lock_chunks(root->fs_info->chunk_root); + check_system_chunk(trans, root, alloc_flags); ++ unlock_chunks(root->fs_info->chunk_root); + } + + btrfs_end_transaction(trans, root); +diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c +index 8222f6f74147..44a7e0398d97 100644 +--- a/fs/btrfs/volumes.c ++++ b/fs/btrfs/volumes.c +@@ -4626,6 +4626,7 @@ int btrfs_alloc_chunk(struct btrfs_trans_handle *trans, + { + u64 chunk_offset; + ++ ASSERT(mutex_is_locked(&extent_root->fs_info->chunk_mutex)); + chunk_offset = find_next_chunk(extent_root->fs_info); + return __btrfs_alloc_chunk(trans, extent_root, chunk_offset, type); + } +diff --git a/fs/dcache.c b/fs/dcache.c +index c71e3732e53b..922f23ef6041 100644 +--- a/fs/dcache.c ++++ b/fs/dcache.c +@@ -1205,13 +1205,13 @@ ascend: + /* might go back up the wrong parent if we have had a rename. */ + if (need_seqretry(&rename_lock, seq)) + goto rename_retry; +- next = child->d_child.next; +- while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED)) { ++ /* go into the first sibling still alive */ ++ do { ++ next = child->d_child.next; + if (next == &this_parent->d_subdirs) + goto ascend; + child = list_entry(next, struct dentry, d_child); +- next = next->next; +- } ++ } while (unlikely(child->d_flags & DCACHE_DENTRY_KILLED)); + rcu_read_unlock(); + goto resume; + } +diff --git a/fs/exec.c b/fs/exec.c +index 00400cf522dc..120244523647 100644 +--- a/fs/exec.c ++++ b/fs/exec.c +@@ -659,6 +659,9 @@ int setup_arg_pages(struct linux_binprm *bprm, + if (stack_base > STACK_SIZE_MAX) + stack_base = STACK_SIZE_MAX; + ++ /* Add space for stack randomization. */ ++ stack_base += (STACK_RND_MASK << PAGE_SHIFT); ++ + /* Make sure we didn't let the argument array grow too large. */ + if (vma->vm_end - vma->vm_start > stack_base) + return -ENOMEM; +diff --git a/fs/ext4/ext4_jbd2.c b/fs/ext4/ext4_jbd2.c +index 3445035c7e01..d41843181818 100644 +--- a/fs/ext4/ext4_jbd2.c ++++ b/fs/ext4/ext4_jbd2.c +@@ -87,6 +87,12 @@ int __ext4_journal_stop(const char *where, unsigned int line, handle_t *handle) + ext4_put_nojournal(handle); + return 0; + } ++ ++ if (!handle->h_transaction) { ++ err = jbd2_journal_stop(handle); ++ return handle->h_err ? handle->h_err : err; ++ } ++ + sb = handle->h_transaction->t_journal->j_private; + err = handle->h_err; + rc = jbd2_journal_stop(handle); +diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c +index 16f6365f65e7..ea4ee1732143 100644 +--- a/fs/ext4/extents.c ++++ b/fs/ext4/extents.c +@@ -377,7 +377,7 @@ static int ext4_valid_extent(struct inode *inode, struct ext4_extent *ext) + ext4_lblk_t lblock = le32_to_cpu(ext->ee_block); + ext4_lblk_t last = lblock + len - 1; + +- if (lblock > last) ++ if (len == 0 || lblock > last) + return 0; + return ext4_data_block_valid(EXT4_SB(inode->i_sb), block, len); + } +diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c +index 852cc521f327..1f252b4e0f51 100644 +--- a/fs/ext4/inode.c ++++ b/fs/ext4/inode.c +@@ -4233,7 +4233,7 @@ static void ext4_update_other_inodes_time(struct super_block *sb, + int inode_size = EXT4_INODE_SIZE(sb); + + oi.orig_ino = orig_ino; +- ino = orig_ino & ~(inodes_per_block - 1); ++ ino = (orig_ino & ~(inodes_per_block - 1)) + 1; + for (i = 0; i < inodes_per_block; i++, ino++, buf += inode_size) { + if (ino == orig_ino) + continue; +diff --git a/fs/fhandle.c b/fs/fhandle.c +index 999ff5c3cab0..d59712dfa3e7 100644 +--- a/fs/fhandle.c ++++ b/fs/fhandle.c +@@ -195,8 +195,9 @@ static int handle_to_path(int mountdirfd, struct file_handle __user *ufh, + goto out_err; + } + /* copy the full handle */ +- if (copy_from_user(handle, ufh, +- sizeof(struct file_handle) + ++ *handle = f_handle; ++ if (copy_from_user(&handle->f_handle, ++ &ufh->f_handle, + f_handle.handle_bytes)) { + retval = -EFAULT; + goto out_handle; +diff --git a/fs/fs_pin.c b/fs/fs_pin.c +index b06c98796afb..611b5408f6ec 100644 +--- a/fs/fs_pin.c ++++ b/fs/fs_pin.c +@@ -9,8 +9,8 @@ static DEFINE_SPINLOCK(pin_lock); + void pin_remove(struct fs_pin *pin) + { + spin_lock(&pin_lock); +- hlist_del(&pin->m_list); +- hlist_del(&pin->s_list); ++ hlist_del_init(&pin->m_list); ++ hlist_del_init(&pin->s_list); + spin_unlock(&pin_lock); + spin_lock_irq(&pin->wait.lock); + pin->done = 1; +diff --git a/fs/jbd2/recovery.c b/fs/jbd2/recovery.c +index b5128c6e63ad..a9079d035ae5 100644 +--- a/fs/jbd2/recovery.c ++++ b/fs/jbd2/recovery.c +@@ -842,15 +842,23 @@ static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, + { + jbd2_journal_revoke_header_t *header; + int offset, max; ++ int csum_size = 0; ++ __u32 rcount; + int record_len = 4; + + header = (jbd2_journal_revoke_header_t *) bh->b_data; + offset = sizeof(jbd2_journal_revoke_header_t); +- max = be32_to_cpu(header->r_count); ++ rcount = be32_to_cpu(header->r_count); + + if (!jbd2_revoke_block_csum_verify(journal, header)) + return -EINVAL; + ++ if (jbd2_journal_has_csum_v2or3(journal)) ++ csum_size = sizeof(struct jbd2_journal_revoke_tail); ++ if (rcount > journal->j_blocksize - csum_size) ++ return -EINVAL; ++ max = rcount; ++ + if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) + record_len = 8; + +diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c +index c6cbaef2bda1..14214da80eb8 100644 +--- a/fs/jbd2/revoke.c ++++ b/fs/jbd2/revoke.c +@@ -577,7 +577,7 @@ static void write_one_revoke_record(journal_t *journal, + { + int csum_size = 0; + struct buffer_head *descriptor; +- int offset; ++ int sz, offset; + journal_header_t *header; + + /* If we are already aborting, this all becomes a noop. We +@@ -594,9 +594,14 @@ static void write_one_revoke_record(journal_t *journal, + if (jbd2_journal_has_csum_v2or3(journal)) + csum_size = sizeof(struct jbd2_journal_revoke_tail); + ++ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) ++ sz = 8; ++ else ++ sz = 4; ++ + /* Make sure we have a descriptor with space left for the record */ + if (descriptor) { +- if (offset >= journal->j_blocksize - csum_size) { ++ if (offset + sz > journal->j_blocksize - csum_size) { + flush_descriptor(journal, descriptor, offset, write_op); + descriptor = NULL; + } +@@ -619,16 +624,13 @@ static void write_one_revoke_record(journal_t *journal, + *descriptorp = descriptor; + } + +- if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) { ++ if (JBD2_HAS_INCOMPAT_FEATURE(journal, JBD2_FEATURE_INCOMPAT_64BIT)) + * ((__be64 *)(&descriptor->b_data[offset])) = + cpu_to_be64(record->blocknr); +- offset += 8; +- +- } else { ++ else + * ((__be32 *)(&descriptor->b_data[offset])) = + cpu_to_be32(record->blocknr); +- offset += 4; +- } ++ offset += sz; + + *offsetp = offset; + } +diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c +index 5f09370c90a8..ff2f2e6ad311 100644 +--- a/fs/jbd2/transaction.c ++++ b/fs/jbd2/transaction.c +@@ -551,7 +551,6 @@ int jbd2_journal_extend(handle_t *handle, int nblocks) + int result; + int wanted; + +- WARN_ON(!transaction); + if (is_handle_aborted(handle)) + return -EROFS; + journal = transaction->t_journal; +@@ -627,7 +626,6 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, gfp_t gfp_mask) + tid_t tid; + int need_to_start, ret; + +- WARN_ON(!transaction); + /* If we've had an abort of any type, don't even think about + * actually doing the restart! */ + if (is_handle_aborted(handle)) +@@ -785,7 +783,6 @@ do_get_write_access(handle_t *handle, struct journal_head *jh, + int need_copy = 0; + unsigned long start_lock, time_lock; + +- WARN_ON(!transaction); + if (is_handle_aborted(handle)) + return -EROFS; + journal = transaction->t_journal; +@@ -1051,7 +1048,6 @@ int jbd2_journal_get_create_access(handle_t *handle, struct buffer_head *bh) + int err; + + jbd_debug(5, "journal_head %p\n", jh); +- WARN_ON(!transaction); + err = -EROFS; + if (is_handle_aborted(handle)) + goto out; +@@ -1266,7 +1262,6 @@ int jbd2_journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) + struct journal_head *jh; + int ret = 0; + +- WARN_ON(!transaction); + if (is_handle_aborted(handle)) + return -EROFS; + journal = transaction->t_journal; +@@ -1397,7 +1392,6 @@ int jbd2_journal_forget (handle_t *handle, struct buffer_head *bh) + int err = 0; + int was_modified = 0; + +- WARN_ON(!transaction); + if (is_handle_aborted(handle)) + return -EROFS; + journal = transaction->t_journal; +@@ -1530,8 +1524,22 @@ int jbd2_journal_stop(handle_t *handle) + tid_t tid; + pid_t pid; + +- if (!transaction) +- goto free_and_exit; ++ if (!transaction) { ++ /* ++ * Handle is already detached from the transaction so ++ * there is nothing to do other than decrease a refcount, ++ * or free the handle if refcount drops to zero ++ */ ++ if (--handle->h_ref > 0) { ++ jbd_debug(4, "h_ref %d -> %d\n", handle->h_ref + 1, ++ handle->h_ref); ++ return err; ++ } else { ++ if (handle->h_rsv_handle) ++ jbd2_free_handle(handle->h_rsv_handle); ++ goto free_and_exit; ++ } ++ } + journal = transaction->t_journal; + + J_ASSERT(journal_current_handle() == handle); +@@ -2373,7 +2381,6 @@ int jbd2_journal_file_inode(handle_t *handle, struct jbd2_inode *jinode) + transaction_t *transaction = handle->h_transaction; + journal_t *journal; + +- WARN_ON(!transaction); + if (is_handle_aborted(handle)) + return -EROFS; + journal = transaction->t_journal; +diff --git a/fs/kernfs/dir.c b/fs/kernfs/dir.c +index 6acc9648f986..345b35fd329d 100644 +--- a/fs/kernfs/dir.c ++++ b/fs/kernfs/dir.c +@@ -518,7 +518,14 @@ static struct kernfs_node *__kernfs_new_node(struct kernfs_root *root, + if (!kn) + goto err_out1; + +- ret = ida_simple_get(&root->ino_ida, 1, 0, GFP_KERNEL); ++ /* ++ * If the ino of the sysfs entry created for a kmem cache gets ++ * allocated from an ida layer, which is accounted to the memcg that ++ * owns the cache, the memcg will get pinned forever. So do not account ++ * ino ida allocations. ++ */ ++ ret = ida_simple_get(&root->ino_ida, 1, 0, ++ GFP_KERNEL | __GFP_NOACCOUNT); + if (ret < 0) + goto err_out2; + kn->ino = ret; +diff --git a/fs/namespace.c b/fs/namespace.c +index 38ed1e1bed41..13b0f7bfc096 100644 +--- a/fs/namespace.c ++++ b/fs/namespace.c +@@ -1709,8 +1709,11 @@ struct vfsmount *collect_mounts(struct path *path) + { + struct mount *tree; + namespace_lock(); +- tree = copy_tree(real_mount(path->mnt), path->dentry, +- CL_COPY_ALL | CL_PRIVATE); ++ if (!check_mnt(real_mount(path->mnt))) ++ tree = ERR_PTR(-EINVAL); ++ else ++ tree = copy_tree(real_mount(path->mnt), path->dentry, ++ CL_COPY_ALL | CL_PRIVATE); + namespace_unlock(); + if (IS_ERR(tree)) + return ERR_CAST(tree); +diff --git a/fs/nfsd/blocklayout.c b/fs/nfsd/blocklayout.c +index 03d647bf195d..cdefaa331a07 100644 +--- a/fs/nfsd/blocklayout.c ++++ b/fs/nfsd/blocklayout.c +@@ -181,6 +181,17 @@ nfsd4_block_proc_layoutcommit(struct inode *inode, + } + + const struct nfsd4_layout_ops bl_layout_ops = { ++ /* ++ * Pretend that we send notification to the client. This is a blatant ++ * lie to force recent Linux clients to cache our device IDs. ++ * We rarely ever change the device ID, so the harm of leaking deviceids ++ * for a while isn't too bad. Unfortunately RFC5661 is a complete mess ++ * in this regard, but I filed errata 4119 for this a while ago, and ++ * hopefully the Linux client will eventually start caching deviceids ++ * without this again. ++ */ ++ .notify_types = ++ NOTIFY_DEVICEID4_DELETE | NOTIFY_DEVICEID4_CHANGE, + .proc_getdeviceinfo = nfsd4_block_proc_getdeviceinfo, + .encode_getdeviceinfo = nfsd4_block_encode_getdeviceinfo, + .proc_layoutget = nfsd4_block_proc_layoutget, +diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c +index ee1cccdb083a..b4541ede7cb8 100644 +--- a/fs/nfsd/nfs4state.c ++++ b/fs/nfsd/nfs4state.c +@@ -4386,10 +4386,17 @@ static __be32 check_stateid_generation(stateid_t *in, stateid_t *ref, bool has_s + return nfserr_old_stateid; + } + ++static __be32 nfsd4_check_openowner_confirmed(struct nfs4_ol_stateid *ols) ++{ ++ if (ols->st_stateowner->so_is_open_owner && ++ !(openowner(ols->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) ++ return nfserr_bad_stateid; ++ return nfs_ok; ++} ++ + static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) + { + struct nfs4_stid *s; +- struct nfs4_ol_stateid *ols; + __be32 status = nfserr_bad_stateid; + + if (ZERO_STATEID(stateid) || ONE_STATEID(stateid)) +@@ -4419,13 +4426,7 @@ static __be32 nfsd4_validate_stateid(struct nfs4_client *cl, stateid_t *stateid) + break; + case NFS4_OPEN_STID: + case NFS4_LOCK_STID: +- ols = openlockstateid(s); +- if (ols->st_stateowner->so_is_open_owner +- && !(openowner(ols->st_stateowner)->oo_flags +- & NFS4_OO_CONFIRMED)) +- status = nfserr_bad_stateid; +- else +- status = nfs_ok; ++ status = nfsd4_check_openowner_confirmed(openlockstateid(s)); + break; + default: + printk("unknown stateid type %x\n", s->sc_type); +@@ -4517,8 +4518,8 @@ nfs4_preprocess_stateid_op(struct net *net, struct nfsd4_compound_state *cstate, + status = nfs4_check_fh(current_fh, stp); + if (status) + goto out; +- if (stp->st_stateowner->so_is_open_owner +- && !(openowner(stp->st_stateowner)->oo_flags & NFS4_OO_CONFIRMED)) ++ status = nfsd4_check_openowner_confirmed(stp); ++ if (status) + goto out; + status = nfs4_check_openmode(stp, flags); + if (status) +diff --git a/fs/omfs/inode.c b/fs/omfs/inode.c +index 138321b0c6c2..454111a3308e 100644 +--- a/fs/omfs/inode.c ++++ b/fs/omfs/inode.c +@@ -306,7 +306,8 @@ static const struct super_operations omfs_sops = { + */ + static int omfs_get_imap(struct super_block *sb) + { +- unsigned int bitmap_size, count, array_size; ++ unsigned int bitmap_size, array_size; ++ int count; + struct omfs_sb_info *sbi = OMFS_SB(sb); + struct buffer_head *bh; + unsigned long **ptr; +@@ -359,7 +360,7 @@ nomem: + } + + enum { +- Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask ++ Opt_uid, Opt_gid, Opt_umask, Opt_dmask, Opt_fmask, Opt_err + }; + + static const match_table_t tokens = { +@@ -368,6 +369,7 @@ static const match_table_t tokens = { + {Opt_umask, "umask=%o"}, + {Opt_dmask, "dmask=%o"}, + {Opt_fmask, "fmask=%o"}, ++ {Opt_err, NULL}, + }; + + static int parse_options(char *options, struct omfs_sb_info *sbi) +diff --git a/fs/overlayfs/copy_up.c b/fs/overlayfs/copy_up.c +index 24f640441bd9..84d693d37428 100644 +--- a/fs/overlayfs/copy_up.c ++++ b/fs/overlayfs/copy_up.c +@@ -299,6 +299,9 @@ int ovl_copy_up_one(struct dentry *parent, struct dentry *dentry, + struct cred *override_cred; + char *link = NULL; + ++ if (WARN_ON(!workdir)) ++ return -EROFS; ++ + ovl_path_upper(parent, &parentpath); + upperdir = parentpath.dentry; + +diff --git a/fs/overlayfs/dir.c b/fs/overlayfs/dir.c +index d139405d2bfa..692ceda3bc21 100644 +--- a/fs/overlayfs/dir.c ++++ b/fs/overlayfs/dir.c +@@ -222,6 +222,9 @@ static struct dentry *ovl_clear_empty(struct dentry *dentry, + struct kstat stat; + int err; + ++ if (WARN_ON(!workdir)) ++ return ERR_PTR(-EROFS); ++ + err = ovl_lock_rename_workdir(workdir, upperdir); + if (err) + goto out; +@@ -322,6 +325,9 @@ static int ovl_create_over_whiteout(struct dentry *dentry, struct inode *inode, + struct dentry *newdentry; + int err; + ++ if (WARN_ON(!workdir)) ++ return -EROFS; ++ + err = ovl_lock_rename_workdir(workdir, upperdir); + if (err) + goto out; +@@ -506,11 +512,28 @@ static int ovl_remove_and_whiteout(struct dentry *dentry, bool is_dir) + struct dentry *opaquedir = NULL; + int err; + +- if (is_dir && OVL_TYPE_MERGE_OR_LOWER(ovl_path_type(dentry))) { +- opaquedir = ovl_check_empty_and_clear(dentry); +- err = PTR_ERR(opaquedir); +- if (IS_ERR(opaquedir)) +- goto out; ++ if (WARN_ON(!workdir)) ++ return -EROFS; ++ ++ if (is_dir) { ++ if (OVL_TYPE_MERGE_OR_LOWER(ovl_path_type(dentry))) { ++ opaquedir = ovl_check_empty_and_clear(dentry); ++ err = PTR_ERR(opaquedir); ++ if (IS_ERR(opaquedir)) ++ goto out; ++ } else { ++ LIST_HEAD(list); ++ ++ /* ++ * When removing an empty opaque directory, then it ++ * makes no sense to replace it with an exact replica of ++ * itself. But emptiness still needs to be checked. ++ */ ++ err = ovl_check_empty_dir(dentry, &list); ++ ovl_cache_free(&list); ++ if (err) ++ goto out; ++ } + } + + err = ovl_lock_rename_workdir(workdir, upperdir); +diff --git a/fs/overlayfs/super.c b/fs/overlayfs/super.c +index 5f0d1993e6e3..bf8537c7f455 100644 +--- a/fs/overlayfs/super.c ++++ b/fs/overlayfs/super.c +@@ -529,7 +529,7 @@ static int ovl_remount(struct super_block *sb, int *flags, char *data) + { + struct ovl_fs *ufs = sb->s_fs_info; + +- if (!(*flags & MS_RDONLY) && !ufs->upper_mnt) ++ if (!(*flags & MS_RDONLY) && (!ufs->upper_mnt || !ufs->workdir)) + return -EROFS; + + return 0; +@@ -925,9 +925,10 @@ static int ovl_fill_super(struct super_block *sb, void *data, int silent) + ufs->workdir = ovl_workdir_create(ufs->upper_mnt, workpath.dentry); + err = PTR_ERR(ufs->workdir); + if (IS_ERR(ufs->workdir)) { +- pr_err("overlayfs: failed to create directory %s/%s\n", +- ufs->config.workdir, OVL_WORKDIR_NAME); +- goto out_put_upper_mnt; ++ pr_warn("overlayfs: failed to create directory %s/%s (errno: %i); mounting read-only\n", ++ ufs->config.workdir, OVL_WORKDIR_NAME, -err); ++ sb->s_flags |= MS_RDONLY; ++ ufs->workdir = NULL; + } + } + +@@ -997,7 +998,6 @@ out_put_lower_mnt: + kfree(ufs->lower_mnt); + out_put_workdir: + dput(ufs->workdir); +-out_put_upper_mnt: + mntput(ufs->upper_mnt); + out_put_lowerpath: + for (i = 0; i < numlower; i++) +diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c +index 15105dbc9e28..0166e7e829a7 100644 +--- a/fs/xfs/libxfs/xfs_attr_leaf.c ++++ b/fs/xfs/libxfs/xfs_attr_leaf.c +@@ -498,8 +498,8 @@ xfs_attr_shortform_add(xfs_da_args_t *args, int forkoff) + * After the last attribute is removed revert to original inode format, + * making all literal area available to the data fork once more. + */ +-STATIC void +-xfs_attr_fork_reset( ++void ++xfs_attr_fork_remove( + struct xfs_inode *ip, + struct xfs_trans *tp) + { +@@ -565,7 +565,7 @@ xfs_attr_shortform_remove(xfs_da_args_t *args) + (mp->m_flags & XFS_MOUNT_ATTR2) && + (dp->i_d.di_format != XFS_DINODE_FMT_BTREE) && + !(args->op_flags & XFS_DA_OP_ADDNAME)) { +- xfs_attr_fork_reset(dp, args->trans); ++ xfs_attr_fork_remove(dp, args->trans); + } else { + xfs_idata_realloc(dp, -size, XFS_ATTR_FORK); + dp->i_d.di_forkoff = xfs_attr_shortform_bytesfit(dp, totsize); +@@ -828,7 +828,7 @@ xfs_attr3_leaf_to_shortform( + if (forkoff == -1) { + ASSERT(dp->i_mount->m_flags & XFS_MOUNT_ATTR2); + ASSERT(dp->i_d.di_format != XFS_DINODE_FMT_BTREE); +- xfs_attr_fork_reset(dp, args->trans); ++ xfs_attr_fork_remove(dp, args->trans); + goto out; + } + +diff --git a/fs/xfs/libxfs/xfs_attr_leaf.h b/fs/xfs/libxfs/xfs_attr_leaf.h +index e2929da7c3ba..4f3a60aa93d4 100644 +--- a/fs/xfs/libxfs/xfs_attr_leaf.h ++++ b/fs/xfs/libxfs/xfs_attr_leaf.h +@@ -53,7 +53,7 @@ int xfs_attr_shortform_remove(struct xfs_da_args *args); + int xfs_attr_shortform_list(struct xfs_attr_list_context *context); + int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp); + int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes); +- ++void xfs_attr_fork_remove(struct xfs_inode *ip, struct xfs_trans *tp); + + /* + * Internal routines when attribute fork size == XFS_LBSIZE(mp). +diff --git a/fs/xfs/xfs_attr_inactive.c b/fs/xfs/xfs_attr_inactive.c +index 83af4c149635..487c8374a1e0 100644 +--- a/fs/xfs/xfs_attr_inactive.c ++++ b/fs/xfs/xfs_attr_inactive.c +@@ -379,23 +379,31 @@ xfs_attr3_root_inactive( + return error; + } + ++/* ++ * xfs_attr_inactive kills all traces of an attribute fork on an inode. It ++ * removes both the on-disk and in-memory inode fork. Note that this also has to ++ * handle the condition of inodes without attributes but with an attribute fork ++ * configured, so we can't use xfs_inode_hasattr() here. ++ * ++ * The in-memory attribute fork is removed even on error. ++ */ + int +-xfs_attr_inactive(xfs_inode_t *dp) ++xfs_attr_inactive( ++ struct xfs_inode *dp) + { +- xfs_trans_t *trans; +- xfs_mount_t *mp; +- int error; ++ struct xfs_trans *trans; ++ struct xfs_mount *mp; ++ int cancel_flags = 0; ++ int lock_mode = XFS_ILOCK_SHARED; ++ int error = 0; + + mp = dp->i_mount; + ASSERT(! XFS_NOT_DQATTACHED(mp, dp)); + +- xfs_ilock(dp, XFS_ILOCK_SHARED); +- if (!xfs_inode_hasattr(dp) || +- dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { +- xfs_iunlock(dp, XFS_ILOCK_SHARED); +- return 0; +- } +- xfs_iunlock(dp, XFS_ILOCK_SHARED); ++ xfs_ilock(dp, lock_mode); ++ if (!XFS_IFORK_Q(dp)) ++ goto out_destroy_fork; ++ xfs_iunlock(dp, lock_mode); + + /* + * Start our first transaction of the day. +@@ -407,13 +415,18 @@ xfs_attr_inactive(xfs_inode_t *dp) + * the inode in every transaction to let it float upward through + * the log. + */ ++ lock_mode = 0; + trans = xfs_trans_alloc(mp, XFS_TRANS_ATTRINVAL); + error = xfs_trans_reserve(trans, &M_RES(mp)->tr_attrinval, 0, 0); +- if (error) { +- xfs_trans_cancel(trans, 0); +- return error; +- } +- xfs_ilock(dp, XFS_ILOCK_EXCL); ++ if (error) ++ goto out_cancel; ++ ++ lock_mode = XFS_ILOCK_EXCL; ++ cancel_flags = XFS_TRANS_RELEASE_LOG_RES | XFS_TRANS_ABORT; ++ xfs_ilock(dp, lock_mode); ++ ++ if (!XFS_IFORK_Q(dp)) ++ goto out_cancel; + + /* + * No need to make quota reservations here. We expect to release some +@@ -421,29 +434,31 @@ xfs_attr_inactive(xfs_inode_t *dp) + */ + xfs_trans_ijoin(trans, dp, 0); + +- /* +- * Decide on what work routines to call based on the inode size. +- */ +- if (!xfs_inode_hasattr(dp) || +- dp->i_d.di_aformat == XFS_DINODE_FMT_LOCAL) { +- error = 0; +- goto out; ++ /* invalidate and truncate the attribute fork extents */ ++ if (dp->i_d.di_aformat != XFS_DINODE_FMT_LOCAL) { ++ error = xfs_attr3_root_inactive(&trans, dp); ++ if (error) ++ goto out_cancel; ++ ++ error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0); ++ if (error) ++ goto out_cancel; + } +- error = xfs_attr3_root_inactive(&trans, dp); +- if (error) +- goto out; + +- error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0); +- if (error) +- goto out; ++ /* Reset the attribute fork - this also destroys the in-core fork */ ++ xfs_attr_fork_remove(dp, trans); + + error = xfs_trans_commit(trans, XFS_TRANS_RELEASE_LOG_RES); +- xfs_iunlock(dp, XFS_ILOCK_EXCL); +- ++ xfs_iunlock(dp, lock_mode); + return error; + +-out: +- xfs_trans_cancel(trans, XFS_TRANS_RELEASE_LOG_RES|XFS_TRANS_ABORT); +- xfs_iunlock(dp, XFS_ILOCK_EXCL); ++out_cancel: ++ xfs_trans_cancel(trans, cancel_flags); ++out_destroy_fork: ++ /* kill the in-core attr fork before we drop the inode lock */ ++ if (dp->i_afp) ++ xfs_idestroy_fork(dp, XFS_ATTR_FORK); ++ if (lock_mode) ++ xfs_iunlock(dp, lock_mode); + return error; + } +diff --git a/fs/xfs/xfs_file.c b/fs/xfs/xfs_file.c +index a2e1cb8a568b..f3ba637a8ece 100644 +--- a/fs/xfs/xfs_file.c ++++ b/fs/xfs/xfs_file.c +@@ -125,7 +125,7 @@ xfs_iozero( + status = 0; + } while (count); + +- return (-status); ++ return status; + } + + int +diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c +index 6163767aa856..b1edda7890f4 100644 +--- a/fs/xfs/xfs_inode.c ++++ b/fs/xfs/xfs_inode.c +@@ -1889,21 +1889,17 @@ xfs_inactive( + /* + * If there are attributes associated with the file then blow them away + * now. The code calls a routine that recursively deconstructs the +- * attribute fork. We need to just commit the current transaction +- * because we can't use it for xfs_attr_inactive(). ++ * attribute fork. If also blows away the in-core attribute fork. + */ +- if (ip->i_d.di_anextents > 0) { +- ASSERT(ip->i_d.di_forkoff != 0); +- ++ if (XFS_IFORK_Q(ip)) { + error = xfs_attr_inactive(ip); + if (error) + return; + } + +- if (ip->i_afp) +- xfs_idestroy_fork(ip, XFS_ATTR_FORK); +- ++ ASSERT(!ip->i_afp); + ASSERT(ip->i_d.di_anextents == 0); ++ ASSERT(ip->i_d.di_forkoff == 0); + + /* + * Free the inode. +diff --git a/include/drm/drm_pciids.h b/include/drm/drm_pciids.h +index 2dd405c9be78..45c39a37f924 100644 +--- a/include/drm/drm_pciids.h ++++ b/include/drm/drm_pciids.h +@@ -186,6 +186,7 @@ + {0x1002, 0x6658, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x665c, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x665d, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ ++ {0x1002, 0x665f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_BONAIRE|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6660, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6663, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ + {0x1002, 0x6664, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_HAINAN|RADEON_IS_MOBILITY|RADEON_NEW_MEMMAP}, \ +diff --git a/include/linux/fs_pin.h b/include/linux/fs_pin.h +index 9dc4e0384bfb..3886b3bffd7f 100644 +--- a/include/linux/fs_pin.h ++++ b/include/linux/fs_pin.h +@@ -13,6 +13,8 @@ struct vfsmount; + static inline void init_fs_pin(struct fs_pin *p, void (*kill)(struct fs_pin *)) + { + init_waitqueue_head(&p->wait); ++ INIT_HLIST_NODE(&p->s_list); ++ INIT_HLIST_NODE(&p->m_list); + p->kill = kill; + } + +diff --git a/include/linux/gfp.h b/include/linux/gfp.h +index 51bd1e72a917..eb6fafe66bec 100644 +--- a/include/linux/gfp.h ++++ b/include/linux/gfp.h +@@ -30,6 +30,7 @@ struct vm_area_struct; + #define ___GFP_HARDWALL 0x20000u + #define ___GFP_THISNODE 0x40000u + #define ___GFP_RECLAIMABLE 0x80000u ++#define ___GFP_NOACCOUNT 0x100000u + #define ___GFP_NOTRACK 0x200000u + #define ___GFP_NO_KSWAPD 0x400000u + #define ___GFP_OTHER_NODE 0x800000u +@@ -85,6 +86,7 @@ struct vm_area_struct; + #define __GFP_HARDWALL ((__force gfp_t)___GFP_HARDWALL) /* Enforce hardwall cpuset memory allocs */ + #define __GFP_THISNODE ((__force gfp_t)___GFP_THISNODE)/* No fallback, no policies */ + #define __GFP_RECLAIMABLE ((__force gfp_t)___GFP_RECLAIMABLE) /* Page is reclaimable */ ++#define __GFP_NOACCOUNT ((__force gfp_t)___GFP_NOACCOUNT) /* Don't account to kmemcg */ + #define __GFP_NOTRACK ((__force gfp_t)___GFP_NOTRACK) /* Don't track with kmemcheck */ + + #define __GFP_NO_KSWAPD ((__force gfp_t)___GFP_NO_KSWAPD) +diff --git a/include/linux/ktime.h b/include/linux/ktime.h +index 5fc3d1083071..2b6a204bd8d4 100644 +--- a/include/linux/ktime.h ++++ b/include/linux/ktime.h +@@ -166,19 +166,34 @@ static inline bool ktime_before(const ktime_t cmp1, const ktime_t cmp2) + } + + #if BITS_PER_LONG < 64 +-extern u64 __ktime_divns(const ktime_t kt, s64 div); +-static inline u64 ktime_divns(const ktime_t kt, s64 div) ++extern s64 __ktime_divns(const ktime_t kt, s64 div); ++static inline s64 ktime_divns(const ktime_t kt, s64 div) + { ++ /* ++ * Negative divisors could cause an inf loop, ++ * so bug out here. ++ */ ++ BUG_ON(div < 0); + if (__builtin_constant_p(div) && !(div >> 32)) { +- u64 ns = kt.tv64; +- do_div(ns, div); +- return ns; ++ s64 ns = kt.tv64; ++ u64 tmp = ns < 0 ? -ns : ns; ++ ++ do_div(tmp, div); ++ return ns < 0 ? -tmp : tmp; + } else { + return __ktime_divns(kt, div); + } + } + #else /* BITS_PER_LONG < 64 */ +-# define ktime_divns(kt, div) (u64)((kt).tv64 / (div)) ++static inline s64 ktime_divns(const ktime_t kt, s64 div) ++{ ++ /* ++ * 32-bit implementation cannot handle negative divisors, ++ * so catch them on 64bit as well. ++ */ ++ WARN_ON(div < 0); ++ return kt.tv64 / div; ++} + #endif + + static inline s64 ktime_to_us(const ktime_t kt) +diff --git a/include/linux/libata.h b/include/linux/libata.h +index 6b08cc106c21..f8994b4b122c 100644 +--- a/include/linux/libata.h ++++ b/include/linux/libata.h +@@ -205,6 +205,7 @@ enum { + ATA_LFLAG_SW_ACTIVITY = (1 << 7), /* keep activity stats */ + ATA_LFLAG_NO_LPM = (1 << 8), /* disable LPM on this link */ + ATA_LFLAG_RST_ONCE = (1 << 9), /* limit recovery to one reset */ ++ ATA_LFLAG_CHANGED = (1 << 10), /* LPM state changed on this link */ + + /* struct ata_port flags */ + ATA_FLAG_SLAVE_POSS = (1 << 0), /* host supports slave dev */ +@@ -310,6 +311,12 @@ enum { + */ + ATA_TMOUT_PMP_SRST_WAIT = 5000, + ++ /* When the LPM policy is set to ATA_LPM_MAX_POWER, there might ++ * be a spurious PHY event, so ignore the first PHY event that ++ * occurs within 10s after the policy change. ++ */ ++ ATA_TMOUT_SPURIOUS_PHY = 10000, ++ + /* ATA bus states */ + BUS_UNKNOWN = 0, + BUS_DMA = 1, +@@ -789,6 +796,8 @@ struct ata_link { + struct ata_eh_context eh_context; + + struct ata_device device[ATA_MAX_DEVICES]; ++ ++ unsigned long last_lpm_change; /* when last LPM change happened */ + }; + #define ATA_LINK_CLEAR_BEGIN offsetof(struct ata_link, active_tag) + #define ATA_LINK_CLEAR_END offsetof(struct ata_link, device[0]) +@@ -1202,6 +1211,7 @@ extern struct ata_device *ata_dev_pair(struct ata_device *adev); + extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev); + extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap); + extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q); ++extern bool sata_lpm_ignore_phy_events(struct ata_link *link); + + extern int ata_cable_40wire(struct ata_port *ap); + extern int ata_cable_80wire(struct ata_port *ap); +diff --git a/include/linux/memcontrol.h b/include/linux/memcontrol.h +index 72dff5fb0d0c..6c8918114804 100644 +--- a/include/linux/memcontrol.h ++++ b/include/linux/memcontrol.h +@@ -463,6 +463,8 @@ memcg_kmem_newpage_charge(gfp_t gfp, struct mem_cgroup **memcg, int order) + if (!memcg_kmem_enabled()) + return true; + ++ if (gfp & __GFP_NOACCOUNT) ++ return true; + /* + * __GFP_NOFAIL allocations will move on even if charging is not + * possible. Therefore we don't even try, and have this allocation +@@ -522,6 +524,8 @@ memcg_kmem_get_cache(struct kmem_cache *cachep, gfp_t gfp) + { + if (!memcg_kmem_enabled()) + return cachep; ++ if (gfp & __GFP_NOACCOUNT) ++ return cachep; + if (gfp & __GFP_NOFAIL) + return cachep; + if (in_interrupt() || (!current->mm) || (current->flags & PF_KTHREAD)) +diff --git a/include/linux/sched/rt.h b/include/linux/sched/rt.h +index 6341f5be6e24..a30b172df6e1 100644 +--- a/include/linux/sched/rt.h ++++ b/include/linux/sched/rt.h +@@ -18,7 +18,7 @@ static inline int rt_task(struct task_struct *p) + #ifdef CONFIG_RT_MUTEXES + extern int rt_mutex_getprio(struct task_struct *p); + extern void rt_mutex_setprio(struct task_struct *p, int prio); +-extern int rt_mutex_check_prio(struct task_struct *task, int newprio); ++extern int rt_mutex_get_effective_prio(struct task_struct *task, int newprio); + extern struct task_struct *rt_mutex_get_top_task(struct task_struct *task); + extern void rt_mutex_adjust_pi(struct task_struct *p); + static inline bool tsk_is_pi_blocked(struct task_struct *tsk) +@@ -31,9 +31,10 @@ static inline int rt_mutex_getprio(struct task_struct *p) + return p->normal_prio; + } + +-static inline int rt_mutex_check_prio(struct task_struct *task, int newprio) ++static inline int rt_mutex_get_effective_prio(struct task_struct *task, ++ int newprio) + { +- return 0; ++ return newprio; + } + + static inline struct task_struct *rt_mutex_get_top_task(struct task_struct *task) +diff --git a/include/linux/tty.h b/include/linux/tty.h +index 358a337af598..790752ac074a 100644 +--- a/include/linux/tty.h ++++ b/include/linux/tty.h +@@ -339,6 +339,7 @@ struct tty_file_private { + #define TTY_EXCLUSIVE 3 /* Exclusive open mode */ + #define TTY_DEBUG 4 /* Debugging */ + #define TTY_DO_WRITE_WAKEUP 5 /* Call write_wakeup after queuing new */ ++#define TTY_OTHER_DONE 6 /* Closed pty has completed input processing */ + #define TTY_LDISC_OPEN 11 /* Line discipline is open */ + #define TTY_PTY_LOCK 16 /* pty private */ + #define TTY_NO_WRITE_SPLIT 17 /* Preserve write boundaries to driver */ +@@ -462,7 +463,6 @@ extern int tty_hung_up_p(struct file *filp); + extern void do_SAK(struct tty_struct *tty); + extern void __do_SAK(struct tty_struct *tty); + extern void no_tty(void); +-extern void tty_flush_to_ldisc(struct tty_struct *tty); + extern void tty_buffer_free_all(struct tty_port *port); + extern void tty_buffer_flush(struct tty_struct *tty, struct tty_ldisc *ld); + extern void tty_buffer_init(struct tty_port *port); +diff --git a/include/xen/events.h b/include/xen/events.h +index 5321cd9636e6..7d95fdf9cf3e 100644 +--- a/include/xen/events.h ++++ b/include/xen/events.h +@@ -17,7 +17,7 @@ int bind_evtchn_to_irqhandler(unsigned int evtchn, + irq_handler_t handler, + unsigned long irqflags, const char *devname, + void *dev_id); +-int bind_virq_to_irq(unsigned int virq, unsigned int cpu); ++int bind_virq_to_irq(unsigned int virq, unsigned int cpu, bool percpu); + int bind_virq_to_irqhandler(unsigned int virq, unsigned int cpu, + irq_handler_t handler, + unsigned long irqflags, const char *devname, +diff --git a/kernel/locking/rtmutex.c b/kernel/locking/rtmutex.c +index 6357265a31ad..ce9108c059fb 100644 +--- a/kernel/locking/rtmutex.c ++++ b/kernel/locking/rtmutex.c +@@ -265,15 +265,17 @@ struct task_struct *rt_mutex_get_top_task(struct task_struct *task) + } + + /* +- * Called by sched_setscheduler() to check whether the priority change +- * is overruled by a possible priority boosting. ++ * Called by sched_setscheduler() to get the priority which will be ++ * effective after the change. + */ +-int rt_mutex_check_prio(struct task_struct *task, int newprio) ++int rt_mutex_get_effective_prio(struct task_struct *task, int newprio) + { + if (!task_has_pi_waiters(task)) +- return 0; ++ return newprio; + +- return task_top_pi_waiter(task)->task->prio <= newprio; ++ if (task_top_pi_waiter(task)->task->prio <= newprio) ++ return task_top_pi_waiter(task)->task->prio; ++ return newprio; + } + + /* +diff --git a/kernel/module.c b/kernel/module.c +index ec53f594e9c9..538794ce3cc7 100644 +--- a/kernel/module.c ++++ b/kernel/module.c +@@ -3366,6 +3366,9 @@ static int load_module(struct load_info *info, const char __user *uargs, + module_bug_cleanup(mod); + mutex_unlock(&module_mutex); + ++ blocking_notifier_call_chain(&module_notify_list, ++ MODULE_STATE_GOING, mod); ++ + /* we can't deallocate the module until we clear memory protection */ + unset_module_init_ro_nx(mod); + unset_module_core_ro_nx(mod); +diff --git a/kernel/sched/core.c b/kernel/sched/core.c +index 3d5f6f6d14c2..f4da2cbbfd7f 100644 +--- a/kernel/sched/core.c ++++ b/kernel/sched/core.c +@@ -3295,15 +3295,18 @@ static void __setscheduler_params(struct task_struct *p, + + /* Actually do priority change: must hold pi & rq lock. */ + static void __setscheduler(struct rq *rq, struct task_struct *p, +- const struct sched_attr *attr) ++ const struct sched_attr *attr, bool keep_boost) + { + __setscheduler_params(p, attr); + + /* +- * If we get here, there was no pi waiters boosting the +- * task. It is safe to use the normal prio. ++ * Keep a potential priority boosting if called from ++ * sched_setscheduler(). + */ +- p->prio = normal_prio(p); ++ if (keep_boost) ++ p->prio = rt_mutex_get_effective_prio(p, normal_prio(p)); ++ else ++ p->prio = normal_prio(p); + + if (dl_prio(p->prio)) + p->sched_class = &dl_sched_class; +@@ -3403,7 +3406,7 @@ static int __sched_setscheduler(struct task_struct *p, + int newprio = dl_policy(attr->sched_policy) ? MAX_DL_PRIO - 1 : + MAX_RT_PRIO - 1 - attr->sched_priority; + int retval, oldprio, oldpolicy = -1, queued, running; +- int policy = attr->sched_policy; ++ int new_effective_prio, policy = attr->sched_policy; + unsigned long flags; + const struct sched_class *prev_class; + struct rq *rq; +@@ -3585,15 +3588,14 @@ change: + oldprio = p->prio; + + /* +- * Special case for priority boosted tasks. +- * +- * If the new priority is lower or equal (user space view) +- * than the current (boosted) priority, we just store the new ++ * Take priority boosted tasks into account. If the new ++ * effective priority is unchanged, we just store the new + * normal parameters and do not touch the scheduler class and + * the runqueue. This will be done when the task deboost + * itself. + */ +- if (rt_mutex_check_prio(p, newprio)) { ++ new_effective_prio = rt_mutex_get_effective_prio(p, newprio); ++ if (new_effective_prio == oldprio) { + __setscheduler_params(p, attr); + task_rq_unlock(rq, p, &flags); + return 0; +@@ -3607,7 +3609,7 @@ change: + put_prev_task(rq, p); + + prev_class = p->sched_class; +- __setscheduler(rq, p, attr); ++ __setscheduler(rq, p, attr, true); + + if (running) + p->sched_class->set_curr_task(rq); +@@ -4382,10 +4384,7 @@ long __sched io_schedule_timeout(long timeout) + long ret; + + current->in_iowait = 1; +- if (old_iowait) +- blk_schedule_flush_plug(current); +- else +- blk_flush_plug(current); ++ blk_schedule_flush_plug(current); + + delayacct_blkio_start(); + rq = raw_rq(); +@@ -7357,7 +7356,7 @@ static void normalize_task(struct rq *rq, struct task_struct *p) + queued = task_on_rq_queued(p); + if (queued) + dequeue_task(rq, p, 0); +- __setscheduler(rq, p, &attr); ++ __setscheduler(rq, p, &attr, false); + if (queued) { + enqueue_task(rq, p, 0); + resched_curr(rq); +diff --git a/kernel/time/hrtimer.c b/kernel/time/hrtimer.c +index bee0c1f78091..38f586c076fe 100644 +--- a/kernel/time/hrtimer.c ++++ b/kernel/time/hrtimer.c +@@ -266,21 +266,23 @@ lock_hrtimer_base(const struct hrtimer *timer, unsigned long *flags) + /* + * Divide a ktime value by a nanosecond value + */ +-u64 __ktime_divns(const ktime_t kt, s64 div) ++s64 __ktime_divns(const ktime_t kt, s64 div) + { +- u64 dclc; + int sft = 0; ++ s64 dclc; ++ u64 tmp; + + dclc = ktime_to_ns(kt); ++ tmp = dclc < 0 ? -dclc : dclc; ++ + /* Make sure the divisor is less than 2^32: */ + while (div >> 32) { + sft++; + div >>= 1; + } +- dclc >>= sft; +- do_div(dclc, (unsigned long) div); +- +- return dclc; ++ tmp >>= sft; ++ do_div(tmp, (unsigned long) div); ++ return dclc < 0 ? -tmp : tmp; + } + EXPORT_SYMBOL_GPL(__ktime_divns); + #endif /* BITS_PER_LONG >= 64 */ +diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c +index a28df5206d95..11649615c505 100644 +--- a/lib/strnlen_user.c ++++ b/lib/strnlen_user.c +@@ -57,7 +57,8 @@ static inline long do_strnlen_user(const char __user *src, unsigned long count, + return res + find_zero(data) + 1 - align; + } + res += sizeof(unsigned long); +- if (unlikely(max < sizeof(unsigned long))) ++ /* We already handled 'unsigned long' bytes. Did we do it all ? */ ++ if (unlikely(max <= sizeof(unsigned long))) + break; + max -= sizeof(unsigned long); + if (unlikely(__get_user(c,(unsigned long __user *)(src+res)))) +diff --git a/mm/kmemleak.c b/mm/kmemleak.c +index 5405aff5a590..f0fe4f2c1fa7 100644 +--- a/mm/kmemleak.c ++++ b/mm/kmemleak.c +@@ -115,7 +115,8 @@ + #define BYTES_PER_POINTER sizeof(void *) + + /* GFP bitmask for kmemleak internal allocations */ +-#define gfp_kmemleak_mask(gfp) (((gfp) & (GFP_KERNEL | GFP_ATOMIC)) | \ ++#define gfp_kmemleak_mask(gfp) (((gfp) & (GFP_KERNEL | GFP_ATOMIC | \ ++ __GFP_NOACCOUNT)) | \ + __GFP_NORETRY | __GFP_NOMEMALLOC | \ + __GFP_NOWARN) + +diff --git a/mm/mempolicy.c b/mm/mempolicy.c +index de5dc5e12691..0f7d73b3e4b1 100644 +--- a/mm/mempolicy.c ++++ b/mm/mempolicy.c +@@ -2517,7 +2517,7 @@ static void __init check_numabalancing_enable(void) + if (numabalancing_override) + set_numabalancing_state(numabalancing_override == 1); + +- if (nr_node_ids > 1 && !numabalancing_override) { ++ if (num_online_nodes() > 1 && !numabalancing_override) { + pr_info("%s automatic NUMA balancing. " + "Configure with numa_balancing= or the " + "kernel.numa_balancing sysctl", +diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c +index 41a4abc7e98e..c4ec9239249a 100644 +--- a/net/ceph/osd_client.c ++++ b/net/ceph/osd_client.c +@@ -1306,8 +1306,6 @@ static void __unregister_linger_request(struct ceph_osd_client *osdc, + if (list_empty(&req->r_osd_item)) + req->r_osd = NULL; + } +- +- list_del_init(&req->r_req_lru_item); /* can be on notarget */ + ceph_osdc_put_request(req); + } + +@@ -2017,20 +2015,29 @@ static void kick_requests(struct ceph_osd_client *osdc, bool force_resend, + err = __map_request(osdc, req, + force_resend || force_resend_writes); + dout("__map_request returned %d\n", err); +- if (err == 0) +- continue; /* no change and no osd was specified */ + if (err < 0) + continue; /* hrm! */ +- if (req->r_osd == NULL) { +- dout("tid %llu maps to no valid osd\n", req->r_tid); +- needmap++; /* request a newer map */ +- continue; +- } ++ if (req->r_osd == NULL || err > 0) { ++ if (req->r_osd == NULL) { ++ dout("lingering %p tid %llu maps to no osd\n", ++ req, req->r_tid); ++ /* ++ * A homeless lingering request makes ++ * no sense, as it's job is to keep ++ * a particular OSD connection open. ++ * Request a newer map and kick the ++ * request, knowing that it won't be ++ * resent until we actually get a map ++ * that can tell us where to send it. ++ */ ++ needmap++; ++ } + +- dout("kicking lingering %p tid %llu osd%d\n", req, req->r_tid, +- req->r_osd ? req->r_osd->o_osd : -1); +- __register_request(osdc, req); +- __unregister_linger_request(osdc, req); ++ dout("kicking lingering %p tid %llu osd%d\n", req, ++ req->r_tid, req->r_osd ? req->r_osd->o_osd : -1); ++ __register_request(osdc, req); ++ __unregister_linger_request(osdc, req); ++ } + } + reset_changed_osds(osdc); + mutex_unlock(&osdc->request_mutex); +diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h +index 8d53d65bd2ab..81e8dc5cb7f9 100644 +--- a/net/mac80211/ieee80211_i.h ++++ b/net/mac80211/ieee80211_i.h +@@ -204,6 +204,8 @@ enum ieee80211_packet_rx_flags { + * @IEEE80211_RX_CMNTR: received on cooked monitor already + * @IEEE80211_RX_BEACON_REPORTED: This frame was already reported + * to cfg80211_report_obss_beacon(). ++ * @IEEE80211_RX_REORDER_TIMER: this frame is released by the ++ * reorder buffer timeout timer, not the normal RX path + * + * These flags are used across handling multiple interfaces + * for a single frame. +@@ -211,6 +213,7 @@ enum ieee80211_packet_rx_flags { + enum ieee80211_rx_flags { + IEEE80211_RX_CMNTR = BIT(0), + IEEE80211_RX_BEACON_REPORTED = BIT(1), ++ IEEE80211_RX_REORDER_TIMER = BIT(2), + }; + + struct ieee80211_rx_data { +diff --git a/net/mac80211/rx.c b/net/mac80211/rx.c +index 1eb730bf8752..4c887d053333 100644 +--- a/net/mac80211/rx.c ++++ b/net/mac80211/rx.c +@@ -2106,7 +2106,8 @@ ieee80211_deliver_skb(struct ieee80211_rx_data *rx) + /* deliver to local stack */ + skb->protocol = eth_type_trans(skb, dev); + memset(skb->cb, 0, sizeof(skb->cb)); +- if (rx->local->napi) ++ if (!(rx->flags & IEEE80211_RX_REORDER_TIMER) && ++ rx->local->napi) + napi_gro_receive(rx->local->napi, skb); + else + netif_receive_skb(skb); +@@ -3215,7 +3216,7 @@ void ieee80211_release_reorder_timeout(struct sta_info *sta, int tid) + /* This is OK -- must be QoS data frame */ + .security_idx = tid, + .seqno_idx = tid, +- .flags = 0, ++ .flags = IEEE80211_RX_REORDER_TIMER, + }; + struct tid_ampdu_rx *tid_agg_rx; + +diff --git a/net/mac80211/wep.c b/net/mac80211/wep.c +index a4220e92f0cc..efa3f48f1ec5 100644 +--- a/net/mac80211/wep.c ++++ b/net/mac80211/wep.c +@@ -98,8 +98,7 @@ static u8 *ieee80211_wep_add_iv(struct ieee80211_local *local, + + hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PROTECTED); + +- if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN || +- skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) ++ if (WARN_ON(skb_headroom(skb) < IEEE80211_WEP_IV_LEN)) + return NULL; + + hdrlen = ieee80211_hdrlen(hdr->frame_control); +@@ -167,6 +166,9 @@ int ieee80211_wep_encrypt(struct ieee80211_local *local, + size_t len; + u8 rc4key[3 + WLAN_KEY_LEN_WEP104]; + ++ if (WARN_ON(skb_tailroom(skb) < IEEE80211_WEP_ICV_LEN)) ++ return -1; ++ + iv = ieee80211_wep_add_iv(local, skb, keylen, keyidx); + if (!iv) + return -1; +diff --git a/net/sunrpc/auth_gss/gss_rpc_xdr.c b/net/sunrpc/auth_gss/gss_rpc_xdr.c +index 1ec19f6f0c2b..eeeba5adee6d 100644 +--- a/net/sunrpc/auth_gss/gss_rpc_xdr.c ++++ b/net/sunrpc/auth_gss/gss_rpc_xdr.c +@@ -793,20 +793,26 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, + { + u32 value_follows; + int err; ++ struct page *scratch; ++ ++ scratch = alloc_page(GFP_KERNEL); ++ if (!scratch) ++ return -ENOMEM; ++ xdr_set_scratch_buffer(xdr, page_address(scratch), PAGE_SIZE); + + /* res->status */ + err = gssx_dec_status(xdr, &res->status); + if (err) +- return err; ++ goto out_free; + + /* res->context_handle */ + err = gssx_dec_bool(xdr, &value_follows); + if (err) +- return err; ++ goto out_free; + if (value_follows) { + err = gssx_dec_ctx(xdr, res->context_handle); + if (err) +- return err; ++ goto out_free; + } else { + res->context_handle = NULL; + } +@@ -814,11 +820,11 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, + /* res->output_token */ + err = gssx_dec_bool(xdr, &value_follows); + if (err) +- return err; ++ goto out_free; + if (value_follows) { + err = gssx_dec_buffer(xdr, res->output_token); + if (err) +- return err; ++ goto out_free; + } else { + res->output_token = NULL; + } +@@ -826,14 +832,17 @@ int gssx_dec_accept_sec_context(struct rpc_rqst *rqstp, + /* res->delegated_cred_handle */ + err = gssx_dec_bool(xdr, &value_follows); + if (err) +- return err; ++ goto out_free; + if (value_follows) { + /* we do not support upcall servers sending this data. */ +- return -EINVAL; ++ err = -EINVAL; ++ goto out_free; + } + + /* res->options */ + err = gssx_dec_option_array(xdr, &res->options); + ++out_free: ++ __free_page(scratch); + return err; + } +diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c +index a8a1e14272a1..a002a6d1e6da 100644 +--- a/sound/pci/hda/hda_intel.c ++++ b/sound/pci/hda/hda_intel.c +@@ -2108,6 +2108,8 @@ static const struct pci_device_id azx_ids[] = { + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + { PCI_DEVICE(0x1002, 0xaab0), + .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, ++ { PCI_DEVICE(0x1002, 0xaac8), ++ .driver_data = AZX_DRIVER_ATIHDMI_NS | AZX_DCAPS_PRESET_ATI_HDMI_NS }, + /* VIA VT8251/VT8237A */ + { PCI_DEVICE(0x1106, 0x3288), + .driver_data = AZX_DRIVER_VIA | AZX_DCAPS_POSFIX_VIA }, +diff --git a/sound/pci/hda/patch_conexant.c b/sound/pci/hda/patch_conexant.c +index da67ea8645a6..e27298bdcd6d 100644 +--- a/sound/pci/hda/patch_conexant.c ++++ b/sound/pci/hda/patch_conexant.c +@@ -973,6 +973,14 @@ static const struct hda_codec_preset snd_hda_preset_conexant[] = { + .patch = patch_conexant_auto }, + { .id = 0x14f150b9, .name = "CX20665", + .patch = patch_conexant_auto }, ++ { .id = 0x14f150f1, .name = "CX20721", ++ .patch = patch_conexant_auto }, ++ { .id = 0x14f150f2, .name = "CX20722", ++ .patch = patch_conexant_auto }, ++ { .id = 0x14f150f3, .name = "CX20723", ++ .patch = patch_conexant_auto }, ++ { .id = 0x14f150f4, .name = "CX20724", ++ .patch = patch_conexant_auto }, + { .id = 0x14f1510f, .name = "CX20751/2", + .patch = patch_conexant_auto }, + { .id = 0x14f15110, .name = "CX20751/2", +@@ -1007,6 +1015,10 @@ MODULE_ALIAS("snd-hda-codec-id:14f150ab"); + MODULE_ALIAS("snd-hda-codec-id:14f150ac"); + MODULE_ALIAS("snd-hda-codec-id:14f150b8"); + MODULE_ALIAS("snd-hda-codec-id:14f150b9"); ++MODULE_ALIAS("snd-hda-codec-id:14f150f1"); ++MODULE_ALIAS("snd-hda-codec-id:14f150f2"); ++MODULE_ALIAS("snd-hda-codec-id:14f150f3"); ++MODULE_ALIAS("snd-hda-codec-id:14f150f4"); + MODULE_ALIAS("snd-hda-codec-id:14f1510f"); + MODULE_ALIAS("snd-hda-codec-id:14f15110"); + MODULE_ALIAS("snd-hda-codec-id:14f15111"); +diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c +index 2fd490b1764b..93c78c3c4b95 100644 +--- a/sound/pci/hda/patch_realtek.c ++++ b/sound/pci/hda/patch_realtek.c +@@ -5027,6 +5027,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x104d, 0x9099, "Sony VAIO S13", ALC275_FIXUP_SONY_DISABLE_AAMIX), + SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK), + SND_PCI_QUIRK(0x10cf, 0x15dc, "Lifebook T731", ALC269_FIXUP_LIFEBOOK_HP_PIN), ++ SND_PCI_QUIRK(0x10cf, 0x1757, "Lifebook E752", ALC269_FIXUP_LIFEBOOK_HP_PIN), + SND_PCI_QUIRK(0x10cf, 0x1845, "Lifebook U904", ALC269_FIXUP_LIFEBOOK_EXTMIC), + SND_PCI_QUIRK(0x144d, 0xc109, "Samsung Ativ book 9 (NP900X3G)", ALC269_FIXUP_INV_DMIC), + SND_PCI_QUIRK(0x1458, 0xfa53, "Gigabyte BXBT-2807", ALC283_FIXUP_BXBT2807_MIC), +@@ -5056,6 +5057,7 @@ static const struct snd_pci_quirk alc269_fixup_tbl[] = { + SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), + SND_PCI_QUIRK(0x17aa, 0x5034, "Thinkpad T450", ALC292_FIXUP_TPT440_DOCK), + SND_PCI_QUIRK(0x17aa, 0x5036, "Thinkpad T450s", ALC292_FIXUP_TPT440_DOCK), ++ SND_PCI_QUIRK(0x17aa, 0x503c, "Thinkpad L450", ALC292_FIXUP_TPT440_DOCK), + SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST), + SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K), + SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD), +@@ -5246,6 +5248,13 @@ static const struct snd_hda_pin_quirk alc269_pin_fixup_tbl[] = { + {0x17, 0x40000000}, + {0x1d, 0x40700001}, + {0x21, 0x02211050}), ++ SND_HDA_PIN_QUIRK(0x10ec0255, 0x1028, "Dell Inspiron 5548", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, ++ ALC255_STANDARD_PINS, ++ {0x12, 0x90a60180}, ++ {0x14, 0x90170130}, ++ {0x17, 0x40000000}, ++ {0x1d, 0x40700001}, ++ {0x21, 0x02211040}), + SND_HDA_PIN_QUIRK(0x10ec0256, 0x1028, "Dell", ALC255_FIXUP_DELL1_MIC_NO_PRESENCE, + ALC256_STANDARD_PINS, + {0x13, 0x40000000}), +diff --git a/sound/pci/hda/thinkpad_helper.c b/sound/pci/hda/thinkpad_helper.c +index 2341fc334163..6ba0b5517c40 100644 +--- a/sound/pci/hda/thinkpad_helper.c ++++ b/sound/pci/hda/thinkpad_helper.c +@@ -72,7 +72,6 @@ static void hda_fixup_thinkpad_acpi(struct hda_codec *codec, + if (led_set_func(TPACPI_LED_MUTE, false) >= 0) { + old_vmaster_hook = spec->vmaster_mute.hook; + spec->vmaster_mute.hook = update_tpacpi_mute_led; +- spec->vmaster_mute_enum = 1; + removefunc = false; + } + if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) { +diff --git a/sound/soc/codecs/mc13783.c b/sound/soc/codecs/mc13783.c +index 2ffb9a0570dc..3d44fc50e4d0 100644 +--- a/sound/soc/codecs/mc13783.c ++++ b/sound/soc/codecs/mc13783.c +@@ -623,14 +623,14 @@ static int mc13783_probe(struct snd_soc_codec *codec) + AUDIO_SSI_SEL, 0); + else + mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_CODEC, +- 0, AUDIO_SSI_SEL); ++ AUDIO_SSI_SEL, AUDIO_SSI_SEL); + + if (priv->dac_ssi_port == MC13783_SSI1_PORT) + mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC, + AUDIO_SSI_SEL, 0); + else + mc13xxx_reg_rmw(priv->mc13xxx, MC13783_AUDIO_DAC, +- 0, AUDIO_SSI_SEL); ++ AUDIO_SSI_SEL, AUDIO_SSI_SEL); + + return 0; + } +diff --git a/sound/soc/codecs/uda1380.c b/sound/soc/codecs/uda1380.c +index dc7778b6dd7f..c3c33bd0df1c 100644 +--- a/sound/soc/codecs/uda1380.c ++++ b/sound/soc/codecs/uda1380.c +@@ -437,7 +437,7 @@ static int uda1380_set_dai_fmt_both(struct snd_soc_dai *codec_dai, + if ((fmt & SND_SOC_DAIFMT_MASTER_MASK) != SND_SOC_DAIFMT_CBS_CFS) + return -EINVAL; + +- uda1380_write(codec, UDA1380_IFACE, iface); ++ uda1380_write_reg_cache(codec, UDA1380_IFACE, iface); + + return 0; + } +diff --git a/sound/soc/codecs/wm8960.c b/sound/soc/codecs/wm8960.c +index 3035d9856415..e97a7615df85 100644 +--- a/sound/soc/codecs/wm8960.c ++++ b/sound/soc/codecs/wm8960.c +@@ -395,7 +395,7 @@ static const struct snd_soc_dapm_route audio_paths[] = { + { "Right Input Mixer", "Boost Switch", "Right Boost Mixer", }, + { "Right Input Mixer", NULL, "RINPUT1", }, /* Really Boost Switch */ + { "Right Input Mixer", NULL, "RINPUT2" }, +- { "Right Input Mixer", NULL, "LINPUT3" }, ++ { "Right Input Mixer", NULL, "RINPUT3" }, + + { "Left ADC", NULL, "Left Input Mixer" }, + { "Right ADC", NULL, "Right Input Mixer" }, +diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c +index 4fbc7689339a..a1c04dab6684 100644 +--- a/sound/soc/codecs/wm8994.c ++++ b/sound/soc/codecs/wm8994.c +@@ -2754,7 +2754,7 @@ static struct { + }; + + static int fs_ratios[] = { +- 64, 128, 192, 256, 348, 512, 768, 1024, 1408, 1536 ++ 64, 128, 192, 256, 384, 512, 768, 1024, 1408, 1536 + }; + + static int bclk_divs[] = { +diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c +index b6f88202b8c9..e19a6765bd8a 100644 +--- a/sound/soc/soc-dapm.c ++++ b/sound/soc/soc-dapm.c +@@ -3074,11 +3074,16 @@ snd_soc_dapm_new_control(struct snd_soc_dapm_context *dapm, + } + + prefix = soc_dapm_prefix(dapm); +- if (prefix) ++ if (prefix) { + w->name = kasprintf(GFP_KERNEL, "%s %s", prefix, widget->name); +- else ++ if (widget->sname) ++ w->sname = kasprintf(GFP_KERNEL, "%s %s", prefix, ++ widget->sname); ++ } else { + w->name = kasprintf(GFP_KERNEL, "%s", widget->name); +- ++ if (widget->sname) ++ w->sname = kasprintf(GFP_KERNEL, "%s", widget->sname); ++ } + if (w->name == NULL) { + kfree(w); + return NULL; +diff --git a/sound/usb/quirks.c b/sound/usb/quirks.c +index 32631a86078b..e21ec5abcc3a 100644 +--- a/sound/usb/quirks.c ++++ b/sound/usb/quirks.c +@@ -1117,6 +1117,8 @@ bool snd_usb_get_sample_rate_quirk(struct snd_usb_audio *chip) + switch (chip->usb_id) { + case USB_ID(0x045E, 0x075D): /* MS Lifecam Cinema */ + case USB_ID(0x045E, 0x076D): /* MS Lifecam HD-5000 */ ++ case USB_ID(0x045E, 0x0772): /* MS Lifecam Studio */ ++ case USB_ID(0x045E, 0x0779): /* MS Lifecam HD-3000 */ + case USB_ID(0x04D8, 0xFEEA): /* Benchmark DAC1 Pre */ + return true; + } +diff --git a/tools/vm/Makefile b/tools/vm/Makefile +index ac884b65a072..93aadaf7ff63 100644 +--- a/tools/vm/Makefile ++++ b/tools/vm/Makefile +@@ -3,7 +3,7 @@ + TARGETS=page-types slabinfo page_owner_sort + + LIB_DIR = ../lib/api +-LIBS = $(LIB_DIR)/libapikfs.a ++LIBS = $(LIB_DIR)/libapi.a + + CC = $(CROSS_COMPILE)gcc + CFLAGS = -Wall -Wextra -I../lib/ |