3.16.4-stable review
Subsystems (2)
Greg Kroah-Hartman
maintainerPATCH 186/357 ARM: 8149/1: perf: Dont sleep while atomic when enabling per-cpu interrupts
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit 505013bc9065391f09a51d51cd3bf0b06dfb570a upstream.
Rob Clark reports a sleeping while atomic bug when using perf.
BUG: sleeping function called from invalid context at ../kernel/locking/mutex.c:583 in_atomic(): 1, irqs_disabled(): 128, pid: 0, name: swapper/0 ------------[ cut here ]------------ WARNING: CPU: 2 PID: 4828 at ../kernel/locking/mutex.c:479 mutex_lock_nested+0x3a0/0x3e8() DEBUG_LOCKS_WARN_ON(in_interrupt()) Modules linked in: CPU: 2 PID: 4828 Comm: Xorg.bin Tainted: G W 3.17.0-rc3-00234-gd535c45-dirty #819 [<c0216690>] (unwind_backtrace) from [<c0212174>] (show_stack+0x10/0x14) [<c0212174>] (show_stack) from [<c0867cc0>] (dump_stack+0x98/0xb8) [<c0867cc0>] (dump_stack) from [<c02492a4>] (warn_slowpath_common+0x70/0x8c) [<c02492a4>] (warn_slowpath_common) from [<c02492f0>] (warn_slowpath_fmt+0x30/0x40) [<c02492f0>] (warn_slowpath_fmt) from [<c086a3f8>] (mutex_lock_nested+0x3a0/0x3e8) [<c086a3f8>] (mutex_lock_nested) from [<c0294d08>] (irq_find_host+0x20/0x9c) [<c0294d08>] (irq_find_host) from [<c0769d50>] (of_irq_get+0x28/0x48) [<c0769d50>] (of_irq_get) from [<c057d104>] (platform_get_irq+0x1c/0x8c) [<c057d104>] (platform_get_irq) from [<c021a06c>] (cpu_pmu_enable_percpu_irq+0x14/0x38) [<c021a06c>] (cpu_pmu_enable_percpu_irq) from [<c02b1634>] (flush_smp_call_function_queue+0x88/0x178) [<c02b1634>] (flush_smp_call_function_queue) from [<c0214dc0>] (handle_IPI+0x88/0x160) [<c0214dc0>] (handle_IPI) from [<c0208930>] (gic_handle_irq+0x64/0x68) [<c0208930>] (gic_handle_irq) from [<c0212d04>] (__irq_svc+0x44/0x5c) Exception stack(0xe63ddea0 to 0xe63ddee8)
dea0: 00000001 00000001 00000000 c2f3b200 c16db380 c032d4a0 e63ddf40 60010013
dec0: 00000000 001fbfd4 00000100 00000000 00000001 e63ddee8 c0284770 c02a2e30
dee0: 20010013 ffffffff
[<c0212d04>] (__irq_svc) from [<c02a2e30>] (ktime_get_ts64+0x1c8/0x200) [<c02a2e30>] (ktime_get_ts64) from [<c032d4a0>] (poll_select_set_timeout+0x60/0xa8) [<c032d4a0>] (poll_select_set_timeout) from [<c032df64>] (SyS_select+0xa8/0x118) [<c032df64>] (SyS_select) from [<c020e8e0>] (ret_fast_syscall+0x0/0x48)
---[ end trace 0bb583b46342da6f ]---
INFO: lockdep is turned off.
We don't really need to get the platform irq again when we're enabling or disabling the per-cpu irq. Furthermore, we don't really need to set and clear bits in the active_irqs bitmask because that's only used in the non-percpu irq case to figure out when the last CPU PMU has been disabled. Just pass the irq directly to the enable/disable functions to clean all this up. This should be slightly more efficient and also fix the scheduling while atomic bug.
--- arch/arm/kernel/perf_event_cpu.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)
arch/arm/kernel/perf_event_cpu.c +4 -10
@@ -76,21 +76,15 @@ static struct pmu_hw_events *cpu_pmu_getstatic void cpu_pmu_enable_percpu_irq (void *data) { -struct arm_pmu *cpu_pmu = data; -struct platform_device *pmu_device = cpu_pmu->plat_device; -int irq =platform_get_irq (pmu_device,0 ); +int irq = *(int *)data;enable_percpu_irq (irq,IRQ_TYPE_NONE ); -cpumask_set_cpu (smp_processor_id (), &cpu_pmu->active_irqs); }static void cpu_pmu_disable_percpu_irq (void *data) { -struct arm_pmu *cpu_pmu = data; -struct platform_device *pmu_device = cpu_pmu->plat_device; -int irq =platform_get_irq (pmu_device,0 ); +int irq = *(int *)data; -cpumask_clear_cpu (smp_processor_id (), &cpu_pmu->active_irqs);disable_percpu_irq (irq); }
@@ -103,7 +97,7 @@ static void cpu_pmu_free_irq(struct arm_ irq =platform_get_irq (pmu_device,0 );if (irq >=0 &&irq_is_percpu (irq)) { -on_each_cpu (cpu_pmu_disable_percpu_irq, cpu_pmu,1 ); +on_each_cpu (cpu_pmu_disable_percpu_irq, &irq,1 );free_percpu_irq (irq, &percpu_pmu); }else {for (i =0 ; i < irqs; ++i) {
@@ -138,7 +132,7 @@ static int cpu_pmu_request_irq(struct ar irq);return err; } -on_each_cpu (cpu_pmu_enable_percpu_irq, cpu_pmu,1 ); +on_each_cpu (cpu_pmu_enable_percpu_irq, &irq,1 ); }else {for (i =0 ; i < irqs; ++i) { err =0 ;
Greg Kroah-Hartman
maintainerPATCH 187/357 ARM: dts: dra7-evm: Fix NAND GPMC timings
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Roger Quadros <[email protected]>
commit 5990047cef0c6a36eefcb166bd32d99a8f95c75b upstream.
The nand timings were scaled down by 2 to account for the 2x rate returned by clk_get_rate(gpmc_fclk).
As the clock data got fixed by [1], revert back to actual timings (i.e. scale them up by 2).
Without this NAND doesn't work on dra7-evm.
[1] - commit dd94324b983afe114ba9e7ee3649313b451f63ce
ARM: dts: dra7xx-clocks: Fix the l3 and l4 clock rates
--- arch/arm/boot/dts/dra7-evm.dts | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-)
arch/arm/boot/dts/dra7-evm.dts +12 -15
@@ -427,22 +427,19 @@ gpmc,device-width = <2>; gpmc,sync-clk-ps = <0>; gpmc,cs-on-ns = <0>; - gpmc,cs-rd-off-ns = <40>; - gpmc,cs-wr-off-ns = <40>; + gpmc,cs-rd-off-ns = <80>; + gpmc,cs-wr-off-ns = <80>; gpmc,adv-on-ns = <0>; - gpmc,adv-rd-off-ns = <30>; - gpmc,adv-wr-off-ns = <30>; - gpmc,we-on-ns = <5>; - gpmc,we-off-ns = <25>; - gpmc,oe-on-ns = <2>; - gpmc,oe-off-ns = <20>; - gpmc,access-ns = <20>; - gpmc,wr-access-ns = <40>; - gpmc,rd-cycle-ns = <40>; - gpmc,wr-cycle-ns = <40>; - gpmc,wait-pin = <0>; - gpmc,wait-on-read; - gpmc,wait-on-write; + gpmc,adv-rd-off-ns = <60>; + gpmc,adv-wr-off-ns = <60>; + gpmc,we-on-ns = <10>; + gpmc,we-off-ns = <50>; + gpmc,oe-on-ns = <4>; + gpmc,oe-off-ns = <40>; + gpmc,access-ns = <40>; + gpmc,wr-access-ns = <80>; + gpmc,rd-cycle-ns = <80>; + gpmc,wr-cycle-ns = <80>; gpmc,bus-turnaround-ns = <0>; gpmc,cycle2cycle-delay-ns = <0>; gpmc,clk-activation-ns = <0>;
Greg Kroah-Hartman
maintainerPATCH 188/357 ARM: DT: imx53: fix lvds channel 1 port
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markus Niebel <[email protected]>
commit 1b134c9c4b555342be667f144ee714af1c3f6a9f upstream.
using LVDS channel 1 on an i.MX53 leads to following error:
imx-ldb 53fa8008.ldb: unable to set di0 parent clock to ldb_di1
This comes from imx_ldb_set_clock with mux = 0. Mux parameter must be "1" for reparenting di1 clock to ldb_di1. The value of the mux param comes from device tree port settings.
On i.MX5, the internal two-input-multiplexer is used. Due to hardware limitations, only one port (port@[0,1]) can be used for each channel (lvds-channel@[0,1], respectively)
Documentation update suggested by Philipp Zabel <[email protected]>
--- Documentation/devicetree/bindings/staging/imx-drm/ldb.txt | 15 ++++++++++++-- arch/arm/boot/dts/imx53.dtsi | 12 +++++++++-- 2 files changed, 23 insertions(+), 4 deletions(-)
Documentation/devicetree/bindings/staging/imx-drm/ldb.txt +13 -2
@@ -56,6 +56,9 @@ Required properties: - fsl,data-width : should be <18> or <24> - port: A port node with endpoint definitions as defined in Documentation/devicetree/bindings/media/video-interfaces.txt. + On i.MX5, the internal two-input-multiplexer is used. + Due to hardware limitations, only one port (port@[0,1]) + can be used for each channel (lvds-channel@[0,1], respectively) On i.MX6, there should be four ports (port@[0-3]) that correspond to the four LVDS multiplexer inputs.
@@ -78,6 +81,8 @@ ldb: ldb@53fa8008 { "di0", "di1"; lvds-channel@0 { + #address-cells = <1>; + #size-cells = <0>; reg = <0>; fsl,data-mapping = "spwg"; fsl,data-width = <24>;
@@ -86,7 +91,9 @@ ldb: ldb@53fa8008 { /* ... */ }; - port { + port@0 { + reg = <0>; + lvds0_in: endpoint { remote-endpoint = <&ipu_di0_lvds0>; };
@@ -94,6 +101,8 @@ ldb: ldb@53fa8008 { }; lvds-channel@1 { + #address-cells = <1>; + #size-cells = <0>; reg = <1>; fsl,data-mapping = "spwg"; fsl,data-width = <24>;
@@ -102,7 +111,9 @@ ldb: ldb@53fa8008 { /* ... */ }; - port { + port@1 { + reg = <1>; + lvds1_in: endpoint { remote-endpoint = <&ipu_di1_lvds1>; };
arch/arm/boot/dts/imx53.dtsi +10 -2
@@ -419,10 +419,14 @@ status = "disabled"; lvds-channel@0 { + #address-cells = <1>; + #size-cells = <0>; reg = <0>; status = "disabled"; - port { + port@0 { + reg = <0>; + lvds0_in: endpoint { remote-endpoint = <&ipu_di0_lvds0>; };
@@ -430,10 +434,14 @@ }; lvds-channel@1 { + #address-cells = <1>; + #size-cells = <0>; reg = <1>; status = "disabled"; - port { + port@1 { + reg = <1>; + lvds1_in: endpoint { remote-endpoint = <&ipu_di1_lvds1>; };
Greg Kroah-Hartman
maintainerPATCH 189/357 ARM: imx: fix .is_enabled() of shared gate clock
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Shawn Guo <[email protected]>
commit 9e1ac462b982f496ed3b491f02c417dcc8e40347 upstream.
Commit 63288b721a80 ("ARM: imx: fix shared gate clock") attempted to fix an issue with particular enable/disable sequence from two shared gate clocks. But unfortunately, while it partially fixed the issue, it also did something wrong in .is_enabled() function hook. In case of shared gate, the function shouldn't really query the hardware state via share_count, because the function is trying to query the enabling state of the clock in question, not the hardware state which is shared by multiple clocks.
Fix the issue by returning the enable_count of the clock itself which is maintained by clock core, in case it's a clock sharing hardware gate with others. As the result, the initialization of share_count per hardware state is not needed now. So remove it.
--- arch/arm/mach-imx/clk-gate2.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
arch/arm/mach-imx/clk-gate2.c +1 -5
@@ -97,7 +97,7 @@ static int clk_gate2_is_enabled(struct cstruct clk_gate2 *gate =to_clk_gate2 (hw);if (gate->share_count) -return !!(*gate->share_count); +return !!__clk_get_enable_count (hw->clk);else return clk_gate2_reg_is_enabled (gate->reg, gate->bit_idx); }
@@ -127,10 +127,6 @@ struct clk *clk_register_gate2(struct de gate->bit_idx = bit_idx; gate->flags = clk_gate2_flags; gate->lock = lock; - -/* Initialize share_count per hardware state */ -if (share_count) - *share_count =clk_gate2_reg_is_enabled (reg, bit_idx) ?1 :0 ; gate->share_count = share_count; init.name = name;
Greg Kroah-Hartman
maintainerPATCH 190/357 ARM: 8165/1: alignment: dont break misaligned NEON load/store
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robin Murphy <[email protected]>
commit 5ca918e5e3f9df4634077c06585c42bc6a8d699a upstream.
The alignment fixup incorrectly decodes faulting ARM VLDn/VSTn instructions (where the optional alignment hint is given but incorrect) as LDR/STR, leading to register corruption. Detect these and correctly treat them as unhandled, so that userspace gets the fault it expects.
--- arch/arm/mm/alignment.c | 3 +++ 1 file changed, 3 insertions(+)
arch/arm/mm/alignment.c +3 -0
@@ -41,6 +41,7 @@* This code is not portable to processors with late data abort handling. */ #define CODING_BITS (i) (i & 0x0e000000) +#define COND_BITS (i) (i & 0xf0000000)#define LDST_I_BIT (i) (i & (1 << 26))/* Immediate constant */ #define LDST_P_BIT (i) (i & (1 << 24))/* Preindex */
@@ -819,6 +820,8 @@ do_alignment(unsigned long addr, unsignebreak ;case 0x04000000 :/* ldr or str immediate */ +if (COND_BITS (instr) ==0xf0000000 )/* NEON VLDn, VSTn */ + goto bad; offset.un =OFFSET_BITS (instr); handler = do_alignment_ldrstr;break ;
Greg Kroah-Hartman
maintainerPATCH 191/357 ARM: 8178/1: fix set_tls for !CONFIG_KUSER_HELPERS
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nathan Lynch <[email protected]>
commit 9cc6d9e5daaa147a9a3e31557efcb331989e77be upstream.
Joachim Eastwood reports that commit fbfb872f5f41 "ARM: 8148/1: flush TLS and thumbee register state during exec" causes a boot-time crash on a Cortex-M4 nommu system:
Freeing unused kernel memory: 68K (281e5000 - 281f6000) Unhandled exception: IPSR = 00000005 LR = fffffff1
CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-rc6-00313-gd2205fa30aa7 #191 task: 29834000 ti: 29832000 task.ti: 29832000 PC is at flush_thread+0x2e/0x40 LR is at flush_thread+0x21/0x40 pc : [<2800954a>] lr : [<2800953d>] psr: 4100000b
sp : 29833d60 ip : 00000000 fp : 00000001
r10: 00003cf8 r9 : 29b1f000 r8 : 00000000
r7 : 29b0bc00 r6 : 29834000 r5 : 29832000 r4 : 29832000 r3 : ffff0ff0 r2 : 29832000 r1 : 00000000 r0 : 282121f0
xPSR: 4100000b
CPU: 0 PID: 1 Comm: swapper Not tainted 3.17.0-rc6-00313-gd2205fa30aa7 #191 [<2800afa5>] (unwind_backtrace) from [<2800a327>] (show_stack+0xb/0xc) [<2800a327>] (show_stack) from [<2800a963>] (__invalid_entry+0x4b/0x4c)
The problem is that set_tls is attempting to clear the TLS location in the kernel-user helper page, which isn't set up on V7M.
Fix this by guarding the write to the kuser helper page with a CONFIG_KUSER_HELPERS ifdef.
--- arch/arm/include/asm/tls.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm/include/asm/tls.h +2 -0
@@ -81,6 +81,7 @@ static inline void set_tls(unsigned long asm("mcr p15, 0, %0, c13, c0, 3" : :"r" (val)); }else { +#ifdef CONFIG_KUSER_HELPERS /* * User space must never try to access this * directly. Expect your app to break
@@ -89,6 +90,7 @@ static inline void set_tls(unsigned long* entry-armv.S for details) */ *((unsigned int *)0xffff0ff0 ) = val; +#endif } }
Greg Kroah-Hartman
maintainerPATCH 192/357 MIPS: ZBOOT: add missing <linux/string.h> include
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aurelien Jarno <[email protected]>
commit 29593fd5a8149462ed6fad0d522234facdaee6c8 upstream.
Commit dc4d7b37 (MIPS: ZBOOT: gather string functions into string.c) moved the string related functions into a separate file, which might cause the following build error, depending on the configuration:
| CC arch/mips/boot/compressed/decompress.o | In file included from linux/arch/mips/boot/compressed/../../../../lib/decompress_unxz.c:234:0, | from linux/arch/mips/boot/compressed/decompress.c:67: | linux/arch/mips/boot/compressed/../../../../lib/xz/xz_dec_stream.c: In function 'fill_temp': | linux/arch/mips/boot/compressed/../../../../lib/xz/xz_dec_stream.c:162:2: error: implicit declaration of function 'memcpy' [-Werror=implicit-function-declaration] | cc1: some warnings being treated as errors | linux/scripts/Makefile.build:308: recipe for target 'arch/mips/boot/compressed/decompress.o' failed | make[6]: *** [arch/mips/boot/compressed/decompress.o] Error 1 | linux/arch/mips/Makefile:308: recipe for target 'vmlinuz' failed
It does not fail with the standard configuration, as when CONFIG_DYNAMIC_DEBUG is not enabled <linux/string.h> gets included in include/linux/dynamic_debug.h. There might be other ways for it to get indirectly included.
We can't add the include directly in xz_dec_stream.c as some architectures might want to use a different version for the boot/ directory (see for example arch/x86/boot/string.h).
Patchwork: https://patchwork.linux-mips.org/patch/7420/
--- arch/mips/boot/compressed/decompress.c | 1 + 1 file changed, 1 insertion(+)
arch/mips/boot/compressed/decompress.c +1 -0
@@ -13,6 +13,7 @@#include <linux/types.h> #include <linux/kernel.h> +#include <linux/string.h> #include <asm/addrspace.h>
Greg Kroah-Hartman
maintainerPATCH 193/357 MIPS: Fix MFC1 & MFHC1 emulation for 64-bit MIPS systems
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Paul Burton <[email protected]>
commit c8c0da6bdf0f0d6f59fc23aab6ee373a131df82d upstream.
Commit bbd426f542cb "MIPS: Simplify FP context access" modified the SIFROMREG & SIFROMHREG macros such that they return unsigned rather than signed 32b integers. I had believed that to be fine, but inadvertently missed the MFC1 & MFHC1 cases which write to a struct pt_regs regs element. On MIPS32 this is fine, but on 64 bit those saved regs' fields are 64 bit wide. Using unsigned values caused the 32 bit value from the FP register to be zero rather than sign extended as the architecture specifies, causing incorrect emulation of the MFC1 & MFHc1 instructions. Fix by reintroducing the casts to signed integers, and therefore the sign extension.
Patchwork: https://patchwork.linux-mips.org/patch/7848/
--- arch/mips/math-emu/cp1emu.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/mips/math-emu/cp1emu.c +3 -3
@@ -650,9 +650,9 @@ static inline int cop1_64bit(struct pt_r#define SIFROMREG (si, x) \ do { \ if (cop1_64bit(xcp)) \ - (si) = get_fpr32(&ctx->fpr[x], 0); \ + (si) = (int)get_fpr32(&ctx->fpr[x], 0); \ else \ - (si) = get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \ + (si) = (int)get_fpr32(&ctx->fpr[(x) & ~1], (x) & 1); \ } while (0)#define SITOREG (si, x) \
@@ -667,7 +667,7 @@ do { \ } \ } while (0) -#define SIFROMHREG (si, x) ((si) = get_fpr32(&ctx->fpr[x], 1)) +#define SIFROMHREG (si, x) ((si) = (int)get_fpr32(&ctx->fpr[x], 1))#define SITOHREG (si, x) \ do { \
Greg Kroah-Hartman
maintainerPATCH 194/357 MIPS: mcount: Adjust stack pointer for static trace in MIPS32
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Markos Chandras <[email protected]>
commit 8a574cfa2652545eb95595d38ac2a0bb501af0ae upstream.
Every mcount() call in the MIPS 32-bit kernel is done as follows:
[...]
move at, ra
jal _mcount
addiu sp, sp, -8
[...]
but upon returning from the mcount() function, the stack pointer is not adjusted properly. This is explained in details in 58b69401c797 (MIPS: Function tracer: Fix broken function tracing).
Commit ad8c396936e3 ("MIPS: Unbreak function tracer for 64-bit kernel.) fixed the stack manipulation for 64-bit but it didn't fix it completely for MIPS32.
Patchwork: https://patchwork.linux-mips.org/patch/7792/
--- arch/mips/kernel/mcount.S | 12 ++++++++++++ 1 file changed, 12 insertions(+)
arch/mips/kernel/mcount.S +12 -0
@@ -123,7 +123,11 @@ NESTED(_mcount, PT_SIZE, ra) nop #endif b ftrace_stub +#ifdef CONFIG_32BIT + addiu sp, sp, 8 +#else nop +#endif static_trace: MCOUNT_SAVE_REGS
@@ -133,6 +137,9 @@ static_trace: move a1, AT /* arg2: parent's return address */ MCOUNT_RESTORE_REGS +#ifdef CONFIG_32BIT + addiu sp, sp, 8 +#endif .globl ftrace_stub ftrace_stub: RETURN_BACK
@@ -177,6 +184,11 @@ NESTED(ftrace_graph_caller, PT_SIZE, ra) jal prepare_ftrace_return nop MCOUNT_RESTORE_REGS +#ifndef CONFIG_DYNAMIC_FTRACE +#ifdef CONFIG_32BIT + addiu sp, sp, 8 +#endif +#endif RETURN_BACK END(ftrace_graph_caller)
Greg Kroah-Hartman
maintainerPATCH 195/357 ACPICA: Update to GPIO region handler interface.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bob Moore <[email protected]>
commit 75ec6e55f1384548311a13ce4fcb39c516053314 upstream.
Changes to correct several GPIO issues:
1) The update_rule in a GPIO field definition is now ignored; a read-modify-write operation is never performed for GPIO fields. (Internally, this means that the field assembly/disassembly code is completely bypassed for GPIO.)
2) The Address parameter passed to a GPIO region handler is now the bit offset of the field from a previous Connection() operator. Thus, it becomes a "Pin Number Index" into the Connection() resource descriptor.
3) The bit_width parameter passed to a GPIO region handler is now the exact bit width of the GPIO field. Thus, it can be interpreted as "number of pins".
Overall, we can now say that the region handler interface to GPIO handlers is a raw "bit/pin" addressed interface, not a byte-addressed interface like the system_memory handler interface.
--- drivers/acpi/acpica/aclocal.h | 1 drivers/acpi/acpica/acobject.h | 1 drivers/acpi/acpica/dsfield.c | 2 + drivers/acpi/acpica/evregion.c | 47 ++++++++++++++++++---------- drivers/acpi/acpica/exfield.c | 67 +++++++++++++++++++++++++++++++++++++++++ drivers/acpi/acpica/exprep.c | 2 + 6 files changed, 104 insertions(+), 16 deletions(-)
drivers/acpi/acpica/aclocal.h +1 -0
@@ -254,6 +254,7 @@ struct acpi_create_field_info {u32 field_bit_position;u32 field_bit_length;u16 resource_length; +u16 pin_number_index;u8 field_flags;u8 attribute;u8 field_type;
drivers/acpi/acpica/acobject.h +1 -0
@@ -264,6 +264,7 @@ struct acpi_object_region_field { ACPI_OBJECT_COMMON_HEADER ACPI_COMMON_FIELD_INFO u16 resource_length;union acpi_operand_object *region_obj;/* Containing op_region object */ u8 *resource_buffer;/* resource_template for serial regions/fields */ +u16 pin_number_index;/* Index relative to previous Connection/Template */ };struct acpi_object_bank_field {
drivers/acpi/acpica/dsfield.c +2 -0
@@ -360,6 +360,7 @@ acpi_ds_get_field_names(struct acpi_crea*/ info->resource_buffer =NULL ; info->connection_node =NULL ; + info->pin_number_index =0 ;/* * A Connection() is either an actual resource descriptor (buffer)
@@ -437,6 +438,7 @@ acpi_ds_get_field_names(struct acpi_crea } info->field_bit_position += info->field_bit_length; + info->pin_number_index++;/* Index relative to previous Connection() */ break ;default :
drivers/acpi/acpica/evregion.c +31 -16
79 lines not on this page · raw message
drivers/acpi/acpica/exfield.c +67 -0
79 lines not on this page · raw message
drivers/acpi/acpica/exprep.c +2 -0
@@ -484,6 +484,8 @@ acpi_status acpi_ex_prep_field_value(str obj_desc->field.resource_length = info->resource_length; } + obj_desc->field.pin_number_index = info->pin_number_index; +/* Allow full data read from EC address space */ if ((obj_desc->field.region_obj->region.space_id ==
Greg Kroah-Hartman
maintainerPATCH 196/357 gpio / ACPI: Use pin index and bit length
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit c15d821ddb9dac9ac6b5beb75bf942f3bc3a4004 upstream.
Fix code when the operation region callback is for an gpio, which is not at index 0 and for partial pins in a GPIO definition. For example:
Name (GMOD, ResourceTemplate ()
{
//3 Outputs that define the Power mode of the device
GpioIo (Exclusive, PullDown, , , , "\\_SB.GPI2") {10, 11, 12}
})
}If opregion callback calls is for:
- Set pin 10, then address = 0 and bit length = 1
- Set pin 11, then address = 1 and bit length = 1
- Set for both pin 11 and pin 12, then address = 1, bit length = 2
This change requires updated ACPICA gpio operation handler code to send the pin index and bit length.
--- drivers/gpio/gpiolib-acpi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpio/gpiolib-acpi.c +4 -1
@@ -357,8 +357,10 @@ acpi_gpio_adr_space_handler(u32 functionstruct gpio_chip *chip = achip->chip;struct acpi_resource_gpio *agpio;struct acpi_resource *ares; +int pin_index = (int )address;acpi_status status;bool pull_up; +int length;int i; status = acpi_buffer_to_resource(achip->conn_info.connection,
@@ -380,7 +382,8 @@ acpi_gpio_adr_space_handler(u32 functionreturn AE_BAD_PARAMETER ; } -for (i =0 ; i < agpio->pin_table_length; i++) { + length =min (agpio->pin_table_length, (u16)(pin_index + bits)); +for (i = pin_index; i < length; ++i) {unsigned pin = agpio->pin_table[i];struct acpi_gpio_connection *conn;struct gpio_desc *desc;
Greg Kroah-Hartman
maintainerPATCH 197/357 ACPI / platform / LPSS: disable async suspend/resume of LPSS devices
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fu Zhonghui <[email protected]>
commit 457920817e645a7dee42c2a75c81c5ed8e12ee1c upstream.
On some systems (Asus T100 in particular) there are strict ordering dependencies between LPSS devices with respect to power management that break if they suspend/resume asynchronously.
In theory it should be possible to follow those dependencies in the async suspend/resume case too (the ACPI tables tell as that the dependencies are there), but since we're missing infrastructure for that at the moment, disable async suspend/resume for all of the LPSS devices for the time being.
--- drivers/acpi/acpi_lpss.c | 1 - 1 file changed, 1 deletion(-)
drivers/acpi/acpi_lpss.c +0 -1
@@ -392,7 +392,6 @@ static int acpi_lpss_create_device(struc adev->driver_data = pdata; pdev =acpi_create_platform_device (adev);if (!IS_ERR_OR_NULL (pdev)) { -device_enable_async_suspend (&pdev->dev);return 1 ; }
Greg Kroah-Hartman
maintainerPATCH 198/357 ACPI / hotplug: Generate online uevents for ACPI containers
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Rafael J. Wysocki" <[email protected]>
commit 8ab17fc92e49bc2b8fff9d220c19bf50ec9c1158 upstream.
Commit 46394fd01 (ACPI / hotplug: Move container-specific code out of the core) removed the generation of "online" uevents for containers, because "add" uevents are now generated for them automatically when container system devices are registered. However, there are user space tools that need to be notified when the container and all of its children have been enumerated, which doesn't happen any more.
For this reason, add a mechanism allowing "online" uevents to be generated for ACPI containers after enumerating the container along with all of its children.
--- drivers/acpi/container.c | 8 ++++++++ drivers/acpi/scan.c | 3 +++ include/acpi/acpi_bus.h | 1 + 3 files changed, 12 insertions(+)
drivers/acpi/container.c +8 -0
@@ -99,6 +99,13 @@ static void container_device_detach(strudevice_unregister (dev); } +static void container_device_online (struct acpi_device *adev) +{ +struct device *dev =acpi_driver_data (adev); + +kobject_uevent (&dev->kobj,KOBJ_ONLINE ); +} +static struct acpi_scan_handler container_handler = { .ids = container_device_ids, .attach = container_device_attach,
@@ -106,6 +113,7 @@ static struct acpi_scan_handler containe .hotplug = { .enabled = true, .demand_offline = true, + .notify_online = container_device_online, }, };
drivers/acpi/scan.c +3 -0
@@ -2184,6 +2184,9 @@ static void acpi_bus_attach(struct acpi_ ok:list_for_each_entry (child, &device->children, node)acpi_bus_attach (child); + +if (device->handler && device->handler->hotplug.notify_online) + device->handler->hotplug.notify_online (device); }/**
include/acpi/acpi_bus.h +1 -0
@@ -118,6 +118,7 @@ struct acpi_device;struct acpi_hotplug_profile {struct kobject kobj;int (*scan_dependent)(struct acpi_device *adev); +void (*notify_online)(struct acpi_device *adev);bool enabled:1 ;bool demand_offline:1 ; };
Greg Kroah-Hartman
maintainerPATCH 199/357 ACPI / scan: Correct error return value of create_modalias()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mika Westerberg <[email protected]>
commit 98d28d0e59160d2d6cb3f6a9050723ac40f89669 upstream.
There is a typo, it should be negative -errno instead.
--- drivers/acpi/scan.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/acpi/scan.c +1 -1
@@ -128,7 +128,7 @@ static int create_modalias(struct acpi_dlist_for_each_entry (id, &acpi_dev->pnp.ids, list) { count =snprintf (&modalias[len], size,"%s:" , id->id);if (count <0 ) -return EINVAL ; +return -EINVAL ;if (count >= size)return -ENOMEM ; len += count;
Greg Kroah-Hartman
maintainerPATCH 200/357 ACPI / video: disable native backlight for ThinkPad X201s
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Aaron Lu <[email protected]>
commit 789eeea128925741e0a105357bebf8855d3bcdee upstream.
The ThinkPad X201s has a working ACPI video backlight interface and is shipped before Win8; then there is BIOS update that starts to query _OSI("Windows 2012") and that would make our video module stop creating backlight interface and caused problem for the user. Add it to the DMI table to disable native backlight to fix this problem.
--- drivers/acpi/video.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/acpi/video.c +8 -0
@@ -675,6 +675,14 @@ static struct dmi_system_id video_dmi_ta DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad T520"), }, }, + { + .callback = video_disable_native_backlight, + .ident = "ThinkPad X201s", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), + DMI_MATCH(DMI_PRODUCT_VERSION, "ThinkPad X201s"), + }, + },/* The native backlight controls do not work on some older machines */ {
Greg Kroah-Hartman
maintainerPATCH 201/357 arm64: Add brackets around user_stack_pointer()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Catalin Marinas <[email protected]>
commit 2520d039728b2a3c5ae7f79fe2a0e9d182855b12 upstream.
Commit 5f888a1d33 (ARM64: perf: support dwarf unwinding in compat mode) changes user_stack_pointer() to return the compat SP for 32-bit tasks but without brackets around the whole definition, with possible issues on the call sites (noticed with a subsequent fix for KSTK_ESP).
--- arch/arm64/include/asm/ptrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/ptrace.h +1 -1
@@ -137,7 +137,7 @@ struct pt_regs { (!((regs)->pstate & PSR_F_BIT))#define user_stack_pointer (regs) \ - (!compat_user_mode(regs)) ? ((regs)->sp) : ((regs)->compat_sp) + (!compat_user_mode(regs) ? (regs)->sp : (regs)->compat_sp)static inline unsigned long regs_return_value (struct pt_regs *regs) {
Greg Kroah-Hartman
maintainerPATCH 202/357 memblock, memhotplug: fix wrong type in memblock_find_in_range_node().
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tang Chen <[email protected]>
commit 0cfb8f0c3e21e36d4a6e472e4c419d58ba848698 upstream.
In memblock_find_in_range_node(), we defined ret as int. But it should be phys_addr_t because it is used to store the return value from __memblock_find_range_bottom_up().
The bug has not been triggered because when allocating low memory near the kernel end, the "int ret" won't turn out to be negative. When we started to allocate memory on other nodes, and the "int ret" could be minus. Then the kernel will panic.
A simple way to reproduce this: comment out the following code in numa_init(),
memblock_set_bottom_up(false);
and the kernel won't boot.
--- mm/memblock.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
mm/memblock.c +1 -2
@@ -192,8 +192,7 @@ phys_addr_t __init_memblock memblock_fin phys_addr_t align, phys_addr_t start, phys_addr_t end, int nid) { - int ret; -phys_addr_t kernel_end; + phys_addr_t kernel_end, ret;/* pump up @end */ if (end ==MEMBLOCK_ALLOC_ACCESSIBLE )
Greg Kroah-Hartman
maintainerPATCH 203/357 regmap: Fix regcache debugfs initialization
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lars-Peter Clausen <[email protected]>
commit 5e0cbe78762b5f02986bf9e59a188dad2f6e0be1 upstream.
Commit 6cfec04bcc05 ("regmap: Separate regmap dev initialization") moved the regmap debugfs initialization after regcache initialization. This means that the regmap debugfs directory is not created yet when the cache initialization runs and so any debugfs files registered by the regcache are created in the debugfs root directory rather than the debugfs directory of the regmap instance. Fix this by adding a separate callback for the regcache debugfs initialization which will be called after the parent debugfs entry has been created.
--- drivers/base/regmap/internal.h | 3 +++ drivers/base/regmap/regcache-rbtree.c | 9 +++------ drivers/base/regmap/regmap-debugfs.c | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-)
drivers/base/regmap/internal.h +3 -0
@@ -146,6 +146,9 @@ struct regcache_ops {enum regcache_type type;int (*init)(struct regmap *map);int (*exit)(struct regmap *map); +#ifdef CONFIG_DEBUG_FS +void (*debugfs_init)(struct regmap *map); +#endif int (*read)(struct regmap *map,unsigned int reg,unsigned int *value);int (*write)(struct regmap *map,unsigned int reg,unsigned int value);int (*sync)(struct regmap *map,unsigned int min,unsigned int max);
drivers/base/regmap/regcache-rbtree.c +3 -6
@@ -194,10 +194,6 @@ static void rbtree_debugfs_init(struct r {debugfs_create_file ("rbtree" ,0400 , map->debugfs, map, &rbtree_fops); } -#else -static void rbtree_debugfs_init (struct regmap *map) -{ -}#endif static int regcache_rbtree_init (struct regmap *map)
@@ -222,8 +218,6 @@ static int regcache_rbtree_init(struct r goto err; } -rbtree_debugfs_init (map); -return 0 ; err:
@@ -532,6 +526,9 @@ struct regcache_ops regcache_rbtree_ops .name = "rbtree", .init = regcache_rbtree_init, .exit = regcache_rbtree_exit, +#ifdef CONFIG_DEBUG_FS + .debugfs_init = rbtree_debugfs_init, +#endif .read = regcache_rbtree_read, .write = regcache_rbtree_write, .sync = regcache_rbtree_sync,
drivers/base/regmap/regmap-debugfs.c +3 -0
@@ -538,6 +538,9 @@ void regmap_debugfs_init(struct regmap * next =rb_next (&range_node->node); } + +if (map->cache_ops && map->cache_ops->debugfs_init) + map->cache_ops->debugfs_init (map); }void regmap_debugfs_exit (struct regmap *map)
Greg Kroah-Hartman
maintainerPATCH 204/357 regmap: Fix handling of volatile registers for format_write() chips
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 5844a8b9d98ec11ce1d77610daacf3f0a0e14715 upstream.
A previous over-zealous factorisation of code means that we only treat registers as volatile if they are readable. For most devices this is fine since normally most registers can be read and volatility implies readability but for format_write() devices where there is no readback from the hardware and we use volatility to mean simply uncacheability this means that we end up treating all registers as cacheble.
A bigger refactoring of the code to clarify this is in order but as a fix make a minimal change and only check readability when checking volatility if there is no format_write() operation defined for the device.
--- drivers/base/regmap/regmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regmap.c +1 -1
@@ -109,7 +109,7 @@ bool regmap_readable(struct regmap *map,bool regmap_volatile (struct regmap *map,unsigned int reg) { -if (!regmap_readable (map, reg)) +if (!map->format.format_write && !regmap_readable (map, reg))return false;if (map->volatile_reg)
Greg Kroah-Hartman
maintainerPATCH 205/357 regmap: Dont attempt block writes when syncing cache on single_rw devices
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mark Brown <[email protected]>
commit 5c1ebe7f73f9166893c3459915db8a09d6d1d715 upstream.
If the device can't support block writes then don't attempt to use raw syncing which will automatically generate block writes for adjacent registers, use the existing _single() block syncing implementation.
--- drivers/base/regmap/regcache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/base/regmap/regcache.c +1 -1
@@ -698,7 +698,7 @@ int regcache_sync_block(struct regmap *m unsigned int block_base, unsigned int start, unsigned int end) { - if (regmap_can_raw_write(map)) + if (regmap_can_raw_write(map) && !map->use_single_rw) return regcache_sync_block_raw(map, block, cache_present, block_base, start, end); else
Greg Kroah-Hartman
maintainerPATCH 206/357 cgroup: reject cgroup names with \n
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alban Crequy <[email protected]>
commit 71b1fb5c4473a5b1e601d41b109bdfe001ec82e0 upstream.
/proc/<pid>/cgroup contains one cgroup path on each line. If cgroup names are allowed to contain "\n", applications cannot parse /proc/<pid>/cgroup safely.
--- kernel/cgroup.c | 5 +++++ 1 file changed, 5 insertions(+)
kernel/cgroup.c +5 -0
@@ -4393,6 +4393,11 @@ static int cgroup_mkdir(struct kernfs_nostruct kernfs_node *kn;int ssid, ret; +/* Do not accept '\n' to prevent making /proc/<pid>/cgroup unparsable. +*/ +if (strchr (name,'\n' )) +return -EINVAL ; + parent =cgroup_kn_lock_live (parent_kn);if (!parent)return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 208/357 cgroup: fix unbalanced locking
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zefan Li <[email protected]>
commit eb4aec84d6bdf98d00cedb41c18000f7a31e648a upstream.
cgroup_pidlist_start() holds cgrp->pidlist_mutex and then calls pidlist_array_load(), and cgroup_pidlist_stop() releases the mutex.
It is wrong that we release the mutex in the failure path in pidlist_array_load(), because cgroup_pidlist_stop() will be called no matter if cgroup_pidlist_start() returns errno or not.
--- kernel/cgroup.c | 1 - 1 file changed, 1 deletion(-)
kernel/cgroup.c +0 -1
@@ -3833,7 +3833,6 @@ static int pidlist_array_load(struct cgr l =cgroup_pidlist_find_create (cgrp, type);if (!l) { -mutex_unlock (&cgrp->pidlist_mutex);pidlist_free (array);return -ENOMEM ; }
Greg Kroah-Hartman
maintainerPATCH 209/357 KVM: s390: Fix user triggerable bug in dead code
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 614a80e474b227cace52fd6e3c790554db8a396e upstream.
In the early days, we had some special handling for the KVM_EXIT_S390_SIEIC exit, but this was gone in 2009 with commit d7b0b5eb3000 (KVM: s390: Make psw available on all exits, not just a subset).
Now this switch statement is just a sanity check for userspace not messing with the kvm_run structure. Unfortunately, this allows userspace to trigger a kernel BUG. Let's just remove this switch statement.
--- arch/s390/kvm/kvm-s390.c | 13 ------------- 1 file changed, 13 deletions(-)
arch/s390/kvm/kvm-s390.c +0 -13
@@ -1286,19 +1286,6 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vkvm_s390_vcpu_start (vcpu); -switch (kvm_run->exit_reason) { -case KVM_EXIT_S390_SIEIC : -case KVM_EXIT_UNKNOWN : -case KVM_EXIT_INTR : -case KVM_EXIT_S390_RESET : -case KVM_EXIT_S390_UCONTROL : -case KVM_EXIT_S390_TSCH : -case KVM_EXIT_DEBUG : -break ; -default : -BUG (); - } - vcpu->arch.sie_block->gpsw.mask = kvm_run->psw_mask; vcpu->arch.sie_block->gpsw.addr = kvm_run->psw_addr;if (kvm_run->kvm_dirty_regs &KVM_SYNC_PREFIX ) {
Greg Kroah-Hartman
maintainerPATCH 210/357 KVM: s390/mm: try a cow on read only pages for key ops
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit ab3f285f227fec62868037e9b1b1fd18294a83b8 upstream.
The PFMF instruction handler blindly wrote the storage key even if the page was mapped R/O in the host. Lets try a COW before continuing and bail out in case of errors.
--- arch/s390/mm/pgtable.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
arch/s390/mm/pgtable.c +10 -0
@@ -986,11 +986,21 @@ int set_guest_storage_key(struct mm_strupte_t *ptep;down_read (&mm->mmap_sem); +retry: ptep =get_locked_pte (current->mm, addr, &ptl);if (unlikely (!ptep)) {up_read (&mm->mmap_sem);return -EFAULT ; } +if (!(pte_val (*ptep) & _PAGE_INVALID) && + (pte_val (*ptep) & _PAGE_PROTECT)) { +pte_unmap_unlock (*ptep, ptl); +if (fixup_user_fault (current, mm, addr,FAULT_FLAG_WRITE )) { +up_read (&mm->mmap_sem); +return -EFAULT ; + } + goto retry; + } new = old =pgste_get_lock (ptep); pgste_val(new) &= ~(PGSTE_GR_BIT | PGSTE_GC_BIT |
Greg Kroah-Hartman
maintainerPATCH 211/357 KVM: s390/mm: Fix storage key corruption during swapping
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 3e03d4c46daa849880837d802e41c14132a03ef9 upstream.
Since 3.12 or more precisely commit 0944fe3f4a32 ("s390/mm:
implement software referenced bits") guest storage keys get corrupted during paging. This commit added another valid->invalid translation for page tables - namely ptep_test_and_clear_young. We have to transfer the storage key into the pgste in that case.
--- arch/s390/include/asm/pgtable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
arch/s390/include/asm/pgtable.h +3 -2
@@ -1115,7 +1115,7 @@ static inline int ptep_test_and_clear_yo unsigned long addr, pte_t *ptep) { pgste_t pgste; -pte_t pte; +pte_t pte, oldpte;int young;if (mm_has_pgste (vma->vm_mm)) {
@@ -1123,12 +1123,13 @@ static inline int ptep_test_and_clear_yo pgste =pgste_ipte_notify (vma->vm_mm, ptep, pgste); } - pte = *ptep; + oldpte = pte = *ptep;ptep_flush_direct (vma->vm_mm, addr, ptep); young =pte_young (pte); pte =pte_mkold (pte);if (mm_has_pgste (vma->vm_mm)) { + pgste =pgste_update_all (&oldpte, pgste, vma->vm_mm); pgste =pgste_set_pte (ptep, pgste, pte);pgste_set_unlock (ptep, pgste); }else
Greg Kroah-Hartman
maintainerPATCH 212/357 KVM: s390/mm: Fix guest storage key corruption in ptep_set_access_flags
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Christian Borntraeger <[email protected]>
commit 1951497d90d6754201af3e65241a06f9ef6755cd upstream.
commit 0944fe3f4a32 ("s390/mm: implement software referenced bits") triggered another paging/storage key corruption. There is an unhandled invalid->valid pte change where we have to set the real storage key from the pgste.
When doing paging a guest page might be swapcache or swap and when faulted in it might be read-only and due to a parallel scan old. An do_wp_page will make it writeable and young. Due to software reference tracking this page was invalid and now becomes valid.
--- arch/s390/include/asm/pgtable.h | 1 + 1 file changed, 1 insertion(+)
arch/s390/include/asm/pgtable.h +1 -0
@@ -1319,6 +1319,7 @@ static inline int ptep_set_access_flags(ptep_flush_direct (vma->vm_mm, address, ptep);if (mm_has_pgste (vma->vm_mm)) { +pgste_set_key (ptep, pgste, entry, vma->vm_mm); pgste =pgste_set_pte (ptep, pgste, entry);pgste_set_unlock (ptep, pgste); }else
Greg Kroah-Hartman
maintainerPATCH 213/357 xen/manage: Always freeze/thaw processes when suspend/resuming
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ross Lagerwall <[email protected]>
commit 61a734d305e16944b42730ef582a7171dc733321 upstream.
Always freeze processes when suspending and thaw processes when resuming to prevent a race noticeable with HVM guests.
This prevents a deadlock where the khubd kthread (which is designed to be freezable) acquires a usb device lock and then tries to allocate memory which requires the disk which hasn't been resumed yet. Meanwhile, the xenwatch thread deadlocks waiting for the usb device lock.
Freezing processes fixes this because the khubd thread is only thawed after the xenwatch thread finishes resuming all the devices.
--- drivers/xen/manage.c | 7 ------- 1 file changed, 7 deletions(-)
drivers/xen/manage.c +0 -7
@@ -103,16 +103,11 @@ static void do_suspend(void) shutting_down =SHUTDOWN_SUSPEND ; -#ifdef CONFIG_PREEMPT -/* If the kernel is preemptible, we need to freeze all the processes -to prevent them from being in the middle of a pagetable update -during suspend. */ err =freeze_processes ();if (err) {pr_err ("%s: freeze failed %d\n" , __func__, err); goto out; } -#endif err =dpm_suspend_start (PMSG_FREEZE );if (err) {
@@ -157,10 +152,8 @@ out_resume:dpm_resume_end (si.cancelled ?PMSG_THAW :PMSG_RESTORE ); out_thaw: -#ifdef CONFIG_PREEMPTthaw_processes (); out: -#endif shutting_down = SHUTDOWN_INVALID; }#endif /* CONFIG_HIBERNATE_CALLBACKS */
Greg Kroah-Hartman
maintainerPATCH 214/357 x86/xen: dont copy bogus duplicate entries into kernel page tables
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stefan Bader <[email protected]>
commit 0b5a50635fc916cf46e3de0b819a61fc3f17e7ee upstream.
When RANDOMIZE_BASE (KASLR) is enabled; or the sum of all loaded modules exceeds 512 MiB, then loading modules fails with a warning (and hence a vmalloc allocation failure) because the PTEs for the newly-allocated vmalloc address space are not zero.
WARNING: CPU: 0 PID: 494 at linux/mm/vmalloc.c:128
vmap_page_range_noflush+0x2a1/0x360()This is caused by xen_setup_kernel_pagetables() copying level2_kernel_pgt into level2_fixmap_pgt, overwriting many non-present entries.
Without KASLR, the normal kernel image size only covers the first half of level2_kernel_pgt and module space starts after that.
L4[511]->level3_kernel_pgt[510]->level2_kernel_pgt[ 0..255]->kernel
[256..511]->module
[511]->level2_fixmap_pgt[ 0..505]->moduleThis allows 512 MiB of of module vmalloc space to be used before having to use the corrupted level2_fixmap_pgt entries.
With KASLR enabled, the kernel image uses the full PUD range of 1G and module space starts in the level2_fixmap_pgt. So basically:
L4[511]->level3_kernel_pgt[510]->level2_kernel_pgt[0..511]->kernel
[511]->level2_fixmap_pgt[0..505]->module
And now no module vmalloc space can be used without using the corrupt level2_fixmap_pgt entries.
Fix this by properly converting the level2_fixmap_pgt entries to MFNs, and setting level1_fixmap_pgt as read-only.
A number of comments were also using the the wrong L3 offset for level2_kernel_pgt. These have been corrected.
--- arch/x86/include/asm/pgtable_64.h | 1 + arch/x86/xen/mmu.c | 27 ++++++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-)
arch/x86/include/asm/pgtable_64.h +1 -0
@@ -19,6 +19,7 @@ extern pud_t level3_ident_pgt[512];extern pmd_t level2_kernel_pgt[512 ];extern pmd_t level2_fixmap_pgt[512 ];extern pmd_t level2_ident_pgt[512 ]; +extern pte_t level1_fixmap_pgt[512 ];extern pgd_t init_level4_pgt[];#define swapper_pg_dir init_level4_pgt
arch/x86/xen/mmu.c +12 -15
@@ -1866,12 +1866,11 @@ static void __init check_pt_base(unsigne* * We can construct this by grafting the Xen provided pagetable into * head_64.S's preconstructed pagetables. We copy the Xen L2's into -* level2_ident_pgt, level2_kernel_pgt and level2_fixmap_pgt. This -* means that only the kernel has a physical mapping to start with - -* but that's enough to get __va working. We need to fill in the rest -* of the physical mapping once some sort of allocator has been set -* up. -* NOTE: for PVH, the page tables are native. +* level2_ident_pgt, and level2_kernel_pgt. This means that only the +* kernel has a physical mapping to start with - but that's enough to +* get __va working. We need to fill in the rest of the physical +* mapping once some sort of allocator has been set up. NOTE: for +* PVH, the page tables are native. */ void __init xen_setup_kernel_pagetable (pgd_t *pgd,unsigned long max_pfn) {
@@ -1902,8 +1901,11 @@ void __init xen_setup_kernel_pagetable(p/* L3_i[0] -> level2_ident_pgt */ convert_pfn_mfn (level3_ident_pgt);/* L3_k[510] -> level2_kernel_pgt -* L3_i[511] -> level2_fixmap_pgt */ +* L3_k[511] -> level2_fixmap_pgt */ convert_pfn_mfn (level3_kernel_pgt); + +/* L3_k[511][506] -> level1_fixmap_pgt */ +convert_pfn_mfn (level2_fixmap_pgt); }/* We get [511][511] and have Xen's version of level2_kernel_pgt */ l3 =m2v (pgd[pgd_index (__START_KERNEL_map)].pgd);
@@ -1913,21 +1915,15 @@ void __init xen_setup_kernel_pagetable(p addr[1 ] = (unsigned long )l3; addr[2 ] = (unsigned long )l2;/* Graft it onto L4[272][0]. Note that we creating an aliasing problem: -* Both L4[272][0] and L4[511][511] have entries that point to the same +* Both L4[272][0] and L4[511][510] have entries that point to the same * L2 (PMD) tables. Meaning that if you modify it in __va space * it will be also modified in the __ka space! (But if you just * modify the PMD table to point to other PTE's or none, then you * are OK - which is what cleanup_highmap does) */ copy_page (level2_ident_pgt, l2); -/* Graft it onto L4[511][511] */ +/* Graft it onto L4[511][510] */ copy_page (level2_kernel_pgt, l2); -/* Get [511][510] and graft that in level2_fixmap_pgt */ - l3 =m2v (pgd[pgd_index (__START_KERNEL_map +PMD_SIZE )].pgd); - l2 =m2v (l3[pud_index (__START_KERNEL_map +PMD_SIZE )].pud); -copy_page (level2_fixmap_pgt, l2); -/* Note that we don't do anything with level1_fixmap_pgt which -* we don't need. */ if (!xen_feature (XENFEAT_auto_translated_physmap)) {/* Make pagetable pieces RO */ set_page_prot (init_level4_pgt,PAGE_KERNEL_RO );
@@ -1937,6 +1933,7 @@ void __init xen_setup_kernel_pagetable(pset_page_prot (level2_ident_pgt,PAGE_KERNEL_RO );set_page_prot (level2_kernel_pgt,PAGE_KERNEL_RO );set_page_prot (level2_fixmap_pgt,PAGE_KERNEL_RO ); +set_page_prot (level1_fixmap_pgt,PAGE_KERNEL_RO );/* Pin down new L4 */ pin_pagetable_pfn(MMUEXT_PIN_L4_TABLE,
Greg Kroah-Hartman
maintainerPATCH 215/357 x86 early_ioremap: Increase FIX_BTMAPS_SLOTS to 8
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dave Young <[email protected]>
commit 3eddc69ffeba092d288c386646bfa5ec0fce25fd upstream.
3.16 kernel boot fail with earlyprintk=efi, it keeps scrolling at the bottom line of screen.
Bisected, the first bad commit is below:
commit 86dfc6f339886559d80ee0d4bd20fe5ee90450f0
Author: Lv Zheng <[email protected]> Date: Fri Apr 4 12:38:57 2014 +0800
ACPICA: Tables: Fix table checksums verification before installation.
I did some debugging by enabling both serial and efi earlyprintk, below is some debug dmesg, seems early_ioremap fails in scroll up function due to no free slot, see below dmesg output:
WARNING: CPU: 0 PID: 0 at mm/early_ioremap.c:116 __early_ioremap+0x90/0x1c4()
__early_ioremap(ed00c800, 00000c80) not found slot
Modules linked in:
CPU: 0 PID: 0 Comm: swapper Not tainted 3.17.0-rc1+ #204
Hardware name: Hewlett-Packard HP Z420 Workstation/1589, BIOS J61 v03.15 05/09/2013
Call Trace:
dump_stack+0x4e/0x7a
warn_slowpath_common+0x75/0x8e
? __early_ioremap+0x90/0x1c4
warn_slowpath_fmt+0x47/0x49
__early_ioremap+0x90/0x1c4
? sprintf+0x46/0x48
early_ioremap+0x13/0x15
early_efi_map+0x24/0x26
early_efi_scroll_up+0x6d/0xc0
early_efi_write+0x1b0/0x214
call_console_drivers.constprop.21+0x73/0x7e
console_unlock+0x151/0x3b2
? vprintk_emit+0x49f/0x532
vprintk_emit+0x521/0x532
? console_unlock+0x383/0x3b2
printk+0x4f/0x51
acpi_os_vprintf+0x2b/0x2d
acpi_os_printf+0x43/0x45
acpi_info+0x5c/0x63
? __acpi_map_table+0x13/0x18
? acpi_os_map_iomem+0x21/0x147
acpi_tb_print_table_header+0x177/0x186
acpi_tb_install_table_with_override+0x4b/0x62
acpi_tb_install_standard_table+0xd9/0x215
? early_ioremap+0x13/0x15
? __acpi_map_table+0x13/0x18
acpi_tb_parse_root_table+0x16e/0x1b4
acpi_initialize_tables+0x57/0x59
acpi_table_init+0x50/0xce
acpi_boot_table_init+0x1e/0x85
setup_arch+0x9b7/0xcc4
start_kernel+0x94/0x42d
? early_idt_handlers+0x120/0x120
x86_64_start_reservations+0x2a/0x2c
x86_64_start_kernel+0xf3/0x100Quote reply from Lv.zheng about the early ioremap slot usage in this case:
"""
In early_efi_scroll_up(), 2 mapping entries will be used for the src/dst screen buffer.
In drivers/acpi/acpica/tbutils.c, we've improved the early table loading code in acpi_tb_parse_root_table(). We now need 2 mapping entries:
1. One mapping entry is used for RSDT table mapping. Each RSDT entry contains an address for another ACPI table.
2. For each entry in RSDP, we need another mapping entry to map the table to perform necessary check/override before installing it.
When acpi_tb_parse_root_table() prints something through EFI earlyprintk console, we'll have 4 mapping entries used. The current 4 slots setting of early_ioremap() seems to be too small for such a use case.
"""
Thus increase the slot to 8 in this patch to fix this issue. boot-time mappings become 512 page with this patch.
--- arch/x86/include/asm/fixmap.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/include/asm/fixmap.h +3 -3
@@ -106,14 +106,14 @@ enum fixed_addresses { __end_of_permanent_fixed_addresses,/* -* 256 temporary boot-time mappings, used by early_ioremap(), +* 512 temporary boot-time mappings, used by early_ioremap(), * before ioremap() is functional. * -* If necessary we round it up to the next 256 pages boundary so +* If necessary we round it up to the next 512 pages boundary so * that we can have a single pgd entry and a single pte table: */ #define NR_FIX_BTMAPS 64 -#define FIX_BTMAPS_SLOTS 4 +#define FIX_BTMAPS_SLOTS 8#define TOTAL_FIX_BTMAPS (NR_FIX_BTMAPS * FIX_BTMAPS_SLOTS) FIX_BTMAP_END = (__end_of_permanent_fixed_addresses ^
Greg Kroah-Hartman
maintainerPATCH 216/357 x86/kaslr: Avoid the setup_data area when picking location
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Kees Cook <[email protected]>
commit 0cacbfbeb5077b63d5d3cf6df88b14ac12ad584b upstream.
The KASLR location-choosing logic needs to avoid the setup_data list memory areas as well. Without this, it would be possible to have the ASLR position stomp on the memory, ultimately causing the boot to fail.
--- arch/x86/boot/compressed/aslr.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/x86/boot/compressed/aslr.c +15 -0
@@ -183,12 +183,27 @@ static void mem_avoid_init(unsigned longstatic bool mem_avoid_overlap (struct mem_vector *img) {int i; +struct setup_data *ptr;for (i =0 ; i <MEM_AVOID_MAX ; i++) {if (mem_overlaps (img, &mem_avoid[i]))return true; } +/* Avoid all entries in the setup_data linked list. */ + ptr = (struct setup_data *)(unsigned long )real_mode->hdr.setup_data; +while (ptr) { +struct mem_vector avoid; + + avoid.start = (u64 )ptr; + avoid.size =sizeof (*ptr) + ptr->len; + +if (mem_overlaps (img, &avoid)) +return true; + + ptr = (struct setup_data *)(unsigned long )ptr->next; + } +return false; }
Greg Kroah-Hartman
maintainerPATCH 217/357 shmem: fix nlink for rename overwrite directory
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Miklos Szeredi <[email protected]>
commit b928095b0a7cff7fb9fcf4c706348ceb8ab2c295 upstream.
If overwriting an empty directory with rename, then need to drop the extra nlink.
Test prog:
#include <stdio.h>
#include <fcntl.h>
#include <err.h>
#include <sys/stat.h>
int main(void)
{
const char *test_dir1 = "test-dir1";
const char *test_dir2 = "test-dir2";
int res;
int fd;
struct stat statbuf;
res = mkdir(test_dir1, 0777);
if (res == -1)
err(1, "mkdir(\"%s\")", test_dir1);
res = mkdir(test_dir2, 0777);
if (res == -1)
err(1, "mkdir(\"%s\")", test_dir2);
fd = open(test_dir2, O_RDONLY);
if (fd == -1)
err(1, "open(\"%s\")", test_dir2);
res = rename(test_dir1, test_dir2);
if (res == -1)
err(1, "rename(\"%s\", \"%s\")", test_dir1, test_dir2);
res = fstat(fd, &statbuf);
if (res == -1)
err(1, "fstat(%i)", fd);
if (statbuf.st_nlink != 0) {
fprintf(stderr, "nlink is %lu, should be 0\n", statbuf.st_nlink);
return 1;
}
return 0;
}--- mm/shmem.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
mm/shmem.c +3 -1
@@ -2064,8 +2064,10 @@ static int shmem_rename(struct inode *olif (new_dentry->d_inode) { (void )shmem_unlink (new_dir, new_dentry); -if (they_are_dirs) +if (they_are_dirs) { +drop_nlink (new_dentry->d_inode);drop_nlink (old_dir); + } }else if (they_are_dirs) {drop_nlink (old_dir);inc_nlink (new_dir);
Greg Kroah-Hartman
maintainerPATCH 218/357 ASoC: davinci-mcasp: Correct rx format unit configuration
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Ujfalusi <[email protected]>
commit fe0a29e163a5d045c73faab682a8dac71c2f8012 upstream.
In case of capture we should not use rotation. The reverse and mask is enough to get the data align correctly from the bus to MCU:
Format data from bus after reverse (XRBUF) S16_LE: |LSB|MSB|xxx|xxx| |xxx|xxx|MSB|LSB| S24_3LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| S24_LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| S32_LE: |LSB|DAT|DAT|MSB| |MSB|DAT|DAT|LSB|
With this patch all supported formats will work for playback and capture.
--- sound/soc/davinci/davinci-mcasp.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
sound/soc/davinci/davinci-mcasp.c +10 -1
@@ -455,8 +455,17 @@ static int davinci_config_channel_size(s {u32 fmt;u32 tx_rotate = (word_length /4 ) &0x7 ; -u32 rx_rotate = (32 - word_length) /4 ;u32 mask = (1ULL << word_length) -1 ; +/* +* For captured data we should not rotate, inversion and masking is +* enoguh to get the data to the right position: +* Format data from bus after reverse (XRBUF) +* S16_LE: |LSB|MSB|xxx|xxx| |xxx|xxx|MSB|LSB| +* S24_3LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| +* S24_LE: |LSB|DAT|MSB|xxx| |xxx|MSB|DAT|LSB| +* S32_LE: |LSB|DAT|DAT|MSB| |MSB|DAT|DAT|LSB| +*/ +u32 rx_rotate =0 ;/* * if s BCLK-to-LRCLK ratio has been configured via the set_clkdiv()
Greg Kroah-Hartman
maintainerPATCH 219/357 SMB3: Fix oops when creating symlinks on smb3
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Steve French <[email protected]>
commit da80659d4aa758dc6935b10ec64513f0b67bc969 upstream.
We were not checking for symlink support properly for SMB2/SMB3 mounts so could oops when mounted with mfsymlinks when try to create symlink when mfsymlinks on smb2/smb3 mounts
--- fs/cifs/link.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
fs/cifs/link.c +6 -2
@@ -213,8 +213,12 @@ create_mf_symlink(const unsigned int xidif (rc) goto out; - rc = tcon->ses->server->ops->create_mf_symlink (xid, tcon, cifs_sb, - fromName, buf, &bytes_written); +if (tcon->ses->server->ops->create_mf_symlink) + rc = tcon->ses->server->ops->create_mf_symlink (xid, tcon, + cifs_sb, fromName, buf, &bytes_written); +else + rc = -EOPNOTSUPP ; +if (rc) goto out;
Greg Kroah-Hartman
maintainerPATCH 220/357 iio:trigger: modify return value for iio_trigger_get
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit f153566570fb9e32c2f59182883f4f66048788fb upstream.
Instead of a void function, return the trigger pointer.
Whilst not in of itself a fix, this makes the following set of 7 fixes cleaner than they would otherwise be.
--- include/linux/iio/trigger.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
include/linux/iio/trigger.h +3 -1
@@ -84,10 +84,12 @@ static inline void iio_trigger_put(strucput_device (&trig->dev); } -static inline void iio_trigger_get (struct iio_trigger *trig) +static inline struct iio_trigger *iio_trigger_get (struct iio_trigger *trig) {get_device (&trig->dev);__module_get (trig->ops->owner); + +return trig; }/**
Greg Kroah-Hartman
maintainerPATCH 221/357 iio: accel: bma180: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 0668a4e4d297328ce08b44d91d160537596115e2 upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/accel/bma180.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/accel/bma180.c +1 -1
@@ -571,7 +571,7 @@ static int bma180_probe(struct i2c_clien trig->ops = &bma180_trigger_ops;iio_trigger_set_drvdata (trig, indio_dev); data->trig = trig; - indio_dev->trig = trig; + indio_dev->trig =iio_trigger_get (trig); ret =iio_trigger_register (trig);if (ret)
Greg Kroah-Hartman
maintainerPATCH 222/357 iio: hid_sensor_hub: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 55a6f9ddfdea0d2d343cd1b39baf8aa752664b6e upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/common/hid-sensors/hid-sensor-trigger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iio/common/hid-sensors/hid-sensor-trigger.c +2 -1
@@ -122,7 +122,8 @@ int hid_sensor_setup_trigger(struct iio_dev_err (&indio_dev->dev,"Trigger Register Failed\n" ); goto error_free_trig; } - indio_dev->trig = attrb->trigger = trig; + attrb->trigger = trig; + indio_dev->trig =iio_trigger_get (trig);return ret;
Greg Kroah-Hartman
maintainerPATCH 223/357 iio: gyro: itg3200: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 0b4dce2ee694a991ef38203ec5ff91a738518cb3 upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/gyro/itg3200_buffer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/gyro/itg3200_buffer.c +1 -1
@@ -132,7 +132,7 @@ int itg3200_probe_trigger(struct iio_dev goto error_free_irq;/* select default trigger */ - indio_dev->trig = st->trig; + indio_dev->trig =iio_trigger_get (st->trig);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 224/357 iio: inv_mpu6050: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit b07e3b3850b2e1f09c19f54d3ed7210d9f529e2c upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/imu/inv_mpu6050/inv_mpu_trigger.c +1 -1
@@ -135,7 +135,7 @@ int inv_mpu6050_probe_trigger(struct iio ret =iio_trigger_register (st->trig);if (ret) goto error_free_irq; - indio_dev->trig = st->trig; + indio_dev->trig =iio_trigger_get (st->trig);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 225/357 iio: meter: ade7758: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 0495081179212b758775df752e657ea71dcae020 upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/staging/iio/meter/ade7758_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/iio/meter/ade7758_trigger.c +1 -1
@@ -85,7 +85,7 @@ int ade7758_probe_trigger(struct iio_dev ret =iio_trigger_register (st->trig);/* select default trigger */ - indio_dev->trig = st->trig; + indio_dev->trig =iio_trigger_get (st->trig);if (ret) goto error_free_irq;
tm_page_alloc.c
@@ -391,14 +391,17 @@ out:
static unsigned long
ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc) {
- static atomic_t start_pool = ATOMIC_INIT(0);
+ static DEFINE_MUTEX(lock);
+ static unsigned start_pool;
unsigned i;
- unsigned pool_offset = atomic_add_return(1, &start_pool);
+ unsigned pool_offset;
struct ttm_page_pool *pool;
int shrink_pages = sc->nr_to_scan;
unsigned long freed = 0;
- pool_offset = pool_offset % NUM_POOLS;
+ if (!mutex_trylock(&lock))
+ return SHRINK_STOP;
+ pool_offset = ++start_pool % NUM_POOLS;
/* select start pool in round robin fashion */ for (i = 0; i < NUM_POOLS; ++i) {
unsigned nr_free = shrink_pages;
@@ -408,6 +411,7 @@ ttm_pool_shrink_scan(struct shrinker *sh
shrink_pages = ttm_page_pool_free(pool, nr_free); freed += nr_free - shrink_pages;
}
+ mutex_unlock(&lock);
return freed;
}
Greg Kroah-Hartman
maintainerPATCH 226/357 iio: st_sensors: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit f0e84acd7056e6d7ade551c6439531606ae30a46 upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/common/st_sensors/st_sensors_trigger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/common/st_sensors/st_sensors_trigger.c +1 -1
@@ -49,7 +49,7 @@ int st_sensors_allocate_trigger(struct idev_err (&indio_dev->dev,"failed to register iio trigger.\n" ); goto iio_trigger_register_error; } - indio_dev->trig = sdata->trig; + indio_dev->trig =iio_trigger_get (sdata->trig);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 227/357 iio: adc: ad_sigma_delta: Fix indio_dev->trig assignment
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Srinivas Pandruvada <[email protected]>
commit 9e5846be33277802c0c76e5c12825d0e4d27f639 upstream.
This can result in wrong reference count for trigger device, call iio_trigger_get to increment reference.
Refer to http://www.spinics.net/lists/linux-iio/msg13669.html for discussion with Jonathan.
--- drivers/iio/adc/ad_sigma_delta.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/ad_sigma_delta.c +1 -1
@@ -472,7 +472,7 @@ static int ad_sd_probe_trigger(struct ii goto error_free_irq;/* select default trigger */ - indio_dev->trig = sigma_delta->trig; + indio_dev->trig =iio_trigger_get (sigma_delta->trig);return 0 ;
Greg Kroah-Hartman
maintainerPATCH 228/357 iio:magnetometer: bugfix magnetometers gain values
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Denis CIOCCA <[email protected]>
commit a31d0928999fbf33b3a6042e8bcb7b7f7e07d094 upstream.
This patch fix gains values. The first driver was designed using engineering samples, in mass production the values are changed.
--- drivers/iio/magnetometer/st_magn_core.c | 52 ++++++++++++++++++-------------- 1 file changed, 30 insertions(+), 22 deletions(-)
drivers/iio/magnetometer/st_magn_core.c +30 -22
@@ -42,7 +42,8 @@#define ST_MAGN_FS_AVL_5600MG 5600#define ST_MAGN_FS_AVL_8000MG 8000#define ST_MAGN_FS_AVL_8100MG 8100 -#define ST_MAGN_FS_AVL_10000MG 10000 +#define ST_MAGN_FS_AVL_12000MG 12000 +#define ST_MAGN_FS_AVL_16000MG 16000/* CUSTOM VALUES FOR SENSOR 1 */ #define ST_MAGN_1_WAI_EXP 0x3c
@@ -69,20 +70,20 @@#define ST_MAGN_1_FS_AVL_4700_VAL 0x05#define ST_MAGN_1_FS_AVL_5600_VAL 0x06#define ST_MAGN_1_FS_AVL_8100_VAL 0x07 -#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 1100 -#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 855 -#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 670 -#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 450 -#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 400 -#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 330 -#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 230 -#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 980 -#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 760 -#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 600 -#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 400 -#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 355 -#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 295 -#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 205 +#define ST_MAGN_1_FS_AVL_1300_GAIN_XY 909 +#define ST_MAGN_1_FS_AVL_1900_GAIN_XY 1169 +#define ST_MAGN_1_FS_AVL_2500_GAIN_XY 1492 +#define ST_MAGN_1_FS_AVL_4000_GAIN_XY 2222 +#define ST_MAGN_1_FS_AVL_4700_GAIN_XY 2500 +#define ST_MAGN_1_FS_AVL_5600_GAIN_XY 3030 +#define ST_MAGN_1_FS_AVL_8100_GAIN_XY 4347 +#define ST_MAGN_1_FS_AVL_1300_GAIN_Z 1020 +#define ST_MAGN_1_FS_AVL_1900_GAIN_Z 1315 +#define ST_MAGN_1_FS_AVL_2500_GAIN_Z 1666 +#define ST_MAGN_1_FS_AVL_4000_GAIN_Z 2500 +#define ST_MAGN_1_FS_AVL_4700_GAIN_Z 2816 +#define ST_MAGN_1_FS_AVL_5600_GAIN_Z 3389 +#define ST_MAGN_1_FS_AVL_8100_GAIN_Z 4878#define ST_MAGN_1_MULTIREAD_BIT false/* CUSTOM VALUES FOR SENSOR 2 */
@@ -105,10 +106,12 @@#define ST_MAGN_2_FS_MASK 0x60#define ST_MAGN_2_FS_AVL_4000_VAL 0x00#define ST_MAGN_2_FS_AVL_8000_VAL 0x01 -#define ST_MAGN_2_FS_AVL_10000_VAL 0x02 -#define ST_MAGN_2_FS_AVL_4000_GAIN 430 -#define ST_MAGN_2_FS_AVL_8000_GAIN 230 -#define ST_MAGN_2_FS_AVL_10000_GAIN 230 +#define ST_MAGN_2_FS_AVL_12000_VAL 0x02 +#define ST_MAGN_2_FS_AVL_16000_VAL 0x03 +#define ST_MAGN_2_FS_AVL_4000_GAIN 146 +#define ST_MAGN_2_FS_AVL_8000_GAIN 292 +#define ST_MAGN_2_FS_AVL_12000_GAIN 438 +#define ST_MAGN_2_FS_AVL_16000_GAIN 584#define ST_MAGN_2_MULTIREAD_BIT false#define ST_MAGN_2_OUT_X_L_ADDR 0x28#define ST_MAGN_2_OUT_Y_L_ADDR 0x2a
@@ -266,9 +269,14 @@ static const struct st_sensors st_magn_s .gain = ST_MAGN_2_FS_AVL_8000_GAIN, }, [2] = { - .num = ST_MAGN_FS_AVL_10000MG, - .value = ST_MAGN_2_FS_AVL_10000_VAL, - .gain = ST_MAGN_2_FS_AVL_10000_GAIN, + .num = ST_MAGN_FS_AVL_12000MG, + .value = ST_MAGN_2_FS_AVL_12000_VAL, + .gain = ST_MAGN_2_FS_AVL_12000_GAIN, + }, + [3] = { + .num = ST_MAGN_FS_AVL_16000MG, + .value = ST_MAGN_2_FS_AVL_16000_VAL, + .gain = ST_MAGN_2_FS_AVL_16000_GAIN, }, }, },
Greg Kroah-Hartman
maintainerPATCH 229/357 iio:inkern: fix overwritten -EPROBE_DEFER in of_iio_channel_get_by_name
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Pointner <[email protected]>
commit 872687f626e033b4ddfaec1e410057cfc6636d77 upstream.
which improperly assumes that of_iio_channel_get_by_name must always return NULL and thus now hides -EPROBE_DEFER.
--- drivers/iio/inkern.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/inkern.c +1 -1
@@ -178,7 +178,7 @@ static struct iio_channel *of_iio_channe index =of_property_match_string (np,"io-channel-names" , name); chan =of_iio_channel_get (np, index); -if (!IS_ERR (chan)) +if (!IS_ERR (chan) ||PTR_ERR (chan) == -EPROBE_DEFER )break ;else if (name && index >=0 ) { pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
Greg Kroah-Hartman
maintainerPATCH 230/357 iio: adc: xilinx-xadc: assign auxiliary channels address correctly
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Subbaraya Sundeep Bhatta <[email protected]>
commit 1887e724e2b6df06847522fe9dc2ab53639516cc upstream.
This patch fixes incorrect logic for assigning address to auxiliary channels of xilinx xadc.
--- drivers/iio/adc/xilinx-xadc-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iio/adc/xilinx-xadc-core.c +1 -1
@@ -1126,7 +1126,7 @@ static int xadc_parse_dt(struct iio_dev chan->address =XADC_REG_VPVN ; }else { chan->scan_index =15 + reg; - chan->scan_index =XADC_REG_VAUX (reg -1 ); + chan->address =XADC_REG_VAUX (reg -1 ); } num_channels++; chan++;
Greg Kroah-Hartman
maintainerPATCH 231/357 iio: adc: at91: dont use the last converted data register
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ludovic Desroches <[email protected]>
commit d4f51956ac8ad302db9b0c4e4232775b1baa7b44 upstream.
If touchscreen mode is enabled and a conversion is requested on another channel, the result in the last converted data register can be a touchscreen relative value. Starting a conversion involves to do a conversion for all active channel. It starts with ADC channels and ends with touchscreen channels. Then if ADC_LCD register is not read quickly, its content may be a touchscreen conversion.
To remove this temporal constraint, the conversion value is taken from the channel data register.
--- drivers/iio/adc/at91_adc.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-)
drivers/iio/adc/at91_adc.c +7 -5
@@ -196,6 +196,7 @@ struct at91_adc_state {bool done;int irq;u16 last_value; +int chnb;struct mutex lock;u8 num_channels;void __iomem *reg_base;
@@ -274,7 +275,7 @@ void handle_adc_eoc_trigger(int irq, strdisable_irq_nosync (irq);iio_trigger_poll (idev->trig,iio_get_time_ns ()); }else { - st->last_value =at91_adc_readl (st,AT91_ADC_LCDR ); + st->last_value =at91_adc_readl (st,AT91_ADC_CHAN (st, st->chnb)); st->done = true;wake_up_interruptible (&st->wq_data_avail); }
@@ -351,7 +352,7 @@ static irqreturn_t at91_adc_rl_interruptunsigned int reg; status &=at91_adc_readl (st,AT91_ADC_IMR ); -if (status & st->registers->drdy_mask) +if (status &GENMASK (st->num_channels -1 ,0 ))handle_adc_eoc_trigger (irq, idev);if (status &AT91RL_ADC_IER_PEN ) {
@@ -418,7 +419,7 @@ static irqreturn_t at91_adc_9x5_interrupAT91_ADC_IER_YRDY |AT91_ADC_IER_PRDY ; -if (status & st->registers->drdy_mask) +if (status &GENMASK (st->num_channels -1 ,0 ))handle_adc_eoc_trigger (irq, idev);if (status &AT91_ADC_IER_PEN ) {
@@ -689,9 +690,10 @@ static int at91_adc_read_raw(struct iio_case IIO_CHAN_INFO_RAW :mutex_lock (&st->lock); + st->chnb = chan->channel;at91_adc_writel (st,AT91_ADC_CHER ,AT91_ADC_CH (chan->channel)); -at91_adc_writel (st,AT91_ADC_IER , st->registers->drdy_mask); +at91_adc_writel (st,AT91_ADC_IER ,BIT (chan->channel));at91_adc_writel (st,AT91_ADC_CR ,AT91_ADC_START ); ret = wait_event_interruptible_timeout(st->wq_data_avail,
@@ -708,7 +710,7 @@ static int at91_adc_read_raw(struct iio_at91_adc_writel (st,AT91_ADC_CHDR ,AT91_ADC_CH (chan->channel)); -at91_adc_writel (st,AT91_ADC_IDR , st->registers->drdy_mask); +at91_adc_writel (st,AT91_ADC_IDR ,BIT (chan->channel)); st->last_value =0 ; st->done = false;
Greg Kroah-Hartman
maintainerPATCH 232/357 Target/iser: Get isert_conn reference once got to connected_handler
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
commit c2f88b17a1d97ca4ecd96cc22333a7a4f1407d39 upstream.
In case the connection didn't reach connected state, disconnected handler will never be invoked thus the second kref_put on isert_conn will be missing.
--- drivers/infiniband/ulp/isert/ib_isert.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/infiniband/ulp/isert/ib_isert.c +3 -2
@@ -586,7 +586,6 @@ isert_connect_request(struct rdma_cm_idinit_completion (&isert_conn->conn_wait);init_completion (&isert_conn->conn_wait_comp_err);kref_init (&isert_conn->conn_kref); -kref_get (&isert_conn->conn_kref);mutex_init (&isert_conn->conn_mutex);spin_lock_init (&isert_conn->conn_lock);INIT_LIST_HEAD (&isert_conn->conn_fr_pool);
@@ -746,7 +745,9 @@ isert_connect_release(struct isert_connstatic void isert_connected_handler (struct rdma_cm_id *cma_id) { -return ; +struct isert_conn *isert_conn = cma_id->context; + +kref_get (&isert_conn->conn_kref); } static void
Greg Kroah-Hartman
maintainerPATCH 233/357 Target/iser: Dont put isert_conn inside disconnected handler
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sagi Grimberg <[email protected]>
commit 0fc4ea701fcf5bc51ace4e288af5be741465f776 upstream.
disconnected_handler is invoked on several CM events (such as DISCONNECTED, DEVICE_REMOVAL, TIMEWAIT_EXIT...). Since multiple events can occur while before isert_free_conn is invoked, we might put all isert_conn references and free the connection too early.
--- drivers/infiniband/ulp/isert/ib_isert.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/infiniband/ulp/isert/ib_isert.c +1 -1
@@ -799,7 +799,6 @@ isert_disconnect_work(struct work_struct wake_up:complete (&isert_conn->conn_wait); -isert_put_conn (isert_conn); } static void
@@ -3235,6 +3234,7 @@ static void isert_wait_conn(struct iscsiwait_for_completion (&isert_conn->conn_wait_comp_err);wait_for_completion (&isert_conn->conn_wait); +isert_put_conn (isert_conn); }static void isert_free_conn (struct iscsi_conn *conn)
Greg Kroah-Hartman
maintainerPATCH 234/357 target: Fix inverted logic in SE_DEV_ALUA_SUPPORT_STATE_STORE
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sebastian Herbszt <[email protected]>
commit 1f0b030c45c781f9fe568e5e2a813d6c8567a051 upstream.
Fix inverted logic in SE_DEV_ALUA_SUPPORT_STATE_STORE for setting the supported ALUA access states via configfs, originally introduced in commit b0a382c5.
A value of 1 should enable the support, not disable it.
--- drivers/target/target_core_configfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/target_core_configfs.c +1 -1
@@ -2363,7 +2363,7 @@ static ssize_t target_core_alua_tg_pt_gppr_err ("Invalid value '%ld', must be '0' or '1'\n" , tmp); \return -EINVAL ; \ } \ -if (!tmp) \ +if (tmp) \ t->_var |= _bit; \else \ t->_var &= ~_bit; \
Greg Kroah-Hartman
maintainerPATCH 235/357 iscsi-target: avoid NULL pointer in iscsi_copy_param_list failure
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joern Engel <[email protected]>
commit 8ae757d09c45102b347a1bc2867f54ffc1ab8fda upstream.
In iscsi_copy_param_list() a failed iscsi_param_list memory allocation currently invokes iscsi_release_param_list() to cleanup, and will promptly trigger a NULL pointer dereference.
Instead, go ahead and return for the first iscsi_copy_param_list() failure case.
Found by coverity.
--- drivers/target/iscsi/iscsi_target_parameters.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target_parameters.c +1 -1
@@ -601,7 +601,7 @@ int iscsi_copy_param_list( param_list =kzalloc (sizeof (struct iscsi_param_list ),GFP_KERNEL );if (!param_list) {pr_err ("Unable to allocate memory for struct iscsi_param_list.\n" ); - goto err_out; +return -1 ; }INIT_LIST_HEAD (¶m_list->param_list);INIT_LIST_HEAD (¶m_list->extra_response_list);
Greg Kroah-Hartman
maintainerPATCH 236/357 iscsi-target: Fix memory corruption in iscsit_logout_post_handler_diffcid
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nicholas Bellinger <[email protected]>
commit b53b0d99d6fbf7d44330395349a895521cfdbc96 upstream.
This patch fixes a bug in iscsit_logout_post_handler_diffcid() where a pointer used as storage for list_for_each_entry() was incorrectly being used to determine if no matching entry had been found.
This patch changes iscsit_logout_post_handler_diffcid() to key off bool conn_found to determine if the function needs to exit early.
--- drivers/target/iscsi/iscsi_target.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/target/iscsi/iscsi_target.c +3 -1
@@ -4540,6 +4540,7 @@ static void iscsit_logout_post_handler_d {struct iscsi_conn *l_conn;struct iscsi_session *sess = conn->sess; +bool conn_found = false;if (!sess)return ;
@@ -4548,12 +4549,13 @@ static void iscsit_logout_post_handler_dlist_for_each_entry (l_conn, &sess->sess_conn_list, conn_list) {if (l_conn->cid == cid) {iscsit_inc_conn_usage_count (l_conn); + conn_found = true;break ; } }spin_unlock_bh (&sess->conn_lock); -if (!l_conn) +if (!conn_found)return ;if (l_conn->sock)
Greg Kroah-Hartman
maintainerPATCH 237/357 NFC: microread: Potential overflows in microread_target_discovered()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit d07f1e8600ccb885c8f4143402b8912f7d827bcb upstream.
Smatch says that skb->data is untrusted so we need to check to make sure that the memcpy() doesn't overflow.
--- drivers/nfc/microread/microread.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/nfc/microread/microread.c +12 -4
@@ -501,9 +501,13 @@ static void microread_target_discovered( targets->sens_res =be16_to_cpu (*(u16 *)&skb->data[MICROREAD_EMCF_A_ATQA ]); targets->sel_res = skb->data[MICROREAD_EMCF_A_SAK ]; -memcpy (targets->nfcid1, &skb->data[MICROREAD_EMCF_A_UID ], - skb->data[MICROREAD_EMCF_A_LEN ]); targets->nfcid1_len = skb->data[MICROREAD_EMCF_A_LEN ]; +if (targets->nfcid1_len >sizeof (targets->nfcid1)) { + r = -EINVAL ; + goto exit_free; + } +memcpy (targets->nfcid1, &skb->data[MICROREAD_EMCF_A_UID ], + targets->nfcid1_len);break ;case MICROREAD_GATE_ID_MREAD_ISO_A_3 : targets->supported_protocols =
@@ -511,9 +515,13 @@ static void microread_target_discovered( targets->sens_res =be16_to_cpu (*(u16 *)&skb->data[MICROREAD_EMCF_A3_ATQA ]); targets->sel_res = skb->data[MICROREAD_EMCF_A3_SAK ]; -memcpy (targets->nfcid1, &skb->data[MICROREAD_EMCF_A3_UID ], - skb->data[MICROREAD_EMCF_A3_LEN ]); targets->nfcid1_len = skb->data[MICROREAD_EMCF_A3_LEN ]; +if (targets->nfcid1_len >sizeof (targets->nfcid1)) { + r = -EINVAL ; + goto exit_free; + } +memcpy (targets->nfcid1, &skb->data[MICROREAD_EMCF_A3_UID ], + targets->nfcid1_len);break ;case MICROREAD_GATE_ID_MREAD_ISO_B : targets->supported_protocols =NFC_PROTO_ISO14443_B_MASK ;
Greg Kroah-Hartman
maintainerPATCH 238/357 SCSI: libiscsi: fix potential buffer overrun in __iscsi_conn_send_pdu
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Christie <[email protected]>
commit db9bfd64b14a3a8f1868d2164518fdeab1b26ad1 upstream.
This patches fixes a potential buffer overrun in __iscsi_conn_send_pdu. This function is used by iscsi drivers and userspace to send iscsi PDUs/ commands. For login commands, we have a set buffer size. For all other commands we do not support data buffers.
This was reported by Dan Carpenter here:
http://www.spinics.net/lists/linux-scsi/msg66838.html
--- drivers/scsi/libiscsi.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
drivers/scsi/libiscsi.c +10 -0
@@ -717,11 +717,21 @@ __iscsi_conn_send_pdu(struct iscsi_connreturn NULL ; } +if (data_size >ISCSI_DEF_MAX_RECV_SEG_LEN ) { +iscsi_conn_printk (KERN_ERR , conn,"Invalid buffer len of %u for login task. Max len is %u\n" , data_size,ISCSI_DEF_MAX_RECV_SEG_LEN ); +return NULL ; + } + task = conn->login_task; }else {if (session->state !=ISCSI_STATE_LOGGED_IN )return NULL ; +if (data_size !=0 ) { +iscsi_conn_printk (KERN_ERR , conn,"Can not send data buffer of len %u for op 0x%x\n" , data_size, opcode); +return NULL ; + } +BUG_ON (conn->c_stage ==ISCSI_CONN_INITIAL_STAGE );BUG_ON (conn->c_stage ==ISCSI_CONN_STOPPED );
Greg Kroah-Hartman
maintainerPATCH 239/357 Revert "iwlwifi: dvm: dont enable CTS to self"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit f47f46d7b09cf1d09e4b44b6cc4dd7d68a08028c upstream.
This reverts commit 43d826ca5979927131685cc2092c7ce862cb91cd.
This commit caused packet loss.
--- drivers/net/wireless/iwlwifi/dvm/rxon.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
drivers/net/wireless/iwlwifi/dvm/rxon.c +12 -0
@@ -1068,6 +1068,13 @@ int iwlagn_commit_rxon(struct iwl_priv */* recalculate basic rates */ iwl_calc_basic_rates (priv, ctx); +/* +* force CTS-to-self frames protection if RTS-CTS is not preferred +* one aggregation protection method +*/ +if (!priv->hw_params.use_rts_for_aggregation) + ctx->staging.flags |=RXON_FLG_SELF_CTS_EN ; +if ((ctx->vif && ctx->vif->bss_conf.use_short_slot) || !(ctx->staging.flags &RXON_FLG_BAND_24G_MSK )) ctx->staging.flags |=RXON_FLG_SHORT_SLOT_MSK ;
@@ -1473,6 +1480,11 @@ void iwlagn_bss_info_changed(struct ieeeelse ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK ; +if (bss_conf->use_cts_prot) + ctx->staging.flags |=RXON_FLG_SELF_CTS_EN ; +else + ctx->staging.flags &= ~RXON_FLG_SELF_CTS_EN ; +memcpy (ctx->staging.bssid_addr, bss_conf->bssid,ETH_ALEN ); if (vif->type == NL80211_IFTYPE_AP ||
Greg Kroah-Hartman
maintainerPATCH 240/357 iwlwifi: mvm: fix endianity issues with Smart Fifo commands
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Emmanuel Grumbach <[email protected]>
commit 86974bff066dd8b98be46d7c7d3aba89034f0833 upstream.
This code was broken on big endian systems. Sparse didn't catch the bug since the firmware command was not tagged as little endian.
Fix the bug for big endian systems and tag the field in the firmware command to prevent such issues in the future.
--- drivers/net/wireless/iwlwifi/mvm/fw-api.h | 4 ++-- drivers/net/wireless/iwlwifi/mvm/sf.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/iwlwifi/mvm/fw-api.h +2 -2
@@ -1487,14 +1487,14 @@ enum iwl_sf_scenario {/** * Smart Fifo configuration command. -* @state: smart fifo state, types listed in iwl_sf_sate. +* @state: smart fifo state, types listed in enum %iwl_sf_sate. * @watermark: Minimum allowed availabe free space in RXF for transient state. * @long_delay_timeouts: aging and idle timer values for each scenario * in long delay state. * @full_on_timeouts: timer values for each scenario in full on state. */ struct iwl_sf_cfg_cmd { -enum iwl_sf_state state; +__le32 state;__le32 watermark[SF_TRANSIENT_STATES_NUMBER ];__le32 long_delay_timeouts[SF_NUM_SCENARIO ][SF_NUM_TIMEOUT_TYPES ];__le32 full_on_timeouts[SF_NUM_SCENARIO ][SF_NUM_TIMEOUT_TYPES ];
drivers/net/wireless/iwlwifi/mvm/sf.c +1 -1
@@ -172,7 +172,7 @@ static int iwl_mvm_sf_config(struct iwl_ enum iwl_sf_state new_state) {struct iwl_sf_cfg_cmd sf_cmd = { - .state = new_state, + .state =cpu_to_le32 (new_state), };struct ieee80211_sta *sta;int ret =0 ;
Greg Kroah-Hartman
maintainerPATCH 241/357 iwlwifi: increase DEFAULT_MAX_TX_POWER
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eliad Peller <[email protected]>
commit 22d059a5c7c5de61e53c88e30b65e55fbfd91e91 upstream.
The chip is able to transmit up to 22dBm, so set
the constant appropriately.
--- drivers/net/wireless/iwlwifi/iwl-config.h | 2 ++ drivers/net/wireless/iwlwifi/iwl-nvm-parse.c | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/net/wireless/iwlwifi/iwl-config.h +2 -0
@@ -120,6 +120,8 @@ enum iwl_led_mode {#define IWL_LONG_WD_TIMEOUT 10000#define IWL_MAX_WD_TIMEOUT 120000 +#define IWL_DEFAULT_MAX_TX_POWER 22 +/* Antenna presence definitions */ #define ANT_NONE 0x0#define ANT_A BIT(0)
drivers/net/wireless/iwlwifi/iwl-nvm-parse.c +1 -3
@@ -143,8 +143,6 @@ static const u8 iwl_nvm_channels_family_#define LAST_2GHZ_HT_PLUS 9#define LAST_5GHZ_HT 161 -#define DEFAULT_MAX_TX_POWER 16 -/* rate data (static) */ static struct ieee80211_rate iwl_cfg80211_rates[] = { { .bitrate =1 *10 , .hw_value =0 , .hw_value_short =0 , },
@@ -279,7 +277,7 @@ static int iwl_init_channel_map(struct d* Default value - highest tx power value. max_power * is not used in mvm, and is used for backwards compatibility */ - channel->max_power =DEFAULT_MAX_TX_POWER ; + channel->max_power =IWL_DEFAULT_MAX_TX_POWER ; is_5ghz = channel->band ==IEEE80211_BAND_5GHZ ; IWL_DEBUG_EEPROM(dev, "Ch. %d [%sGHz] %s%s%s%s%s%s(0x%02x %ddBm): Ad-Hoc %ssupported\n",
Greg Kroah-Hartman
maintainerPATCH 242/357 iwlwifi: mvm: treat EAPOLs like mgmt frames wrt rate
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eyal Shapira <[email protected]>
commit aa11bbf3df026d6b1c6b528bef634fd9de7c2619 upstream.
Using the LQ table which is initially set according to the rssi could lead to EAPOLs being sent in high legacy rates like 54mbps.
It's better to avoid sending EAPOLs in high rates as it reduces the chances of a successful 4-Way handshake.
Avoid this and treat them like other mgmt frames which would initially get sent at the basic rate.
--- drivers/net/wireless/iwlwifi/mvm/tx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/wireless/iwlwifi/mvm/tx.c +6 -2
@@ -169,10 +169,14 @@ static void iwl_mvm_set_tx_cmd_rate(stru/* * for data packets, rate info comes from the table inside the fw. This -* table is controlled by LINK_QUALITY commands +* table is controlled by LINK_QUALITY commands. Exclude ctrl port +* frames like EAPOLs which should be treated as mgmt frames. This +* avoids them being sent initially in high rates which increases the +* chances for completion of the 4-Way handshake. */ -if (ieee80211_is_data (fc) && sta) { +if (ieee80211_is_data (fc) && sta && + !(info->control.flags &IEEE80211_TX_CTRL_PORT_CTRL_PROTO )) { tx_cmd->initial_rate_index =0 ; tx_cmd->tx_flags |=cpu_to_le32 (TX_CMD_FLG_STA_RATE );return ;
Greg Kroah-Hartman
maintainerPATCH 243/357 iwlwifi: mvm: set MAC_FILTER_IN_BEACON correctly for STA/P2P client
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Luciano Coelho <[email protected]>
commit 7c8b3bc688bdcfd7789efbd17da4d85b104ad351 upstream.
In commit cad3f08c (iwlwifi: mvm: enable MAC_FILTER_IN_BEACON when forced_assoc_off is set) the code to set the MAC_FILTER_IN_BEACON flag was accidentally moved to the main block of the if statement, while it should be in the else block instead. Move it to the right place.
--- drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/wireless/iwlwifi/mvm/mac-ctxt.c +5 -5
@@ -720,11 +720,6 @@ static int iwl_mvm_mac_ctxt_cmd_sta(stru !force_assoc_off) {u32 dtim_offs; -/* Allow beacons to pass through as long as we are not -* associated, or we do not have dtim period information. -*/ - cmd.filter_flags |=cpu_to_le32 (MAC_FILTER_IN_BEACON ); -/* * The DTIM count counts down, so when it is N that means N * more beacon intervals happen until the DTIM TBTT. Therefore
@@ -758,6 +753,11 @@ static int iwl_mvm_mac_ctxt_cmd_sta(stru ctxt_sta->is_assoc =cpu_to_le32 (1 ); }else { ctxt_sta->is_assoc =cpu_to_le32 (0 ); + +/* Allow beacons to pass through as long as we are not +* associated, or we do not have dtim period information. +*/ + cmd.filter_flags |=cpu_to_le32 (MAC_FILTER_IN_BEACON ); } ctxt_sta->bi =cpu_to_le32 (vif->bss_conf.beacon_int);
Greg Kroah-Hartman
maintainerPATCH 244/357 workqueue: apply __WQ_ORDERED to create_singlethread_workqueue()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit e09c2c295468476a239d13324ce9042ec4de05eb upstream.
create_singlethread_workqueue() is a compat interface for single threaded workqueue which maps to ordered workqueue w/ rescuer in the current implementation. create_singlethread_workqueue() currently implemented by invoking alloc_workqueue() w/ appropriate parameters.
8719dceae2f9 ("workqueue: reject adjusting max_active or applying attrs to ordered workqueues") introduced __WQ_ORDERED to protect ordered workqueues against dynamic attribute changes which can break ordering guarantees but forgot to apply it to create_singlethread_workqueue(). This in itself is okay as nobody currently uses dynamic attribute change on workqueues created with create_singlethread_workqueue().
However, 4c16bd327c ("workqueue: implement NUMA affinity for unbound workqueues") broke singlethreaded guarantee for ordered workqueues through allocating a separate pool_workqueue on each NUMA node by default. A later change 8a2b75384444 ("workqueue: fix ordered workqueues in NUMA setups") fixed it by allocating only one global pool_workqueue if __WQ_ORDERED is set.
Combined, the __WQ_ORDERED omission in create_singlethread_workqueue() became critical breaking its single threadedness and ordering guarantee.
Let's make create_singlethread_workqueue() wrap alloc_ordered_workqueue() instead so that it inherits __WQ_ORDERED and can implicitly track future ordered_workqueue changes.
v2: I missed that __WQ_ORDERED now protects against pwq splitting
across NUMA nodes and incorrectly described the patch as a nice-to-have fix to protect against future dynamic attribute usages. Oleg pointed out that this is actually a critical breakage due to 8a2b75384444 ("workqueue: fix ordered workqueues in NUMA setups").
--- include/linux/workqueue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/workqueue.h +1 -1
@@ -419,7 +419,7 @@ __alloc_workqueue_key(const char *fmt, ualloc_workqueue ("%s" ,WQ_FREEZABLE |WQ_UNBOUND |WQ_MEM_RECLAIM , \ 1, (name))#define create_singlethread_workqueue (name) \ - alloc_workqueue("%s", WQ_UNBOUND | WQ_MEM_RECLAIM, 1, (name)) + alloc_ordered_workqueue("%s", WQ_MEM_RECLAIM, name)extern void destroy_workqueue (struct workqueue_struct *wq);
Greg Kroah-Hartman
maintainerPATCH 245/357 futex: Unlock hb->lock in futex_wait_requeue_pi() error path
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Thomas Gleixner <[email protected]>
commit 13c42c2f43b19aab3195f2d357db00d1e885eaa8 upstream.
futex_wait_requeue_pi() calls futex_wait_setup(). If futex_wait_setup() succeeds it returns with hb->lock held and preemption disabled. Now the sanity check after this does:
if (match_futex(&q.key, &key2)) {
ret = -EINVAL;
goto out_put_keys;
}which releases the keys but does not release hb->lock.
So we happily return to user space with hb->lock held and therefor preemption disabled.
Unlock hb->lock before taking the exit route.
--- kernel/futex.c | 1 + 1 file changed, 1 insertion(+)
kernel/futex.c +1 -0
@@ -2628,6 +2628,7 @@ static int futex_wait_requeue_pi(u32 __u* shared futexes. We need to compare the keys: */ if (match_futex (&q.key, &key2)) { +queue_unlock (hb); ret = -EINVAL ; goto out_put_keys; }
Greg Kroah-Hartman
maintainerPATCH 246/357 block: Fix dev_t minor allocation lifetime
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Keith Busch <[email protected]>
commit 2da78092dda13f1efd26edbbf99a567776913750 upstream.
Releases the dev_t minor when all references are closed to prevent another device from acquiring the same major/minor.
Since the partition's release may be invoked from call_rcu's soft-irq context, the ext_dev_idr's mutex had to be replaced with a spinlock so as not so sleep.
--- block/genhd.c | 24 ++++++++++++++---------- block/partition-generic.c | 2 +- 2 files changed, 15 insertions(+), 11 deletions(-)
block/genhd.c +14 -10
@@ -28,10 +28,10 @@ struct kobject *block_depr;/* for extended dynamic devt allocation, currently only one major is used */ #define NR_EXT_DEVT (1 << MINORBITS) -/* For extended devt allocation. ext_devt_mutex prevents look up +/* For extended devt allocation. ext_devt_lock prevents look up * results from going away underneath its user. */ -static DEFINE_MUTEX (ext_devt_mutex); +static DEFINE_SPINLOCK (ext_devt_lock);static DEFINE_IDR (ext_devt_idr);static struct device_type disk_type;
@@ -420,9 +420,13 @@ int blk_alloc_devt(struct hd_struct *par }/* allocate ext devt */ -mutex_lock (&ext_devt_mutex); - idx =idr_alloc (&ext_devt_idr, part,0 ,NR_EXT_DEVT ,GFP_KERNEL ); -mutex_unlock (&ext_devt_mutex); +idr_preload (GFP_KERNEL ); + +spin_lock (&ext_devt_lock); + idx =idr_alloc (&ext_devt_idr, part,0 ,NR_EXT_DEVT ,GFP_NOWAIT ); +spin_unlock (&ext_devt_lock); + +idr_preload_end ();if (idx <0 )return idx == -ENOSPC ? -EBUSY : idx;
@@ -447,9 +451,9 @@ void blk_free_devt(dev_t devt)return ;if (MAJOR (devt) ==BLOCK_EXT_MAJOR ) { -mutex_lock (&ext_devt_mutex); +spin_lock (&ext_devt_lock);idr_remove (&ext_devt_idr,blk_mangle_minor (MINOR (devt))); -mutex_unlock (&ext_devt_mutex); +spin_unlock (&ext_devt_lock); } }
@@ -665,7 +669,6 @@ void del_gendisk(struct gendisk *disk)sysfs_remove_link (block_depr,dev_name (disk_to_dev (disk)));pm_runtime_set_memalloc_noio (disk_to_dev (disk), false);device_del (disk_to_dev (disk)); -blk_free_devt (disk_to_dev (disk)->devt); }EXPORT_SYMBOL (del_gendisk);
@@ -690,13 +693,13 @@ struct gendisk *get_gendisk(dev_t devt, }else {struct hd_struct *part; -mutex_lock (&ext_devt_mutex); +spin_lock (&ext_devt_lock); part =idr_find (&ext_devt_idr,blk_mangle_minor (MINOR (devt)));if (part &&get_disk (part_to_disk (part))) { *partno = part->partno; disk =part_to_disk (part); } -mutex_unlock (&ext_devt_mutex); +spin_unlock (&ext_devt_lock); }return disk;
@@ -1098,6 +1101,7 @@ static void disk_release(struct device * {struct gendisk *disk =dev_to_disk (dev); +blk_free_devt (dev->devt);disk_release_events (disk);kfree (disk->random);disk_replace_part_tbl (disk,NULL );
block/partition-generic.c +1 -1
@@ -211,6 +211,7 @@ static const struct attribute_group *parstatic void part_release (struct device *dev) {struct hd_struct *p =dev_to_part (dev); +blk_free_devt (dev->devt);free_part_stats (p);free_part_info (p);kfree (p);
@@ -253,7 +254,6 @@ void delete_partition(struct gendisk *dircu_assign_pointer (ptbl->last_lookup,NULL );kobject_put (part->holder_dir);device_del (part_to_dev (part)); -blk_free_devt (part_devt (part));hd_struct_put (part); }
Greg Kroah-Hartman
maintainerPATCH 247/357 dm cache: fix race causing dirty blocks to be marked as clean
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anssi Hannula <[email protected]>
commit 40aa978eccec61347cd47b97c598df49acde8be5 upstream.
When a writeback or a promotion of a block is completed, the cell of that block is removed from the prison, the block is marked as clean, and the clear_dirty() callback of the cache policy is called.
Unfortunately, performing those actions in this order allows an incoming new write bio for that block to come in before clearing the dirty status is completed and therefore possibly causing one of these two scenarios:
Scenario A:
Thread 1 Thread 2 cell_defer() . - cell removed from prison . - detained bios queued . . incoming write bio . remapped to cache . set_dirty() called,
. but block already dirty
. => it does nothingclear_dirty() .
- block marked clean .
- policy clear_dirty() called .
Result: Block is marked clean even though it is actually dirty. No writeback will occur.
Scenario B:
Thread 1 Thread 2 cell_defer() . - cell removed from prison . - detained bios queued . clear_dirty() . - block marked clean . . incoming write bio . remapped to cache . set_dirty() called . - block marked dirty . - policy set_dirty() called
- policy clear_dirty() called .
Result: Block is properly marked as dirty, but policy thinks it is clean and therefore never asks us to writeback it.
This case is visible in "dmsetup status" dirty block count (which normally decreases to 0 on a quiet device).
Fix these issues by calling clear_dirty() before calling cell_defer(). Incoming bios for that block will then be detained in the cell and released only after clear_dirty() has completed, so the race will not occur.
Found by inspecting the code after noticing spurious dirty counts (scenario B).
--- drivers/md/dm-cache-target.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/dm-cache-target.c +2 -2
@@ -873,8 +873,8 @@ static void migration_success_pre_commitstruct cache *cache = mg->cache;if (mg->writeback) { -cell_defer (cache, mg->old_ocell, false);clear_dirty (cache, mg->old_oblock, mg->cblock); +cell_defer (cache, mg->old_ocell, false);cleanup_migration (mg);return ;
@@ -929,13 +929,13 @@ static void migration_success_post_commi } }else { +clear_dirty (cache, mg->new_oblock, mg->cblock);if (mg->requeue_holder)cell_defer (cache, mg->new_ocell, true);else {bio_endio (mg->new_ocell->holder,0 );cell_defer (cache, mg->new_ocell, false); } -clear_dirty (cache, mg->new_oblock, mg->cblock);cleanup_migration (mg); } }
Greg Kroah-Hartman
maintainerPATCH 248/357 dm crypt: fix access beyond the end of allocated space
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mikulas Patocka <[email protected]>
commit d49ec52ff6ddcda178fc2476a109cf1bd1fa19ed upstream.
The DM crypt target accesses memory beyond allocated space resulting in a crash on 32 bit x86 systems.
This bug is very old (it dates back to 2.6.25 commit 3a7f6c990ad04 "dm
crypt: use async crypto"). However, this bug was masked by the fact that kmalloc rounds the size up to the next power of two. This bug wasn't exposed until 3.17-rc1 commit 298a9fa08a ("dm crypt: use per-bio data"). By switching to using per-bio data there was no longer any padding beyond the end of a dm-crypt allocated memory block.
To minimize allocation overhead dm-crypt puts several structures into one block allocated with kmalloc. The block holds struct ablkcipher_request, cipher-specific scratch pad (crypto_ablkcipher_reqsize(any_tfm(cc))), struct dm_crypt_request and an initialization vector.
The variable dmreq_start is set to offset of struct dm_crypt_request within this memory block. dm-crypt allocates the block with this size:cc->dmreq_start + sizeof(struct dm_crypt_request) + cc->iv_size.
When accessing the initialization vector, dm-crypt uses the function iv_of_dmreq, which performs this calculation: ALIGN((unsigned long)(dmreq
+ 1), crypto_ablkcipher_alignmask(any_tfm(cc)) + 1).
dm-crypt allocated "cc->iv_size" bytes beyond the end of dm_crypt_request structure. However, when dm-crypt accesses the initialization vector, it takes a pointer to the end of dm_crypt_request, aligns it, and then uses it as the initialization vector. If the end of dm_crypt_request is not aligned on a crypto_ablkcipher_alignmask(any_tfm(cc)) boundary the alignment causes the initialization vector to point beyond the allocated space.
Fix this bug by calculating the variable iv_size_padding and adding it to the allocated size.
Also correct the alignment of dm_crypt_request. struct dm_crypt_request is specific to dm-crypt (it isn't used by the crypto subsystem at all), so it is aligned on __alignof__(struct dm_crypt_request).
Also align per_bio_data_size on ARCH_KMALLOC_MINALIGN, so that it is aligned as if the block was allocated with kmalloc.
--- drivers/md/dm-crypt.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-)
drivers/md/dm-crypt.c +16 -4
@@ -1681,6 +1681,7 @@ static int crypt_ctr(struct dm_target *tunsigned int key_size, opt_params;unsigned long long tmpll;int ret; +size_t iv_size_padding;struct dm_arg_set as;const char *opt_string;char dummy;
@@ -1717,12 +1718,23 @@ static int crypt_ctr(struct dm_target *t cc->dmreq_start =sizeof (struct ablkcipher_request ); cc->dmreq_start +=crypto_ablkcipher_reqsize (any_tfm (cc)); - cc->dmreq_start =ALIGN (cc->dmreq_start,crypto_tfm_ctx_alignment ()); - cc->dmreq_start +=crypto_ablkcipher_alignmask (any_tfm (cc)) & - ~(crypto_tfm_ctx_alignment () -1 ); + cc->dmreq_start =ALIGN (cc->dmreq_start, __alignof__(struct dm_crypt_request )); + +if (crypto_ablkcipher_alignmask (any_tfm (cc)) <CRYPTO_MINALIGN ) { +/* Allocate the padding exactly */ + iv_size_padding = -(cc->dmreq_start +sizeof (struct dm_crypt_request )) + &crypto_ablkcipher_alignmask (any_tfm (cc)); + }else { +/* +* If the cipher requires greater alignment than kmalloc +* alignment, we don't know the exact position of the +* initialization vector. We must assume worst case. +*/ + iv_size_padding =crypto_ablkcipher_alignmask (any_tfm (cc)); + } cc->req_pool =mempool_create_kmalloc_pool (MIN_IOS , cc->dmreq_start + -sizeof (struct dm_crypt_request ) + cc->iv_size); +sizeof (struct dm_crypt_request ) + iv_size_padding + cc->iv_size);if (!cc->req_pool) { ti->error ="Cannot allocate crypt request mempool" ; goto bad;
Greg Kroah-Hartman
maintainerPATCH 249/357 Input: serport - add compat handling for SPIOCSTYPE ioctl
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: John Sung <[email protected]>
commit a80d8b02751060a178bb1f7a6b7a93645a7a308b upstream.
When running a 32-bit inputattach utility in a 64-bit system, there will be error code "inputattach: can't set device type". This is caused by the serport device driver not supporting compat_ioctl, so that SPIOCSTYPE ioctl fails.
--- drivers/input/serio/serport.c | 45 +++++++++++++++++++++++++++++++++++------- 1 file changed, 38 insertions(+), 7 deletions(-)
drivers/input/serio/serport.c +38 -7
@@ -21,6 +21,7 @@#include <linux/init.h> #include <linux/serio.h> #include <linux/tty.h> +#include <linux/compat.h> MODULE_AUTHOR ("Vojtech Pavlik <[email protected]>" );MODULE_DESCRIPTION ("Input device TTY line discipline" );
@@ -198,28 +199,55 @@ static ssize_t serport_ldisc_read(structreturn 0 ; } +static void serport_set_type (struct tty_struct *tty,unsigned long type) +{ +struct serport *serport = tty->disc_data; + + serport->id.proto = type &0x000000ff ; + serport->id.id = (type &0x0000ff00 ) >>8 ; + serport->id.extra = (type &0x00ff0000 ) >>16 ; +} +/* * serport_ldisc_ioctl() allows to set the port protocol, and device ID */ -static int serport_ldisc_ioctl (struct tty_struct * tty,struct file * file,unsigned int cmd,unsigned long arg) +static int serport_ldisc_ioctl (struct tty_struct *tty,struct file *file, +unsigned int cmd,unsigned long arg) { -struct serport *serport = (struct serport *) tty->disc_data; -unsigned long type; -if (cmd ==SPIOCSTYPE ) { +unsigned long type; +if (get_user (type, (unsigned long __user *) arg))return -EFAULT ; - serport->id.proto = type &0x000000ff ; - serport->id.id = (type &0x0000ff00 ) >>8 ; - serport->id.extra = (type &0x00ff0000 ) >>16 ; +serport_set_type (tty, type); +return 0 ; + } + +return -EINVAL ; +} + +#ifdef CONFIG_COMPAT +#define COMPAT_SPIOCSTYPE _IOW('q', 0x01, compat_ulong_t) +static long serport_ldisc_compat_ioctl (struct tty_struct *tty, +struct file *file, +unsigned int cmd,unsigned long arg) +{ +if (cmd ==COMPAT_SPIOCSTYPE ) { +void __user *uarg =compat_ptr (arg); +compat_ulong_t compat_type; + +if (get_user (compat_type, (compat_ulong_t __user *)uarg)) +return -EFAULT ; +serport_set_type (tty, compat_type);return 0 ; }return -EINVAL ; } +#endif static void serport_ldisc_write_wakeup (struct tty_struct * tty) {
@@ -243,6 +271,9 @@ static struct tty_ldisc_ops serport_ldis .close = serport_ldisc_close, .read = serport_ldisc_read, .ioctl = serport_ldisc_ioctl, +#ifdef CONFIG_COMPAT + .compat_ioctl = serport_ldisc_compat_ioctl, +#endif .receive_buf = serport_ldisc_receive, .write_wakeup = serport_ldisc_write_wakeup };
Greg Kroah-Hartman
maintainerPATCH 250/357 Input: synaptics - add support for ForcePads
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit 5715fc764f7753d464dbe094b5ef9cffa6e479a4 upstream.
ForcePads are found on HP EliteBook 1040 laptops. They lack any kind of physical buttons, instead they generate primary button click when user presses somewhat hard on the surface of the touchpad. Unfortunately they also report primary button click whenever there are 2 or more contacts on the pad, messing up all multi-finger gestures (2-finger scrolling, multi-finger tapping, etc). To cope with this behavior we introduce a delay (currently 50 msecs) in reporting primary press in case more contacts appear.
--- drivers/input/mouse/synaptics.c | 68 ++++++++++++++++++++++++++++++---------- drivers/input/mouse/synaptics.h | 11 ++++++ 2 files changed, 63 insertions(+), 16 deletions(-)
drivers/input/mouse/synaptics.c +52 -16
@@ -626,10 +626,61 @@ static int synaptics_parse_hw_state(cons ((buf[0 ] &0x04 ) >>1 ) | ((buf[3] & 0x04) >> 2)); +if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || +SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && + hw->w ==2 ) { +synaptics_parse_agm (buf, priv, hw); +return 1 ; + } + + hw->x = (((buf[3 ] &0x10 ) <<8 ) | + ((buf[1 ] &0x0f ) <<8 ) | + buf[4 ]); + hw->y = (((buf[3 ] &0x20 ) <<7 ) | + ((buf[1 ] &0xf0 ) <<4 ) | + buf[5 ]); + hw->z = buf[2 ]; + hw->left = (buf[0 ] &0x01 ) ?1 :0 ; hw->right = (buf[0 ] &0x02 ) ?1 :0 ; -if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) { +if (SYN_CAP_FORCEPAD (priv->ext_cap_0c)) { +/* +* ForcePads, like Clickpads, use middle button +* bits to report primary button clicks. +* Unfortunately they report primary button not +* only when user presses on the pad above certain +* threshold, but also when there are more than one +* finger on the touchpad, which interferes with +* out multi-finger gestures. +*/ +if (hw->z ==0 ) { +/* No contacts */ + priv->press = priv->report_press = false; + }else if (hw->w >=4 && ((buf[0 ] ^ buf[3 ]) &0x01 )) { +/* +* Single-finger touch with pressure above +* the threshold. If pressure stays long +* enough, we'll start reporting primary +* button. We rely on the device continuing +* sending data even if finger does not +* move. +*/ +if (!priv->press) { + priv->press_start = jiffies; + priv->press = true; + }else if (time_after (jiffies, + priv->press_start + +msecs_to_jiffies (50 ))) { + priv->report_press = true; + } + }else { + priv->press = false; + } + + hw->left = priv->report_press; + + }else if (SYN_CAP_CLICKPAD (priv->ext_cap_0c)) {/* * Clickpad's button is transmitted as middle button, * however, since it is primary button, we will report
@@ -648,21 +699,6 @@ static int synaptics_parse_hw_state(cons hw->down = ((buf[0 ] ^ buf[3 ]) &0x02 ) ?1 :0 ; } -if ((SYN_CAP_ADV_GESTURE (priv->ext_cap_0c) || -SYN_CAP_IMAGE_SENSOR (priv->ext_cap_0c)) && - hw->w ==2 ) { -synaptics_parse_agm (buf, priv, hw); -return 1 ; - } - - hw->x = (((buf[3 ] &0x10 ) <<8 ) | - ((buf[1 ] &0x0f ) <<8 ) | - buf[4 ]); - hw->y = (((buf[3 ] &0x20 ) <<7 ) | - ((buf[1 ] &0xf0 ) <<4 ) | - buf[5 ]); - hw->z = buf[2 ]; -if (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) && ((buf[0 ] ^ buf[3 ]) &0x02 )) {switch (SYN_CAP_MULTI_BUTTON_NO (priv->ext_cap) & ~0x01 ) {
drivers/input/mouse/synaptics.h +11 -0
@@ -78,6 +78,11 @@* 2 0x08 image sensor image sensor tracks 5 fingers, but only * reports 2. * 2 0x20 report min query 0x0f gives min coord reported +* 2 0x80 forcepad forcepad is a variant of clickpad that +* does not have physical buttons but rather +* uses pressure above certain threshold to +* report primary clicks. Forcepads also have +* clickpad bit set. */ #define SYN_CAP_CLICKPAD (ex0c) ((ex0c) & 0x100000)/* 1-button ClickPad */ #define SYN_CAP_CLICKPAD2BTN (ex0c) ((ex0c) & 0x000100)/* 2-button ClickPad */
@@ -86,6 +91,7 @@#define SYN_CAP_ADV_GESTURE (ex0c) ((ex0c) & 0x080000)#define SYN_CAP_REDUCED_FILTERING (ex0c) ((ex0c) & 0x000400)#define SYN_CAP_IMAGE_SENSOR (ex0c) ((ex0c) & 0x000800) +#define SYN_CAP_FORCEPAD (ex0c) ((ex0c) & 0x008000)/* synaptics modes query bits */ #define SYN_MODE_ABSOLUTE (m) ((m) & (1 << 7))
@@ -177,6 +183,11 @@ struct synaptics_data {*/ struct synaptics_hw_state agm;bool agm_pending;/* new AGM packet received */ + +/* ForcePad handling */ +unsigned long press_start; +bool press; +bool report_press; };void synaptics_module_init (void );
Greg Kroah-Hartman
maintainerPATCH 252/357 Input: atkbd - do not try deactivate keyboard on any LG laptops
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dmitry Torokhov <[email protected]>
commit c01206796139e2b1feb7539bc72174fef1c6dc6e upstream.
We are getting more and more reports about LG laptops not having functioning keyboard if we try to deactivate keyboard during probe. Given that having keyboard deactivated is merely "nice to have" instead of a hard requirement for probing, let's disable it on all LG boxes instead of trying to hunt down particular models.
This change is prompted by patches trying to add "LG Electronics"/"ROCKY" and "LG Electronics"/"LW60-F27B" to the DMI list.
https://bugzilla.kernel.org/show_bug.cgi?id=77051
--- drivers/input/keyboard/atkbd.c | 8 -------- 1 file changed, 8 deletions(-)
drivers/input/keyboard/atkbd.c +0 -8
@@ -1791,14 +1791,6 @@ static const struct dmi_system_id atkbd_ { .matches = { DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), - DMI_MATCH(DMI_PRODUCT_NAME, "LW25-B7HV"), - }, - .callback = atkbd_deactivate_fixup, - }, - { - .matches = { - DMI_MATCH(DMI_SYS_VENDOR, "LG Electronics"), - DMI_MATCH(DMI_PRODUCT_NAME, "P1-J273B"), }, .callback = atkbd_deactivate_fixup, },
Greg Kroah-Hartman
maintainerPATCH 253/357 Input: i8042 - add Fujitsu U574 to no_timeout dmi table
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit cc18a69c92d0972bc2fc5a047ee3be1e8398171b upstream.
https://bugzilla.kernel.org/show_bug.cgi?id=69731
--- drivers/input/serio/i8042-x86ia64io.h | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +8 -0
@@ -608,6 +608,14 @@ static const struct dmi_system_id __init DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"), }, }, + { + /* Fujitsu U574 laptop */ + /* https://bugzilla.kernel.org/show_bug.cgi?id=69731 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "FUJITSU"), + DMI_MATCH(DMI_PRODUCT_NAME, "LIFEBOOK U574"), + }, + }, { } };
Greg Kroah-Hartman
maintainerPATCH 254/357 Input: i8042 - add nomux quirk for Avatar AVIU-145A6
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans de Goede <[email protected]>
commit d2682118f4bb3ceb835f91c1a694407a31bb7378 upstream.
The sys_vendor / product_name are somewhat generic unfortunately, so this may lead to some false positives. But nomux usually does no harm, where as not having it clearly is causing problems on the Avatar AVIU-145A6.
https://bugzilla.kernel.org/show_bug.cgi?id=77391
--- drivers/input/serio/i8042-x86ia64io.h | 7 +++++++ 1 file changed, 7 insertions(+)
drivers/input/serio/i8042-x86ia64io.h +7 -0
@@ -465,6 +465,13 @@ static const struct dmi_system_id __init DMI_MATCH(DMI_PRODUCT_NAME, "HP Pavilion dv4 Notebook PC"), }, }, + { + /* Avatar AVIU-145A6 */ + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Intel"), + DMI_MATCH(DMI_PRODUCT_NAME, "IC4I"), + }, + }, { } };
Greg Kroah-Hartman
maintainerPATCH 255/357 hwmon: (ds1621) Update zbits after conversion rate change
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Robert Coulson <[email protected]>
commit 39c627a084475e8a690a4a9e7601410ca173ddd2 upstream.
After the conversion rate is changed, the zbits are not updated, but should be, since they are used later in the set_temp function.
--- drivers/hwmon/ds1621.c | 1 + 1 file changed, 1 insertion(+)
drivers/hwmon/ds1621.c +1 -0
@@ -309,6 +309,7 @@ static ssize_t set_convrate(struct devic data->conf |= (resol <<DS1621_REG_CONFIG_RESOL_SHIFT );i2c_smbus_write_byte_data (client,DS1621_REG_CONF , data->conf); data->update_interval = ds1721_convrates[resol]; + data->zbits =7 - resol;mutex_unlock (&data->update_lock);return count;
Greg Kroah-Hartman
maintainerPATCH 256/357 ata_piix: Add Device IDs for Intel 9 Series PCH
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: James Ralston <[email protected]>
commit 6cad1376954e591c3c41500c4e586e183e7ffe6d upstream.
This patch adds the IDE mode SATA Device IDs for the Intel 9 Series PCH.
--- drivers/ata/ata_piix.c | 8 ++++++++ 1 file changed, 8 insertions(+)
drivers/ata/ata_piix.c +8 -0
@@ -340,6 +340,14 @@ static const struct pci_device_id piix_p { 0x8086, 0x0F21, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_byt },/* SATA Controller IDE (Coleto Creek) */ { 0x8086, 0x23a6, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata }, +/* SATA Controller IDE (9 Series) */ + { 0x8086, 0x8c88, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb }, +/* SATA Controller IDE (9 Series) */ + { 0x8086, 0x8c89, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_2port_sata_snb }, +/* SATA Controller IDE (9 Series) */ + { 0x8086, 0x8c80, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, +/* SATA Controller IDE (9 Series) */ + { 0x8086, 0x8c81, PCI_ANY_ID, PCI_ANY_ID, 0, 0, ich8_sata_snb }, { } /* terminate list */ };
Greg Kroah-Hartman
maintainerPATCH 257/357 gpio: Fix potential NULL handler data in chained irqchip handler
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jarkko Nikula <[email protected]>
commit 324b0398781e7afb846378dd2d8a4374faaf236b upstream.
There is possibility with misconfigured pins that interrupt occurs instantly after setting irq_set_chained_handler() in gpiochip_set_chained_irqchip(). Now if handler gets called before irq_set_handler_data() the handler gets NULL handler data.
Fix this by moving irq_set_handler_data() call before irq_set_chained_handler() in gpiochip_set_chained_irqchip().
--- drivers/gpio/gpiolib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpiolib.c +1 -1
@@ -1368,12 +1368,12 @@ void gpiochip_set_chained_irqchip(structreturn ; } -irq_set_chained_handler (parent_irq, parent_handler);/* * The parent irqchip is already using the chip_data for this * irqchip, so our callbacks simply use the handler_data. */ irq_set_handler_data (parent_irq, gpiochip); +irq_set_chained_handler (parent_irq, parent_handler); }EXPORT_SYMBOL_GPL (gpiochip_set_chained_irqchip);
Greg Kroah-Hartman
maintainerPATCH 258/357 percpu: free percpu allocation info for uniprocessor system
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Honggang Li <[email protected]>
commit 3189eddbcafcc4d827f7f19facbeddec4424eba8 upstream.
Currently, only SMP system free the percpu allocation info. Uniprocessor system should free it too. For example, one x86 UML virtual machine with 256MB memory, UML kernel wastes one page memory.
--- mm/percpu.c | 2 ++ 1 file changed, 2 insertions(+)
mm/percpu.c +2 -0
@@ -1933,6 +1933,8 @@ void __init setup_per_cpu_areas(void)if (pcpu_setup_first_chunk (ai, fc) <0 )panic ("Failed to initialize percpu areas." ); + + pcpu_free_alloc_info(ai); }#endif /* CONFIG_SMP */
Greg Kroah-Hartman
maintainerPATCH 259/357 percpu: fix pcpu_alloc_pages() failure path
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit f0d279654dea22b7a6ad34b9334aee80cda62cde upstream.
When pcpu_alloc_pages() fails midway, pcpu_free_pages() is invoked to free what has already been allocated. The invocation is across the whole requested range and pcpu_free_pages() will try to free all non-NULL pages; unfortunately, this is incorrect as pcpu_get_pages_and_bitmap(), unlike what its comment suggests, doesn't clear the pages array and thus the array may have entries from the previous invocations making the partial failure path free incorrect pages.
Fix it by open-coding the partial freeing of the already allocated pages.
--- mm/percpu-vm.c | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-)
mm/percpu-vm.c +15 -6
@@ -108,7 +108,7 @@ static int pcpu_alloc_pages(struct pcpu_ int page_start, int page_end) {const gfp_t gfp =GFP_KERNEL | __GFP_HIGHMEM | __GFP_COLD; -unsigned int cpu; +unsigned int cpu, tcpu;int i;for_each_possible_cpu (cpu) {
@@ -116,14 +116,23 @@ static int pcpu_alloc_pages(struct pcpu_struct page **pagep = &pages[pcpu_page_idx (cpu, i)]; *pagep =alloc_pages_node (cpu_to_node (cpu), gfp,0 ); -if (!*pagep) { -pcpu_free_pages (chunk, pages, populated, - page_start, page_end); -return -ENOMEM ; - } +if (!*pagep) + goto err; } }return 0 ; + +err: +while (--i >= page_start) +__free_page (pages[pcpu_page_idx (cpu, i)]); + +for_each_possible_cpu (tcpu) { +if (tcpu == cpu) +break ; +for (i = page_start; i < page_end; i++) +__free_page (pages[pcpu_page_idx (tcpu, i)]); + } +return -ENOMEM ; }/**
Greg Kroah-Hartman
maintainerPATCH 260/357 percpu: perform tlb flush after pcpu_map_pages() failure
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tejun Heo <[email protected]>
commit 849f5169097e1ba35b90ac9df76b5bb6f9c0aabd upstream.
If pcpu_map_pages() fails midway, it unmaps the already mapped pages. Currently, it doesn't flush tlb after the partial unmapping. This may be okay in most cases as the established mapping hasn't been used at that point but it can go wrong and when it goes wrong it'd be extremely difficult to track down.
Flush tlb after the partial unmapping.
--- mm/percpu-vm.c | 1 + 1 file changed, 1 insertion(+)
mm/percpu-vm.c +1 -0
@@ -272,6 +272,7 @@ err:__pcpu_unmap_pages (pcpu_chunk_addr (chunk, tcpu, page_start), page_end - page_start); } +pcpu_post_unmap_tlb_flush (chunk, page_start, page_end);return err; }
Greg Kroah-Hartman
maintainerPATCH 261/357 regulatory: add NUL to alpha2
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eliad Peller <[email protected]>
commit a5fe8e7695dc3f547e955ad2b662e3e72969e506 upstream.
alpha2 is defined as 2-chars array, but is used in multiple places as string (e.g. with nla_put_string calls), which might leak kernel data.
Solve it by simply adding an extra char for the NULL terminator, making such operations safe.
--- include/net/regulatory.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/net/regulatory.h +1 -1
@@ -167,7 +167,7 @@ struct ieee80211_reg_rule {struct ieee80211_regdomain {struct rcu_head rcu_head;u32 n_reg_rules; -char alpha2[2 ]; +char alpha2[3 ];enum nl80211_dfs_regions dfs_region;struct ieee80211_reg_rule reg_rules[]; };
Greg Kroah-Hartman
maintainerPATCH 262/357 rtlwifi: rtl8192cu: Add new ID
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Larry Finger <[email protected]>
commit c66517165610b911e4c6d268f28d8c640832dbd1 upstream.
The Sitecom WLA-2102 adapter uses this driver.
--- drivers/net/wireless/rtlwifi/rtl8192cu/sw.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/wireless/rtlwifi/rtl8192cu/sw.c +1 -0
@@ -317,6 +317,7 @@ static struct usb_device_id rtl8192c_usb {RTL_USB_DEVICE(0x0bda, 0x5088, rtl92cu_hal_cfg)}, /*Thinkware-CC&C*/ {RTL_USB_DEVICE(0x0df6, 0x0052, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ {RTL_USB_DEVICE(0x0df6, 0x005c, rtl92cu_hal_cfg)}, /*Sitecom - Edimax*/ + {RTL_USB_DEVICE(0x0df6, 0x0070, rtl92cu_hal_cfg)}, /*Sitecom - 150N */ {RTL_USB_DEVICE(0x0df6, 0x0077, rtl92cu_hal_cfg)}, /*Sitecom-WLA2100V2*/ {RTL_USB_DEVICE(0x0eb0, 0x9071, rtl92cu_hal_cfg)}, /*NO Brand - Etop*/ {RTL_USB_DEVICE(0x4856, 0x0091, rtl92cu_hal_cfg)}, /*NetweeN - Feixun*/
Greg Kroah-Hartman
maintainerPATCH 263/357 lockd: fix rpcbind crash on lockd startup failure
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "J. Bruce Fields" <[email protected]>
commit 7c17705e77b12b20fb8afb7c1b15dcdb126c0c12 upstream.
Nikita Yuschenko reported that booting a kernel with init=/bin/sh and then nfs mounting without portmap or rpcbind running using a busybox mount resulted in:
# mount -t nfs 10.30.130.21:/opt /mnt svc: failed to register lockdv1 RPC service (errno 111). lockd_up: makesock failed, error=-111 Unable to handle kernel paging request for data at address 0x00000030 Faulting instruction address: 0xc055e65c Oops: Kernel access of bad area, sig: 11 [#1] MPC85xx CDS Modules linked in: CPU: 0 PID: 1338 Comm: mount Not tainted 3.10.44.cge #117 task: cf29cea0 ti: cf35c000 task.ti: cf35c000 NIP: c055e65c LR: c0566490 CTR: c055e648 REGS: cf35dad0 TRAP: 0300 Not tainted (3.10.44.cge) MSR: 00029000 <CE,EE,ME> CR: 22442488 XER: 20000000 DEAR: 00000030, ESR: 00000000
GPR00: c05606f4 cf35db80 cf29cea0 cf0ded80 cf0dedb8 00000001 1dec3086 00000000
GPR08: 00000000 c07b1640 00000007 1dec3086 22442482 100b9758 00000000 10090ae8
GPR16: 00000000 000186a5 00000000 00000000 100c3018 bfa46edc 100b0000 bfa46ef0
GPR24: cf386ae0 c07834f0 00000000 c0565f88 00000001 cf0dedb8 00000000 cf0ded80
NIP [c055e65c] call_start+0x14/0x34
LR [c0566490] __rpc_execute+0x70/0x250
Call Trace: [cf35db80] [00000080] 0x80 (unreliable) [cf35dbb0] [c05606f4] rpc_run_task+0x9c/0xc4 [cf35dbc0] [c0560840] rpc_call_sync+0x50/0xb8 [cf35dbf0] [c056ee90] rpcb_register_call+0x54/0x84 [cf35dc10] [c056f24c] rpcb_register+0xf8/0x10c [cf35dc70] [c0569e18] svc_unregister.isra.23+0x100/0x108 [cf35dc90] [c0569e38] svc_rpcb_cleanup+0x18/0x30 [cf35dca0] [c0198c5c] lockd_up+0x1dc/0x2e0 [cf35dcd0] [c0195348] nlmclnt_init+0x2c/0xc8 [cf35dcf0] [c015bb5c] nfs_start_lockd+0x98/0xec [cf35dd20] [c015ce6c] nfs_create_server+0x1e8/0x3f4 [cf35dd90] [c0171590] nfs3_create_server+0x10/0x44 [cf35dda0] [c016528c] nfs_try_mount+0x158/0x1e4 [cf35de20] [c01670d0] nfs_fs_mount+0x434/0x8c8 [cf35de70] [c00cd3bc] mount_fs+0x20/0xbc [cf35de90] [c00e4f88] vfs_kern_mount+0x50/0x104 [cf35dec0] [c00e6e0c] do_mount+0x1d0/0x8e0 [cf35df10] [c00e75ac] SyS_mount+0x90/0xd0 [cf35df40] [c000ccf4] ret_from_syscall+0x0/0x3c
The addition of svc_shutdown_net() resulted in two calls to svc_rpcb_cleanup(); the second is no longer necessary and crashes when it calls rpcb_register_call with clnt=NULL.
--- fs/lockd/svc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
fs/lockd/svc.c +1 -3
@@ -253,13 +253,11 @@ static int lockd_up_net(struct svc_serv error =make_socks (serv, net);if (error <0 ) - goto err_socks; + goto err_bind;set_grace_period (net);dprintk ("lockd_up_net: per-net data created; net=%p\n" , net);return 0 ; -err_socks: -svc_rpcb_cleanup (serv, net); err_bind: ln->nlmsvc_users--;return error;
Greg Kroah-Hartman
maintainerPATCH 264/357 lockdep: Revert lockdep check in raw_seqcount_begin()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Trond Myklebust <[email protected]>
commit 22fdcf02f6e80d64a927f702dd9d631a927d87d4 upstream.
This commit reverts the addition of lockdep checking to raw_seqcount_begin for the following reasons:
1) It violates the naming convention that raw_* functions should not do lockdep checks (a convention that is also followed by the other raw_*_seqcount_begin functions).
2) raw_seqcount_begin does not spin, so it can only be part of an ABBA deadlock in very special circumstances (for instance if a lock is held across the entire raw_seqcount_begin()+read_seqcount_retry() loop while also being taken inside the write_seqcount protected area).
3) It is causing false positives with some existing callers, and there is no non-lockdep alternative for those callers to use.
None of the three existing callers (__d_lookup_rcu, netdev_get_name, and the NFS state code) appear to use the function in a manner that is ABBA deadlock prone.
--- include/linux/seqlock.h | 2 -- 1 file changed, 2 deletions(-)
include/linux/seqlock.h +0 -2
@@ -164,8 +164,6 @@ static inline unsigned read_seqcount_begstatic inline unsigned raw_seqcount_begin (const seqcount_t *s) {unsigned ret =ACCESS_ONCE (s->sequence); - -seqcount_lockdep_reader_access (s);smp_rmb ();return ret & ~1 ; }
Greg Kroah-Hartman
maintainerPATCH 265/357 genhd: fix leftover might_sleep() in blk_free_devt()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Jens Axboe <[email protected]>
commit 46f341ffcfb5d8530f7d1e60f3be06cce6661b62 upstream.
Commit 2da78092 changed the locking from a mutex to a spinlock, so we now longer sleep in this context. But there was a leftover might_sleep() in there, which now triggers since we do the final free from an RCU callback. Get rid of it.
--- block/genhd.c | 2 -- 1 file changed, 2 deletions(-)
block/genhd.c +0 -2
@@ -445,8 +445,6 @@ int blk_alloc_devt(struct hd_struct *par*/ void blk_free_devt (dev_t devt) { -might_sleep (); -if (devt ==MKDEV (0 ,0 ))return ;
Greg Kroah-Hartman
maintainerPATCH 266/357 usb: dwc3: fix TRB completion when multiple TRBs are started
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Felipe Balbi <[email protected]>
commit 0b93a4c838fa10370d72f86fe712426ac63804de upstream.
After commit 2ec2a8be (usb: dwc3: gadget:
always enable IOC on bulk/interrupt transfers) we created a situation where it was possible to hang a bulk/interrupt endpoint if we had more than one pending request in our queue and they were both started with a single Start Transfer command.
The problems triggers because we had not enabled Transfer In Progress event for those endpoints and we were not able to process early giveback of requests completed without LST bit set.
Fix the problem by finally enabling Xfer In Progress event for all endpoint types, except control.
enable IOC on bulk/interrupt transfers)
--- drivers/usb/dwc3/gadget.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/usb/dwc3/gadget.c +1 -7
@@ -527,7 +527,7 @@ static int dwc3_gadget_set_ep_config(str dep->stream_capable = true; } -if (usb_endpoint_xfer_isoc (desc)) +if (!usb_endpoint_xfer_control (desc)) params.param1 |=DWC3_DEPCFG_XFER_IN_PROGRESS_EN ;/*
@@ -2042,12 +2042,6 @@ static void dwc3_endpoint_interrupt(strudwc3_endpoint_transfer_complete (dwc, dep, event,1 );break ;case DWC3_DEPEVT_XFERINPROGRESS : -if (!usb_endpoint_xfer_isoc (dep->endpoint.desc)) { -dev_dbg (dwc->dev,"%s is not an Isochronous endpoint\n" , - dep->name); -return ; - } -dwc3_endpoint_transfer_complete (dwc, dep, event,0 );break ;case DWC3_DEPEVT_XFERNOTREADY :
Greg Kroah-Hartman
maintainerPATCH 267/357 ftrace: Allow ftrace_ops to use the hashes from other ops
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 33b7f99cf003ca6c1d31c42b50e1100ad71aaec0 upstream.
Currently the top level debug file system function tracer shares its ftrace_ops with the function graph tracer. This was thought to be fine because the tracers are not used together, as one can only enable function or function_graph tracer in the current_tracer file.
But that assumption proved to be incorrect. The function profiler can use the function graph tracer when function tracing is enabled. Since all function graph users uses the function tracing ftrace_ops this causes a conflict and when a user enables both function profiling as well as the function tracer it will crash ftrace and disable it.
The quick solution so far is to move them as separate ftrace_ops like it was earlier. The problem though is to synchronize the functions that are traced because both function and function_graph tracer are limited by the selections made in the set_ftrace_filter and set_ftrace_notrace files.
To handle this, a new structure is made called ftrace_ops_hash. This structure will now hold the filter_hash and notrace_hash, and the ftrace_ops will point to this structure. That will allow two ftrace_ops to share the same hashes.
Since most ftrace_ops do not share the hashes, and to keep allocation simple, the ftrace_ops structure will include both a pointer to the ftrace_ops_hash called func_hash, as well as the structure itself, called local_hash. When the ops are registered, the func_hash pointer will be initialized to point to the local_hash within the ftrace_ops structure. Some of the ftrace internal ftrace_ops will be initialized statically. This will allow for the function and function_graph tracer to have separate ops but still share the same hash tables that determine what functions they trace.
--- include/linux/ftrace.h | 13 +++++- kernel/trace/ftrace.c | 98 +++++++++++++++++++++++++------------------------ 2 files changed, 62 insertions(+), 49 deletions(-)
include/linux/ftrace.h +11 -2
@@ -103,6 +103,15 @@ enum { FTRACE_OPS_FL_DELETED = 1 << 8, }; +#ifdef CONFIG_DYNAMIC_FTRACE +/* The hash used to know what functions callbacks trace */ +struct ftrace_ops_hash { +struct ftrace_hash *notrace_hash; +struct ftrace_hash *filter_hash; +struct mutex regex_lock; +}; +#endif +/* * Note, ftrace_ops can be referenced outside of RCU protection. * (Although, for perf, the control ops prevent that). If ftrace_ops is
@@ -121,8 +130,8 @@ struct ftrace_ops {int __percpu *disabled;void *private;#ifdef CONFIG_DYNAMIC_FTRACE -struct ftrace_hash *notrace_hash; -struct ftrace_hash *filter_hash; +struct ftrace_ops_hash local_hash; +struct ftrace_ops_hash *func_hash;struct mutex regex_lock;#endif };
kernel/trace/ftrace.c +51 -47
281 lines not on this page · raw message
Greg Kroah-Hartman
maintainerPATCH 268/357 ftrace: Fix function_profiler and function tracer together
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 5f151b240192a1557119d5375af71efc26825bc8 upstream.
The latest rewrite of ftrace removed the separate ftrace_ops of the function tracer and the function graph tracer and had them share the same ftrace_ops. This simplified the accounting by removing the multiple layers of functions called, where the global_ops func would call a special list that would iterate over the other ops that were registered within it (like function and function graph), which itself was registered to the ftrace ops list of all functions currently active. If that sounds confusing, the code that implemented it was also confusing and its removal is a good thing.
The problem with this change was that it assumed that the function and function graph tracer can never be used at the same time. This is mostly true, but there is an exception. That is when the function profiler uses the function graph tracer to profile. The function profiler can be activated the same time as the function tracer, and this breaks the assumption and the result is that ftrace will crash (it detects the error and shuts itself down, it does not cause a kernel oops).
To solve this issue, a previous change allowed the hash tables for the functions traced by a ftrace_ops to be a pointer and let multiple ftrace_ops share the same hash. This allows the function and function_graph tracer to have separate ftrace_ops, but still share the hash, which is what is done.
Now the function and function graph tracers have separate ftrace_ops again, and the function tracer can be run while the function_profile is active.
--- kernel/trace/ftrace.c | 49 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 13 deletions(-)
kernel/trace/ftrace.c +36 -13
@@ -68,8 +68,12 @@#define INIT_OPS_HASH (opsname) \ .func_hash = &opsname.local_hash, \ .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock), +#define ASSIGN_OPS_HASH (opsname, val) \ + .func_hash = val, \ + .local_hash.regex_lock = __MUTEX_INITIALIZER(opsname.local_hash.regex_lock),#else #define INIT_OPS_HASH (opsname) +#define ASSIGN_OPS_HASH (opsname, val)#endif static struct ftrace_ops ftrace_list_end__read_mostly = {
@@ -110,6 +114,7 @@ static struct ftrace_ops *ftrace_ops_lisftrace_func_t ftrace_trace_function__read_mostly = ftrace_stub;ftrace_func_t ftrace_pid_function__read_mostly = ftrace_stub;static struct ftrace_ops global_ops; +static struct ftrace_ops graph_ops;static struct ftrace_ops control_ops;#if ARCH_SUPPORTS_FTRACE_OPS
@@ -4339,7 +4344,6 @@ void __init ftrace_init(void)static struct ftrace_ops global_ops = { .func = ftrace_stub, .flags =FTRACE_OPS_FL_RECURSION_SAFE |FTRACE_OPS_FL_INITIALIZED , -INIT_OPS_HASH (global_ops) };static int __init ftrace_nodyn_init (void )
@@ -4877,6 +4881,14 @@ ftrace_enable_sysctl(struct ctl_table *t#ifdef CONFIG_FUNCTION_GRAPH_TRACER +static struct ftrace_ops graph_ops = { + .func = ftrace_stub, + .flags =FTRACE_OPS_FL_RECURSION_SAFE | +FTRACE_OPS_FL_INITIALIZED | +FTRACE_OPS_FL_STUB , +ASSIGN_OPS_HASH (graph_ops, &global_ops.local_hash) +}; +static int ftrace_graph_active;int ftrace_graph_entry_stub (struct ftrace_graph_ent *trace)
@@ -5039,12 +5051,28 @@ static int ftrace_graph_entry_test(struc*/ static void update_function_graph_func (void ) { -if (ftrace_ops_list == &ftrace_list_end || - (ftrace_ops_list == &global_ops && - global_ops.next == &ftrace_list_end)) - ftrace_graph_entry = __ftrace_graph_entry; -else +struct ftrace_ops *op; +bool do_test = false; + +/* +* The graph and global ops share the same set of functions +* to test. If any other ops is on the list, then +* the graph tracing needs to test if its the function +* it should call. +*/ +do_for_each_ftrace_op (op, ftrace_ops_list) { +if (op != &global_ops && op != &graph_ops && + op != &ftrace_list_end) { + do_test = true; +/* in double loop, break out with goto */ + goto out; + } + }while_for_each_ftrace_op (op); + out: +if (do_test) ftrace_graph_entry = ftrace_graph_entry_test; +else + ftrace_graph_entry = __ftrace_graph_entry; }static struct notifier_block ftrace_suspend_notifier = {
@@ -5085,11 +5113,7 @@ int register_ftrace_graph(trace_func_gra ftrace_graph_entry = ftrace_graph_entry_test;update_function_graph_func (); -/* Function graph doesn't use the .func field of global_ops */ - global_ops.flags |=FTRACE_OPS_FL_STUB ; - - ret =ftrace_startup (&global_ops,FTRACE_START_FUNC_RET ); - + ret =ftrace_startup (&graph_ops,FTRACE_START_FUNC_RET ); out:mutex_unlock (&ftrace_lock);return ret;
@@ -5106,8 +5130,7 @@ void unregister_ftrace_graph(void) ftrace_graph_return = (trace_func_graph_ret_t )ftrace_stub; ftrace_graph_entry = ftrace_graph_entry_stub; __ftrace_graph_entry = ftrace_graph_entry_stub; -ftrace_shutdown (&global_ops,FTRACE_STOP_FUNC_RET ); - global_ops.flags &= ~FTRACE_OPS_FL_STUB ; +ftrace_shutdown (&graph_ops,FTRACE_STOP_FUNC_RET );unregister_pm_notifier (&ftrace_suspend_notifier);unregister_trace_sched_switch (ftrace_graph_probe_sched_switch,NULL );
Greg Kroah-Hartman
maintainerPATCH 269/357 ftrace: Update all ftrace_ops for a ftrace_hash_ops update
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: "Steven Rostedt (Red Hat)" <[email protected]>
commit 84261912ebee41269004e8a9f3614ba38ef6b206 upstream.
When updating what an ftrace_ops traces, if it is registered (that is, actively tracing), and that ftrace_ops uses the shared global_ops local_hash, then we need to update all tracers that are active and also share the global_ops' ftrace_hash_ops.
--- kernel/trace/ftrace.c | 43 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 39 insertions(+), 4 deletions(-)
kernel/trace/ftrace.c +39 -4
@@ -1298,9 +1298,9 @@ alloc_and_copy_ftrace_hash(int size_bits }static void -ftrace_hash_rec_disable (struct ftrace_ops *ops,int filter_hash); +ftrace_hash_rec_disable_modify (struct ftrace_ops *ops,int filter_hash);static void -ftrace_hash_rec_enable (struct ftrace_ops *ops,int filter_hash); +ftrace_hash_rec_enable_modify (struct ftrace_ops *ops,int filter_hash); static int ftrace_hash_move(struct ftrace_ops *ops, int enable,
@@ -1320,7 +1320,7 @@ ftrace_hash_move(struct ftrace_ops *ops,* Remove the current set, update the hash and add * them back. */ -ftrace_hash_rec_disable (ops, enable); +ftrace_hash_rec_disable_modify (ops, enable);/* * If the new source is empty, just free dst and assign it
@@ -1369,7 +1369,7 @@ ftrace_hash_move(struct ftrace_ops *ops,* On success, we enable the new hash. * On failure, we re-enable the original hash. */ -ftrace_hash_rec_enable (ops, enable); +ftrace_hash_rec_enable_modify (ops, enable);return ret; }
@@ -1613,6 +1613,41 @@ static void ftrace_hash_rec_enable(struc__ftrace_hash_rec_update (ops, filter_hash,1 ); } +static void ftrace_hash_rec_update_modify (struct ftrace_ops *ops, +int filter_hash,int inc) +{ +struct ftrace_ops *op; + +__ftrace_hash_rec_update (ops, filter_hash, inc); + +if (ops->func_hash != &global_ops.local_hash) +return ; + +/* +* If the ops shares the global_ops hash, then we need to update +* all ops that are enabled and use this hash. +*/ +do_for_each_ftrace_op (op, ftrace_ops_list) { +/* Already done */ +if (op == ops) +continue ; +if (op->func_hash == &global_ops.local_hash) +__ftrace_hash_rec_update (op, filter_hash, inc); + }while_for_each_ftrace_op (op); +} + +static void ftrace_hash_rec_disable_modify (struct ftrace_ops *ops, +int filter_hash) +{ +ftrace_hash_rec_update_modify (ops, filter_hash,0 ); +} + +static void ftrace_hash_rec_enable_modify (struct ftrace_ops *ops, +int filter_hash) +{ +ftrace_hash_rec_update_modify (ops, filter_hash,1 ); +} +static void print_ip_ins (const char *fmt,unsigned char *p) {int i;
Greg Kroah-Hartman
maintainerPATCH 270/357 Revert "mac80211: disable uAPSD if all ACs are under ACM"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit bb512ad0732232f1d2693bb68f31a76bed8f22ae upstream.
This reverts commit 24aa11ab8ae03292d38ec0dbd9bc2ac49fe8a6dd.
That commit was wrong since it uses data that hasn't even been set up yet, but might be a hold-over from a previous connection.
Additionally, it seems like a driver-specific workaround that shouldn't have been in mac80211 to start with.
--- net/mac80211/mlme.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
net/mac80211/mlme.c +1 -2
@@ -4355,8 +4355,7 @@ int ieee80211_mgd_assoc(struct ieee80211rcu_read_unlock ();if (bss->wmm_used && bss->uapsd_supported && - (sdata->local->hw.flags &IEEE80211_HW_SUPPORTS_UAPSD ) && - sdata->wmm_acm !=0xff ) { + (sdata->local->hw.flags &IEEE80211_HW_SUPPORTS_UAPSD )) { assoc_data->uapsd = true; ifmgd->flags |=IEEE80211_STA_UAPSD_ENABLED ; }else {
Greg Kroah-Hartman
maintainerPATCH 271/357 kernel/printk/printk.c: fix faulty logic in the case of recursive printk
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Patrick Palka <[email protected]>
commit 000a7d66ec30898f46869be01ab8205b056385d0 upstream.
We shouldn't set text_len in the code path that detects printk recursion because text_len corresponds to the length of the string inside textbuf. A few lines down from the line
text_len = strlen(recursion_msg);
is the line
text_len += vscnprintf(text + text_len, ...);
So if printk detects recursion, it sets text_len to 29 (the length of recursion_msg) and logs an error. Then the message supplied by the caller of printk is stored inside textbuf but offset by 29 bytes. This means that the output of the recursive call to printk will contain 29 bytes of garbage in front of it.
This defect is caused by commit 458df9fd4815 ("printk: remove separate printk_sched buffers and use printk buf instead") which turned the line
text_len = vscnprintf(text, ...);
into
text_len += vscnprintf(text + text_len, ...);
To fix this, this patch avoids setting text_len when logging the printk recursion error. This patch also marks unlikely() the branch leading up to this code.
--- kernel/printk/printk.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/printk/printk.c +3 -3
@@ -1617,15 +1617,15 @@ asmlinkage int vprintk_emit(int facilityraw_spin_lock (&logbuf_lock); logbuf_cpu = this_cpu; -if (recursion_bug) { +if (unlikely (recursion_bug)) {static const char recursion_msg[] ="BUG: recent printk recursion!" ; recursion_bug =0 ; - text_len =strlen (recursion_msg);/* emit KERN_CRIT message */ printed_len +=log_store (0 ,2 ,LOG_PREFIX |LOG_NEWLINE ,0 , -NULL ,0 , recursion_msg, text_len); +NULL ,0 , recursion_msg, +strlen (recursion_msg)); }/*
Greg Kroah-Hartman
maintainerPATCH 273/357 kcmp: fix standard comparison bug
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Rasmus Villemoes <[email protected]>
commit acbbe6fbb240a927ee1f5994f04d31267d422215 upstream.
The C operator <= defines a perfectly fine total ordering on the set of values representable in a long. However, unlike its namesake in the integers, it is not translation invariant, meaning that we do not have "b <= c" iff "a+b <= a+c" for all a,b,c.
This means that it is always wrong to try to boil down the relationship between two longs to a question about the sign of their difference, because the resulting relation [a LEQ b iff a-b <= 0] is neither anti-symmetric or transitive. The former is due to -LONG_MIN==LONG_MIN (take any two a,b with a-b = LONG_MIN; then a LEQ b and b LEQ a, but a != b). The latter can either be seen observing that x LEQ x+1 for all x, implying x LEQ x+1 LEQ x+2 ... LEQ x-1 LEQ x; or more directly with the simple example a=LONG_MIN, b=0, c=1, for which a-b < 0, b-c < 0, but a-c > 0.
Note that it makes absolutely no difference that a transmogrying bijection has been applied before the comparison is done. In fact, had the obfuscation not been done, one could probably not observe the bug (assuming all values being compared always lie in one half of the address space, the mathematical value of a-b is always representable in a long). As it stands, one can easily obtain three file descriptors exhibiting the non-transitivity of kcmp().
Side note 1: I can't see that ensuring the MSB of the multiplier is set serves any purpose other than obfuscating the obfuscating code.
Side note 2:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <fcntl.h>
#include <unistd.h>
#include <assert.h>
#include <sys/syscall.h>
enum kcmp_type {
KCMP_FILE,
KCMP_VM,
KCMP_FILES,
KCMP_FS,
KCMP_SIGHAND,
KCMP_IO,
KCMP_SYSVSEM,
KCMP_TYPES,
};pid_t pid;
int kcmp(pid_t pid1, pid_t pid2, int type,
unsigned long idx1, unsigned long idx2)
{
return syscall(SYS_kcmp, pid1, pid2, type, idx1, idx2);
}
int cmp_fd(int fd1, int fd2)
{
int c = kcmp(pid, pid, KCMP_FILE, fd1, fd2);
if (c < 0) {
perror("kcmp");
exit(1);
}
assert(0 <= c && c < 3);
return c;
}
int cmp_fdp(const void *a, const void *b)
{
static const int normalize[] = {0, -1, 1};
return normalize[cmp_fd(*(int*)a, *(int*)b)];
}
#define MAX 100 /* This is plenty; I've seen it trigger for MAX==3 */
int main(int argc, char *argv[])
{
int r, s, count = 0;
int REL[3] = {0,0,0};
int fd[MAX];
pid = getpid();
while (count < MAX) {
r = open("/dev/null", O_RDONLY);
if (r < 0)
break;
fd[count++] = r;
}
printf("opened %d file descriptors\n", count);
for (r = 0; r < count; ++r) {
for (s = r+1; s < count; ++s) {
REL[cmp_fd(fd[r], fd[s])]++;
}
}
printf("== %d\t< %d\t> %d\n", REL[0], REL[1], REL[2]);
qsort(fd, count, sizeof(fd[0]), cmp_fdp);
memset(REL, 0, sizeof(REL));
for (r = 0; r < count; ++r) {
for (s = r+1; s < count; ++s) {
REL[cmp_fd(fd[r], fd[s])]++;
}
}
printf("== %d\t< %d\t> %d\n", REL[0], REL[1], REL[2]);
return (REL[0] + REL[2] != 0);
}"Eric W. Biederman" <[email protected]>
--- kernel/kcmp.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
kernel/kcmp.c +4 -3
@@ -44,11 +44,12 @@ static long kptr_obfuscate(long v, int t*/ static int kcmp_ptr (void *v1,void *v2,enum kcmp_type type) { -long ret; +long t1, t2; - ret =kptr_obfuscate ((long )v1, type) -kptr_obfuscate ((long )v2, type); + t1 =kptr_obfuscate ((long )v1, type); + t2 =kptr_obfuscate ((long )v2, type); -return (ret <0 ) | ((ret >0 ) <<1 ); +return (t1 < t2) | ((t1 > t2) <<1 ); }/* The caller must have pinned the task */
Greg Kroah-Hartman
maintainerPATCH 274/357 fsnotify/fdinfo: use named constants instead of hardcoded values
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Vagin <[email protected]>
commit 1fc98d11cac6dd66342e5580cb2687e5b1e9a613 upstream.
MAX_HANDLE_SZ is equal to 128, but currently the size of pad is only 64 bytes, so exportfs_encode_inode_fh can return an error.
--- fs/notify/fdinfo.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/notify/fdinfo.c +2 -2
@@ -42,7 +42,7 @@ static int show_mark_fhandle(struct seq_ {struct {struct file_handle handle; -u8 pad[64 ]; +u8 pad[MAX_HANDLE_SZ ]; } f;int size, ret, i;
@@ -50,7 +50,7 @@ static int show_mark_fhandle(struct seq_ size = f.handle.handle_bytes >>2 ; ret =exportfs_encode_inode_fh (inode, (struct fid *)f.handle.f_handle, &size,0 ); -if ((ret ==255 ) || (ret == -ENOSPC )) { +if ((ret ==FILEID_INVALID ) || (ret == -ENOSPC )) {WARN_ONCE (1 ,"Can't encode file handler for inotify: %d\n" , ret);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 275/357 fs/notify: dont show f_handle if exportfs_encode_inode_fh failed
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andrey Vagin <[email protected]>
commit 7e8824816bda16bb11ff5ff1e1212d642e57b0b3 upstream.
Currently we handle only ENOSPC. In case of other errors the file_handle variable isn't filled properly and we will show a part of stack.
--- fs/notify/fdinfo.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/notify/fdinfo.c +1 -1
@@ -50,7 +50,7 @@ static int show_mark_fhandle(struct seq_ size = f.handle.handle_bytes >>2 ; ret =exportfs_encode_inode_fh (inode, (struct fid *)f.handle.f_handle, &size,0 ); -if ((ret ==FILEID_INVALID ) || (ret == -ENOSPC )) { +if ((ret ==FILEID_INVALID ) || (ret <0 )) {WARN_ONCE (1 ,"Can't encode file handler for inotify: %d\n" , ret);return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 276/357 nilfs2: fix data loss with mmap()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andreas Rohner <[email protected]>
commit 56d7acc792c0d98f38f22058671ee715ff197023 upstream.
This bug leads to reproducible silent data loss, despite the use of msync(), sync() and a clean unmount of the file system. It is easily reproducible with the following script:
----------------[BEGIN SCRIPT]-------------------- mkfs.nilfs2 -f /dev/sdb
mount /dev/sdb /mnt
dd if=/dev/zero bs=1M count=30 of=/mnt/testfile
umount /mnt mount /dev/sdb /mnt CHECKSUM_BEFORE="$(md5sum /mnt/testfile)"
/root/mmaptest/mmaptest /mnt/testfile 30 10 5
sync CHECKSUM_AFTER="$(md5sum /mnt/testfile)" umount /mnt mount /dev/sdb /mnt CHECKSUM_AFTER_REMOUNT="$(md5sum /mnt/testfile)" umount /mnt
echo "BEFORE MMAP:\t$CHECKSUM_BEFORE" echo "AFTER MMAP:\t$CHECKSUM_AFTER"
echo "AFTER REMOUNT:\t$CHECKSUM_AFTER_REMOUNT" ----------------[END SCRIPT]--------------------
The mmaptest tool looks something like this (very simplified, with error checking removed):
----------------[BEGIN mmaptest]-------------------- data = mmap(NULL, file_size - file_offset, PROT_READ | PROT_WRITE,
MAP_SHARED, fd, file_offset);
for (i = 0; i < write_count; ++i) {
memcpy(data + i * 4096, buf, sizeof(buf));
msync(data, file_size - file_offset, MS_SYNC))
}
----------------[END mmaptest]--------------------The output of the script looks something like this:
BEFORE MMAP: 281ed1d5ae50e8419f9b978aab16de83 /mnt/testfile AFTER MMAP: 6604a1c31f10780331a6850371b3a313 /mnt/testfile AFTER REMOUNT: 281ed1d5ae50e8419f9b978aab16de83 /mnt/testfile
So it is clear, that the changes done using mmap() do not survive a remount. This can be reproduced a 100% of the time. The problem was introduced in commit 136e8770cd5d ("nilfs2: fix issue of nilfs_set_page_dirty() for page at EOF boundary").
If the page was read with mpage_readpage() or mpage_readpages() for example, then it has no buffers attached to it. In that case page_has_buffers(page) in nilfs_set_page_dirty() will be false. Therefore nilfs_set_file_dirty() is never called and the pages are never collected and never written to disk.
This patch fixes the problem by also calling nilfs_set_file_dirty() if the page has no buffers attached to it.
--- fs/nilfs2/inode.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
fs/nilfs2/inode.c +6 -1
@@ -24,6 +24,7 @@#include <linux/buffer_head.h> #include <linux/gfp.h> #include <linux/mpage.h> +#include <linux/pagemap.h> #include <linux/writeback.h> #include <linux/aio.h> #include "nilfs.h"
@@ -219,10 +220,10 @@ static int nilfs_writepage(struct page *static int nilfs_set_page_dirty (struct page *page) { +struct inode *inode = page->mapping->host;int ret =__set_page_dirty_nobuffers (page);if (page_has_buffers (page)) { -struct inode *inode = page->mapping->host;unsigned nr_dirty =0 ;struct buffer_head *bh, *head;
@@ -245,6 +246,10 @@ static int nilfs_set_page_dirty(struct pif (nr_dirty)nilfs_set_file_dirty (inode, nr_dirty); + }else if (ret) { +unsigned nr_dirty =1 << (PAGE_CACHE_SHIFT - inode->i_blkbits); + +nilfs_set_file_dirty (inode, nr_dirty); }return ret; }
Greg Kroah-Hartman
maintainerPATCH 277/357 ocfs2/dlm: do not get resource spinlock if lockres is new
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Joseph Qi <[email protected]>
commit 5760a97c7143c208fa3a8f8cad0ed7dd672ebd28 upstream.
There is a deadlock case which reported by Guozhonghua:
https://oss.oracle.com/pipermail/ocfs2-devel/2014-September/010079.html
This case is caused by &res->spinlock and &dlm->master_lock misordering in different threads.
It was introduced by commit 8d400b81cc83 ("ocfs2/dlm: Clean up refmap helpers"). Since lockres is new, it doesn't not require the &res->spinlock. So remove it.
--- fs/ocfs2/dlm/dlmmaster.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-)
fs/ocfs2/dlm/dlmmaster.c +10 -8
@@ -655,12 +655,9 @@ void dlm_lockres_clear_refmap_bit(structclear_bit (bit, res->refmap); } - -void dlm_lockres_grab_inflight_ref (struct dlm_ctxt *dlm, +static void __dlm_lockres_grab_inflight_ref (struct dlm_ctxt *dlm,struct dlm_lock_resource *res) { -assert_spin_locked (&res->spinlock); - res->inflight_locks++; mlog(0, "%s: res %.*s, inflight++: now %u, %ps()\n", dlm->name,
@@ -668,6 +665,13 @@ void dlm_lockres_grab_inflight_ref(struc __builtin_return_address(0)); } +void dlm_lockres_grab_inflight_ref (struct dlm_ctxt *dlm, +struct dlm_lock_resource *res) +{ +assert_spin_locked (&res->spinlock); +__dlm_lockres_grab_inflight_ref (dlm, res); +} +void dlm_lockres_drop_inflight_ref (struct dlm_ctxt *dlm,struct dlm_lock_resource *res) {
@@ -894,10 +898,8 @@ lookup:/* finally add the lockres to its hash bucket */ __dlm_insert_lockres (dlm, res); -/* Grab inflight ref to pin the resource */ -spin_lock (&res->spinlock); -dlm_lockres_grab_inflight_ref (dlm, res); -spin_unlock (&res->spinlock); +/* since this lockres is new it doesn't not require the spinlock */ +__dlm_lockres_grab_inflight_ref (dlm, res);/* get an extra ref on the mle in case this is a BLOCK * if so, the creator of the BLOCK may try to put the last
Greg Kroah-Hartman
maintainerPATCH 278/357 mm, slab: initialize object alignment on cache creation
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Rientjes <[email protected]>
commit d4a5fca592b9ab52b90bb261a90af3c8f53be011 upstream.
Since commit 4590685546a3 ("mm/sl[aou]b: Common alignment code"), the "ralign" automatic variable in __kmem_cache_create() may be used as uninitialized.
The proper alignment defaults to BYTES_PER_WORD and can be overridden by SLAB_RED_ZONE or the alignment specified by the caller.
This fixes https://bugzilla.kernel.org/show_bug.cgi?id=85031
--- mm/slab.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-)
mm/slab.c +2 -9
@@ -2224,7 +2224,8 @@ static int __init_refok setup_cpu_cache(int __kmem_cache_create (struct kmem_cache *cachep,unsigned long flags) { -size_t left_over, freelist_size, ralign; +size_t left_over, freelist_size; +size_t ralign =BYTES_PER_WORD ;gfp_t gfp;int err;size_t size = cachep->size;
@@ -2257,14 +2258,6 @@ __kmem_cache_create (struct kmem_cache * size &= ~(BYTES_PER_WORD -1 ); } -/* -* Redzoning and user store require word alignment or possibly larger. -* Note this will be overridden by architecture or caller mandated -* alignment if either is greater than BYTES_PER_WORD. -*/ -if (flags &SLAB_STORE_USER ) - ralign =BYTES_PER_WORD ; -if (flags &SLAB_RED_ZONE ) { ralign =REDZONE_ALIGN ;/* If redzoning, ensure that the second redzone is suitably
Greg Kroah-Hartman
maintainerPATCH 279/357 fs/cachefiles: add missing \n to kerror conversions
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Fabian Frederick <[email protected]>
commit 6ff66ac77aeaa9c13db28784e1c50c027a1f487b upstream.
Commit 0227d6abb378 ("fs/cachefiles: replace kerror by pr_err") didn't include newline featuring in original kerror definition
--- fs/cachefiles/bind.c | 8 ++++---- fs/cachefiles/daemon.c | 30 +++++++++++++++--------------- fs/cachefiles/internal.h | 2 +- fs/cachefiles/main.c | 2 +- fs/cachefiles/namei.c | 14 +++++++------- fs/cachefiles/xattr.c | 10 +++++----- 6 files changed, 33 insertions(+), 33 deletions(-)
fs/cachefiles/bind.c +4 -4
@@ -50,18 +50,18 @@ int cachefiles_daemon_bind(struct cachef cache->brun_percent < 100);if (*args) { -pr_err ("'bind' command doesn't take an argument" ); +pr_err ("'bind' command doesn't take an argument\n" );return -EINVAL ; }if (!cache->rootdirname) { -pr_err ("No cache directory specified" ); +pr_err ("No cache directory specified\n" );return -EINVAL ; }/* don't permit already bound caches to be re-bound */ if (test_bit (CACHEFILES_READY , &cache->flags)) { -pr_err ("Cache already bound" ); +pr_err ("Cache already bound\n" );return -EBUSY ; }
@@ -248,7 +248,7 @@ error_open_root:kmem_cache_free (cachefiles_object_jar, fsdef); error_root_object:cachefiles_end_secure (cache, saved_cred); -pr_err ("Failed to register: %d" , ret); +pr_err ("Failed to register: %d\n" , ret);return ret; }
fs/cachefiles/daemon.c +15 -15
@@ -315,7 +315,7 @@ static unsigned int cachefiles_daemon_postatic int cachefiles_daemon_range_error (struct cachefiles_cache *cache,char *args) { -pr_err ("Free space limits must be in range 0%%<=stop<cull<run<100%%" ); +pr_err ("Free space limits must be in range 0%%<=stop<cull<run<100%%\n" );return -EINVAL ; }
@@ -475,12 +475,12 @@ static int cachefiles_daemon_dir(struct_enter (",%s" , args);if (!*args) { -pr_err ("Empty directory specified" ); +pr_err ("Empty directory specified\n" );return -EINVAL ; }if (cache->rootdirname) { -pr_err ("Second cache directory specified" ); +pr_err ("Second cache directory specified\n" );return -EEXIST ; }
@@ -503,12 +503,12 @@ static int cachefiles_daemon_secctx(stru_enter (",%s" , args);if (!*args) { -pr_err ("Empty security context specified" ); +pr_err ("Empty security context specified\n" );return -EINVAL ; }if (cache->secctx) { -pr_err ("Second security context specified" ); +pr_err ("Second security context specified\n" );return -EINVAL ; }
@@ -531,7 +531,7 @@ static int cachefiles_daemon_tag(struct_enter (",%s" , args);if (!*args) { -pr_err ("Empty tag specified" ); +pr_err ("Empty tag specified\n" );return -EINVAL ; }
@@ -562,12 +562,12 @@ static int cachefiles_daemon_cull(struct goto inval;if (!test_bit (CACHEFILES_READY , &cache->flags)) { -pr_err ("cull applied to unready cache" ); +pr_err ("cull applied to unready cache\n" );return -EIO ; }if (test_bit (CACHEFILES_DEAD , &cache->flags)) { -pr_err ("cull applied to dead cache" ); +pr_err ("cull applied to dead cache\n" );return -EIO ; }
@@ -587,11 +587,11 @@ static int cachefiles_daemon_cull(struct notdir:path_put (&path); -pr_err ("cull command requires dirfd to be a directory" ); +pr_err ("cull command requires dirfd to be a directory\n" );return -ENOTDIR ; inval: -pr_err ("cull command requires dirfd and filename" ); +pr_err ("cull command requires dirfd and filename\n" );return -EINVAL ; }
@@ -614,7 +614,7 @@ static int cachefiles_daemon_debug(strucreturn 0 ; inval: -pr_err ("debug command requires mask" ); +pr_err ("debug command requires mask\n" );return -EINVAL ; }
@@ -634,12 +634,12 @@ static int cachefiles_daemon_inuse(struc goto inval;if (!test_bit (CACHEFILES_READY , &cache->flags)) { -pr_err ("inuse applied to unready cache" ); +pr_err ("inuse applied to unready cache\n" );return -EIO ; }if (test_bit (CACHEFILES_DEAD , &cache->flags)) { -pr_err ("inuse applied to dead cache" ); +pr_err ("inuse applied to dead cache\n" );return -EIO ; }
@@ -659,11 +659,11 @@ static int cachefiles_daemon_inuse(struc notdir:path_put (&path); -pr_err ("inuse command requires dirfd to be a directory" ); +pr_err ("inuse command requires dirfd to be a directory\n" );return -ENOTDIR ; inval: -pr_err ("inuse command requires dirfd and filename" ); +pr_err ("inuse command requires dirfd and filename\n" );return -EINVAL ; }
fs/cachefiles/internal.h +1 -1
@@ -255,7 +255,7 @@ extern int cachefiles_remove_object_xatt#define cachefiles_io_error (___cache,FMT , ...) \ do { \ - pr_err("I/O Error: " FMT, ##__VA_ARGS__); \ + pr_err("I/O Error: " FMT"\n", ##__VA_ARGS__); \ fscache_io_error(&(___cache)->cache); \ set_bit(CACHEFILES_DEAD, &(___cache)->flags); \ } while (0)
fs/cachefiles/main.c +1 -1
@@ -84,7 +84,7 @@ error_proc: error_object_jar:misc_deregister (&cachefiles_dev); error_dev: -pr_err ("failed to register: %d" , ret); +pr_err ("failed to register: %d\n" , ret);return ret; }
fs/cachefiles/namei.c +7 -7
@@ -543,7 +543,7 @@ lookup_again: next, next->d_inode, next->d_inode->i_ino); }else if (!S_ISDIR (next->d_inode->i_mode)) { -pr_err ("inode %lu is not a directory" , +pr_err ("inode %lu is not a directory\n" , next->d_inode->i_ino); ret = -ENOBUFS ; goto error;
@@ -574,7 +574,7 @@ lookup_again: }else if (!S_ISDIR (next->d_inode->i_mode) && !S_ISREG (next->d_inode->i_mode) ) { -pr_err ("inode %lu is not a file or directory" , +pr_err ("inode %lu is not a file or directory\n" , next->d_inode->i_ino); ret = -ENOBUFS ; goto error;
@@ -768,7 +768,7 @@ struct dentry *cachefiles_get_directory(ASSERT (subdir->d_inode);if (!S_ISDIR (subdir->d_inode->i_mode)) { -pr_err ("%s is not a directory" , dirname); +pr_err ("%s is not a directory\n" , dirname); ret = -EIO ; goto check_error; }
@@ -795,13 +795,13 @@ check_error: mkdir_error:mutex_unlock (&dir->d_inode->i_mutex);dput (subdir); -pr_err ("mkdir %s failed with error %d" , dirname, ret); +pr_err ("mkdir %s failed with error %d\n" , dirname, ret);return ERR_PTR (ret); lookup_error:mutex_unlock (&dir->d_inode->i_mutex); ret =PTR_ERR (subdir); -pr_err ("Lookup %s failed with error %d" , dirname, ret); +pr_err ("Lookup %s failed with error %d\n" , dirname, ret);return ERR_PTR (ret); nomem_d_alloc:
@@ -891,7 +891,7 @@ lookup_error:if (ret == -EIO ) {cachefiles_io_error (cache,"Lookup failed" ); }else if (ret != -ENOMEM ) { -pr_err ("Internal error: %d" , ret); +pr_err ("Internal error: %d\n" , ret); ret = -EIO ; }
@@ -950,7 +950,7 @@ error: }if (ret != -ENOMEM ) { -pr_err ("Internal error: %d" , ret); +pr_err ("Internal error: %d\n" , ret); ret = -EIO ; }
fs/cachefiles/xattr.c +5 -5
@@ -51,7 +51,7 @@ int cachefiles_check_object_type(struct }if (ret != -EEXIST ) { -pr_err ("Can't set xattr on %*.*s [%lu] (err %d)" , +pr_err ("Can't set xattr on %*.*s [%lu] (err %d)\n" , dentry->d_name.len, dentry->d_name.len, dentry->d_name.name, dentry->d_inode->i_ino, -ret);
@@ -64,7 +64,7 @@ int cachefiles_check_object_type(structif (ret == -ERANGE ) goto bad_type_length; -pr_err ("Can't read xattr on %*.*s [%lu] (err %d)" , +pr_err ("Can't read xattr on %*.*s [%lu] (err %d)\n" , dentry->d_name.len, dentry->d_name.len, dentry->d_name.name, dentry->d_inode->i_ino, -ret);
@@ -85,14 +85,14 @@ error:return ret; bad_type_length: -pr_err ("Cache object %lu type xattr length incorrect" , +pr_err ("Cache object %lu type xattr length incorrect\n" , dentry->d_inode->i_ino); ret = -EIO ; goto error; bad_type: xtype[2 ] =0 ; -pr_err ("Cache object %*.*s [%lu] type %s not %s" , +pr_err ("Cache object %*.*s [%lu] type %s not %s\n" , dentry->d_name.len, dentry->d_name.len, dentry->d_name.name, dentry->d_inode->i_ino, xtype, type);
@@ -293,7 +293,7 @@ error:return ret; bad_type_length: -pr_err ("Cache object %lu xattr length incorrect" , +pr_err ("Cache object %lu xattr length incorrect\n" , dentry->d_inode->i_ino); ret = -EIO ; goto error;
Greg Kroah-Hartman
maintainerPATCH 280/357 mm: softdirty: keep bit when zapping file pte
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Peter Feiner <[email protected]>
commit dbab31aa2ceec2d201966fa0b552f151310ba5f4 upstream.
This fixes the same bug as b43790eedd31 ("mm: softdirty: don't forget to save file map softdiry bit on unmap") and 9aed8614af5a ("mm/memory.c:
don't forget to set softdirty on file mapped fault") where the return value of pte_*mksoft_dirty was being ignored.
To be sure that no other pte/pmd "mk" function return values were being ignored, I annotated the functions in arch/x86/include/asm/pgtable.h with __must_check and rebuilt.
The userspace effect of this bug is that the softdirty mark might be lost if a file mapped pte get zapped.
--- mm/memory.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/memory.c +1 -1
@@ -1125,7 +1125,7 @@ again: addr) != page->index) {pte_t ptfile =pgoff_to_pte (page->index);if (pte_soft_dirty (ptent)) -pte_file_mksoft_dirty (ptfile); + ptfile =pte_file_mksoft_dirty (ptfile);set_pte_at (mm, addr, pte, ptfile); }if (PageAnon (page))
Greg Kroah-Hartman
maintainerPATCH 281/357 sched: Fix unreleased llc_shared_mask bit during CPU hotplug
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Wanpeng Li <[email protected]>
commit 03bd4e1f7265548832a76e7919a81f3137c44fd1 upstream.
The following bug can be triggered by hot adding and removing a large number of xen domain0's vcpus repeatedly:
BUG: unable to handle kernel NULL pointer dereference at 0000000000000004 IP: [..] find_busiest_group PGD 5a9d5067 PUD 13067 PMD 0 Oops: 0000 [#3] SMP [...] Call Trace: load_balance ? _raw_spin_unlock_irqrestore idle_balance __schedule schedule schedule_timeout ? lock_timer_base schedule_timeout_uninterruptible msleep lock_device_hotplug_sysfs online_store dev_attr_store sysfs_write_file vfs_write SyS_write system_call_fastpath
Last level cache shared mask is built during CPU up and the build_sched_domain() routine takes advantage of it to setup the sched domain CPU topology.
However, llc_shared_mask is not released during CPU disable, which leads to an invalid sched domainCPU topology.
This patch fix it by releasing the llc_shared_mask correctly during CPU disable.
Yasuaki also reported that this can happen on real hardware:
https://lkml.org/lkml/2014/7/22/1018
His case is here:
== Here is an example on my system. My system has 4 sockets and each socket has 15 cores and HT is enabled. In this case, each core of sockes is numbered as follows: | CPU# Socket#0 | 0-14 , 60-74 Socket#1 | 15-29, 75-89 Socket#2 | 30-44, 90-104 Socket#3 | 45-59, 105-119 Then llc_shared_mask of CPU#30 has 0x3fff80000001fffc0000000. It means that last level cache of Socket#2 is shared with CPU#30-44 and 90-104. When hot-removing socket#2 and #3, each core of sockets is numbered as follows: | CPU# Socket#0 | 0-14 , 60-74 Socket#1 | 15-29, 75-89 But llc_shared_mask is not cleared. So llc_shared_mask of CPU#30 remains having 0x3fff80000001fffc0000000. After that, when hot-adding socket#2 and #3, each core of sockets is numbered as follows: | CPU# Socket#0 | 0-14 , 60-74 Socket#1 | 15-29, 75-89 Socket#2 | 30-59 Socket#3 | 90-119 Then llc_shared_mask of CPU#30 becomes 0x3fff8000fffffffc0000000. It means that last level cache of Socket#2 is shared with CPU#30-59 and 90-104. So the mask has the wrong value.
--- arch/x86/kernel/smpboot.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kernel/smpboot.c +3 -0
@@ -1292,6 +1292,9 @@ static void remove_siblinginfo(int cpu)for_each_cpu (sibling,cpu_sibling_mask (cpu))cpumask_clear_cpu (cpu,cpu_sibling_mask (sibling)); +for_each_cpu (sibling,cpu_llc_shared_mask (cpu)) +cpumask_clear_cpu (cpu,cpu_llc_shared_mask (sibling)); +cpumask_clear (cpu_llc_shared_mask (cpu));cpumask_clear (cpu_sibling_mask (cpu));cpumask_clear (cpu_core_mask (cpu)); c->phys_proc_id =0 ;
Greg Kroah-Hartman
maintainerPATCH 282/357 brcmfmac: handle IF event for P2P_DEVICE interface
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arend van Spriel <[email protected]>
commit 87c4790330810fe5caf0172d9320cf24ef19cebe upstream.
The firmware notifies about interface changes through the IF event which has a NO_IF flag that means host can ignore the event. This behaviour was introduced in the driver by:
commit 2ee8382fc6c763c76396a6aaff77a27089eed3aa
Author: Arend van Spriel <[email protected]>
Date: Sat Aug 10 12:27:24 2013 +0200
brcmfmac: ignore IF event if firmware indicates it
It turns out that the IF event for the P2P_DEVICE also has this flag set, but the event should not be ignored in this scenario. The mentioned commit caused a regression in 3.12 kernel in creation of the P2P_DEVICE interface.
--- drivers/net/wireless/brcm80211/brcmfmac/fweh.c | 12 +++++++++--- drivers/net/wireless/brcm80211/brcmfmac/fweh.h | 2 ++ 2 files changed, 11 insertions(+), 3 deletions(-)
drivers/net/wireless/brcm80211/brcmfmac/fweh.c +9 -3
@@ -185,7 +185,13 @@ static void brcmf_fweh_handle_if_event(s ifevent->action, ifevent->ifidx, ifevent->bssidx, ifevent->flags, ifevent->role); -if (ifevent->flags &BRCMF_E_IF_FLAG_NOIF ) { +/* The P2P Device interface event must not be ignored +* contrary to what firmware tells us. The only way to +* distinguish the P2P Device is by looking at the ifidx +* and bssidx received. +*/ +if (!(ifevent->ifidx ==0 && ifevent->bssidx ==1 ) && + (ifevent->flags &BRCMF_E_IF_FLAG_NOIF )) {brcmf_dbg (EVENT ,"event can be ignored\n" );return ; }
@@ -210,12 +216,12 @@ static void brcmf_fweh_handle_if_event(sreturn ; } -if (ifevent->action ==BRCMF_E_IF_CHANGE ) +if (ifp && ifevent->action ==BRCMF_E_IF_CHANGE )brcmf_fws_reset_interface (ifp); err =brcmf_fweh_call_event_handler (ifp, emsg->event_code, emsg, data); -if (ifevent->action ==BRCMF_E_IF_DEL ) { +if (ifp && ifevent->action ==BRCMF_E_IF_DEL ) {brcmf_fws_del_interface (ifp);brcmf_del_if (drvr, ifevent->bssidx); }
drivers/net/wireless/brcm80211/brcmfmac/fweh.h +2 -0
@@ -167,6 +167,8 @@ enum brcmf_fweh_event_code {#define BRCMF_E_IF_ROLE_STA 0#define BRCMF_E_IF_ROLE_AP 1#define BRCMF_E_IF_ROLE_WDS 2 +#define BRCMF_E_IF_ROLE_P2P_GO 3 +#define BRCMF_E_IF_ROLE_P2P_CLIENT 4/** * definitions for event packet validation.
Greg Kroah-Hartman
maintainerPATCH 283/357 ath9k_htc: fix random decryption failure
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Stezenbach <[email protected]>
commit d21ccfd0a60ea3dece3e1d142f52694abf87a0b1 upstream.
In v3.15 the driver stopped to accept network packets after successful authentification, which could be worked around by passing the nohwcrypt=1 module parameter. This was not reproducible by everyone, and showed random behaviour in some tests.
It was caused by an uninitialized variable introduced
in 4ed1a8d4a257 ("ath9k_htc: use ath9k_cmn_rx_accept") and used in 341b29b9cd2f ("ath9k_htc: use ath9k_cmn_rx_skb_postprocess").
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=78581
--- drivers/net/wireless/ath/ath9k/htc_drv_txrx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/wireless/ath/ath9k/htc_drv_txrx.c +1 -1
@@ -978,7 +978,7 @@ static bool ath9k_rx_prepare(struct ath9struct ath_hw *ah = common->ah;struct ath_htc_rx_status *rxstatus;struct ath_rx_status rx_stats; -bool decrypt_error; +bool decrypt_error = false;if (skb->len <HTC_RX_FRAME_HEADER_SIZE ) { ath_err(common, "Corrupted RX frame, dropping (len: %d)\n",
Greg Kroah-Hartman
maintainerPATCH 284/357 powerpc/perf: Fix ABIv2 kernel backtraces
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Blanchard <[email protected]>
commit 85101af13bb854a6572fa540df7c7201958624b9 upstream.
ABIv2 kernels are failing to backtrace through the kernel. An example:
39.30% readseek2_proce [kernel.kallsyms] [k] find_get_entry
|
--- find_get_entry
__GI___libc_readThe problem is in valid_next_sp() where we check that the new stack pointer is at least STACK_FRAME_OVERHEAD below the previous one.
ABIv1 has a minimum stack frame size of 112 bytes consisting of 48 bytes and 64 bytes of parameter save area. ABIv2 changes that to 32 bytes with no paramter save area.
STACK_FRAME_OVERHEAD is in theory the minimum stack frame size, but we over 240 uses of it, some of which assume that it includes space for the parameter area.
We need to work through all our stack defines and rationalise them but let's fix perf now by creating STACK_FRAME_MIN_SIZE and using in valid_next_sp(). This fixes the issue:
30.64% readseek2_proce [kernel.kallsyms] [k] find_get_entry
|
--- find_get_entry
pagecache_get_page
generic_file_read_iter
new_sync_read
vfs_read
sys_read
syscall_exit
__GI___libc_read--- arch/powerpc/include/asm/ptrace.h | 7 +++++++ arch/powerpc/perf/callchain.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-)
arch/powerpc/include/asm/ptrace.h +7 -0
@@ -47,6 +47,12 @@ STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)#define STACK_FRAME_MARKER 12 +#if defined(_CALL_ELF) && _CALL_ELF ==2 +#define STACK_FRAME_MIN_SIZE 32 +#else +#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD +#endif +/* Size of dummy stack frame allocated when calling signal handler. */ #define __SIGNAL_FRAMESIZE 128#define __SIGNAL_FRAMESIZE32 64
@@ -60,6 +66,7 @@#define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)#define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)#define STACK_FRAME_MARKER 2 +#define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD/* Size of stack frame allocated when calling signal handler. */ #define __SIGNAL_FRAMESIZE 64
arch/powerpc/perf/callchain.c +1 -1
@@ -35,7 +35,7 @@ static int valid_next_sp(unsigned long sreturn 0 ;/* must be 16-byte aligned */ if (!validate_sp (sp, current,STACK_FRAME_OVERHEAD ))return 0 ; -if (sp >= prev_sp +STACK_FRAME_OVERHEAD ) +if (sp >= prev_sp +STACK_FRAME_MIN_SIZE )return 1 ;/* * sp could decrease when we jump off an interrupt stack
Greg Kroah-Hartman
maintainerPATCH 285/357 powerpc: Add smp_mb() to arch_spin_is_locked()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 51d7d5205d3389a32859f9939f1093f267409929 upstream.
The kernel defines the function spin_is_locked(), which can be used to check if a spinlock is currently locked.
Using spin_is_locked() on a lock you don't hold is obviously racy. That is, even though you may observe that the lock is unlocked, it may become locked at any time.
There is (at least) one exception to that, which is if two locks are used as a pair, and the holder of each checks the status of the other before doing any update.
Assuming *A and *B are two locks, and *COUNTER is a shared non-atomic value:
The first CPU does:
spin_lock(*A) if spin_is_locked(*B) # nothing else smp_mb() LOAD r = *COUNTER r++ STORE *COUNTER = r spin_unlock(*A)
And the second CPU does:
spin_lock(*B) if spin_is_locked(*A) # nothing else smp_mb() LOAD r = *COUNTER r++ STORE *COUNTER = r spin_unlock(*B)
Although this is a strange locking construct, it should work.
It seems to be understood, but not documented, that spin_is_locked() is not a memory barrier, so in the examples above and below the caller inserts its own memory barrier before acting on the result of spin_is_locked().
For now we assume spin_is_locked() is implemented as below, and we break it out in our examples:
bool spin_is_locked(*LOCK) {
LOAD l = *LOCK
return l.locked
}Our intuition is that there should be no problem even if the two code sequences run simultaneously such as:
CPU 0 CPU 1 ================================================== spin_lock(*A) spin_lock(*B) LOAD b = *B LOAD a = *A if b.locked # true if a.locked # true # nothing # nothing spin_unlock(*A) spin_unlock(*B)
If one CPU gets the lock before the other then it will do the update and the other CPU will back off:
CPU 0 CPU 1 ================================================== spin_lock(*A) LOAD b = *B spin_lock(*B) if b.locked # false LOAD a = *A else if a.locked # true smp_mb() # nothing LOAD r1 = *COUNTER spin_unlock(*B) r1++ STORE *COUNTER = r1 spin_unlock(*A)
However in reality spin_lock() itself is not indivisible. On powerpc we implement it as a load-and-reserve and store-conditional.
Ignoring the retry logic for the lost reservation case, it boils down to:
spin_lock(*LOCK) {
LOAD l = *LOCK
l.locked = true
STORE *LOCK = l
ACQUIRE_BARRIER
}
The ACQUIRE_BARRIER is required to give spin_lock() ACQUIRE semantics as defined in memory-barriers.txt:
This acts as a one-way permeable barrier. It guarantees that all memory operations after the ACQUIRE operation will appear to happen after the ACQUIRE operation with respect to the other components of the system.
On modern powerpc systems we use lwsync for ACQUIRE_BARRIER. lwsync is also know as "lightweight sync", or "sync 1".
As described in Power ISA v2.07 section B.2.1.1, in this scenario the lwsync is not the barrier itself. It instead causes the LOAD of *LOCK to act as the barrier, preventing any loads or stores in the locked region from occurring prior to the load of *LOCK.
Whether this behaviour is in accordance with the definition of ACQUIRE semantics in memory-barriers.txt is open to discussion, we may switch to a different barrier in future.
What this means in practice is that the following can occur:
CPU 0 CPU 1
==================================================
LOAD a = *A LOAD b = *B
a.locked = true b.locked = true
LOAD b = *B LOAD a = *A
STORE *A = a STORE *B = b
if b.locked # false if a.locked # false
else else
smp_mb() smp_mb()
LOAD r1 = *COUNTER LOAD r2 = *COUNTER
r1++ r2++
STORE *COUNTER = r1
STORE *COUNTER = r2 # Lost update
spin_unlock(*A) spin_unlock(*B)
That is, the load of *B can occur prior to the store that makes *A visibly locked. And similarly for CPU 1. The result is both CPUs hold their lock and believe the other lock is unlocked.
The easiest fix for this is to add a full memory barrier to the start of spin_is_locked(), so adding to our previous definition would give us:
bool spin_is_locked(*LOCK) {
smp_mb()
LOAD l = *LOCK
return l.locked
}The new barrier orders the store to the lock we are locking vs the load of the other lock:
CPU 0 CPU 1
==================================================
LOAD a = *A LOAD b = *B
a.locked = true b.locked = true
STORE *A = a STORE *B = b
smp_mb() smp_mb()
LOAD b = *B LOAD a = *A
if b.locked # true if a.locked # true
# nothing # nothing
spin_unlock(*A) spin_unlock(*B)
Although the above example is theoretical, there is code similar to this example in sem_lock() in ipc/sem.c. This commit in addition to the next commit appears to be a fix for crashes we are seeing in that code where we believe this race happens in practice.
--- arch/powerpc/include/asm/spinlock.h | 1 + 1 file changed, 1 insertion(+)
arch/powerpc/include/asm/spinlock.h +1 -0
@@ -61,6 +61,7 @@ static __always_inline int arch_spin_valstatic inline int arch_spin_is_locked (arch_spinlock_t *lock) { +smp_mb ();return !arch_spin_value_unlocked (*lock); }
Greg Kroah-Hartman
maintainerPATCH 286/357 powerpc: Add smp_mb()s to arch_spin_unlock_wait()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Michael Ellerman <[email protected]>
commit 78e05b1421fa41ae8457701140933baa5e7d9479 upstream.
Similar to the previous commit which described why we need to add a barrier to arch_spin_is_locked(), we have a similar problem with spin_unlock_wait().
We need a barrier on entry to ensure any spinlock we have previously taken is visibly locked prior to the load of lock->slock.
It's also not clear if spin_unlock_wait() is intended to have ACQUIRE semantics. For now be conservative and add a barrier on exit to give it ACQUIRE semantics.
--- arch/powerpc/lib/locks.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/powerpc/lib/locks.c +4 -0
@@ -70,12 +70,16 @@ void __rw_yield(arch_rwlock_t *rw)void arch_spin_unlock_wait (arch_spinlock_t *lock) { +smp_mb (); +while (lock->slock) {HMT_low ();if (SHARED_PROCESSOR )__spin_yield (lock); }HMT_medium (); + +smp_mb (); }EXPORT_SYMBOL (arch_spin_unlock_wait);
Greg Kroah-Hartman
maintainerPATCH 287/357 tty/serial: at91: BUG: disable interrupts when !UART_ENABLE_MS()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Genoud <[email protected]>
commit 35b675b9100fc38f58cb75b30e422ecd342519a8 upstream.
In set_termios(), interrupts where not disabled if UART_ENABLE_MS() was false.
Tested on at91sam9g35.
--- drivers/tty/serial/atmel_serial.c | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
drivers/tty/serial/atmel_serial.c +42 -1
@@ -527,6 +527,45 @@ static void atmel_enable_ms(struct uart_ }/* +* Disable modem status interrupts +*/ +static void atmel_disable_ms (struct uart_port *port) +{ +struct atmel_uart_port *atmel_port =to_atmel_uart_port (port); +uint32_t idr =0 ; + +/* +* Interrupt should not be disabled twice +*/ +if (!atmel_port->ms_irq_enabled) +return ; + + atmel_port->ms_irq_enabled = false; + +if (atmel_port->gpio_irq[UART_GPIO_CTS ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_CTS ]); +else + idr |=ATMEL_US_CTSIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DSR ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DSR ]); +else + idr |=ATMEL_US_DSRIC ; + +if (atmel_port->gpio_irq[UART_GPIO_RI ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_RI ]); +else + idr |=ATMEL_US_RIIC ; + +if (atmel_port->gpio_irq[UART_GPIO_DCD ] >=0 ) +disable_irq (atmel_port->gpio_irq[UART_GPIO_DCD ]); +else + idr |=ATMEL_US_DCDIC ; + +UART_PUT_IDR (port, idr); +} + +/* * Control the transmission of a break signal */ static void atmel_break_ctl (struct uart_port *port,int break_state)
@@ -1993,7 +2032,9 @@ static void atmel_set_termios(struct uar/* CTS flow-control and modem-status interrupts */ if (UART_ENABLE_MS (port, termios->c_cflag)) - port->ops->enable_ms (port); +atmel_enable_ms (port); +else +atmel_disable_ms (port);spin_unlock_irqrestore (&port->lock, flags); }
Greg Kroah-Hartman
maintainerPATCH 288/357 dont bugger nd->seq on set_root_rcu() from follow_dotdot_rcu()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit 7bd88377d482e1eae3c5329b12e33cfd664fa6a9 upstream.
return the value instead, and have path_init() do the assignment. Broken by "vfs: Fix absolute RCU path walk failures due to uninitialized seq number", which was Cc-stable with 2.6.38+ as destination. This one should go where it went.
To avoid dummy value returned in case when root is already set (it would do no harm, actually, since the only caller that doesn't ignore the return value is guaranteed to have nd->root *not* set, but it's more obvious that way), lift the check into callers. And do the same to set_root(), to keep them in sync.
--- fs/namei.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
fs/namei.c +17 -16
@@ -644,24 +644,22 @@ static int complete_walk(struct nameidat static __always_inline void set_root(struct nameidata *nd) { -if (!nd->root.mnt) -get_fs_root (current->fs, &nd->root); +get_fs_root (current->fs, &nd->root); }static int link_path_walk (const char *,struct nameidata *); -static __always_inline void set_root_rcu(struct nameidata *nd) +static __always_inline unsigned set_root_rcu (struct nameidata *nd) { -if (!nd->root.mnt) { -struct fs_struct *fs = current->fs; -unsigned seq; +struct fs_struct *fs = current->fs; +unsigned seq, res; -do { - seq =read_seqcount_begin (&fs->seq); - nd->root = fs->root; - nd->seq =__read_seqcount_begin (&nd->root.dentry->d_seq); - }while (read_seqcount_retry (&fs->seq, seq)); - } +do { + seq =read_seqcount_begin (&fs->seq); + nd->root = fs->root; + res =__read_seqcount_begin (&nd->root.dentry->d_seq); + }while (read_seqcount_retry (&fs->seq, seq)); +return res; }static void path_put_conditional (struct path *path,struct nameidata *nd)
@@ -861,7 +859,8 @@ follow_link(struct path *link, struct nareturn PTR_ERR (s); }if (*s =='/' ) { -set_root (nd); +if (!nd->root.mnt) +set_root (nd);path_put (&nd->path); nd->path = nd->root;path_get (&nd->root);
@@ -1136,7 +1135,8 @@ static bool __follow_mount_rcu(struct nastatic int follow_dotdot_rcu (struct nameidata *nd) { -set_root_rcu (nd); +if (!nd->root.mnt) +set_root_rcu (nd);while (1 ) { if (nd->path.dentry == nd->root.dentry &&
@@ -1249,7 +1249,8 @@ static void follow_mount(struct path *pastatic void follow_dotdot (struct nameidata *nd) { -set_root (nd); +if (!nd->root.mnt) +set_root (nd);while (1 ) {struct dentry *old = nd->path.dentry;
@@ -1847,7 +1848,7 @@ static int path_init(int dfd, const charif (*name=='/' ) {if (flags &LOOKUP_RCU ) {rcu_read_lock (); -set_root_rcu (nd); + nd->seq =set_root_rcu (nd); }else {set_root (nd);path_get (&nd->root);
Greg Kroah-Hartman
maintainerPATCH 289/357 parisc: Implement new LWS CAS supporting 64 bit operations.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Guy Martin <[email protected]>
commit 89206491201cbd1571009b36292af781cef74c1b upstream.
The current LWS cas only works correctly for 32bit. The new LWS allows for CAS operations of variable size.
--- arch/parisc/kernel/syscall.S | 233 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 229 insertions(+), 4 deletions(-)
arch/parisc/kernel/syscall.S +229 -4
@@ -74,7 +74,7 @@ ENTRY(linux_gateway_page) /* ADDRESS 0xb0 to 0xb8, lws uses two insns for entry */ /* Light-weight-syscall entry must always be located at 0xb0 */ /* WARNING: Keep this number updated with table size changes */ -#define __NR_lws_entries (2) +#define __NR_lws_entries (3) lws_entry: gate lws_start, %r0 /* increase privilege */
@@ -502,7 +502,7 @@ lws_exit: /*************************************************** - Implementing CAS as an atomic operation: + Implementing 32bit CAS as an atomic operation: %r26 - Address to examine %r25 - Old value to check (old)
@@ -659,6 +659,230 @@ cas_action: ASM_EXCEPTIONTABLE_ENTRY(2b-linux_gateway_page, 3b-linux_gateway_page) + /*************************************************** + New CAS implementation which uses pointers and variable size + information. The value pointed by old and new MUST NOT change + while performing CAS. The lock only protect the value at %r26. + + %r26 - Address to examine + %r25 - Pointer to the value to check (old) + %r24 - Pointer to the value to set (new) + %r23 - Size of the variable (0/1/2/3 for 8/16/32/64 bit) + %r28 - Return non-zero on failure + %r21 - Kernel error code + + %r21 has the following meanings: + + EAGAIN - CAS is busy, ldcw failed, try again. + EFAULT - Read or write failed. + + Scratch: r20, r22, r28, r29, r1, fr4 (32bit for 64bit CAS only) + + ****************************************************/ + + /* ELF32 Process entry path */ +lws_compare_and_swap_2: +#ifdef CONFIG_64BIT + /* Clip the input registers */ + depdi 0, 31, 32, %r26 + depdi 0, 31, 32, %r25 + depdi 0, 31, 32, %r24 + depdi 0, 31, 32, %r23 +#endif + + /* Check the validity of the size pointer */ + subi,>>= 4, %r23, %r0 + b,n lws_exit_nosys + + /* Jump to the functions which will load the old and new values into + registers depending on the their size */ + shlw %r23, 2, %r29 + blr %r29, %r0 + nop + + /* 8bit load */ +4: ldb 0(%sr3,%r25), %r25 + b cas2_lock_start +5: ldb 0(%sr3,%r24), %r24 + nop + nop + nop + nop + nop + + /* 16bit load */ +6: ldh 0(%sr3,%r25), %r25 + b cas2_lock_start +7: ldh 0(%sr3,%r24), %r24 + nop + nop + nop + nop + nop + + /* 32bit load */ +8: ldw 0(%sr3,%r25), %r25 + b cas2_lock_start +9: ldw 0(%sr3,%r24), %r24 + nop + nop + nop + nop + nop + + /* 64bit load */ +#ifdef CONFIG_64BIT +10: ldd 0(%sr3,%r25), %r25 +11: ldd 0(%sr3,%r24), %r24 +#else + /* Load new value into r22/r23 - high/low */ +10: ldw 0(%sr3,%r25), %r22 +11: ldw 4(%sr3,%r25), %r23 + /* Load new value into fr4 for atomic store later */ +12: flddx 0(%sr3,%r24), %fr4 +#endif + +cas2_lock_start: + /* Load start of lock table */ + ldil L%lws_lock_start, %r20 + ldo R%lws_lock_start(%r20), %r28 + + /* Extract four bits from r26 and hash lock (Bits 4-7) */ + extru %r26, 27, 4, %r20 + + /* Find lock to use, the hash is either one of 0 to + 15, multiplied by 16 (keep it 16-byte aligned) + and add to the lock table offset. */ + shlw %r20, 4, %r20 + add %r20, %r28, %r20 + + rsm PSW_SM_I, %r0 /* Disable interrupts */ + /* COW breaks can cause contention on UP systems */ + LDCW 0(%sr2,%r20), %r28 /* Try to acquire the lock */ + cmpb,<>,n %r0, %r28, cas2_action /* Did we get it? */ +cas2_wouldblock: + ldo 2(%r0), %r28 /* 2nd case */ + ssm PSW_SM_I, %r0 + b lws_exit /* Contended... */ + ldo -EAGAIN(%r0), %r21 /* Spin in userspace */ + + /* + prev = *addr; + if ( prev == old ) + *addr = new; + return prev; + */ + + /* NOTES: + This all works becuse intr_do_signal + and schedule both check the return iasq + and see that we are on the kernel page + so this process is never scheduled off + or is ever sent any signal of any sort, + thus it is wholly atomic from usrspaces + perspective + */ +cas2_action: + /* Jump to the correct function */ + blr %r29, %r0 + /* Set %r28 as non-zero for now */ + ldo 1(%r0),%r28 + + /* 8bit CAS */ +13: ldb,ma 0(%sr3,%r26), %r29 + sub,= %r29, %r25, %r0 + b,n cas2_end +14: stb,ma %r24, 0(%sr3,%r26) + b cas2_end + copy %r0, %r28 + nop + nop + + /* 16bit CAS */ +15: ldh,ma 0(%sr3,%r26), %r29 + sub,= %r29, %r25, %r0 + b,n cas2_end +16: sth,ma %r24, 0(%sr3,%r26) + b cas2_end + copy %r0, %r28 + nop + nop + + /* 32bit CAS */ +17: ldw,ma 0(%sr3,%r26), %r29 + sub,= %r29, %r25, %r0 + b,n cas2_end +18: stw,ma %r24, 0(%sr3,%r26) + b cas2_end + copy %r0, %r28 + nop + nop + + /* 64bit CAS */ +#ifdef CONFIG_64BIT +19: ldd,ma 0(%sr3,%r26), %r29 + sub,= %r29, %r25, %r0 + b,n cas2_end +20: std,ma %r24, 0(%sr3,%r26) + copy %r0, %r28 +#else + /* Compare first word */ +19: ldw,ma 0(%sr3,%r26), %r29 + sub,= %r29, %r22, %r0 + b,n cas2_end + /* Compare second word */ +20: ldw,ma 4(%sr3,%r26), %r29 + sub,= %r29, %r23, %r0 + b,n cas2_end + /* Perform the store */ +21: fstdx %fr4, 0(%sr3,%r26) + copy %r0, %r28 +#endif + +cas2_end: + /* Free lock */ + stw,ma %r20, 0(%sr2,%r20) + /* Enable interrupts */ + ssm PSW_SM_I, %r0 + /* Return to userspace, set no error */ + b lws_exit + copy %r0, %r21 + +22: + /* Error occurred on load or store */ + /* Free lock */ + stw %r20, 0(%sr2,%r20) + ssm PSW_SM_I, %r0 + ldo 1(%r0),%r28 + b lws_exit + ldo -EFAULT(%r0),%r21 /* set errno */ + nop + nop + nop + + /* Exception table entries, for the load and store, return EFAULT. + Each of the entries must be relocated. */ + ASM_EXCEPTIONTABLE_ENTRY(4b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(5b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(6b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(7b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(8b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(9b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(10b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(11b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(13b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(14b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(15b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(16b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(17b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(18b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(19b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(20b-linux_gateway_page, 22b-linux_gateway_page) +#ifndef CONFIG_64BIT + ASM_EXCEPTIONTABLE_ENTRY(12b-linux_gateway_page, 22b-linux_gateway_page) + ASM_EXCEPTIONTABLE_ENTRY(21b-linux_gateway_page, 22b-linux_gateway_page) +#endif + /* Make sure nothing else is placed on this page */ .align PAGE_SIZE END(linux_gateway_page)
@@ -675,8 +899,9 @@ ENTRY(end_linux_gateway_page) /* Light-weight-syscall table */ /* Start of lws table. */ ENTRY(lws_table) - LWS_ENTRY(compare_and_swap32) /* 0 - ELF32 Atomic compare and swap */ - LWS_ENTRY(compare_and_swap64) /* 1 - ELF64 Atomic compare and swap */ + LWS_ENTRY(compare_and_swap32) /* 0 - ELF32 Atomic 32bit CAS */ + LWS_ENTRY(compare_and_swap64) /* 1 - ELF64 Atomic 32bit CAS */ + LWS_ENTRY(compare_and_swap_2) /* 2 - ELF32 Atomic 64bit CAS */ END(lws_table) /* End of lws table */
Greg Kroah-Hartman
maintainerPATCH 290/357 parisc: Only use -mfast-indirect-calls option for 32-bit kernel builds
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: John David Anglin <[email protected]>
commit d26a7730b5874a5fa6779c62f4ad7c5065a94723 upstream.
In spite of what the GCC manual says, the -mfast-indirect-calls has never been supported in the 64-bit parisc compiler. Indirect calls have always been done using function descriptors irrespective of the -mfast-indirect-calls option.
Recently, it was noticed that a function descriptor was always requested when the -mfast-indirect-calls option was specified. This caused problems when the option was used in application code and doesn't make any sense because the whole point of the option is to avoid using a function descriptor for indirect calls.
Fixing this broke 64-bit kernel builds.
I will fix GCC but for now we need the attached change. This results in the same kernel code as before.
--- arch/parisc/Makefile | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
arch/parisc/Makefile +6 -1
@@ -48,7 +48,12 @@ cflags-y := -pipe # These flags should be implied by an hppa-linux configuration, but they # are not in gcc 3.2. -cflags-y += -mno-space-regs -mfast-indirect-calls +cflags-y += -mno-space-regs + +# -mfast-indirect-calls is only relevant for 32-bit kernels. +ifndef CONFIG_64BIT +cflags-y += -mfast-indirect-calls +endif # Currently we save and restore fpregs on all kernel entry/interruption paths. # If that gets optimized, we might need to disable the use of fpregs in the
Greg Kroah-Hartman
maintainerPATCH 291/357 alarmtimer: Return relative times in timer_gettime
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Larocque <[email protected]>
commit e86fea764991e00a03ff1e56409ec9cacdbda4c9 upstream.
Returns the time remaining for an alarm timer, rather than the time at which it is scheduled to expire. If the timer has already expired or it is not currently scheduled, the it_value's members are set to zero.
This new behavior matches that of the other posix-timers and the POSIX specifications.
This is a change in user-visible behavior, and may break existing applications. Hopefully, few users rely on the old incorrect behavior.
--- kernel/time/alarmtimer.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-)
kernel/time/alarmtimer.c +11 -7
@@ -541,18 +541,22 @@ static int alarm_timer_create(struct k_i* @new_timer: k_itimer pointer * @cur_setting: itimerspec data to fill * -* Copies the itimerspec data out from the k_itimer +* Copies out the current itimerspec data */ static void alarm_timer_get (struct k_itimer *timr,struct itimerspec *cur_setting) { -memset (cur_setting,0 ,sizeof (struct itimerspec )); +ktime_t relative_expiry_time = +alarm_expires_remaining (&(timr->it.alarm.alarmtimer)); - cur_setting->it_interval = -ktime_to_timespec (timr->it.alarm.interval); - cur_setting->it_value = -ktime_to_timespec (timr->it.alarm.alarmtimer.node.expires); -return ; +if (ktime_to_ns (relative_expiry_time) >0 ) { + cur_setting->it_value =ktime_to_timespec (relative_expiry_time); + }else { + cur_setting->it_value.tv_sec =0 ; + cur_setting->it_value.tv_nsec =0 ; + } + + cur_setting->it_interval =ktime_to_timespec (timr->it.alarm.interval); }/**
Greg Kroah-Hartman
maintainerPATCH 292/357 alarmtimer: Do not signal SIGEV_NONE timers
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Larocque <[email protected]>
commit 265b81d23a46c39df0a735a3af4238954b41a4c2 upstream.
Avoids sending a signal to alarm timers created with sigev_notify set to SIGEV_NONE by checking for that special case in the timeout callback.
The regular posix timers avoid sending signals to SIGEV_NONE timers by not scheduling any callbacks for them in the first place. Although it would be possible to do something similar for alarm timers, it's simpler to handle this as a special case in the timeout.
Prior to this patch, the alarm timer would ignore the sigev_notify value and try to deliver signals to the process anyway. Even worse, the sanity check for the value of sigev_signo is skipped when SIGEV_NONE was specified, so the signal number could be bogus. If sigev_signo was an unitialized value (as it often would be if SIGEV_NONE is used), then it's hard to predict which signal will be sent.
--- kernel/time/alarmtimer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
kernel/time/alarmtimer.c +4 -2
@@ -466,8 +466,10 @@ static enum alarmtimer_restart alarm_han { struct k_itimer *ptr = container_of(alarm, struct k_itimer, it.alarm.alarmtimer); -if (posix_timer_event (ptr,0 ) !=0 ) - ptr->it_overrun++; +if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) { +if (posix_timer_event (ptr,0 ) !=0 ) + ptr->it_overrun++; + }/* Re-add periodic timers */ if (ptr->it.alarm.interval.tv64) {
Greg Kroah-Hartman
maintainerPATCH 293/357 alarmtimer: Lock k_itimer during timer callback
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Richard Larocque <[email protected]>
commit 474e941bed9262f5fa2394f9a4a67e24499e5926 upstream.
Locks the k_itimer's it_lock member when handling the alarm timer's expiry callback.
The regular posix timers defined in posix-timers.c have this lock held during timout processing because their callbacks are routed through posix_timer_fn(). The alarm timers follow a different path, so they ought to grab the lock somewhere else.
--- kernel/time/alarmtimer.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
kernel/time/alarmtimer.c +8 -2
@@ -464,8 +464,12 @@ static enum alarmtimer_type clock2alarm(static enum alarmtimer_restart alarm_handle_timer (struct alarm *alarm,ktime_t now) { +unsigned long flags; struct k_itimer *ptr = container_of(alarm, struct k_itimer, it.alarm.alarmtimer); +enum alarmtimer_restart result =ALARMTIMER_NORESTART ; + +spin_lock_irqsave (&ptr->it_lock, flags);if ((ptr->it_sigev_notify & ~SIGEV_THREAD_ID ) !=SIGEV_NONE ) {if (posix_timer_event (ptr,0 ) !=0 ) ptr->it_overrun++;
@@ -475,9 +479,11 @@ static enum alarmtimer_restart alarm_hanif (ptr->it.alarm.interval.tv64) { ptr->it_overrun +=alarm_forward (alarm, now, ptr->it.alarm.interval); -return ALARMTIMER_RESTART ; + result =ALARMTIMER_RESTART ; } -return ALARMTIMER_NORESTART ; +spin_unlock_irqrestore (&ptr->it_lock, flags); + +return result; }/**
Greg Kroah-Hartman
maintainerPATCH 294/357 virtio: rng: delay hwrng_register() till driver is ready
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Shah <[email protected]>
commit 5c06273401f2eb7b290cadbae18ee00f8f65e893 upstream.
Instead of calling hwrng_register() in the probe routing, call it in the scan routine. This ensures that when hwrng_register() is successful, and it requests a few random bytes to seed the kernel's pool at init, we're ready to service that request.
This will also enable us to remove the workaround added previously to check whether probe was completed, and only then ask for data from the host. The revert follows in the next commit.
There's a slight behaviour change here on unsuccessful hwrng_register(). Previously, when hwrng_register() failed, the probe() routine would fail, and the vqs would be torn down, and driver would be marked not initialized. Now, the vqs will remain initialized, driver would be marked initialized as well, but won't be available in the list of RNGs available to hwrng core. To fix the failures, the procedure remains the same, i.e. unload and re-load the module, and hope things succeed the next time around.
--- drivers/char/hw_random/virtio-rng.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-)
drivers/char/hw_random/virtio-rng.c +15 -10
@@ -36,6 +36,7 @@ struct virtrng_info {bool busy;char name[25 ];int index; +bool hwrng_register_done; };static bool probe_done;
@@ -137,15 +138,6 @@ static int probe_common(struct virtio_dereturn err; } - err =hwrng_register (&vi->hwrng); -if (err) { - vdev->config->del_vqs (vdev); - vi->vq =NULL ; -kfree (vi); -ida_simple_remove (&rng_index_ida, index); -return err; - } - probe_done = true;return 0 ; }
@@ -153,9 +145,11 @@ static int probe_common(struct virtio_destatic void remove_common (struct virtio_device *vdev) {struct virtrng_info *vi = vdev->priv; + vdev->config->reset (vdev); vi->busy = false; -hwrng_unregister (&vi->hwrng); +if (vi->hwrng_register_done) +hwrng_unregister (&vi->hwrng); vdev->config->del_vqs (vdev);ida_simple_remove (&rng_index_ida, vi->index);kfree (vi);
@@ -171,6 +165,16 @@ static void virtrng_remove(struct virtioremove_common (vdev); } +static void virtrng_scan (struct virtio_device *vdev) +{ +struct virtrng_info *vi = vdev->priv; +int err; + + err =hwrng_register (&vi->hwrng); +if (!err) + vi->hwrng_register_done = true; +} +#ifdef CONFIG_PM_SLEEP static int virtrng_freeze (struct virtio_device *vdev) {
@@ -195,6 +199,7 @@ static struct virtio_driver virtio_rng_d .id_table = id_table, .probe = virtrng_probe, .remove = virtrng_remove, + .scan = virtrng_scan, #ifdef CONFIG_PM_SLEEP .freeze = virtrng_freeze, .restore = virtrng_restore,
Greg Kroah-Hartman
maintainerPATCH 295/357 Revert "hwrng: virtio - ensure reads happen after successful probe"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Amit Shah <[email protected]>
commit eeec626366ffe558fc3d5685bd2b49a962acf57d upstream.
This reverts commit e052dbf554610e2104c5a7518c4d8374bed701bb.
Now that we use the virtio ->scan() function to register with the hwrng core, we will not get read requests till probe is successfully finished.
So revert the workaround we had in place to refuse read requests while we were not yet setup completely.
--- drivers/char/hw_random/core.c | 6 ------ drivers/char/hw_random/virtio-rng.c | 9 --------- 2 files changed, 15 deletions(-)
drivers/char/hw_random/core.c +0 -6
@@ -68,12 +68,6 @@ static void add_early_randomness(structunsigned char bytes[16 ];int bytes_read; -/* -* Currently only virtio-rng cannot return data during device -* probe, and that's handled in virtio-rng.c itself. If there -* are more such devices, this call to rng_get_data can be -* made conditional here instead of doing it per-device. -*/ bytes_read =rng_get_data (rng, bytes,sizeof (bytes),1 );if (bytes_read >0 )add_device_randomness (bytes, bytes_read);
drivers/char/hw_random/virtio-rng.c +0 -9
@@ -39,7 +39,6 @@ struct virtrng_info {bool hwrng_register_done; }; -static bool probe_done;static void random_recv_done (struct virtqueue *vq) {
@@ -70,13 +69,6 @@ static int virtio_read(struct hwrng *rngint ret;struct virtrng_info *vi = (struct virtrng_info *)rng->priv; -/* -* Don't ask host for data till we're setup. This call can -* happen during hwrng_register(), after commit d9e7972619. -*/ -if (unlikely (!probe_done)) -return 0 ; -if (!vi->busy) { vi->busy = true;init_completion (&vi->have_data);
@@ -138,7 +130,6 @@ static int probe_common(struct virtio_dereturn err; } - probe_done = true;return 0 ; }
Greg Kroah-Hartman
maintainerPATCH 296/357 GFS2: fix d_splice_alias() misuses
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Al Viro <[email protected]>
commit cfb2f9d5c921e38b0f12bb26fed10b877664444d upstream.
Callers of d_splice_alias(dentry, inode) don't need iput(), neither on success nor on failure. Either the reference to inode is stored in a previously negative dentry, or it's dropped. In either case inode reference the caller used to hold is consumed.
__gfs2_lookup() does iput() in case when d_splice_alias() has failed. Double iput() if we ever hit that. And gfs2_create_inode() ends up not only with double iput(), but with link count dropped to zero - on an inode it has just found in directory.
--- fs/gfs2/inode.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/gfs2/inode.c +3 -2
@@ -626,8 +626,10 @@ static int gfs2_create_inode(struct inodif (!IS_ERR (inode)) { d =d_splice_alias (inode, dentry); error =PTR_ERR (d); -if (IS_ERR (d)) +if (IS_ERR (d)) { + inode =ERR_CAST (d); goto fail_gunlock; + } error =0 ;if (file) {if (S_ISREG (inode->i_mode)) {
@@ -854,7 +856,6 @@ static struct dentry *__gfs2_lookup(stru d =d_splice_alias (inode, dentry);if (IS_ERR (d)) { -iput (inode);gfs2_glock_dq_uninit (&gh);return d; }
Greg Kroah-Hartman
maintainerPATCH 297/357 IB/qib: Correct reference counting in debugfs qp_stats
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mike Marciniszyn <[email protected]>
commit 85cbb7c728bf39c45a9789b88c9471c0d7a58b0e upstream.
This particular reference count is not needed with the rcu protection, and the current code leaks a reference count, causing a hang in qib_qp_destroy().
--- drivers/infiniband/hw/qib/qib_debugfs.c | 3 ++- drivers/infiniband/hw/qib/qib_qp.c | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-)
drivers/infiniband/hw/qib/qib_debugfs.c +2 -1
@@ -193,6 +193,7 @@ static void *_qp_stats_seq_start(structstruct qib_qp_iter *iter;loff_t n = *pos; +rcu_read_lock (); iter =qib_qp_iter_init (s->private);if (!iter)return NULL ;
@@ -224,7 +225,7 @@ static void *_qp_stats_seq_next(struct sstatic void _qp_stats_seq_stop (struct seq_file *s,void *iter_ptr) { -/* nothing for now */ +rcu_read_unlock (); }static int _qp_stats_seq_show (struct seq_file *s,void *iter_ptr)
drivers/infiniband/hw/qib/qib_qp.c +0 -8
@@ -1325,7 +1325,6 @@ int qib_qp_iter_next(struct qib_qp_iterstruct qib_qp *pqp = iter->qp;struct qib_qp *qp; -rcu_read_lock ();for (; n < dev->qp_table_size; n++) {if (pqp) qp =rcu_dereference (pqp->next);
@@ -1333,18 +1332,11 @@ int qib_qp_iter_next(struct qib_qp_iter qp =rcu_dereference (dev->qp_table[n]); pqp = qp;if (qp) { -if (iter->qp) -atomic_dec (&iter->qp->refcount); -atomic_inc (&qp->refcount); -rcu_read_unlock (); iter->qp = qp; iter->n = n;return 0 ; } } -rcu_read_unlock (); -if (iter->qp) -atomic_dec (&iter->qp->refcount);return ret; }
Greg Kroah-Hartman
maintainerPATCH 298/357 IB/mlx4: Avoid null pointer dereference in mlx4_ib_scan_netdevs()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moni Shoua <[email protected]>
commit e381835cf1b8e3b2857277dbc3b77d8c5350f70a upstream.
When Ethernet netdev is not present for a port (e.g. when the link layer type of the port is InfiniBand) it's possible to dereference a null pointer when we do netdevice scanning.
To fix that, we move a section of code that needs to run only when netdev is present to a proper if () statement.
--- drivers/infiniband/hw/mlx4/main.c | 49 ++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 23 deletions(-)
drivers/infiniband/hw/mlx4/main.c +26 -23
@@ -1788,31 +1788,34 @@ static void mlx4_ib_scan_netdevs(struct port_state = (netif_running (curr_netdev) &&netif_carrier_ok (curr_netdev)) ?IB_PORT_ACTIVE :IB_PORT_DOWN ;mlx4_ib_set_default_gid (ibdev, curr_netdev, port); - }else { -reset_gid_table (ibdev, port); - } -/* if using bonding/team and a slave port is down, we don't the bond IP -* based gids in the table since flows that select port by gid may get -* the down port. -*/ -if (curr_master && (port_state ==IB_PORT_DOWN )) { -reset_gid_table (ibdev, port); -mlx4_ib_set_default_gid (ibdev, curr_netdev, port); - } -/* if bonding is used it is possible that we add it to masters -* only after IP address is assigned to the net bonding -* interface. -*/ -if (curr_master && (old_master != curr_master)) { -reset_gid_table (ibdev, port); -mlx4_ib_set_default_gid (ibdev, curr_netdev, port); -mlx4_ib_get_dev_addr (curr_master, ibdev, port); - } +/* if using bonding/team and a slave port is down, we +* don't the bond IP based gids in the table since +* flows that select port by gid may get the down port. +*/ +if (curr_master && (port_state ==IB_PORT_DOWN )) { +reset_gid_table (ibdev, port); +mlx4_ib_set_default_gid (ibdev, + curr_netdev, port); + } +/* if bonding is used it is possible that we add it to +* masters only after IP address is assigned to the +* net bonding interface. +*/ +if (curr_master && (old_master != curr_master)) { +reset_gid_table (ibdev, port); +mlx4_ib_set_default_gid (ibdev, + curr_netdev, port); +mlx4_ib_get_dev_addr (curr_master, ibdev, port); + } -if (!curr_master && (old_master != curr_master)) { +if (!curr_master && (old_master != curr_master)) { +reset_gid_table (ibdev, port); +mlx4_ib_set_default_gid (ibdev, + curr_netdev, port); +mlx4_ib_get_dev_addr (curr_netdev, ibdev, port); + } + }else {reset_gid_table (ibdev, port); -mlx4_ib_set_default_gid (ibdev, curr_netdev, port); -mlx4_ib_get_dev_addr (curr_netdev, ibdev, port); } }
Greg Kroah-Hartman
maintainerPATCH 299/357 IB/mlx4: Dont duplicate the default RoCE GID
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Moni Shoua <[email protected]>
commit f5c4834d9328c4ed9fe5dcbec6128d6da16db69a upstream.
When reading the IPv6 addresses from the net-device, make sure to avoid adding a duplicate entry to the GID table because of equality between the default GID we generate and the default IPv6 link-local address of the device.
--- drivers/infiniband/hw/mlx4/main.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/hw/mlx4/main.c +4 -0
@@ -1678,6 +1678,7 @@ static void mlx4_ib_get_dev_addr(structstruct inet6_dev *in6_dev;union ib_gid *pgid;struct inet6_ifaddr *ifp; +union ib_gid default_gid;#endif union ib_gid gid;
@@ -1698,12 +1699,15 @@ static void mlx4_ib_get_dev_addr(structin_dev_put (in_dev); }#if IS_ENABLED (CONFIG_IPV6 ) +mlx4_make_default_gid (dev, &default_gid);/* IPv6 gids */ in6_dev =in6_dev_get (dev);if (in6_dev) {read_lock_bh (&in6_dev->lock);list_for_each_entry (ifp, &in6_dev->addr_list, if_list) { pgid = (union ib_gid *)&ifp->addr; +if (!memcmp (pgid, &default_gid,sizeof (*pgid))) +continue ;update_gid_table (ibdev, port, pgid,0 ,0 ); }read_unlock_bh (&in6_dev->lock);
Greg Kroah-Hartman
maintainerPATCH 300/357 IB/core: When marshaling uverbs path, clear unused fields
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Matan Barak <[email protected]>
commit a59c5850f09b4c2d6ad2fc47e5e1be8d654529d6 upstream.
When marsheling a user path to the kernel struct ib_sa_path, need to zero smac, dmac and set the vlan id to the "no vlan" value.
--- drivers/infiniband/core/uverbs_marshall.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/infiniband/core/uverbs_marshall.c +4 -0
@@ -140,5 +140,9 @@ void ib_copy_path_rec_from_user(struct i dst->packet_life_time = src->packet_life_time; dst->preference = src->preference; dst->packet_life_time_selector = src->packet_life_time_selector; + +memset (dst->smac,0 ,sizeof (dst->smac)); +memset (dst->dmac,0 ,sizeof (dst->dmac)); + dst->vlan_id =0xffff ; }EXPORT_SYMBOL (ib_copy_path_rec_from_user);
Greg Kroah-Hartman
maintainerPATCH 301/357 spi: fsl: Dont use devm_kzalloc in master->setup callback
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit d9f26748128c73ec6bed2846ca52fb1c2edc3ced upstream.
device_add() expects that any memory allocated via devm_* API is only done in the device's probe function.
Fix below boot warning:
[ 3.092348] WARNING: at drivers/base/dd.c:286 [ 3.096637] Modules linked in: [ 3.099697] CPU: 0 PID: 25 Comm: kworker/u2:1 Tainted: G W 3.16.1-s3k-drv-999-svn5771_knld-999 #158 [ 3.109610] Workqueue: deferwq deferred_probe_work_func [ 3.114736] task: c787f020 ti: c790c000 task.ti: c790c000 [ 3.120062] NIP: c01df158 LR: c01df144 CTR: 00000000 [ 3.124983] REGS: c790db30 TRAP: 0700 Tainted: G W (3.16.1-s3k-drv-999-svn5771_knld-999) [ 3.134162] MSR: 00029032 <EE,ME,IR,DR,RI> CR: 22002082 XER: 20000000 [ 3.140703] [ 3.140703] GPR00: 00000001 c790dbe0 c787f020 00000044 00000054 00000308 c056da0e 20737069 [ 3.140703] GPR08: 33323736 000ebfe0 00000308 000ebfdf 22002082 00000000 c046c5a0 c046c608 [ 3.140703] GPR16: c046c614 c046c620 c046c62c c046c638 c046c648 c046c654 c046c68c c046c6c4 [ 3.140703] GPR24: 00000000 00000000 00000003 c0401aa0 c0596638 c059662c c054e7a8 c7996800 [ 3.170102] NIP [c01df158] driver_probe_device+0xf8/0x334 [ 3.175431] LR [c01df144] driver_probe_device+0xe4/0x334 [ 3.180633] Call Trace: [ 3.183093] [c790dbe0] [c01df144] driver_probe_device+0xe4/0x334 (unreliable) [ 3.190147] [c790dc10] [c01dd15c] bus_for_each_drv+0x7c/0xc0 [ 3.195741] [c790dc40] [c01df5fc] device_attach+0xcc/0xf8 [ 3.201076] [c790dc60] [c01dd6d4] bus_probe_device+0xb4/0xc4 [ 3.206666] [c790dc80] [c01db9f8] device_add+0x270/0x564 [ 3.211923] [c790dcc0] [c0219e84] spi_add_device+0xc0/0x190 [ 3.217427] [c790dce0] [c021a79c] spi_register_master+0x720/0x834 [ 3.223455] [c790dd40] [c021cb48] of_fsl_spi_probe+0x55c/0x614 [ 3.229234] [c790dda0] [c01e0d2c] platform_drv_probe+0x30/0x74 [ 3.234987] [c790ddb0] [c01df18c] driver_probe_device+0x12c/0x334 [ 3.241008] [c790dde0] [c01dd15c] bus_for_each_drv+0x7c/0xc0 [ 3.246602] [c790de10] [c01df5fc] device_attach+0xcc/0xf8 [ 3.251937] [c790de30] [c01dd6d4] bus_probe_device+0xb4/0xc4 [ 3.257536] [c790de50] [c01de9d8] deferred_probe_work_func+0x98/0xe0 [ 3.263816] [c790de70] [c00305b8] process_one_work+0x18c/0x440 [ 3.269577] [c790dea0] [c0030a00] worker_thread+0x194/0x67c [ 3.275105] [c790def0] [c0039198] kthread+0xd0/0xe4 [ 3.279911] [c790df40] [c000c6d0] ret_from_kernel_thread+0x5c/0x64 [ 3.285970] Instruction dump: [ 3.288900] 80de0000 419e01d0 3b7b0038 3c60c046 7f65db78 38635264 48211b99 813f00a0 [ 3.296559] 381f00a0 7d290278 3169ffff 7c0b4910 <0f000000> 93df0044 7fe3fb78 4bfffd4d
--- drivers/spi/spi-fsl-espi.c | 15 ++++++++++++--- drivers/spi/spi-fsl-spi.c | 10 +++++++--- 2 files changed, 19 insertions(+), 6 deletions(-)
drivers/spi/spi-fsl-espi.c +12 -3
@@ -452,16 +452,16 @@ static int fsl_espi_setup(struct spi_devint retval;u32 hw_mode;u32 loop_mode; -struct spi_mpc8xxx_cs *cs = spi->controller_state; +struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi);if (!spi->max_speed_hz)return -EINVAL ;if (!cs) { - cs =devm_kzalloc (&spi->dev,sizeof (*cs),GFP_KERNEL ); + cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs)return -ENOMEM ; - spi->controller_state = cs; +spi_set_ctldata (spi, cs); } mpc8xxx_spi =spi_master_get_devdata (spi->master);
@@ -496,6 +496,14 @@ static int fsl_espi_setup(struct spi_devreturn 0 ; } +static void fsl_espi_cleanup (struct spi_device *spi) +{ +struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi); + +kfree (cs); +spi_set_ctldata (spi,NULL ); +} +void fsl_espi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events) {struct fsl_espi_reg *reg_base = mspi->reg_base;
@@ -605,6 +613,7 @@ static struct spi_master * fsl_espi_prob master->bits_per_word_mask =SPI_BPW_RANGE_MASK (4 ,16 ); master->setup = fsl_espi_setup; + master->cleanup = fsl_espi_cleanup; mpc8xxx_spi =spi_master_get_devdata (master); mpc8xxx_spi->spi_do_one_msg = fsl_espi_do_one_msg;
drivers/spi/spi-fsl-spi.c +7 -3
@@ -425,16 +425,16 @@ static int fsl_spi_setup(struct spi_devistruct fsl_spi_reg *reg_base;int retval;u32 hw_mode; -struct spi_mpc8xxx_cs *cs = spi->controller_state; +struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi);if (!spi->max_speed_hz)return -EINVAL ;if (!cs) { - cs =devm_kzalloc (&spi->dev,sizeof (*cs),GFP_KERNEL ); + cs =kzalloc (sizeof (*cs),GFP_KERNEL );if (!cs)return -ENOMEM ; - spi->controller_state = cs; +spi_set_ctldata (spi, cs); } mpc8xxx_spi =spi_master_get_devdata (spi->master);
@@ -496,9 +496,13 @@ static int fsl_spi_setup(struct spi_devistatic void fsl_spi_cleanup (struct spi_device *spi) {struct mpc8xxx_spi *mpc8xxx_spi =spi_master_get_devdata (spi->master); +struct spi_mpc8xxx_cs *cs =spi_get_ctldata (spi);if (mpc8xxx_spi->type ==TYPE_GRLIB &&gpio_is_valid (spi->cs_gpio))gpio_free (spi->cs_gpio); + +kfree (cs); +spi_set_ctldata (spi,NULL ); }static void fsl_spi_cpu_irq (struct mpc8xxx_spi *mspi,u32 events)
Greg Kroah-Hartman
maintainerPATCH 302/357 spi: dw: Dont use devm_kzalloc in master->setup callback
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Axel Lin <[email protected]>
commit a97c883a16da7e0691a3be5465926c92a8da4da6 upstream.
device_add() expects that any memory allocated via devm_* API is only done in the device's probe function.
Fix below boot warning:
WARNING: CPU: 1 PID: 1 at drivers/base/dd.c:286 driver_probe_device+0x2b4/0x2f4() Modules linked in: CPU: 1 PID: 1 Comm: swapper/0 Not tainted 3.16.0-10474-g835c90b-dirty #160 [<c0016364>] (unwind_backtrace) from [<c001251c>] (show_stack+0x20/0x24) [<c001251c>] (show_stack) from [<c04eaefc>] (dump_stack+0x7c/0x98) [<c04eaefc>] (dump_stack) from [<c0023d4c>] (warn_slowpath_common+0x78/0x9c) [<c0023d4c>] (warn_slowpath_common) from [<c0023d9c>] (warn_slowpath_null+0x2c/0x34) [<c0023d9c>] (warn_slowpath_null) from [<c0302c60>] (driver_probe_device+0x2b4/0x2f4) [<c0302c60>] (driver_probe_device) from [<c0302d90>] (__device_attach+0x50/0x54) [<c0302d90>] (__device_attach) from [<c0300e60>] (bus_for_each_drv+0x54/0x9c) [<c0300e60>] (bus_for_each_drv) from [<c0302958>] (device_attach+0x84/0x90) [<c0302958>] (device_attach) from [<c0301f10>] (bus_probe_device+0x94/0xb8) [<c0301f10>] (bus_probe_device) from [<c03000c0>] (device_add+0x434/0x4fc) [<c03000c0>] (device_add) from [<c0342dd4>] (spi_add_device+0x98/0x164) [<c0342dd4>] (spi_add_device) from [<c03444a4>] (spi_register_master+0x598/0x768) [<c03444a4>] (spi_register_master) from [<c03446b4>] (devm_spi_register_master+0x40/0x80) [<c03446b4>] (devm_spi_register_master) from [<c0346214>] (dw_spi_add_host+0x1a8/0x258) [<c0346214>] (dw_spi_add_host) from [<c0346920>] (dw_spi_mmio_probe+0x1d4/0x294) [<c0346920>] (dw_spi_mmio_probe) from [<c0304560>] (platform_drv_probe+0x3c/0x6c) [<c0304560>] (platform_drv_probe) from [<c0302a98>] (driver_probe_device+0xec/0x2f4) [<c0302a98>] (driver_probe_device) from [<c0302d3c>] (__driver_attach+0x9c/0xa0) [<c0302d3c>] (__driver_attach) from [<c0300f0c>] (bus_for_each_dev+0x64/0x98) [<c0300f0c>] (bus_for_each_dev) from [<c0302518>] (driver_attach+0x2c/0x30) [<c0302518>] (driver_attach) from [<c0302134>] (bus_add_driver+0xdc/0x1f4) [<c0302134>] (bus_add_driver) from [<c03035c8>] (driver_register+0x88/0x104) [<c03035c8>] (driver_register) from [<c030445c>] (__platform_driver_register+0x58/0x6c) [<c030445c>] (__platform_driver_register) from [<c0700f00>] (dw_spi_mmio_driver_init+0x18/0x20) [<c0700f00>] (dw_spi_mmio_driver_init) from [<c0008914>] (do_one_initcall+0x90/0x1d4) [<c0008914>] (do_one_initcall) from [<c06d7d90>] (kernel_init_freeable+0x178/0x248) [<c06d7d90>] (kernel_init_freeable) from [<c04e687c>] (kernel_init+0x18/0xfc) [<c04e687c>] (kernel_init) from [<c000ecd8>] (ret_from_fork+0x14/0x20)
--- drivers/spi/spi-dw.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/spi/spi-dw.c +10 -2
@@ -547,8 +547,7 @@ static int dw_spi_setup(struct spi_devic/* Only alloc on first setup */ chip =spi_get_ctldata (spi);if (!chip) { - chip =devm_kzalloc (&spi->dev,sizeof (struct chip_data ), -GFP_KERNEL ); + chip =kzalloc (sizeof (struct chip_data ),GFP_KERNEL );if (!chip)return -ENOMEM ;spi_set_ctldata (spi, chip);
@@ -606,6 +605,14 @@ static int dw_spi_setup(struct spi_devicreturn 0 ; } +static void dw_spi_cleanup (struct spi_device *spi) +{ +struct chip_data *chip =spi_get_ctldata (spi); + +kfree (chip); +spi_set_ctldata (spi,NULL ); +} +/* Restart the controller, disable all interrupts, clean rx fifo */ static void spi_hw_init (struct dw_spi *dws) {
@@ -661,6 +668,7 @@ int dw_spi_add_host(struct device *dev, master->bus_num = dws->bus_num; master->num_chipselect = dws->num_cs; master->setup = dw_spi_setup; + master->cleanup = dw_spi_cleanup; master->transfer_one_message = dw_spi_transfer_one_message; master->max_speed_hz = dws->max_freq;
Greg Kroah-Hartman
maintainerPATCH 303/357 spi: sirf: enable RX_IO_DMA_INT interrupt
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Qipan Li <[email protected]>
commit f2a08b404691ef3e7be6ce81c185335cfc68b6db upstream.
in spi interrupt handler, we need check RX_IO_DMA status to ensure rx fifo have received the specify count data.
if not set, the while statement in spi isr function will keep loop, at last, make the kernel hang.
[The code is actually there in the interrupt handler but apparently it needs the interrupt unmasking so the handler sees the status -- broonie]
--- drivers/spi/spi-sirf.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/spi/spi-sirf.c +2 -1
@@ -438,7 +438,8 @@ static void spi_sirfsoc_pio_transfer(str sspi->tx_word (sspi);writel (SIRFSOC_SPI_TXFIFO_EMPTY_INT_EN |SIRFSOC_SPI_TX_UFLOW_INT_EN | -SIRFSOC_SPI_RX_OFLOW_INT_EN , +SIRFSOC_SPI_RX_OFLOW_INT_EN | +SIRFSOC_SPI_RX_IO_DMA_INT_EN , sspi->base +SIRFSOC_SPI_INT_EN );writel (SIRFSOC_SPI_RX_EN |SIRFSOC_SPI_TX_EN , sspi->base +SIRFSOC_SPI_TX_RX_EN );
Greg Kroah-Hartman
maintainerPATCH 305/357 perf: Fix a race condition in perf_remove_from_context()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Cong Wang <[email protected]>
commit 3577af70a2ce4853d58e57d832e687d739281479 upstream.
We saw a kernel soft lockup in perf_remove_from_context(), it looks like the perf process, when exiting, could not go out of the retry loop. Meanwhile, the target process was forking a child. So either the target process should execute the smp function call to deactive the event (if it was running) or it should do a context switch which deactives the event.
It seems we optimize out a context switch in perf_event_context_sched_out(), and what's more important, we still test an obsolete task pointer when retrying, so no one actually would deactive that event in this situation. Fix it directly by reloading the task pointer in perf_remove_from_context().
This should cure the above soft lockup.
--- kernel/events/core.c | 10 ++++++++++ 1 file changed, 10 insertions(+)
kernel/events/core.c +10 -0
@@ -1523,6 +1523,11 @@ retry:*/ if (ctx->is_active) {raw_spin_unlock_irq (&ctx->lock); +/* +* Reload the task pointer, it might have been changed by +* a concurrent perf_event_context_sched_out(). +*/ + task = ctx->task; goto retry; }
@@ -1966,6 +1971,11 @@ retry:*/ if (ctx->is_active) {raw_spin_unlock_irq (&ctx->lock); +/* +* Reload the task pointer, it might have been changed by +* a concurrent perf_event_context_sched_out(). +*/ + task = ctx->task; goto retry; }
Greg Kroah-Hartman
maintainerPATCH 307/357 PCI: Add pci_ignore_hotplug() to ignore hotplug events for a device
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
commit b440bde74f043c8ec31081cb59c9a53ade954701 upstream.
Powering off a hot-pluggable device, e.g., with pci_set_power_state(D3cold), normally generates a hot-remove event that unbinds the driver.
Some drivers expect to remain bound to a device even while they power it off and back on again. This can be dangerous, because if the device is removed or replaced while it is powered off, the driver doesn't know that anything changed. But some drivers accept that risk.
Add pci_ignore_hotplug() for use by drivers that know their device cannot be removed. Using pci_ignore_hotplug() tells the PCI core that hot-plug events for the device should be ignored.
The radeon and nouveau drivers use this to switch between a low-power, integrated GPU and a higher-power, higher-performance discrete GPU. They power off the unused GPU, but they want to remain bound to it.
This is a reimplementation of f244d8b623da ("ACPIPHP / radeon / nouveau:
Fix VGA switcheroo problem related to hotplug") but extends it to work with both acpiphp and pciehp.
This fixes a problem where systems with dual GPUs using the radeon drivers become unusable, freezing every few seconds (see bugzillas below). The resume of the radeon device may also fail, e.g.,
This fixes problems on dual GPU systems where the radeon driver becomes unusable because of problems while suspending the device, as in bug 79701:
[drm] radeon: finishing device.
radeon 0000:01:00.0: Userspace still has active objects !
radeon 0000:01:00.0: ffff8800cb4ec288 ffff8800cb4ec000 16384 4294967297 force free
...
WARNING: CPU: 0 PID: 67 at /home/apw/COD/linux/drivers/gpu/drm/radeon/radeon_gart.c:234 radeon_gart_unbind+0xd2/0xe0 [radeon]() trying to unbind memory from uninitialized GART !
or while resuming it, as in bug 77261:
radeon 0000:01:00.0: ring 0 stalled for more than 10158msec
radeon 0000:01:00.0: GPU lockup ...
radeon 0000:01:00.0: GPU pci config reset
pciehp 0000:00:01.0:pcie04: Card not present on Slot(1-1)
radeon 0000:01:00.0: GPU reset succeeded, trying to resume
*ERROR* radeon: dpm resume failed
radeon 0000:01:00.0: Wait for MC idle timedout !--- drivers/gpu/drm/nouveau/nouveau_drm.c | 1 + drivers/gpu/drm/radeon/radeon_drv.c | 1 + drivers/pci/hotplug/acpiphp_glue.c | 16 ++++++---------- drivers/pci/hotplug/pciehp_hpc.c | 12 ++++++++++++ include/linux/pci.h | 6 ++++++ 5 files changed, 26 insertions(+), 10 deletions(-)
drivers/gpu/drm/nouveau/nouveau_drm.c +1 -0
@@ -596,6 +596,7 @@ int nouveau_pmops_suspend(struct devicepci_save_state (pdev);pci_disable_device (pdev); +pci_ignore_hotplug (pdev);pci_set_power_state (pdev, PCI_D3hot);return 0 ; }
drivers/gpu/drm/radeon/radeon_drv.c +1 -0
@@ -429,6 +429,7 @@ static int radeon_pmops_runtime_suspend( ret =radeon_suspend_kms (drm_dev, false, false);pci_save_state (pdev);pci_disable_device (pdev); +pci_ignore_hotplug (pdev);pci_set_power_state (pdev, PCI_D3cold); drm_dev->switch_power_state =DRM_SWITCH_POWER_DYNAMIC_OFF ;
drivers/pci/hotplug/acpiphp_glue.c +6 -10
@@ -573,19 +573,15 @@ static void disable_slot(struct acpiphp_ slot->flags &= (~SLOT_ENABLED ); } -static bool acpiphp_no_hotplug (struct acpi_device *adev) -{ -return adev && adev->flags.no_hotplug; -} -static bool slot_no_hotplug (struct acpiphp_slot *slot) { -struct acpiphp_func *func; +struct pci_bus *bus = slot->bus; +struct pci_dev *dev; -list_for_each_entry (func, &slot->funcs, sibling) -if (acpiphp_no_hotplug (func_to_acpi_device (func))) +list_for_each_entry (dev, &bus->devices, bus_list) { +if (PCI_SLOT (dev->devfn) == slot->device && dev->ignore_hotplug)return true; - + }return false; }
@@ -658,7 +654,7 @@ static void trim_stale_devices(struct pc status =acpi_evaluate_integer (adev->handle,"_STA" ,NULL , &sta); alive = (ACPI_SUCCESS (status) &&device_status_valid (sta)) - ||acpiphp_no_hotplug (adev); + || dev->ignore_hotplug; }if (!alive) alive =pci_device_is_present (dev);
drivers/pci/hotplug/pciehp_hpc.c +12 -0
@@ -508,6 +508,8 @@ static irqreturn_t pcie_isr(int irq, voi {struct controller *ctrl = (struct controller *)dev_id;struct pci_dev *pdev =ctrl_dev (ctrl); +struct pci_bus *subordinate = pdev->subordinate; +struct pci_dev *dev;struct slot *slot = ctrl->slot;u16 detected, intr_loc;
@@ -541,6 +543,16 @@ static irqreturn_t pcie_isr(int irq, voiwake_up (&ctrl->queue); } +if (subordinate) { +list_for_each_entry (dev, &subordinate->devices, bus_list) { +if (dev->ignore_hotplug) { +ctrl_dbg (ctrl,"ignoring hotplug event %#06x (%s requested no hotplug)\n" , + intr_loc,pci_name (dev)); +return IRQ_HANDLED ; + } + } + } +if (!(intr_loc & ~PCI_EXP_SLTSTA_CC ))return IRQ_HANDLED ;
include/linux/pci.h +6 -0
@@ -303,6 +303,7 @@ struct pci_dev {D3cold, not set for devices powered on/off by the corresponding bridge */ + unsigned int ignore_hotplug:1; /* Ignore hotplug events */unsigned int d3_delay;/* D3->D0 transition time in ms */ unsigned int d3cold_delay;/* D3cold->D0 transition time in ms */
@@ -1019,6 +1020,11 @@ bool pci_dev_run_wake(struct pci_dev *debool pci_check_pme_status (struct pci_dev *dev);void pci_pme_wakeup_bus (struct pci_bus *bus); +static inline void pci_ignore_hotplug (struct pci_dev *dev) +{ + dev->ignore_hotplug =1 ; +} +static inline int pci_enable_wake (struct pci_dev *dev,pci_power_t state,bool enable) {
Greg Kroah-Hartman
maintainerPATCH 308/357 Revert "PCI: Dont scan random busses in pci_scan_bridge()"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
commit 7a0b33d4a45d30b9a838fba4efcd80b7b57d4d16 upstream.
This reverts commit fc1b253141b3 ("PCI: Don't scan random busses in pci_scan_bridge()") because it breaks CardBus on some machines.
David tested a Dell Latitude D505 that worked like this prior to fc1b253141b3:
pci 0000:00:1e.0: PCI bridge to [bus 01]
pci 0000:01:01.0: CardBus bridge to [bus 02-05]Note that the 01:01.0 CardBus bridge has a bus number aperture of [bus 02-05], but those buses are all outside the 00:1e.0 PCI bridge bus number aperture, so accesses to buses 02-05 never reach CardBus. This is later patched up by yenta_fixup_parent_bridge(), which changes the subordinate bus number of the 00:1e.0 PCI bridge:
pci_bus 0000:01: Raising subordinate bus# of parent bus (#01) from #01 to #05
With fc1b253141b3, pci_scan_bridge() fails immediately when it notices that we can't allocate a valid secondary bus number for the CardBus bridge, and CardBus doesn't work at all:
pci 0000:01:01.0: can't allocate child bus 01 from [bus 01]
I'd prefer to fix this by integrating the yenta_fixup_parent_bridge() logic into pci_scan_bridge() so we fix the bus number apertures up front. But I don't think we can do that before v3.17, so I'm going to revert this to avoid the problem while we're working on the long-term fix.
--- drivers/pci/probe.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/pci/probe.c +3 -7
@@ -838,16 +838,12 @@ int pci_scan_bridge(struct pci_bus *bus, goto out; } -if (max >= bus->busn_res.end) { -dev_warn (&dev->dev,"can't allocate child bus %02x from %pR\n" , - max, &bus->busn_res); - goto out; - } -/* Clear errors */ pci_write_config_word (dev,PCI_STATUS ,0xffff ); -/* The bus will already exist if we are rescanning */ +/* Prevent assigning a bus number that already exists. +* This can happen when a bridge is hot-plugged, so in +* this case we only re-scan this bus. */ child =pci_find_bus (pci_domain_nr (bus), max+1 );if (!child) { child =pci_add_new_bus (bus, dev, max+1 );
Greg Kroah-Hartman
maintainerPATCH 312/357 Fix nasty 32-bit overflow bug in buffer i/o code.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Anton Altaparmakov <[email protected]>
commit f2d5a94436cc7cc0221b9a81bba2276a25187dd3 upstream.
On 32-bit architectures, the legacy buffer_head functions are not always handling the sector number with the proper 64-bit types, and will thus fail on 4TB+ disks.
Any code that uses __getblk() (and thus bread(), breadahead(), sb_bread(), sb_breadahead(), sb_getblk()), and calls it using a 64-bit block on a 32-bit arch (where "long" is 32-bit) causes an inifinite loop in __getblk_slow() with an infinite stream of errors logged to dmesg like this:
__find_get_block_slow() failed. block=6740375944, b_blocknr=2445408648 b_state=0x00000020, b_size=512
device sda1 blocksize: 512
Note how in hex block is 0x191C1F988 and b_blocknr is 0x91C1F988 i.e. the top 32-bits are missing (in this case the 0x1 at the top).
This is because grow_dev_page() is broken and has a 32-bit overflow due to shifting the page index value (a pgoff_t - which is just 32 bits on 32-bit architectures) left-shifted as the block number. But the top bits to get lost as the pgoff_t is not type cast to sector_t / 64-bit before the shift.
This patch fixes this issue by type casting "index" to sector_t before doing the left shift.
Note this is not a theoretical bug but has been seen in the field on a 4TiB hard drive with logical sector size 512 bytes.
This patch has been verified to fix the infinite loop problem on 3.17-rc5 kernel using a 4TB disk image mounted using "-o loop". Without this patch doing a "find /nt" where /nt is an NTFS volume causes the inifinite loop 100% reproducibly whilst with the patch it works fine as expected.
--- fs/buffer.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
fs/buffer.c +4 -2
@@ -1029,7 +1029,8 @@ grow_dev_page(struct block_device *bdev, bh =page_buffers (page);if (bh->b_size == size) { end_block =init_page_buffers (page, bdev, - index << sizebits, size); + (sector_t )index << sizebits, + size); goto done; }if (!try_to_free_buffers (page))
@@ -1050,7 +1051,8 @@ grow_dev_page(struct block_device *bdev,*/ spin_lock (&inode->i_mapping->private_lock);link_dev_buffers (page, bh); - end_block =init_page_buffers (page, bdev, index << sizebits, size); + end_block =init_page_buffers (page, bdev, (sector_t )index << sizebits, + size);spin_unlock (&inode->i_mapping->private_lock); done: ret = (block < end_block) ?1 : -ENXIO ;
Greg Kroah-Hartman
maintainerPATCH 313/357 blk-mq: Avoid race condition with uninitialized requests
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: David Hildenbrand <[email protected]>
commit 683d0e126232d898a481daa3a4ca032c2b1a9660 upstream.
This patch should fix the bug reported in
https://lkml.org/lkml/2014/9/11/249.
We have to initialize at least the atomic_flags and the cmd_flags when allocating storage for the requests.
Otherwise blk_mq_timeout_check() might dereference uninitialized pointers when racing with the creation of a request.
Also move the reset of cmd_flags for the initializing code to the point where a request is freed. So we will never end up with pending flush request indicators that might trigger dereferences of invalid pointers in blk_mq_timeout_check().
--- block/blk-mq.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
block/blk-mq.c +3 -1
@@ -219,7 +219,6 @@ __blk_mq_alloc_request(struct blk_mq_allif (tag !=BLK_MQ_TAG_FAIL ) { rq = data->hctx->tags->rqs[tag]; - rq->cmd_flags =0 ;if (blk_mq_tag_busy (data->hctx)) { rq->cmd_flags =REQ_MQ_INFLIGHT ;atomic_inc (&data->hctx->nr_active);
@@ -274,6 +273,7 @@ static void __blk_mq_free_request(structif (rq->cmd_flags &REQ_MQ_INFLIGHT )atomic_dec (&hctx->nr_active); + rq->cmd_flags =0 ;clear_bit (REQ_ATOM_STARTED , &rq->atomic_flags);blk_mq_put_tag (hctx, tag, &ctx->last_tag);
@@ -1411,6 +1411,8 @@ static struct blk_mq_tags *blk_mq_init_r left -= to_do * rq_size;for (j =0 ; j < to_do; j++) { tags->rqs[i] = p; + tags->rqs[i]->atomic_flags =0 ; + tags->rqs[i]->cmd_flags =0 ;if (set->ops->init_request) { if (set->ops->init_request(set->driver_data, tags->rqs[i], hctx_idx, i,
Greg Kroah-Hartman
maintainerPATCH 314/357 crypto: ccp - Check for CCP before registering crypto algs
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tom Lendacky <[email protected]>
commit c9f21cb6388898bfe69886d001316dae7ecc9a4b upstream.
If the ccp is built as a built-in module, then ccp-crypto (whether built as a module or a built-in module) will be able to load and it will register its crypto algorithms. If the system does not have a CCP this will result in -ENODEV being returned whenever a command is attempted to be queued by the registered crypto algorithms.
Add an API, ccp_present(), that checks for the presence of a CCP on the system. The ccp-crypto module can use this to determine if it should register it's crypto alogorithms.
--- drivers/crypto/ccp/ccp-crypto-main.c | 4 ++++ drivers/crypto/ccp/ccp-dev.c | 14 ++++++++++++++ include/linux/ccp.h | 12 ++++++++++++ 3 files changed, 30 insertions(+)
drivers/crypto/ccp/ccp-crypto-main.c +4 -0
@@ -367,6 +367,10 @@ static int ccp_crypto_init(void) {int ret; + ret =ccp_present (); +if (ret) +return ret; +spin_lock_init (&req_queue_lock);INIT_LIST_HEAD (&req_queue.cmds); req_queue.backlog = &req_queue.cmds;
drivers/crypto/ccp/ccp-dev.c +14 -0
@@ -53,6 +53,20 @@ static inline void ccp_del_device(struct }/** +* ccp_present - check if a CCP device is present +* +* Returns zero if a CCP device is present, -ENODEV otherwise. +*/ +int ccp_present (void ) +{ +if (ccp_get_device ()) +return 0 ; + +return -ENODEV ; +} +EXPORT_SYMBOL_GPL (ccp_present); + +/** * ccp_enqueue_cmd - queue an operation for processing by the CCP * * @cmd: ccp_cmd struct to be processed
include/linux/ccp.h +12 -0
@@ -27,6 +27,13 @@ struct ccp_cmd;defined (CONFIG_CRYPTO_DEV_CCP_DD_MODULE)/** +* ccp_present - check if a CCP device is present +* +* Returns zero if a CCP device is present, -ENODEV otherwise. +*/ +int ccp_present(void); + +/** * ccp_enqueue_cmd - queue an operation for processing by the CCP * * @cmd: ccp_cmd struct to be processed
@@ -53,6 +60,11 @@ int ccp_enqueue_cmd(struct ccp_cmd *cmd)#else /* CONFIG_CRYPTO_DEV_CCP_DD is not enabled */ +static inline int ccp_present (void ) +{ +return -ENODEV ; +} +static inline int ccp_enqueue_cmd (struct ccp_cmd *cmd) {return -ENODEV ;
Greg Kroah-Hartman
maintainerPATCH 315/357 nl80211: clear skb cb before passing to netlink
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Johannes Berg <[email protected]>
commit bd8c78e78d5011d8111bc2533ee73b13a3bd6c42 upstream.
In testmode and vendor command reply/event SKBs we use the skb cb data to store nl80211 parameters between allocation and sending. This causes the code for CONFIG_NETLINK_MMAP to get confused, because it takes ownership of the skb cb data when the SKB is handed off to netlink, and it doesn't explicitly clear it.
Clear the skb cb explicitly when we're done and before it gets passed to netlink to avoid this issue.
--- net/wireless/nl80211.c | 6 ++++++ 1 file changed, 6 insertions(+)
net/wireless/nl80211.c +6 -0
@@ -6978,6 +6978,9 @@ void __cfg80211_send_event_skb(struct skstruct nlattr *data = ((void **)skb->cb)[2 ];enum nl80211_multicast_groups mcgrp =NL80211_MCGRP_TESTMODE ; +/* clear CB data for netlink core to own from now on */ +memset (skb->cb,0 ,sizeof (skb->cb)); +nla_nest_end (skb, data);genlmsg_end (skb, hdr);
@@ -9300,6 +9303,9 @@ int cfg80211_vendor_cmd_reply(struct sk_void *hdr = ((void **)skb->cb)[1 ];struct nlattr *data = ((void **)skb->cb)[2 ]; +/* clear CB data for netlink core to own from now on */ +memset (skb->cb,0 ,sizeof (skb->cb)); +if (WARN_ON (!rdev->cur_cmd_info)) {kfree_skb (skb);return -EINVAL ;
Greg Kroah-Hartman
maintainerPATCH 316/357 Revert "PCI: Make sure bus number resources stay within their parents bounds"
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bjorn Helgaas <[email protected]>
commit 12d8706963f073fffad16c7c24160ef20d9aeaff upstream.
This reverts commit 1820ffdccb9b ("PCI: Make sure bus number resources stay within their parents bounds") because it breaks some systems with LSI Logic FC949ES Fibre Channel Adapters, apparently by exposing a defect in those adapters.
Dirk tested a Tyan VX50 (B4985) with this device that worked like this prior to 1820ffdccb9b:
bus: [bus 00-7f] on node 0 link 1
ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-07])
pci 0000:00:0e.0: PCI bridge to [bus 0a]
pci_bus 0000:0a: busn_res: can not insert [bus 0a] under [bus 00-07] (conflicts with (null) [bus 00-07])
pci 0000:0a:00.0: [1000:0646] type 00 class 0x0c0400 (FC adapter)Note that the root bridge [bus 00-07] aperture is wrong; this is a BIOS defect in the PCI0 _CRS method. But prior to 1820ffdccb9b, we didn't enforce that aperture, and the FC adapter worked fine at 0a:00.0.
After 1820ffdccb9b, we notice that 00:0e.0's aperture is not contained in the root bridge's aperture, so we reconfigure it so it *is* contained:
pci 0000:00:0e.0: bridge configuration invalid ([bus 0a-0a]), reconfiguring
pci 0000:00:0e.0: PCI bridge to [bus 06-07]This effectively moves the FC device from 0a:00.0 to 07:00.0, which should be legal. But when we enumerate bus 06, the FC device doesn't respond, so we don't find anything. This is probably a defect in the FC device.
Possible fixes (due to Yinghai):
1) Add a quirk to fix the _CRS information based on what amd_bus.c read from the hardware
2) Reset the FC device after we change its bus number
3) Revert 1820ffdccb9b
Fix 1 would be relatively easy, but it does sweep the LSI FC issue under the rug. We might want to reconfigure bus numbers in the future for some other reason, e.g., hotplug, and then we could trip over this again.
For that reason, I like fix 2, but we don't know whether it actually works, and we don't have a patch for it yet.
This revert is fix 3, which also sweeps the LSI FC issue under the rug.
--- drivers/pci/probe.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/pci/probe.c +2 -8
@@ -775,7 +775,7 @@ int pci_scan_bridge(struct pci_bus *bus,/* Check if setup is sensible at all */ if (!pass && (primary != bus->number || secondary <= bus->number || - secondary > subordinate || subordinate > bus->busn_res.end)) { + secondary > subordinate)) {dev_info (&dev->dev,"bridge configuration invalid ([bus %02x-%02x]), reconfiguring\n" , secondary, subordinate); broken =1 ;
@@ -849,8 +849,7 @@ int pci_scan_bridge(struct pci_bus *bus, child =pci_add_new_bus (bus, dev, max+1 );if (!child) goto out; -pci_bus_insert_busn_res (child, max+1 , - bus->busn_res.end); +pci_bus_insert_busn_res (child, max+1 ,0xff ); } max++; buses = (buses &0xff000000 )
@@ -909,11 +908,6 @@ int pci_scan_bridge(struct pci_bus *bus,/* * Set the subordinate bus number to its real value. */ -if (max > bus->busn_res.end) { -dev_warn (&dev->dev,"max busn %02x is outside %pR\n" , - max, &bus->busn_res); - max = bus->busn_res.end; - }pci_bus_update_busn_res_end (child, max);pci_write_config_byte (dev,PCI_SUBORDINATE_BUS , max); }
Greg Kroah-Hartman
maintainerPATCH 317/357 cpufreq: release policy->rwsem on error
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Prarit Bhargava <[email protected]>
commit 7106e02baed4a72fb23de56b02ad4d31daa74d95 upstream.
While debugging a cpufreq-related hardware failure on a system I saw the following lockdep warning:
=========================
[ BUG: held lock freed! ] 3.17.0-rc4+ #1 Tainted: G E
-------------------------
insmod/2247 is freeing memory ffff88006e1b1400-ffff88006e1b17ff, with a lock still held there!
(&policy->rwsem){+.+...}, at: [<ffffffff8156d37d>] __cpufreq_add_dev.isra.21+0x47d/0xb80
3 locks held by insmod/2247:
#0: (subsys mutex#5){+.+.+.}, at: [<ffffffff81485579>] subsys_interface_register+0x69/0x120
#1: (cpufreq_rwsem){.+.+.+}, at: [<ffffffff8156cf73>] __cpufreq_add_dev.isra.21+0x73/0xb80
#2: (&policy->rwsem){+.+...}, at: [<ffffffff8156d37d>] __cpufreq_add_dev.isra.21+0x47d/0xb80stack backtrace: CPU: 0 PID: 2247 Comm: insmod Tainted: G E 3.17.0-rc4+ #1 Hardware name: HP ProLiant MicroServer Gen8, BIOS J06 08/24/2013 0000000000000000 000000008f3063c4 ffff88006f87bb30 ffffffff8171b358 ffff88006bcf3750 ffff88006f87bb68 ffffffff810e09e1 ffff88006e1b1400 ffffea0001b86c00 ffffffff8156d327 ffff880073003500 0000000000000246 Call Trace: [<ffffffff8171b358>] dump_stack+0x4d/0x66 [<ffffffff810e09e1>] debug_check_no_locks_freed+0x171/0x180 [<ffffffff8156d327>] ? __cpufreq_add_dev.isra.21+0x427/0xb80 [<ffffffff8121412b>] kfree+0xab/0x2b0 [<ffffffff8156d327>] __cpufreq_add_dev.isra.21+0x427/0xb80 [<ffffffff81724cf7>] ? _raw_spin_unlock+0x27/0x40 [<ffffffffa003517f>] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq] [<ffffffff8156da8e>] cpufreq_add_dev+0xe/0x10 [<ffffffff814855d1>] subsys_interface_register+0xc1/0x120 [<ffffffff8156bcf2>] cpufreq_register_driver+0x112/0x340 [<ffffffff8121415a>] ? kfree+0xda/0x2b0 [<ffffffffa003517f>] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq] [<ffffffffa003562e>] pcc_cpufreq_init+0x4af/0xe81 [pcc_cpufreq] [<ffffffffa003517f>] ? pcc_cpufreq_do_osc+0x17f/0x17f [pcc_cpufreq] [<ffffffff81002144>] do_one_initcall+0xd4/0x210 [<ffffffff811f7472>] ? __vunmap+0xd2/0x120 [<ffffffff81127155>] load_module+0x1315/0x1b70 [<ffffffff811222a0>] ? store_uevent+0x70/0x70 [<ffffffff811229d9>] ? copy_module_from_fd.isra.44+0x129/0x180 [<ffffffff81127b86>] SyS_finit_module+0xa6/0xd0 [<ffffffff81725b69>] system_call_fastpath+0x16/0x1b cpufreq: __cpufreq_add_dev: ->get() failed
insmod: ERROR: could not insert module pcc-cpufreq.ko: No such device
The warning occurs in the __cpufreq_add_dev() code which does
down_write(&policy->rwsem);
...
if (cpufreq_driver->get && !cpufreq_driver->setpolicy) {
policy->cur = cpufreq_driver->get(policy->cpu);
if (!policy->cur) {
pr_err("%s: ->get() failed\n", __func__);
goto err_get_freq;
}If cpufreq_driver->get(policy->cpu) returns an error we execute the code at err_get_freq, which does not up the policy->rwsem. This causes the lockdep warning.
Trivial patch to up the policy->rwsem in the error path.
After the patch has been applied, and an error occurs in the cpufreq_driver->get(policy->cpu) call we will now see
cpufreq: __cpufreq_add_dev: ->get() failed
cpufreq: __cpufreq_add_dev: ->get() failed
modprobe: ERROR: could not insert 'pcc_cpufreq': No such device
--- drivers/cpufreq/cpufreq.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/cpufreq/cpufreq.c +2 -0
@@ -1279,6 +1279,8 @@ err_get_freq:per_cpu (cpufreq_cpu_data, j) =NULL ;write_unlock_irqrestore (&cpufreq_driver_lock, flags); +up_write (&policy->rwsem); +if (cpufreq_driver->exit) cpufreq_driver->exit (policy); err_set_policy_cpu:
Greg Kroah-Hartman
maintainerPATCH 318/357 cpufreq: fix cpufreq suspend/resume for intel_pstate
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Lan Tianyu <[email protected]>
commit 8e30444e153008e8eb3e74cbcb7a865bfcfb04a0 upstream.
Cpufreq core introduces cpufreq_suspended flag to let cpufreq sysfs nodes across S2RAM/S2DISK. But the flag is only set in the cpufreq_suspend() for cpufreq drivers which have target or target_index callback. This skips intel_pstate driver. This patch is to set the flag before checking target or target_index callback.
--- drivers/cpufreq/cpufreq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/cpufreq/cpufreq.c +4 -4
@@ -1666,6 +1666,8 @@ void cpufreq_suspend(void)if (!cpufreq_driver)return ; + cpufreq_suspended = true; +if (!has_target ())return ;
@@ -1680,8 +1682,6 @@ void cpufreq_suspend(void)pr_err ("%s: Failed to suspend driver: %p\n" , __func__, policy); } - - cpufreq_suspended = true; }/**
@@ -1697,13 +1697,13 @@ void cpufreq_resume(void)if (!cpufreq_driver)return ; + cpufreq_suspended = false; +if (!has_target ())return ;pr_debug ("%s: Resuming Governors\n" , __func__); - cpufreq_suspended = false; -list_for_each_entry (policy, &cpufreq_policy_list, policy_list) {if (cpufreq_driver->resume && cpufreq_driver->resume (policy)) pr_err("%s: Failed to resume driver: %p\n", __func__,
Greg Kroah-Hartman
maintainerPATCH 319/357 media: it913x: init tuner on attach
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bimow Chen <[email protected]>
commit 01b461bbe74b89da8941f4c95711777d87b9172e upstream.
That register is needed to program very first in order to operate correctly.
[[email protected]: returned sequence back, removed sleep, moved reg write earlier to prevent populating tuner ops in case of failure]
--- drivers/media/tuners/tuner_it913x.c | 6 ++++++ 1 file changed, 6 insertions(+)
drivers/media/tuners/tuner_it913x.c +6 -0
@@ -396,6 +396,7 @@ struct dvb_frontend *it913x_attach(struc struct i2c_adapter *i2c_adap, u8 i2c_addr, u8 config) { struct it913x_state *state = NULL; +int ret;/* allocate memory for the internal state */ state =kzalloc (sizeof (struct it913x_state ),GFP_KERNEL );
@@ -425,6 +426,11 @@ struct dvb_frontend *it913x_attach(struc state->tuner_type = config; state->firmware_ver =1 ; +/* tuner RF initial */ + ret =it913x_wr_reg (state,PRO_DMOD ,0xec4c ,0x68 ); +if (ret <0 ) + goto error; + fe->tuner_priv = state;memcpy (&fe->ops.tuner_ops, &it913x_tuner_ops,sizeof (struct dvb_tuner_ops ));
Greg Kroah-Hartman
maintainerPATCH 320/357 media: af9035: new IDs: add support for PCTV 78e and PCTV 79e
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Malcolm Priestley <[email protected]>
commit a04646c045cab08a9e62b9be8f01ecbb0632d24e upstream.
add the following IDsUSB_PID_PCTV_78E (0x025a) for PCTV 78eUSB_PID_PCTV_79E (0x0262) for PCTV 79e
For these it9135 devices.
--- drivers/media/dvb-core/dvb-usb-ids.h | 2 ++ drivers/media/usb/dvb-usb-v2/af9035.c | 4 ++++ 2 files changed, 6 insertions(+)
drivers/media/dvb-core/dvb-usb-ids.h +2 -0
@@ -279,6 +279,8 @@#define USB_PID_PCTV_400E 0x020f#define USB_PID_PCTV_450E 0x0222#define USB_PID_PCTV_452E 0x021f +#define USB_PID_PCTV_78E 0x025a +#define USB_PID_PCTV_79E 0x0262#define USB_PID_REALTEK_RTL2831U 0x2831#define USB_PID_REALTEK_RTL2832U 0x2832#define USB_PID_TECHNOTREND_CONNECT_S2_3600 0x3007
drivers/media/usb/dvb-usb-v2/af9035.c +4 -0
@@ -1555,6 +1555,10 @@ static const struct usb_device_id af9035 &af9035_props, "Leadtek WinFast DTV Dongle Dual", NULL) }, {DVB_USB_DEVICE (USB_VID_HAUPPAUGE ,0xf900 , &af9035_props, "Hauppauge WinTV-MiniStick 2", NULL) }, + { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_78E, + &af9035_props, "PCTV 78e", RC_MAP_IT913X_V1) }, + { DVB_USB_DEVICE(USB_VID_PCTV, USB_PID_PCTV_79E, + &af9035_props, "PCTV 79e", RC_MAP_IT913X_V2) }, { } };MODULE_DEVICE_TABLE (usb, af9035_id_table);
Greg Kroah-Hartman
maintainerPATCH 321/357 media: af9033: feed clock to RF tuner
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Antti Palosaari <[email protected]>
commit 9dc0f3fe3fe6b83b44e5920a0b143b4f96755b59 upstream.
IT9135 RF tuner clock is coming from demodulator. We need enable it early in demod init, before any tuner I/O. Currently it is enabled by tuner driver itself, but it is too late and performance will be reduced as some registers are not updated correctly. Clock is disabled automatically when demod is put onto sleep.
--- drivers/media/dvb-frontends/af9033.c | 13 +++++++++++++ 1 file changed, 13 insertions(+)
drivers/media/dvb-frontends/af9033.c +13 -0
@@ -314,6 +314,19 @@ static int af9033_init(struct dvb_fronte goto err; } +/* feed clock to RF tuner */ +switch (state->cfg.tuner) { +case AF9033_TUNER_IT9135_38 : +case AF9033_TUNER_IT9135_51 : +case AF9033_TUNER_IT9135_52 : +case AF9033_TUNER_IT9135_60 : +case AF9033_TUNER_IT9135_61 : +case AF9033_TUNER_IT9135_62 : + ret =af9033_wr_reg (state,0x80fba8 ,0x00 ); +if (ret <0 ) + goto err; + } +/* settings for TS interface */ if (state->cfg.ts_mode ==AF9033_TS_MODE_USB ) { ret =af9033_wr_reg_mask (state,0x80f9a5 ,0x00 ,0x01 );
Greg Kroah-Hartman
maintainerPATCH 322/357 media: cx18: fix kernel oops with tda8290 tuner
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 6a03dc92cc2edfa2257502557b9f714893987383 upstream.
This was caused by an uninitialized setup.config field.
Based on a suggestion from Devin Heitmueller.
Thanks-to: Devin Heitmueller <[email protected]>
--- drivers/media/pci/cx18/cx18-driver.c | 1 + 1 file changed, 1 insertion(+)
drivers/media/pci/cx18/cx18-driver.c +1 -0
@@ -1091,6 +1091,7 @@ static int cx18_probe(struct pci_dev *pc setup.addr =ADDR_UNSET ; setup.type = cx->options.tuner; setup.mode_mask =T_ANALOG_TV ;/* matches TV tuners */ + setup.config =NULL ;if (cx->options.radio >0 ) setup.mode_mask |=T_RADIO ; setup.tuner_callback = (setup.type == TUNER_XC2028) ?
Greg Kroah-Hartman
maintainerPATCH 323/357 media: af9033: update IT9135 tuner inittabs
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Bimow Chen <[email protected]>
commit 0df6580c5fc115034de29aa52af5cf6bd83d37d8 upstream.
Update IT9135 BX tuner config 60 and 61 inittabs.
--- drivers/media/dvb-frontends/af9033_priv.h | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-)
drivers/media/dvb-frontends/af9033_priv.h +9 -11
@@ -1418,7 +1418,7 @@ static const struct reg_val tuner_init_i { 0x800068, 0x0a }, { 0x80006a, 0x03 }, { 0x800070, 0x0a }, - { 0x800071, 0x05 }, + { 0x800071, 0x0a }, { 0x800072, 0x02 }, { 0x800075, 0x8c }, { 0x800076, 0x8c },
@@ -1484,7 +1484,6 @@ static const struct reg_val tuner_init_i { 0x800104, 0x02 }, { 0x800105, 0xbe }, { 0x800106, 0x00 }, - { 0x800109, 0x02 }, { 0x800115, 0x0a }, { 0x800116, 0x03 }, { 0x80011a, 0xbe },
@@ -1510,7 +1509,6 @@ static const struct reg_val tuner_init_i { 0x80014b, 0x8c }, { 0x80014d, 0xac }, { 0x80014e, 0xc6 }, - { 0x80014f, 0x03 }, { 0x800151, 0x1e }, { 0x800153, 0xbc }, { 0x800178, 0x09 },
@@ -1522,9 +1520,10 @@ static const struct reg_val tuner_init_i { 0x80018d, 0x5f }, { 0x80018f, 0xa0 }, { 0x800190, 0x5a }, - { 0x80ed02, 0xff }, - { 0x80ee42, 0xff }, - { 0x80ee82, 0xff }, + { 0x800191, 0x00 }, + { 0x80ed02, 0x40 }, + { 0x80ee42, 0x40 }, + { 0x80ee82, 0x40 }, { 0x80f000, 0x0f }, { 0x80f01f, 0x8c }, { 0x80f020, 0x00 },
@@ -1699,7 +1698,6 @@ static const struct reg_val tuner_init_i { 0x800104, 0x02 }, { 0x800105, 0xc8 }, { 0x800106, 0x00 }, - { 0x800109, 0x02 }, { 0x800115, 0x0a }, { 0x800116, 0x03 }, { 0x80011a, 0xc6 },
@@ -1725,7 +1723,6 @@ static const struct reg_val tuner_init_i { 0x80014b, 0x8c }, { 0x80014d, 0xa8 }, { 0x80014e, 0xc6 }, - { 0x80014f, 0x03 }, { 0x800151, 0x28 }, { 0x800153, 0xcc }, { 0x800178, 0x09 },
@@ -1737,9 +1734,10 @@ static const struct reg_val tuner_init_i { 0x80018d, 0x5f }, { 0x80018f, 0xfb }, { 0x800190, 0x5c }, - { 0x80ed02, 0xff }, - { 0x80ee42, 0xff }, - { 0x80ee82, 0xff }, + { 0x800191, 0x00 }, + { 0x80ed02, 0x40 }, + { 0x80ee42, 0x40 }, + { 0x80ee82, 0x40 }, { 0x80f000, 0x0f }, { 0x80f01f, 0x8c }, { 0x80f020, 0x00 },
Greg Kroah-Hartman
maintainerPATCH 324/357 media: adv7604: fix inverted condition
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 77639ff2b3404a913b8037d230a384798b854bae upstream.
The log_status function should show HDMI information, but the test checking for an HDMI input was inverted. Fix this.
--- drivers/media/i2c/adv7604.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/i2c/adv7604.c +1 -1
@@ -2325,7 +2325,7 @@ static int adv7604_log_status(struct v4lv4l2_info (sd,"HDCP keys read: %s%s\n" , (hdmi_read (sd,0x04 ) &0x20 ) ?"yes" :"no" , (hdmi_read (sd,0x04 ) &0x10 ) ?"ERROR" :"" ); -if (!is_hdmi (sd)) { +if (is_hdmi (sd)) {bool audio_pll_locked =hdmi_read (sd,0x04 ) &0x01 ;bool audio_sample_packet_detect =hdmi_read (sd,0x18 ) &0x01 ;bool audio_mute =io_read (sd,0x65 ) &0x40 ;
Greg Kroah-Hartman
maintainerPATCH 325/357 media: em28xx: fix VBI handling logic
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Mauro Carvalho Chehab <[email protected]>
commit c7854c2c5d692a329b4d9a9a73bcf36ae137ee7c upstream.
When both VBI and video are streaming, and video stream is stopped, a subsequent trial to restart it will fail, because S_FMT will return -EBUSY.
That prevents applications like zvbi to work properly.
Please notice that, while this fix it fully for zvbi, the best is to get rid of streaming_users and res_get logic as a hole.
However, this single-line patch is better to be merged at -stable.
--- drivers/media/usb/em28xx/em28xx-video.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/usb/em28xx/em28xx-video.c +1 -1
@@ -1344,7 +1344,7 @@ static int vidioc_s_fmt_vid_cap(struct fstruct em28xx *dev =video_drvdata (file);struct em28xx_v4l2 *v4l2 = dev->v4l2; -if (v4l2->streaming_users >0 ) +if (vb2_is_busy (&v4l2->vb_vidq))return -EBUSY ;vidioc_try_fmt_vid_cap (file, priv, f);
Greg Kroah-Hartman
maintainerPATCH 326/357 media: videobuf2-dma-sg: fix for wrong GFP mask to sg_alloc_table_from_pages
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit 47bc59c52b005f546343c373370a7eec6a2b0f84 upstream.
sg_alloc_table_from_pages() only allocates a sg_table, so it should just use GFP_KERNEL, not gfp_flags. If gfp_flags contains __GFP_DMA32 then mm/sl[au]b.c will call BUG_ON:
[ 358.027515] ------------[ cut here ]------------ [ 358.027546] kernel BUG at mm/slub.c:1416! [ 358.027558] invalid opcode: 0000 [#1] PREEMPT SMP [ 358.027576] Modules linked in: mt2131 s5h1409 tda8290 tuner cx25840 cx23885 btcx_risc altera_ci tda18271 altera_stapl videobuf2_dvb tveeprom cx2341x videobuf2_dma_sg dvb_core rc_core videobuf2_memops videobuf2_core nouveau zr36067 videocodec v4l2_common videodev media x86_pkg_temp_thermal cfbfillrect cfbimgblt cfbcopyarea ttm drm_kms_helper processor button isci [ 358.027712] CPU: 19 PID: 3654 Comm: cat Not tainted 3.16.0-rc6-telek #167 [ 358.027723] Hardware name: ASUSTeK COMPUTER INC. Z9PE-D8 WS/Z9PE-D8 WS, BIOS 5404 02/10/2014 [ 358.027741] task: ffff880897c7d960 ti: ffff88089b4d4000 task.ti: ffff88089b4d4000 [ 358.027753] RIP: 0010:[<ffffffff81196040>] [<ffffffff81196040>] new_slab+0x280/0x320 [ 358.027776] RSP: 0018:ffff88089b4d7ae8 EFLAGS: 00010002 [ 358.027787] RAX: ffff880897c7d960 RBX: 0000000000000000 RCX: ffff88089b4d7b50 [ 358.027798] RDX: 00000000ffffffff RSI: 0000000000000004 RDI: ffff88089f803b00 [ 358.027809] RBP: ffff88089b4d7bb8 R08: 0000000000000000 R09: 0000000100400040 [ 358.027821] R10: 0000160000000000 R11: ffff88109bc02c40 R12: 0000000000000001 [ 358.027832] R13: ffff88089f8000c0 R14: ffff88089f803b00 R15: ffff8810bfcf4be0 [ 358.027845] FS: 00007f83fe5c0700(0000) GS:ffff8810bfce0000(0000) knlGS:0000000000000000 [ 358.027858] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 [ 358.027868] CR2: 0000000001dfd568 CR3: 0000001097d5a000 CR4: 00000000000407e0 [ 358.027878] Stack: [ 358.027885] ffffffff81198860 ffff8810bfcf4be0 ffff880897c7d960 0000000000001b00 [ 358.027905] ffff880897c7d960 0000000000000000 ffff8810bfcf4bf0 0000000000000000 [ 358.027924] 0000000000000000 0000000100000100 ffffffff813ef84a 00000004ffffffff [ 358.027944] Call Trace: [ 358.027956] [<ffffffff81198860>] ? __slab_alloc+0x400/0x4e0 [ 358.027973] [<ffffffff813ef84a>] ? sg_kmalloc+0x1a/0x30 [ 358.027985] [<ffffffff81198f17>] __kmalloc+0x127/0x150 [ 358.027997] [<ffffffff813ef84a>] ? sg_kmalloc+0x1a/0x30 [ 358.028009] [<ffffffff813ef84a>] sg_kmalloc+0x1a/0x30 [ 358.028023] [<ffffffff813eff84>] __sg_alloc_table+0x74/0x180 [ 358.028035] [<ffffffff813ef830>] ? sg_kfree+0x20/0x20 [ 358.028048] [<ffffffff813f00af>] sg_alloc_table+0x1f/0x60 [ 358.028061] [<ffffffff813f0174>] sg_alloc_table_from_pages+0x84/0x1f0 [ 358.028077] [<ffffffffa007c3f9>] vb2_dma_sg_alloc+0x159/0x230 [videobuf2_dma_sg] [ 358.028095] [<ffffffffa003d55a>] __vb2_queue_alloc+0x10a/0x680 [videobuf2_core] [ 358.028113] [<ffffffffa003e110>] __reqbufs.isra.14+0x220/0x3e0 [videobuf2_core] [ 358.028130] [<ffffffffa003e79d>] __vb2_init_fileio+0xbd/0x380 [videobuf2_core] [ 358.028147] [<ffffffffa003f563>] __vb2_perform_fileio+0x5b3/0x6e0 [videobuf2_core] [ 358.028164] [<ffffffffa003f871>] vb2_fop_read+0xb1/0x100 [videobuf2_core] [ 358.028184] [<ffffffffa06dd2e5>] v4l2_read+0x65/0xb0 [videodev] [ 358.028198] [<ffffffff811a243f>] vfs_read+0x8f/0x170 [ 358.028210] [<ffffffff811a30a1>] SyS_read+0x41/0xb0 [ 358.028224] [<ffffffff818f02e9>] system_call_fastpath+0x16/0x1b [ 358.028234] Code: 66 90 e9 dc fd ff ff 0f 1f 40 00 41 8b 4d 68 e9 d5 fe ff ff 0f 1f 80 00 00 00 00 f0 41 80 4d 00 40 e9 03 ff ff ff 0f 1f 44 00 00 <0f> 0b 66 0f 1f 44 00 00 44 89 c6 4c 89 45 d0 e8 0c 82 ff ff 48 [ 358.028415] RIP [<ffffffff81196040>] new_slab+0x280/0x320 [ 358.028432] RSP <ffff88089b4d7ae8> [ 358.032208] ---[ end trace 6443240199c706e4 ]---
--- drivers/media/v4l2-core/videobuf2-dma-sg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf2-dma-sg.c +1 -1
@@ -113,7 +113,7 @@ static void *vb2_dma_sg_alloc(void *allo goto fail_pages_alloc; ret =sg_alloc_table_from_pages (&buf->sg_table, buf->pages, - buf->num_pages,0 , size, gfp_flags); + buf->num_pages,0 , size,GFP_KERNEL );if (ret) goto fail_table_alloc;
Greg Kroah-Hartman
maintainerPATCH 327/357 media: vb2: fix vb2 state check when start_streaming fails
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Hans Verkuil <[email protected]>
commit bf3593d939520559774cbfee03ba5f314d909620 upstream.
Commit bd994ddb2a12a3ff48cd549ec82cdceaea9614df (vb2: Fix stream start and buffer completion race) broke the buffer state check in vb2_buffer_done.
So accept all three possible states there since I can no longer tell the difference between vb2_buffer_done called from start_streaming or from elsewhere.
Instead add a WARN_ON at the end of start_streaming that will check whether any buffers were added to the done list, since that implies that the wrong state was used as well.
--- drivers/media/v4l2-core/videobuf2-core.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/media/v4l2-core/videobuf2-core.c +10 -7
@@ -1161,13 +1161,10 @@ void vb2_buffer_done(struct vb2_buffer *if (WARN_ON (vb->state !=VB2_BUF_STATE_ACTIVE ))return ; -if (!q->start_streaming_called) { -if (WARN_ON (state !=VB2_BUF_STATE_QUEUED )) - state =VB2_BUF_STATE_QUEUED ; - }else if (WARN_ON (state !=VB2_BUF_STATE_DONE && - state !=VB2_BUF_STATE_ERROR )) { - state =VB2_BUF_STATE_ERROR ; - } +if (WARN_ON (state !=VB2_BUF_STATE_DONE && + state !=VB2_BUF_STATE_ERROR && + state !=VB2_BUF_STATE_QUEUED )) + state =VB2_BUF_STATE_ERROR ;#ifdef CONFIG_VIDEO_ADV_DEBUG /*
@@ -1774,6 +1771,12 @@ static int vb2_start_streaming(struct vb/* Must be zero now */ WARN_ON (atomic_read (&q->owned_by_drv_count)); } +/* +* If done_list is not empty, then start_streaming() didn't call +* vb2_buffer_done(vb, VB2_BUF_STATE_QUEUED) but STATE_ERROR or +* STATE_DONE. +*/ +WARN_ON (!list_empty (&q->done_list));return ret; }
Greg Kroah-Hartman
maintainerPATCH 328/357 media: vb2: fix plane index sanity check in vb2_plane_cookie()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Zhaowei Yuan <[email protected]>
commit a9ae4692eda4b99f85757b15d60971ff78a0a0e2 upstream.
It's also invalid when plane_no is equal to vb->num_planes
--- drivers/media/v4l2-core/videobuf2-core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/v4l2-core/videobuf2-core.c +1 -1
@@ -1126,7 +1126,7 @@ EXPORT_SYMBOL_GPL(vb2_plane_vaddr);*/ void *vb2_plane_cookie (struct vb2_buffer *vb,unsigned int plane_no) { -if (plane_no > vb->num_planes || !vb->planes[plane_no].mem_priv) +if (plane_no >= vb->num_planes || !vb->planes[plane_no].mem_priv)return NULL ;return call_ptr_memop (vb, cookie, vb->planes[plane_no].mem_priv);
Greg Kroah-Hartman
maintainerPATCH 329/357 md/raid1: clean up request counts properly in close_sync()
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 669cc7ba77864e7b1ac39c9f2b2afb8730f341f4 upstream.
If there are outstanding writes when close_sync is called, the change to ->start_next_window might cause them to decrement the wrong counter when they complete. Fix this by merging the two counters into the one that will be decremented.
Having an incorrect value in a counter can cause raise_barrier() to hangs, so this is suitable for -stable.
--- drivers/md/raid1.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/md/raid1.c +5 -0
@@ -1548,8 +1548,13 @@ static void close_sync(struct r1conf *comempool_destroy (conf->r1buf_pool); conf->r1buf_pool =NULL ; +spin_lock_irq (&conf->resync_lock); conf->next_resync =0 ; conf->start_next_window = MaxSector; + conf->current_window_requests += + conf->next_window_requests; + conf->next_window_requests =0 ; +spin_unlock_irq (&conf->resync_lock); }static int raid1_spare_active (struct mddev *mddev)
Greg Kroah-Hartman
maintainerPATCH 330/357 md/raid1: be more cautious where we read-balance during resync.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit c6d119cf1b5a778e9ed60a006e2a434fcc4471a2 upstream.
commit 79ef3a8aa1cb1523cc231c9a90a278333c21f761 made it possible for reads to happen concurrently with resync. This means that we need to be more careful where read_balancing is allowed during resync - we can no longer be sure that any resync that has already started will definitely finish.
So keep read_balancing to before recovery_cp, which is conservative but safe.
This bug makes it possible to read from a device that doesn't have up-to-date data, so it can cause data corruption. So it is suitable for any kernel since 3.11.
--- drivers/md/raid1.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)
drivers/md/raid1.c +1 -5
@@ -540,11 +540,7 @@ static int read_balance(struct r1conf *c has_nonrot_disk =0 ; choose_next_idle =0 ; -if (conf->mddev->recovery_cp < MaxSector && - (this_sector + sectors >= conf->next_resync)) - choose_first =1 ; -else - choose_first =0 ; + choose_first = (conf->mddev->recovery_cp < this_sector + sectors);for (disk =0 ; disk < conf->raid_disks *2 ; disk++) {sector_t dist;
Greg Kroah-Hartman
maintainerPATCH 331/357 md/raid1: make sure resync waits for conflicting writes to complete.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 2f73d3c55d09ce60647b96ad2a9b539c95a530ee upstream.
The resync/recovery process for raid1 was recently changed so that writes could happen in parallel with resync providing they were in different regions of the device.
There is a problem though: While a write request will always wait for conflicting resync to complete, a resync request will *not* always wait for conflicting writes to complete.
Two changes are needed to fix this:
1/ raise_barrier (which waits until it is safe to do resync)
must wait until current_window_requests is zero
2/ wait_battier (which waits at the start of a new write request)
must update current_window_requests if the request could possible conflict with a concurrent resync.
As concurrent writes and resync can lead to data loss, this patch is suitable for -stable.
--- drivers/md/raid1.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/md/raid1.c +4 -2
@@ -845,10 +845,12 @@ static void raise_barrier(struct r1conf* C: next_resync + RESYNC_SECTORS > start_next_window, meaning * next resync will reach to the window which normal bios are * handling. +* D: while there are any active requests in the current window. */ wait_event_lock_irq (conf->wait_barrier, !conf->array_frozen && conf->barrier <RESYNC_DEPTH && + conf->current_window_requests ==0 && (conf->start_next_window >= conf->next_resync +RESYNC_SECTORS ), conf->resync_lock);
@@ -915,8 +917,8 @@ static sector_t wait_barrier(struct r1co }if (bio &&bio_data_dir (bio) ==WRITE ) { -if (conf->next_resync +NEXT_NORMALIO_DISTANCE - <= bio->bi_iter.bi_sector) { +if (bio->bi_iter.bi_sector >= + conf->next_resync) {if (conf->start_next_window == MaxSector) conf->start_next_window = conf->next_resync +
Greg Kroah-Hartman
maintainerPATCH 332/357 md/raid1: Dont use next_resync to determine how far resync has progressed
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 235549605eb7f1c5a37cef8b09d12e6d412c5cd6 upstream.
next_resync is (approximately) the location for the next resync request. However it does *not* reliably determine the earliest location at which resync might be happening.
This is because resync requests can complete out of order, and we only limit the number of current requests, not the distance from the earliest pending request to the latest.
mddev->curr_resync_completed is a reliable indicator of the earliest
position at which resync could be happening. It is updated less
frequently, but is actually reliable which is more important.
So use it to determine if a write request is before the region being resynced and so safe from conflict.
This error can allow resync IO to interfere with normal IO which could lead to data corruption. Hence: stable.
--- drivers/md/raid1.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
drivers/md/raid1.c +5 -7
@@ -875,12 +875,10 @@ static bool need_to_wait_for_sync(structif (conf->array_frozen || !bio) wait = true;else if (conf->barrier &&bio_data_dir (bio) ==WRITE ) { -if (conf->next_resync <RESYNC_WINDOW_SECTORS ) - wait = true; -else if ((conf->next_resync -RESYNC_WINDOW_SECTORS - >=bio_end_sector (bio)) || - (conf->next_resync +NEXT_NORMALIO_DISTANCE - <= bio->bi_iter.bi_sector)) +if ((conf->mddev->curr_resync_completed + >=bio_end_sector (bio)) || + (conf->next_resync +NEXT_NORMALIO_DISTANCE + <= bio->bi_iter.bi_sector)) wait = false;else wait = true;
@@ -918,7 +916,7 @@ static sector_t wait_barrier(struct r1coif (bio &&bio_data_dir (bio) ==WRITE ) {if (bio->bi_iter.bi_sector >= - conf->next_resync) { + conf->mddev->curr_resync_completed) {if (conf->start_next_window == MaxSector) conf->start_next_window = conf->next_resync +
Greg Kroah-Hartman
maintainerPATCH 333/357 md/raid1: update next_resync under resync_lock.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit c2fd4c94deedb89ac1746c4a53219be499372c06 upstream.
raise_barrier() uses next_resync as part of its calculations, so it really should be updated first, instead of afterwards.
next_resync is always used under resync_lock so update it under resync lock to, just before it is used. That is safest.
This could cause normal IO and resync IO to interact badly so it suitable for -stable.
--- drivers/md/raid1.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/md/raid1.c +3 -3
@@ -827,7 +827,7 @@ static void flush_pending_writes(struct* there is no normal IO happeing. It must arrange to call * lower_barrier when the particular background IO completes. */ -static void raise_barrier (struct r1conf *conf) +static void raise_barrier (struct r1conf *conf,sector_t sector_nr) {spin_lock_irq (&conf->resync_lock);
@@ -837,6 +837,7 @@ static void raise_barrier(struct r1conf/* block any new IO from starting */ conf->barrier++; + conf->next_resync = sector_nr;/* For these conditions we must wait: * A: while the array is in frozen state
@@ -2542,9 +2543,8 @@ static sector_t sync_request(struct mddebitmap_cond_end_sync (mddev->bitmap, sector_nr); r1_bio =mempool_alloc (conf->r1buf_pool,GFP_NOIO ); -raise_barrier (conf); - conf->next_resync = sector_nr; +raise_barrier (conf, sector_nr);rcu_read_lock ();/*
Greg Kroah-Hartman
maintainerPATCH 334/357 md/raid1: count resync requests in nr_pending.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit 34e97f170149bfa14979581c4c748bc9b4b79d5b upstream.
Both normal IO and resync IO can be retried with reschedule_retry() and so be counted into ->nr_queued, but only normal IO gets counted in ->nr_pending.
Before the recent improvement to RAID1 resync there could only possibly have been one or the other on the queue. When handling a read failure it could only be normal IO. So when handle_read_error() called freeze_array() the fact that freeze_array only compares ->nr_queued against ->nr_pending was safe.
But now that these two types can interleave, we can have both normal and resync IO requests queued, so we need to count them both in nr_pending.
This error can lead to freeze_array() hanging if there is a read error, so it is suitable for -stable.
--- drivers/md/raid1.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/raid1.c +2 -0
@@ -856,6 +856,7 @@ static void raise_barrier(struct r1conf conf->next_resync + RESYNC_SECTORS), conf->resync_lock); + conf->nr_pending++;spin_unlock_irq (&conf->resync_lock); }
@@ -865,6 +866,7 @@ static void lower_barrier(struct r1confBUG_ON (conf->barrier <=0 );spin_lock_irqsave (&conf->resync_lock, flags); conf->barrier--; + conf->nr_pending--;spin_unlock_irqrestore (&conf->resync_lock, flags);wake_up (&conf->wait_barrier); }
Greg Kroah-Hartman
maintainerPATCH 335/357 md/raid1: fix_read_error should act on all non-faulty devices.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit b8cb6b4c121e1bf1963c16ed69e7adcb1bc301cd upstream.
If a devices is being recovered it is not InSync and is not Faulty.
If a read error is experienced on that device, fix_read_error() will be called, but it ignores non-InSync devices. So it will neither fix the error nor fail the device.
It is incorrect that fix_read_error() ignores non-InSync devices. It should only ignore Faulty devices. So fix it.
This became a bug when we allowed reading from a device that was being recovered. It is suitable for any subsequent -stable kernel.
--- drivers/md/raid1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/md/raid1.c +2 -2
@@ -2154,7 +2154,7 @@ static void fix_read_error(struct r1conf d--; rdev = conf->mirrors[d].rdev;if (rdev && -test_bit (In_sync, &rdev->flags)) + !test_bit (Faulty, &rdev->flags))r1_sync_page_io (rdev, sect, s, conf->tmppage,WRITE ); }
@@ -2166,7 +2166,7 @@ static void fix_read_error(struct r1conf d--; rdev = conf->mirrors[d].rdev;if (rdev && -test_bit (In_sync, &rdev->flags)) { + !test_bit (Faulty, &rdev->flags)) {if (r1_sync_page_io (rdev, sect, s, conf->tmppage,READ )) {atomic_add (s, &rdev->corrected_errors);
Greg Kroah-Hartman
maintainerPATCH 336/357 md/raid1: intialise start_next_window for READ case to avoid hang
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: NeilBrown <[email protected]>
commit f0cc9a057151892b885be21a1d19b0185568281d upstream.
r1_bio->start_next_window is not initialised in the READ case, so allow_barrier may incorrectly decrement
conf->current_window_requests
which can cause raise_barrier() to block forever.
--- drivers/md/raid1.c | 1 + 1 file changed, 1 insertion(+)
drivers/md/raid1.c +1 -0
@@ -1185,6 +1185,7 @@ read_again: atomic_read(&bitmap->behind_writes) == 0); } r1_bio->read_disk = rdisk; + r1_bio->start_next_window =0 ; read_bio =bio_clone_mddev (bio,GFP_NOIO , mddev); bio_trim(read_bio, r1_bio->sector - bio->bi_iter.bi_sector,
Greg Kroah-Hartman
maintainerPATCH 337/357 netfilter: xt_hashlimit: perform garbage collection from process context
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Eric Dumazet <[email protected]>
commit 7bd8490eef9776ced7632345df5133384b6be0fe upstream.
xt_hashlimit cannot be used with large hash tables, because garbage collector is run from a timer. If table is really big, its possible to hold cpu for more than 500 msec, which is unacceptable.
Switch to a work queue, and use proper scheduling points to remove latencies spikes.
Later, we also could switch to a smoother garbage collection done at lookup time, one bucket at a time...
--- net/netfilter/xt_hashlimit.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-)
net/netfilter/xt_hashlimit.c +16 -15
@@ -104,7 +104,7 @@ struct xt_hashlimit_htable {spinlock_t lock;/* lock for list_head */ u_int32_t rnd;/* random seed for hash */ unsigned int count;/* number entries in table */ -struct timer_list timer;/* timer for gc */ +struct delayed_work gc_work;/* seq_file stuff */ struct proc_dir_entry *pde;
@@ -213,7 +213,7 @@ dsthash_free(struct xt_hashlimit_htablecall_rcu_bh (&ent->rcu, dsthash_free_rcu); ht->count--; } -static void htable_gc (unsigned long htlong); +static void htable_gc (struct work_struct *work);static int htable_create (struct net *net,struct xt_hashlimit_mtinfo1 *minfo,u_int8_t family)
@@ -273,9 +273,9 @@ static int htable_create(struct net *net } hinfo->net = net; -setup_timer (&hinfo->timer, htable_gc, (unsigned long )hinfo); - hinfo->timer.expires = jiffies +msecs_to_jiffies (hinfo->cfg.gc_interval); -add_timer (&hinfo->timer); +INIT_DEFERRABLE_WORK (&hinfo->gc_work, htable_gc); +queue_delayed_work (system_power_efficient_wq, &hinfo->gc_work, +msecs_to_jiffies (hinfo->cfg.gc_interval));hlist_add_head (&hinfo->node, &hashlimit_net->htables);
@@ -300,29 +300,30 @@ static void htable_selective_cleanup(str {unsigned int i; -/* lock hash table and iterate over it */ -spin_lock_bh (&ht->lock);for (i =0 ; i < ht->cfg.size; i++) {struct dsthash_ent *dh;struct hlist_node *n; + +spin_lock_bh (&ht->lock);hlist_for_each_entry_safe (dh, n, &ht->hash[i], node) {if ((*select)(ht, dh))dsthash_free (ht, dh); } +spin_unlock_bh (&ht->lock); +cond_resched (); } -spin_unlock_bh (&ht->lock); } -/* hash table garbage collector, run by timer */ -static void htable_gc (unsigned long htlong) +static void htable_gc (struct work_struct *work) { -struct xt_hashlimit_htable *ht = (struct xt_hashlimit_htable *)htlong; +struct xt_hashlimit_htable *ht; + + ht = container_of(work, struct xt_hashlimit_htable, gc_work.work);htable_selective_cleanup (ht, select_gc); -/* re-add the timer accordingly */ - ht->timer.expires = jiffies +msecs_to_jiffies (ht->cfg.gc_interval); -add_timer (&ht->timer); +queue_delayed_work (system_power_efficient_wq, + &ht->gc_work,msecs_to_jiffies (ht->cfg.gc_interval)); }static void htable_remove_proc_entry (struct xt_hashlimit_htable *hinfo)
@@ -341,7 +342,7 @@ static void htable_remove_proc_entry(strstatic void htable_destroy (struct xt_hashlimit_htable *hinfo) { -del_timer_sync (&hinfo->timer); +cancel_delayed_work_sync (&hinfo->gc_work);htable_remove_proc_entry (hinfo);htable_selective_cleanup (hinfo, select_all);kfree (hinfo->name);
Greg Kroah-Hartman
maintainerPATCH 338/357 ipvs: Maintain all DSCP and ECN bits for ipv6 tun forwarding
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Alex Gartrell <[email protected]>
commit 76f084bc10004b3050b2cff9cfac29148f1f6088 upstream.
Previously, only the four high bits of the tclass were maintained in the ipv6 case. This matches the behavior of ipv4, though whether or not we should reflect ECN bits may be up for debate.
--- net/netfilter/ipvs/ip_vs_xmit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_xmit.c +1 -1
@@ -967,8 +967,8 @@ ip_vs_tunnel_xmit_v6(struct sk_buff *skb iph->nexthdr =IPPROTO_IPV6 ; iph->payload_len = old_iph->payload_len;be16_add_cpu (&iph->payload_len,sizeof (*old_iph)); - iph->priority = old_iph->priority;memset (&iph->flow_lbl,0 ,sizeof (iph->flow_lbl)); +ipv6_change_dsfield (iph,0 ,ipv6_get_dsfield (old_iph)); iph->daddr = cp->daddr.in6; iph->saddr = saddr; iph->hop_limit = old_iph->hop_limit;
Greg Kroah-Hartman
maintainerPATCH 339/357 netfilter: x_tables: allow to use default cgroup match
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Daniel Borkmann <[email protected]>
commit caa8ad94edf686d02b555c65a6162c0d1b434958 upstream.
There's actually no good reason why we cannot use cgroup id 0, so lets just remove this artificial barrier.
--- net/netfilter/xt_cgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/xt_cgroup.c +1 -1
@@ -31,7 +31,7 @@ static int cgroup_mt_check(const structif (info->invert & ~1 )return -EINVAL ; -return info->id ?0 : -EINVAL ; +return 0 ; } static bool
Greg Kroah-Hartman
maintainerPATCH 340/357 ipvs: fix ipv6 hook registration for local replies
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Julian Anastasov <[email protected]>
commit eb90b0c734ad793d5f5bf230a9e9a4dcc48df8aa upstream.
commit fc604767613b6d2036cdc35b660bc39451040a47 ("ipvs: changes for local real server") from 2.6.37 introduced DNAT support to local real server but the IPv6 LOCAL_OUT handler ip_vs_local_reply6() is registered incorrectly as IPv4 hook causing any outgoing IPv4 traffic to be dropped depending on the IP header values.
Chris tracked down the problem to CONFIG_IP_VS_IPV6=y
Bug report: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1349768
--- net/netfilter/ipvs/ip_vs_core.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/netfilter/ipvs/ip_vs_core.c +1 -1
@@ -1906,7 +1906,7 @@ static struct nf_hook_ops ip_vs_ops[] __ { .hook = ip_vs_local_reply6, .owner = THIS_MODULE, - .pf = NFPROTO_IPV4, + .pf = NFPROTO_IPV6, .hooknum = NF_INET_LOCAL_OUT, .priority = NF_IP6_PRI_NAT_DST + 1, },
Greg Kroah-Hartman
maintainerPATCH 341/357 netfilter: nf_tables: dont update chain with unset counters
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Pablo Neira Ayuso <[email protected]>
commit b88825de8545ad252c31543fef13cadf4de7a2bc upstream.
Fix possible replacement of the per-cpu chain counters by null pointer when updating an existing chain in the commit path.
--- net/netfilter/nf_tables_api.c | 3 +++ 1 file changed, 3 insertions(+)
net/netfilter/nf_tables_api.c +3 -0
@@ -899,6 +899,9 @@ static struct nft_stats __percpu *nft_ststatic void nft_chain_stats_replace (struct nft_base_chain *chain,struct nft_stats __percpu *newstats) { +if (newstats ==NULL ) +return ; +if (chain->stats) {struct nft_stats __percpu *oldstats =nft_dereference (chain->stats);
Greg Kroah-Hartman
maintainerPATCH 342/357 mmc: mmci: Reverse IRQ handling for the arm_variant
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Ulf Hansson <[email protected]>
commit 7878289b269d41c8e611aa6d4519feae706e49f3 upstream.
Commit "mmc: mmci: Handle CMD irq before DATA irq", caused an issue when using the ARM model of the PL181 and running QEMU.
The bug was reported for the following QEMU version:
$ qemu-system-arm -version QEMU emulator version 2.0.0 (Debian 2.0.0+dfsg-2ubuntu1.1), Copyright (c) 2003-2008 Fabrice Bellard
To resolve the problem, let's restore the old behavior were the DATA irq is handled prior the CMD irq, but only for the arm_variant, which the problem was reported for.
--- drivers/mmc/host/mmci.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/mmc/host/mmci.c +10 -2
@@ -65,6 +65,7 @@ static unsigned int fmax = 515633;* @pwrreg_clkgate: MMCIPOWER register must be used to gate the clock * @busy_detect: true if busy detection on dat0 is supported * @pwrreg_nopower: bits in MMCIPOWER don't controls ext. power supply +* @reversed_irq_handling: handle data irq before cmd irq. */ struct variant_data {unsigned int clkreg;
@@ -80,6 +81,7 @@ struct variant_data {bool pwrreg_clkgate;bool busy_detect;bool pwrreg_nopower; +bool reversed_irq_handling; };static struct variant_data variant_arm = {
@@ -87,6 +89,7 @@ static struct variant_data variant_arm = .fifohalfsize = 8 * 4, .datalength_bits = 16, .pwrreg_powerup = MCI_PWR_UP, + .reversed_irq_handling = true, };static struct variant_data variant_arm_extended_fifo = {
@@ -1163,8 +1166,13 @@ static irqreturn_t mmci_irq(int irq, voidev_dbg (mmc_dev (host->mmc),"irq0 (data+cmd) %08x\n" , status); -mmci_cmd_irq (host, host->cmd, status); -mmci_data_irq (host, host->data, status); +if (host->variant->reversed_irq_handling) { +mmci_data_irq (host, host->data, status); +mmci_cmd_irq (host, host->cmd, status); + }else { +mmci_cmd_irq (host, host->cmd, status); +mmci_data_irq (host, host->data, status); + }/* Don't poll for busy completion in irq context. */ if (host->busy_status)
Greg Kroah-Hartman
maintainerPATCH 343/357 dmaengine: dw: introduce dwc_dostart_first_queued() helper
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit e7637c6c0382485f4d2e20715d058dae6f2b6a7c upstream.
We have a duplicate code which starts first descriptor in the queue. Let's make this as a separate helper that can be used in future as well.
--- drivers/dma/dw/core.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/dma/dw/core.c +11 -8
@@ -279,6 +279,15 @@ static void dwc_dostart(struct dw_dma_chchannel_set_bit (dw,CH_EN , dwc->mask); } +static void dwc_dostart_first_queued (struct dw_dma_chan *dwc) +{ +if (list_empty (&dwc->queue)) +return ; + +list_move (dwc->queue.next, &dwc->active_list); +dwc_dostart (dwc,dwc_first_active (dwc)); +} +/*----------------------------------------------------------------------*/ static void
@@ -335,10 +344,7 @@ static void dwc_complete_all(struct dw_d* the completed ones. */ list_splice_init (&dwc->active_list, &list); -if (!list_empty (&dwc->queue)) { -list_move (dwc->queue.next, &dwc->active_list); -dwc_dostart (dwc,dwc_first_active (dwc)); - } +dwc_dostart_first_queued (dwc);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -467,10 +473,7 @@ static void dwc_scan_descriptors(struct/* Try to continue after resetting the channel... */ dwc_chan_disable (dw, dwc); -if (!list_empty (&dwc->queue)) { -list_move (dwc->queue.next, &dwc->active_list); -dwc_dostart (dwc,dwc_first_active (dwc)); - } +dwc_dostart_first_queued (dwc);spin_unlock_irqrestore (&dwc->lock, flags); }
Greg Kroah-Hartman
maintainerPATCH 344/357 dmaengine: dw: dont perform DMA when dmaengine_submit is called
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Andy Shevchenko <[email protected]>
commit dd8ecfcac66b4485416b2d1df0ec4798b198d7d6 upstream.
Accordingly to discussion [1] and followed up documentation the DMA controller driver shouldn't start any DMA operations when dmaengine_submit() is called.
This patch fixes the workflow in dw_dmac driver to follow the documentation.
[1] http://www.spinics.net/lists/arm-kernel/msg125987.html
--- drivers/dma/TODO | 1 - drivers/dma/dw/core.c | 19 +++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-)
drivers/dma/TODO +0 -1
@@ -7,7 +7,6 @@ TODO for slave dma - imx-dma - imx-sdma - mxs-dma.c - - dw_dmac - intel_mid_dma 4. Check other subsystems for dma drivers and merge/move to dmaengine 5. Remove dma_slave_config's dma direction.
drivers/dma/dw/core.c +7 -12
@@ -680,17 +680,9 @@ static dma_cookie_t dwc_tx_submit(struct* possible, perhaps even appending to those already submitted * for DMA. But this is hard to do in a race-free manner. */ -if (list_empty (&dwc->active_list)) { -dev_vdbg (chan2dev (tx->chan),"%s: started %u\n" , __func__, - desc->txd.cookie); -list_add_tail (&desc->desc_node, &dwc->active_list); -dwc_dostart (dwc,dwc_first_active (dwc)); - }else { -dev_vdbg (chan2dev (tx->chan),"%s: queued %u\n" , __func__, - desc->txd.cookie); -list_add_tail (&desc->desc_node, &dwc->queue); - } +dev_vdbg (chan2dev (tx->chan),"%s: queued %u\n" , __func__, desc->txd.cookie); +list_add_tail (&desc->desc_node, &dwc->queue);spin_unlock_irqrestore (&dwc->lock, flags);
@@ -1095,9 +1087,12 @@ dwc_tx_status(struct dma_chan *chan,static void dwc_issue_pending (struct dma_chan *chan) {struct dw_dma_chan *dwc =to_dw_dma_chan (chan); +unsigned long flags; -if (!list_empty (&dwc->queue)) -dwc_scan_descriptors (to_dw_dma (chan->device), dwc); +spin_lock_irqsave (&dwc->lock, flags); +if (list_empty (&dwc->active_list)) +dwc_dostart_first_queued (dwc); +spin_unlock_irqrestore (&dwc->lock, flags); }static int dwc_alloc_chan_resources (struct dma_chan *chan)
Greg Kroah-Hartman
maintainerPATCH 345/357 partitions: aix.c: off by one bug
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Dan Carpenter <[email protected]>
commit d97a86c170b4e432f76db072a827fe30b4d6f659 upstream.
The lvip[] array has "state->limit" elements so the condition here should be >= instead of >.
--- block/partitions/aix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/partitions/aix.c +1 -1
@@ -253,7 +253,7 @@ int aix_partition(struct parsed_partitiocontinue ; } lv_ix =be16_to_cpu (p->lv_ix) -1 ; -if (lv_ix > state->limit) { +if (lv_ix >= state->limit) { cur_lv_ix =-1 ;continue ; }
Greg Kroah-Hartman
maintainerPATCH 346/357 cpufreq: update cpufreq_suspended after stopping governors
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Viresh Kumar <[email protected]>
commit b1b12babe3b72cfb08b875245e5a5d7c2747c772 upstream.
Commit 8e30444e1530 ("cpufreq: fix cpufreq suspend/resume for intel_pstate") introduced a bug where the governors wouldn't be stopped anymore for ->target{_index}() drivers during suspend. This happens because 'cpufreq_suspended' is updated before stopping the governors during suspend and due to this __cpufreq_governor() would return early due to this check:
/* Don't start any governor operations if we are entering suspend */ if (cpufreq_suspended) return 0;
--- drivers/cpufreq/cpufreq.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/cpufreq/cpufreq.c +4 -3
@@ -1666,10 +1666,8 @@ void cpufreq_suspend(void)if (!cpufreq_driver)return ; - cpufreq_suspended = true; -if (!has_target ()) -return ; + goto suspend;pr_debug ("%s: Suspending Governors\n" , __func__);
@@ -1682,6 +1680,9 @@ void cpufreq_suspend(void)pr_err ("%s: Failed to suspend driver: %p\n" , __func__, policy); } + +suspend: + cpufreq_suspended = true; }/**
Greg Kroah-Hartman
maintainerPATCH 347/357 clk: ti: dra7-atl: Provide error check for incoming parameters in set_rate
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nishanth Menon <[email protected]>
commit 20411dad75ece9a613af715df4489e60990c4017 upstream.
Check for valid parameters in check rate. Else, we end up getting errors.
This occurs as part of the inital clock tree update of child clock nodes where new_rate could be 0 for non functional clocks.
--- drivers/clk/ti/clk-dra7-atl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/clk/ti/clk-dra7-atl.c +5 -1
@@ -139,9 +139,13 @@ static long atl_clk_round_rate(struct clstatic int atl_clk_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) { -struct dra7_atl_desc *cdesc =to_atl_desc (hw); +struct dra7_atl_desc *cdesc;u32 divider; +if (!hw || !rate) +return -EINVAL ; + + cdesc =to_atl_desc (hw); divider = ((parent_rate + rate /2 ) / rate) -1 ;if (divider >DRA7_ATL_DIVIDER_MASK ) divider =DRA7_ATL_DIVIDER_MASK ;
Greg Kroah-Hartman
maintainerPATCH 348/357 clk: prevent erronous parsing of children during rate change
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Tero Kristo <[email protected]>
commit 067bb1741c27c8d3b74ac98c0b8fc12b31e67005 upstream.
In some cases, clocks can switch their parent with clk_set_rate, for example clk_mux can do this in some cases. Current implementation of clk_change_rate uses un-safe list iteration on the clock children, which will cause wrong clocks to be parsed in case any of the clock children change their parents during the change rate operation. Fixed by using the safe list iterator instead.
The problem was detected due to some divide by zero errors generated by clock init on dra7-evm board, see discussion under
http://article.gmane.org/gmane.linux.ports.arm.kernel/349180 for details.
--- drivers/clk/clk.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clk/clk.c +6 -1
@@ -1495,6 +1495,7 @@ static struct clk *clk_propagate_rate_chstatic void clk_change_rate (struct clk *clk) {struct clk *child; +struct hlist_node *tmp;unsigned long old_rate;unsigned long best_parent_rate =0 ;bool skip_set_rate = false;
@@ -1530,7 +1531,11 @@ static void clk_change_rate(struct clk *if (clk->notifier_count && old_rate != clk->rate)__clk_notify (clk,POST_RATE_CHANGE , old_rate, clk->rate); -hlist_for_each_entry (child, &clk->children, child_node) { +/* +* Use safe iteration, as change_rate can actually swap parents +* for certain clock types. +*/ +hlist_for_each_entry_safe (child, tmp, &clk->children, child_node) {/* Skip children who will be reparented to another clock */ if (child->new_parent && child->new_parent != clk)continue ;
Greg Kroah-Hartman
maintainerPATCH 349/357 clk: ti: divider: Provide error check for incoming parameters in set_rate
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Nishanth Menon <[email protected]>
commit 2f1032517623b70920d99529e5c87c8c680ab8bf upstream.
Check for valid parameters in check rate. Else, we end up getting errors like:
[ 0.000000] Division by zero in kernel. [ 0.000000] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.17.0-rc1 #1 [ 0.000000] [<c0015160>] (unwind_backtrace) from [<c0011978>] (show_stack+0x10/0x14) [ 0.000000] [<c0011978>] (show_stack) from [<c055f5f4>] (dump_stack+0x78/0x94) [ 0.000000] [<c055f5f4>] (dump_stack) from [<c02e17cc>] (Ldiv0+0x8/0x10) [ 0.000000] [<c02e17cc>] (Ldiv0) from [<c047d228>] (ti_clk_divider_set_rate+0x14/0x14c) [ 0.000000] [<c047d228>] (ti_clk_divider_set_rate) from [<c047a938>] (clk_change_rate+0x138/0x180) [ 0.000000] [<c047a938>] (clk_change_rate) from [<c047a908>] (clk_change_rate+0x108/0x180)
This occurs as part of the inital clock tree update of child clock nodes where new_rate could be 0 for non functional clocks.
--- drivers/clk/ti/divider.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/clk/ti/divider.c +6 -1
@@ -211,11 +211,16 @@ static long ti_clk_divider_round_rate(ststatic int ti_clk_divider_set_rate (struct clk_hw *hw,unsigned long rate,unsigned long parent_rate) { -struct clk_divider *divider =to_clk_divider (hw); +struct clk_divider *divider;unsigned int div, value;unsigned long flags =0 ;u32 val; +if (!hw || !rate) +return -EINVAL ; + + divider =to_clk_divider (hw); + div =DIV_ROUND_UP (parent_rate, rate); value =_get_val (divider, div);
Greg Kroah-Hartman
maintainerPATCH 350/357 ahci_xgene: Removing NCQ support from the APM X-Gene SoC AHCI SATA Host Controller driver.
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Suman Tripathi <[email protected]>
commit 72f79f9e35bd3f78ee8853f2fcacaa197d23ebac upstream.
This patch removes the NCQ support from the APM X-Gene SoC AHCI Host Controller driver as it doesn't support it.
--- drivers/ata/ahci_xgene.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/ata/ahci_xgene.c +2 -2
@@ -337,7 +337,7 @@ static struct ata_port_operations xgene_ };static const struct ata_port_info xgene_ahci_port_info = { - .flags =AHCI_FLAG_COMMON |ATA_FLAG_NCQ , + .flags =AHCI_FLAG_COMMON , .pio_mask =ATA_PIO4 , .udma_mask =ATA_UDMA6 , .port_ops = &xgene_ahci_ops,
@@ -484,7 +484,7 @@ static int xgene_ahci_probe(struct platf goto disable_resources; } - hflags =AHCI_HFLAG_NO_PMP |AHCI_HFLAG_YES_NCQ ; + hflags =AHCI_HFLAG_NO_PMP |AHCI_HFLAG_NO_NCQ ; rc =ahci_platform_init_host (pdev, hpriv, &xgene_ahci_port_info, hflags,0 ,0 );
Greg Kroah-Hartman
maintainerPATCH 351/357 aio: block exit_aio() until all context requests are completed
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Gu Zheng <[email protected]>
commit 6098b45b32e6baeacc04790773ced9340601d511 upstream.
It seems that exit_aio() also needs to wait for all iocbs to complete (like io_destroy), but we missed the wait step in current implemention, so fix it in the same way as we did in io_destroy.
--- fs/aio.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)
fs/aio.c +7 -1
@@ -797,6 +797,9 @@ void exit_aio(struct mm_struct *mm)unsigned i =0 ;while (1 ) { +struct completion requests_done = +COMPLETION_INITIALIZER_ONSTACK (requests_done); +rcu_read_lock (); table =rcu_dereference (mm->ioctx_table);
@@ -824,7 +827,10 @@ void exit_aio(struct mm_struct *mm)*/ ctx->mmap_size =0 ; -kill_ioctx (mm, ctx,NULL ); +kill_ioctx (mm, ctx, &requests_done); + +/* Wait until all IO for the context are done. */ +wait_for_completion (&requests_done); } }
Greg Kroah-Hartman
maintainerPATCH 352/357 ext4: propagate errors up to ext4_find_entry()s callers
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit 36de928641ee48b2078d3fe9514242aaa2f92013 upstream.
If we run into some kind of error, such as ENOMEM, while calling ext4_getblk() or ext4_dx_find_entry(), we need to make sure this error gets propagated up to ext4_find_entry() and then to its callers. This way, transient errors such as ENOMEM can get propagated to the VFS. This is important so that the system calls return the appropriate error, and also so that in the case of ext4_lookup(), we return an error instead of a NULL inode, since that will result in a negative dentry cache entry that will stick around long past the OOM condition which caused a transient ENOMEM error.
Google-Bug-Id: #17142205
--- fs/ext4/ext4.h | 2 +- fs/ext4/namei.c | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 34 insertions(+), 3 deletions(-)
fs/ext4/ext4.h +1 -1
@@ -1826,7 +1826,7 @@ ext4_group_first_block_no(struct super_b/* * Special error return code only used by dx_probe() and its callers. */ -#define ERR_BAD_DX_DIR -75000 +#define ERR_BAD_DX_DIR (-(MAX_ERRNO - 1))/* * Timeout and state flag for lazy initialization inode thread.
fs/ext4/namei.c +33 -2
@@ -1227,7 +1227,7 @@ static struct buffer_head * ext4_find_enbuffer */ int num =0 ;ext4_lblk_t nblocks; -int i, err; +int i, err =0 ;int namelen; *res_dir =NULL ;
@@ -1264,7 +1264,11 @@ static struct buffer_head * ext4_find_en* return. Otherwise, fall back to doing a search the * old fashioned way. */ -if (bh || (err !=ERR_BAD_DX_DIR )) +if (err == -ENOENT ) +return NULL ; +if (err && err !=ERR_BAD_DX_DIR ) +return ERR_PTR (err); +if (bh)return bh;dxtrace (printk (KERN_DEBUG "ext4_find_entry: dx failed, " "falling back\n" ));
@@ -1295,6 +1299,11 @@ restart: } num++; bh =ext4_getblk (NULL , dir, b++,0 , &err); +if (unlikely (err)) { +if (ra_max ==0 ) +return ERR_PTR (err); +break ; + } bh_use[ra_max] = bh;if (bh) ll_rw_block(READ | REQ_META | REQ_PRIO,
@@ -1417,6 +1426,8 @@ static struct dentry *ext4_lookup(structreturn ERR_PTR (-ENAMETOOLONG ); bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return (struct dentry *) bh; inode =NULL ;if (bh) {__u32 ino =le32_to_cpu (de->inode);
@@ -1450,6 +1461,8 @@ struct dentry *ext4_get_parent(struct destruct buffer_head *bh; bh =ext4_find_entry (child->d_inode, &dotdot, &de,NULL ); +if (IS_ERR (bh)) +return (struct dentry *) bh;if (!bh)return ERR_PTR (-ENOENT ); ino =le32_to_cpu (de->inode);
@@ -2727,6 +2740,8 @@ static int ext4_rmdir(struct inode *dir, retval = -ENOENT ; bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (!bh) goto end_rmdir;
@@ -2794,6 +2809,8 @@ static int ext4_unlink(struct inode *dir retval = -ENOENT ; bh =ext4_find_entry (dir, &dentry->d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (!bh) goto end_unlink;
@@ -3121,6 +3138,8 @@ static int ext4_find_delete_entry(handlestruct ext4_dir_entry_2 *de; bh =ext4_find_entry (dir, d_name, &de,NULL ); +if (IS_ERR (bh)) +return PTR_ERR (bh);if (bh) { retval =ext4_delete_entry (handle, dir, de, bh);brelse (bh);
@@ -3205,6 +3224,8 @@ static int ext4_rename(struct inode *olddquot_initialize (new.inode); old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de,NULL ); +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors. * We might rmdir the source, keep it as pwd of some process
@@ -3217,6 +3238,10 @@ static int ext4_rename(struct inode *old new.bh =ext4_find_entry (new.dir, &new.dentry->d_name, &new.de, &new.inlined); +if (IS_ERR (new.bh)) { + retval =PTR_ERR (new.bh); + goto end_rename; + }if (new.bh) {if (!new.inode) {brelse (new.bh);
@@ -3345,6 +3370,8 @@ static int ext4_cross_rename(struct inod old.bh =ext4_find_entry (old.dir, &old.dentry->d_name, &old.de, &old.inlined); +if (IS_ERR (old.bh)) +return PTR_ERR (old.bh);/* * Check for inode number is _not_ due to possible IO errors. * We might rmdir the source, keep it as pwd of some process
@@ -3357,6 +3384,10 @@ static int ext4_cross_rename(struct inod new.bh =ext4_find_entry (new.dir, &new.dentry->d_name, &new.de, &new.inlined); +if (IS_ERR (new.bh)) { + retval =PTR_ERR (new.bh); + goto end_rename; + }/* RENAME_EXCHANGE case: old *and* new must both exist */ if (!new.bh ||le32_to_cpu (new.de->inode) != new.inode->i_ino)
Greg Kroah-Hartman
maintainerPATCH 353/357 ext4: avoid trying to kfree an ERR_PTR pointer
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Theodore Ts'o <[email protected]>
commit a9cfcd63e8d206ce4235c355d857c4fbdf0f4587 upstream.
Thanks to Dan Carpenter for extending smatch to find bugs like this. (This was found using a development version of smatch.)
--- fs/ext4/namei.c | 2 ++ fs/ext4/resize.c | 2 ++ 2 files changed, 4 insertions(+)
fs/ext4/namei.c +2 -0
@@ -3240,6 +3240,7 @@ static int ext4_rename(struct inode *old &new.de, &new.inlined);if (IS_ERR (new.bh)) { retval =PTR_ERR (new.bh); + new.bh =NULL ; goto end_rename; }if (new.bh) {
@@ -3386,6 +3387,7 @@ static int ext4_cross_rename(struct inod &new.de, &new.inlined);if (IS_ERR (new.bh)) { retval =PTR_ERR (new.bh); + new.bh =NULL ; goto end_rename; }
fs/ext4/resize.c +2 -0
@@ -575,6 +575,7 @@ handle_bb: bh =bclean (handle, sb, block);if (IS_ERR (bh)) { err =PTR_ERR (bh); + bh =NULL ; goto out; } overhead =ext4_group_overhead_blocks (sb, group);
@@ -603,6 +604,7 @@ handle_ib: bh =bclean (handle, sb, block);if (IS_ERR (bh)) { err =PTR_ERR (bh); + bh =NULL ; goto out; }
Greg Kroah-Hartman
maintainerPATCH 354/357 staging/lustre: disable virtual block device for 64K pages
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Arnd Bergmann <[email protected]>
commit 0bf22be0da8ea74bc7ccc5b07d7855830be16eca upstream.
The lustre virtual block device cannot handle 64K pages and fails at compile time. To avoid running into this error, let's disable the Kconfig option for this driver in cases it doesn't support.
--- drivers/staging/lustre/lustre/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/staging/lustre/lustre/Kconfig +1 -0
@@ -57,4 +57,5 @@ config LUSTRE_TRANSLATE_ERRNOS config LUSTRE_LLITE_LLOOP tristate "Lustre virtual block device" depends on LUSTRE_FS && BLOCK + depends on !PPC_64K_PAGES && !ARM64_64K_PAGES default m
Greg Kroah-Hartman
maintainerPATCH 355/357 clk: qcom: Fix MN frequency tables, parent map, and jpegd
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit ff20783f7b9f35b29e768d8ecc7076c1ca1a60ca upstream.
Clocks that don't have a pre-divider don't list any pre-divider in their frequency tables, but their tables are initialized using aggregate initializers. Use tagged initializers so we properly assign the m and n values for each frequency. Furthermore, the mmcc_pxo_pll8_pll2_pll3 array improperly mapped the second element to pll2 instead of pll8, causing the clock driver to recalculate the wrong rate for any clocks using this array along with a rate that uses pll2. Plus the .num_parents field is 3 instead of 4 so you can't even switch the parent to pll3. Finally I noticed that the jpegd clock improperly indicates that the pre-divider width is only 2, when it's actually 4 bits wide.
--- drivers/clk/qcom/mmcc-msm8960.c | 82 ++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 40 deletions(-)
drivers/clk/qcom/mmcc-msm8960.c +42 -40
@@ -38,6 +38,8 @@#define P_PLL2 2#define P_PLL3 3 +#define F_MN (f, s, _m, _n) { .freq = f, .src = s, .m = _m, .n = _n } +static u8 mmcc_pxo_pll8_pll2_map[] = { [P_PXO ] =0 , [P_PLL8 ] =2 ,
@@ -59,8 +61,8 @@ static u8 mmcc_pxo_pll8_pll2_pll3_map[]static const char *mmcc_pxo_pll8_pll2_pll3[] = {"pxo" , -"pll2" ,"pll8_vote" , +"pll2" ,"pll3" , };
@@ -710,18 +712,18 @@ static struct clk_branch csiphy2_timer_c };static struct freq_tbl clk_tbl_gfx2d[] = { - {27000000 ,P_PXO ,1 ,0 }, - {48000000 ,P_PLL8 ,1 ,8 }, - {54857000 ,P_PLL8 ,1 ,7 }, - {64000000 ,P_PLL8 ,1 ,6 }, - {76800000 ,P_PLL8 ,1 ,5 }, - {96000000 ,P_PLL8 ,1 ,4 }, - {128000000 ,P_PLL8 ,1 ,3 }, - {145455000 ,P_PLL2 ,2 ,11 }, - {160000000 ,P_PLL2 ,1 ,5 }, - {177778000 ,P_PLL2 ,2 ,9 }, - {200000000 ,P_PLL2 ,1 ,4 }, - {228571000 ,P_PLL2 ,2 ,7 }, +F_MN (27000000 ,P_PXO ,1 ,0 ), +F_MN (48000000 ,P_PLL8 ,1 ,8 ), +F_MN (54857000 ,P_PLL8 ,1 ,7 ), +F_MN (64000000 ,P_PLL8 ,1 ,6 ), +F_MN (76800000 ,P_PLL8 ,1 ,5 ), +F_MN (96000000 ,P_PLL8 ,1 ,4 ), +F_MN (128000000 ,P_PLL8 ,1 ,3 ), +F_MN (145455000 ,P_PLL2 ,2 ,11 ), +F_MN (160000000 ,P_PLL2 ,1 ,5 ), +F_MN (177778000 ,P_PLL2 ,2 ,9 ), +F_MN (200000000 ,P_PLL2 ,1 ,4 ), +F_MN (228571000 ,P_PLL2 ,2 ,7 ), { } };
@@ -842,22 +844,22 @@ static struct clk_branch gfx2d1_clk = { };static struct freq_tbl clk_tbl_gfx3d[] = { - {27000000 ,P_PXO ,1 ,0 }, - {48000000 ,P_PLL8 ,1 ,8 }, - {54857000 ,P_PLL8 ,1 ,7 }, - {64000000 ,P_PLL8 ,1 ,6 }, - {76800000 ,P_PLL8 ,1 ,5 }, - {96000000 ,P_PLL8 ,1 ,4 }, - {128000000 ,P_PLL8 ,1 ,3 }, - {145455000 ,P_PLL2 ,2 ,11 }, - {160000000 ,P_PLL2 ,1 ,5 }, - {177778000 ,P_PLL2 ,2 ,9 }, - {200000000 ,P_PLL2 ,1 ,4 }, - {228571000 ,P_PLL2 ,2 ,7 }, - {266667000 ,P_PLL2 ,1 ,3 }, - {300000000 ,P_PLL3 ,1 ,4 }, - {320000000 ,P_PLL2 ,2 ,5 }, - {400000000 ,P_PLL2 ,1 ,2 }, +F_MN (27000000 ,P_PXO ,1 ,0 ), +F_MN (48000000 ,P_PLL8 ,1 ,8 ), +F_MN (54857000 ,P_PLL8 ,1 ,7 ), +F_MN (64000000 ,P_PLL8 ,1 ,6 ), +F_MN (76800000 ,P_PLL8 ,1 ,5 ), +F_MN (96000000 ,P_PLL8 ,1 ,4 ), +F_MN (128000000 ,P_PLL8 ,1 ,3 ), +F_MN (145455000 ,P_PLL2 ,2 ,11 ), +F_MN (160000000 ,P_PLL2 ,1 ,5 ), +F_MN (177778000 ,P_PLL2 ,2 ,9 ), +F_MN (200000000 ,P_PLL2 ,1 ,4 ), +F_MN (228571000 ,P_PLL2 ,2 ,7 ), +F_MN (266667000 ,P_PLL2 ,1 ,3 ), +F_MN (300000000 ,P_PLL3 ,1 ,4 ), +F_MN (320000000 ,P_PLL2 ,2 ,5 ), +F_MN (400000000 ,P_PLL2 ,1 ,2 ), { } };
@@ -897,7 +899,7 @@ static struct clk_dyn_rcg gfx3d_src = { .hw.init = &(struct clk_init_data){ .name ="gfx3d_src" , .parent_names = mmcc_pxo_pll8_pll2_pll3, - .num_parents =3 , + .num_parents =4 , .ops = &clk_dyn_rcg_ops, }, },
@@ -995,7 +997,7 @@ static struct clk_rcg jpegd_src = { .ns_reg = 0x00ac, .p = { .pre_div_shift = 12, - .pre_div_width = 2, + .pre_div_width = 4, }, .s = { .src_sel_shift = 0,
@@ -1342,15 +1344,15 @@ static struct clk_branch hdmi_app_clk = };static struct freq_tbl clk_tbl_vcodec[] = { - {27000000 ,P_PXO ,1 ,0 }, - {32000000 ,P_PLL8 ,1 ,12 }, - {48000000 ,P_PLL8 ,1 ,8 }, - {54860000 ,P_PLL8 ,1 ,7 }, - {96000000 ,P_PLL8 ,1 ,4 }, - {133330000 ,P_PLL2 ,1 ,6 }, - {200000000 ,P_PLL2 ,1 ,4 }, - {228570000 ,P_PLL2 ,2 ,7 }, - {266670000 ,P_PLL2 ,1 ,3 }, +F_MN (27000000 ,P_PXO ,1 ,0 ), +F_MN (32000000 ,P_PLL8 ,1 ,12 ), +F_MN (48000000 ,P_PLL8 ,1 ,8 ), +F_MN (54860000 ,P_PLL8 ,1 ,7 ), +F_MN (96000000 ,P_PLL8 ,1 ,4 ), +F_MN (133330000 ,P_PLL2 ,1 ,6 ), +F_MN (200000000 ,P_PLL2 ,1 ,4 ), +F_MN (228570000 ,P_PLL2 ,2 ,7 ), +F_MN (266670000 ,P_PLL2 ,1 ,3 ), { } };
Greg Kroah-Hartman
maintainerPATCH 356/357 clk: qcom: mdp_lut_clk is a child of mdp_src
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit f87dfcabc6f173cc811d185d33327f50a8c88399 upstream.
The mdp_lut_clk isn't a child of the mdp_clk. Instead it's the child of the mdp_src clock. Fix it.
--- drivers/clk/qcom/mmcc-msm8960.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/qcom/mmcc-msm8960.c +1 -1
@@ -1117,7 +1117,7 @@ static struct clk_branch mdp_lut_clk = { .enable_reg = 0x016c, .enable_mask = BIT(0), .hw.init = &(struct clk_init_data ){ - .parent_names = (const char *[]){"mdp_clk" }, + .parent_names = (const char *[]){"mdp_src" }, .num_parents =1 , .name ="mdp_lut_clk" , .ops = &clk_branch_ops,
h_string(np, "io-channel-names",
name);
chan = of_iio_channel_get(np, index);
- if (!IS_ERR(chan))
+ if (!IS_ERR(chan) || PTR_ERR(chan) == -EPROBE_DEFER)
break;
else if (name && index >= 0) {
pr_err("ERROR: could not get IIO channel %s:%s(%i)\n",
Greg Kroah-Hartman
maintainerPATCH 357/357 clk: qcom: Fix PLL rate configurations
In reply to Greg Kroah-Hartman3.16-stable review patch. If anyone has any objections, please let me know.
------------------
From: Stephen Boyd <[email protected]>
commit 5b6b7490af110c2b0df807eddd00ae6290bcf50a upstream.
Sometimes we need to program PLLs with a fixed rate configuration during driver probe. Doing this after we register the PLLs with the clock framework causes the common clock framework to assume the rate of the PLLs are 0. This causes all sorts of problems for rate recalculations because the common clock framework caches the rate once at registration time unless a flag is set to always recalculate the rates.
Split the qcom_cc_probe() function into two pieces, map and everything else, so that drivers which need to configure some PLL rates or otherwise twiddle bits in the clock controller can do so before registering clocks. This allows us to properly detect the rates of PLLs that are programmed at boot.
--- drivers/clk/qcom/common.c | 39 ++++++++++++++++++++++++++++----------- drivers/clk/qcom/common.h | 6 ++++++ drivers/clk/qcom/mmcc-msm8974.c | 10 ++++------ 3 files changed, 38 insertions(+), 17 deletions(-)
drivers/clk/qcom/common.c +28 -11
@@ -27,30 +27,35 @@ struct qcom_cc {struct clk *clks[]; }; -int qcom_cc_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc) +struct regmap * +qcom_cc_map (struct platform_device *pdev,const struct qcom_cc_desc *desc) {void __iomem *base;struct resource *res; +struct device *dev = &pdev->dev; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); + base =devm_ioremap_resource (dev, res); +if (IS_ERR (base)) +return ERR_CAST (base); + +return devm_regmap_init_mmio (dev, base, desc->config); +} +EXPORT_SYMBOL_GPL (qcom_cc_map); + +int qcom_cc_really_probe (struct platform_device *pdev, +const struct qcom_cc_desc *desc,struct regmap *regmap) +{int i, ret;struct device *dev = &pdev->dev;struct clk *clk;struct clk_onecell_data *data;struct clk **clks; -struct regmap *regmap;struct qcom_reset_controller *reset;struct qcom_cc *cc;size_t num_clks = desc->num_clks;struct clk_regmap **rclks = desc->clks; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - base =devm_ioremap_resource (dev, res); -if (IS_ERR (base)) -return PTR_ERR (base); - - regmap =devm_regmap_init_mmio (dev, base, desc->config); -if (IS_ERR (regmap)) -return PTR_ERR (regmap); - cc =devm_kzalloc (dev,sizeof (*cc) +sizeof (*clks) * num_clks,GFP_KERNEL );if (!cc)
@@ -91,6 +96,18 @@ int qcom_cc_probe(struct platform_devicereturn ret; } +EXPORT_SYMBOL_GPL (qcom_cc_really_probe); + +int qcom_cc_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc) +{ +struct regmap *regmap; + + regmap =qcom_cc_map (pdev, desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); + +return qcom_cc_really_probe (pdev, desc, regmap); +}EXPORT_SYMBOL_GPL (qcom_cc_probe);void qcom_cc_remove (struct platform_device *pdev)
drivers/clk/qcom/common.h +6 -0
@@ -17,6 +17,7 @@ struct platform_device;struct regmap_config ;struct clk_regmap ;struct qcom_reset_map ; +struct regmap ;struct qcom_cc_desc {const struct regmap_config *config;
@@ -26,6 +27,11 @@ struct qcom_cc_desc {size_t num_resets; }; +extern struct regmap *qcom_cc_map (struct platform_device *pdev, +const struct qcom_cc_desc *desc); +extern int qcom_cc_really_probe (struct platform_device *pdev, +const struct qcom_cc_desc *desc, +struct regmap *regmap);extern int qcom_cc_probe (struct platform_device *pdev,const struct qcom_cc_desc *desc);
drivers/clk/qcom/mmcc-msm8974.c +4 -6
@@ -2547,18 +2547,16 @@ MODULE_DEVICE_TABLE(of, mmcc_msm8974_matstatic int mmcc_msm8974_probe (struct platform_device *pdev) { -int ret;struct regmap *regmap; - ret =qcom_cc_probe (pdev, &mmcc_msm8974_desc); -if (ret) -return ret; + regmap =qcom_cc_map (pdev, &mmcc_msm8974_desc); +if (IS_ERR (regmap)) +return PTR_ERR (regmap); - regmap =dev_get_regmap (&pdev->dev,NULL );clk_pll_configure_sr_hpm_lp (&mmpll1, regmap, &mmpll1_config, true);clk_pll_configure_sr_hpm_lp (&mmpll3, regmap, &mmpll3_config, false); -return 0 ; +return qcom_cc_really_probe (pdev, &mmcc_msm8974_desc, regmap); }static int mmcc_msm8974_remove (struct platform_device *pdev)
Quoted 17 lines · Greg Kroah-Hartman
---------------------------------
Note: This is a big stable release. Mostly my fault for being on the road last week, combined with an unusually large number of patches being tagged for the stable tree. Anyway, I've caught up with all pending patches before 3.17-rc7, so if you have marked something for the stable tree that I have not applied, or emailed the [email protected] list asking for a patch, that is not here, please let me know.
---------------------------------This is the start of the stable review cycle for the 3.16.4 release. There are 357 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun Oct 5 21:28:42 UTC 2014. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.4-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Compiled and booted on my test system. No dmesg regressions.
Looking better than the previous with clean dmesg err
drm:ivb_err_int_handlererrors I was seeing went away. Must be changes in drivers/gpu/drm/i915
-- Shuah
Signature · 4 lines
Shuah Khan Sr. Linux Kernel Developer Samsung Research America (Silicon Valley) [email protected] | (970) 217-8978
Greg Kroah-Hartman
maintainerQuoted 27 lines · Shuah Khan
Quoted 17 lines · Greg Kroah-Hartman
---------------------------------
Note: This is a big stable release. Mostly my fault for being on the road last week, combined with an unusually large number of patches being tagged for the stable tree. Anyway, I've caught up with all pending patches before 3.17-rc7, so if you have marked something for the stable tree that I have not applied, or emailed the [email protected] list asking for a patch, that is not here, please let me know.
---------------------------------This is the start of the stable review cycle for the 3.16.4 release. There are 357 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun Oct 5 21:28:42 UTC 2014. Anything received after that time might be too late.
Quoted 8 lines
The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v3.0/stable-review/patch-3.16.4-rc1.gzand the diffstat can be found below.
thanks,
greg k-h
Quoted 6 lines
Compiled and booted on my test system. No dmesg regressions.
Looking better than the previous with clean dmesg err
drm:ivb_err_int_handlererrors I was seeing went away. Must be changes in
drivers/gpu/drm/i915
Thanks for testing all of these and letting me know.
greg k-h
Quoted 9 lines · Greg Kroah-Hartman
---------------------------------
Note: This is a big stable release. Mostly my fault for being on the road last week, combined with an unusually large number of patches being tagged for the stable tree. Anyway, I've caught up with all pending patches before 3.17-rc7, so if you have marked something for the stable tree that I have not applied, or emailed the [email protected] list asking for a patch, that is not here, please let me know.
---------------------------------
Quoted 8 lines
This is the start of the stable review cycle for the 3.16.4 release. There are 357 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun Oct 5 21:28:42 UTC 2014. Anything received after that time might be too late.
Build results:
total: 136 pass: 134 fail: 2
Failed builds:
arm:omap2plus_defconfig
arm:multi_v7_defconfig
Qemu test results:
total: 28 pass: 28 fail: 0
Build errors are the same as in 3.14, with the same culprit and fix.
Guenter
Greg Kroah-Hartman
maintainerQuoted 21 lines · Guenter Roeck
Quoted 9 lines · Greg Kroah-Hartman
---------------------------------
Note: This is a big stable release. Mostly my fault for being on the road last week, combined with an unusually large number of patches being tagged for the stable tree. Anyway, I've caught up with all pending patches before 3.17-rc7, so if you have marked something for the stable tree that I have not applied, or emailed the [email protected] list asking for a patch, that is not here, please let me know.
---------------------------------Quoted 8 lines
This is the start of the stable review cycle for the 3.16.4 release. There are 357 patches in this series, all will be posted as a response to this one. If anyone has any issues with these being applied, please let me know.
Responses should be made by Sun Oct 5 21:28:42 UTC 2014. Anything received after that time might be too late.
Build results:
total: 136 pass: 134 fail: 2
Quoted 8 lines
Failed builds:
arm:omap2plus_defconfig
arm:multi_v7_defconfigQemu test results:
total: 28 pass: 28 fail: 0Build errors are the same as in 3.14, with the same culprit and fix.
Thanks, now added that patch to this queue.
greg k-h