Re: [PATCH v3] arm: imx: dts: Use lower case for bindings notation
On Fri, Dec 15, 2017 at 08:19:30PM +0100, Mathieu Malaterre wrote: > Improve the DTS files using lower case to fix the following dtc warnings: > > Warning (simple_bus_reg): Node /XXX@ simple-bus unit address format > error, expected "" > > Converted using the following command: > > find . -type f \( -iname *.dts -o -iname *.dtsi \) -exec sed -i -e > "s/@\([0-9a-fA-FxX\.;:#]+\)\s*{/@\L\1 {/g" -e "s/@0x\(.*\) {/@\1 {/g" -e > "s/@0+\(.*\) {/@\1 {/g" {} +^C > > For simplicity, two sed expressions were used to solve each warnings > separately. > > To make the regex expression more robust a few other issues were resolved, > namely setting unit-address to lower case, and adding a whitespace before the > the opening curly brace: > > https://elinux.org/Device_Tree_Linux#Linux_conventions > > This is a follow up to commit 4c9847b7375a ("dt-bindings: Remove leading 0x > from bindings notation") > > Reported-by: David Daney > Suggested-by: Rob Herring > Signed-off-by: Mathieu Malaterre Applied, thanks.
[RFC PATCH bpf-next v2 4/4] error-injection: Support fault injection framework
Support in-kernel fault-injection framework via debugfs. This allows you to inject a conditional error to specified function using debugfs interfaces. Signed-off-by: Masami Hiramatsu --- Documentation/fault-injection/fault-injection.txt |5 + kernel/Makefile |1 kernel/fail_function.c| 169 + lib/Kconfig.debug | 10 + 4 files changed, 185 insertions(+) create mode 100644 kernel/fail_function.c diff --git a/Documentation/fault-injection/fault-injection.txt b/Documentation/fault-injection/fault-injection.txt index 918972babcd8..6243a588dd71 100644 --- a/Documentation/fault-injection/fault-injection.txt +++ b/Documentation/fault-injection/fault-injection.txt @@ -30,6 +30,11 @@ o fail_mmc_request injects MMC data errors on devices permitted by setting debugfs entries under /sys/kernel/debug/mmc0/fail_mmc_request +o fail_function + + injects error return on specific functions by setting debugfs entries + under /sys/kernel/debug/fail_function. No boot option supported. + Configure fault-injection capabilities behavior --- diff --git a/kernel/Makefile b/kernel/Makefile index 172d151d429c..f85ae5dfa474 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -81,6 +81,7 @@ obj-$(CONFIG_AUDIT_TREE) += audit_tree.o obj-$(CONFIG_GCOV_KERNEL) += gcov/ obj-$(CONFIG_KCOV) += kcov.o obj-$(CONFIG_KPROBES) += kprobes.o +obj-$(CONFIG_FAIL_FUNCTION) += fail_function.o obj-$(CONFIG_KGDB) += debug/ obj-$(CONFIG_DETECT_HUNG_TASK) += hung_task.o obj-$(CONFIG_LOCKUP_DETECTOR) += watchdog.o diff --git a/kernel/fail_function.c b/kernel/fail_function.c new file mode 100644 index ..203d3582487a --- /dev/null +++ b/kernel/fail_function.c @@ -0,0 +1,169 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * fail_function.c: Function-based error injection + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include + +static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs); + +static DEFINE_MUTEX(fei_lock); +static struct { + struct kprobe kp; + unsigned long retval; + struct fault_attr attr; +} fei_attr = { + .kp = { .pre_handler = fei_kprobe_handler, }, + .retval = ~0UL, /* This indicates -1 in long/int return value */ + .attr = FAULT_ATTR_INITIALIZER, +}; + +static int fei_kprobe_handler(struct kprobe *kp, struct pt_regs *regs) +{ + if (should_fail(&fei_attr.attr, 1)) { + regs_set_return_value(regs, fei_attr.retval); + override_function_with_return(regs); + /* Kprobe specific fixup */ + reset_current_kprobe(); + preempt_enable_no_resched(); + return 1; + } + + return 0; +} +NOKPROBE_SYMBOL(fei_kprobe_handler) + +static void *fei_seq_start(struct seq_file *m, loff_t *pos) +{ + mutex_lock(&fei_lock); + return *pos == 0 ? (void *)1 : NULL; +} + +static void fei_seq_stop(struct seq_file *m, void *v) +{ + mutex_unlock(&fei_lock); +} + +static void *fei_seq_next(struct seq_file *m, void *v, loff_t *pos) +{ + return NULL; +} + +static int fei_seq_show(struct seq_file *m, void *v) +{ + if (fei_attr.kp.addr) + seq_printf(m, "%pf\n", fei_attr.kp.addr); + else + seq_puts(m, "# not specified\n"); + return 0; +} + +static const struct seq_operations fei_seq_ops = { + .start = fei_seq_start, + .next = fei_seq_next, + .stop = fei_seq_stop, + .show = fei_seq_show, +}; + +static int fei_open(struct inode *inode, struct file *file) +{ + return seq_open(file, &fei_seq_ops); +} + +static ssize_t fei_write(struct file *file, const char __user *buffer, +size_t count, loff_t *ppos) +{ + unsigned long addr; + char *buf, *sym; + int ret; + + /* cut off if it is too long */ + if (count > KSYM_NAME_LEN) + count = KSYM_NAME_LEN; + buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (copy_from_user(buf, buffer, count)) { + ret = -EFAULT; + goto out; + } + buf[count] = '\0'; + sym = strstrip(buf); + + if (strlen(sym) == 0 || sym[0] == '0') { + if (fei_attr.kp.addr) { + unregister_kprobe(&fei_attr.kp); + fei_attr.kp.addr = NULL; + } + ret = count; + goto out; + } + + addr = kallsyms_lookup_name(sym); + if (!addr) { + ret = -EINVAL; + goto out; + } + if (!within_error_injection_list(addr)) { + ret = -ERANGE; + goto out; + } + + if (fei_attr.kp.addr) { + unregister_kprobe(&fei_a
[RFC PATCH bpf-next v2 3/4] error-injection: Separate error-injection from kprobe
Since error-injection framework is not limited to be used by kprobes, nor bpf. Other kernel subsystems can use it freely for checking safeness of error-injection, e.g. livepatch, ftrace etc. So this separate error-injection framework from kprobes. Some differences has been made: - "kprobe" word is removed from any APIs/structures. - BPF_ALLOW_ERROR_INJECTION() is renamed to ALLOW_ERROR_INJECTION() since it is not limited for BPF too. - CONFIG_FUNCTION_ERROR_INJECTION is the config item of this feature. It is automatically enabled if the arch supports error injection feature for kprobe or ftrace etc. Signed-off-by: Masami Hiramatsu --- Changes in v2: - Fix the override function name to override_function_with_return() - Show only function name in the list, user don't have to care about it's size, since function override only happens at the entry. --- arch/Kconfig |2 arch/x86/Kconfig |2 arch/x86/include/asm/error-injection.h | 12 ++ arch/x86/kernel/kprobes/ftrace.c | 14 -- arch/x86/lib/Makefile |2 arch/x86/lib/error-inject.c| 19 +++ fs/btrfs/disk-io.c |2 fs/btrfs/free-space-cache.c|2 include/asm-generic/error-injection.h | 20 +++ include/asm-generic/vmlinux.lds.h | 14 +- include/linux/bpf.h| 12 -- include/linux/error-injection.h| 21 +++ include/linux/kprobes.h|1 include/linux/module.h |6 - kernel/kprobes.c | 163 -- kernel/module.c|8 + kernel/trace/Kconfig |2 kernel/trace/bpf_trace.c |2 kernel/trace/trace_kprobe.c|3 lib/Kconfig.debug |4 + lib/Makefile |1 lib/error-inject.c | 198 22 files changed, 300 insertions(+), 210 deletions(-) create mode 100644 arch/x86/include/asm/error-injection.h create mode 100644 arch/x86/lib/error-inject.c create mode 100644 include/asm-generic/error-injection.h create mode 100644 include/linux/error-injection.h create mode 100644 lib/error-inject.c diff --git a/arch/Kconfig b/arch/Kconfig index d3f4aaf9cb7a..97376accfb14 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -196,7 +196,7 @@ config HAVE_OPTPROBES config HAVE_KPROBES_ON_FTRACE bool -config HAVE_KPROBE_OVERRIDE +config HAVE_FUNCTION_ERROR_INJECTION bool config HAVE_NMI diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 04d66e6fa447..fc519e3ae754 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -154,7 +154,7 @@ config X86 select HAVE_KERNEL_XZ select HAVE_KPROBES select HAVE_KPROBES_ON_FTRACE - select HAVE_KPROBE_OVERRIDE + select HAVE_FUNCTION_ERROR_INJECTION select HAVE_KRETPROBES select HAVE_KVM select HAVE_LIVEPATCH if X86_64 diff --git a/arch/x86/include/asm/error-injection.h b/arch/x86/include/asm/error-injection.h new file mode 100644 index ..6c2a133622f4 --- /dev/null +++ b/arch/x86/include/asm/error-injection.h @@ -0,0 +1,12 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_ERROR_INJECTION_H +#define _ASM_ERROR_INJECTION_H + +#include +#include +#include + +asmlinkage void just_return_func(void); +void override_function_with_return(struct pt_regs *regs); + +#endif /* _ASM_ERROR_INJECTION_H */ diff --git a/arch/x86/kernel/kprobes/ftrace.c b/arch/x86/kernel/kprobes/ftrace.c index 1ea748d682fd..8dc0161cec8f 100644 --- a/arch/x86/kernel/kprobes/ftrace.c +++ b/arch/x86/kernel/kprobes/ftrace.c @@ -97,17 +97,3 @@ int arch_prepare_kprobe_ftrace(struct kprobe *p) p->ainsn.boostable = false; return 0; } - -asmlinkage void override_func(void); -asm( - ".type override_func, @function\n" - "override_func:\n" - " ret\n" - ".size override_func, .-override_func\n" -); - -void arch_ftrace_kprobe_override_function(struct pt_regs *regs) -{ - regs->ip = (unsigned long)&override_func; -} -NOKPROBE_SYMBOL(arch_ftrace_kprobe_override_function); diff --git a/arch/x86/lib/Makefile b/arch/x86/lib/Makefile index 7b181b61170e..081f09435d28 100644 --- a/arch/x86/lib/Makefile +++ b/arch/x86/lib/Makefile @@ -26,6 +26,8 @@ lib-y += memcpy_$(BITS).o lib-$(CONFIG_RWSEM_XCHGADD_ALGORITHM) += rwsem.o lib-$(CONFIG_INSTRUCTION_DECODER) += insn.o inat.o insn-eval.o lib-$(CONFIG_RANDOMIZE_BASE) += kaslr.o +lib-$(CONFIG_FUNCTION_ERROR_INJECTION) += error-inject.o + obj-y += msr.o msr-reg.o msr-reg-export.o hweight.o diff --git a/arch/x86/lib/error-inject.c b/arch/x86/lib/error-inject.c new file mode 100644 index ..7b881d03d0dd --- /dev/null +++ b/arch/x86/lib/error-inject.c @@ -0,0 +1,19 @@ +// SPDX-License-Identifier: GPL-2.0 + +#includ
[RFC PATCH bpf-next v2 1/4] tracing/kprobe: bpf: Check error injectable event is on function entry
Check whether error injectable event is on function entry or not. Currently it checks the event is ftrace-based kprobes or not, but that is wrong. It should check if the event is on the entry of target function. Since error injection will override a function to just return with modified return value, that operation must be done before the target function starts making stackframe. As a side effect, bpf error injection is no need to depend on function-tracer. It can work with sw-breakpoint based kprobe events too. Signed-off-by: Masami Hiramatsu --- kernel/trace/Kconfig|2 -- kernel/trace/bpf_trace.c|6 +++--- kernel/trace/trace_kprobe.c |8 +--- kernel/trace/trace_probe.h | 12 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/kernel/trace/Kconfig b/kernel/trace/Kconfig index ae3a2d519e50..6400e1bf97c5 100644 --- a/kernel/trace/Kconfig +++ b/kernel/trace/Kconfig @@ -533,9 +533,7 @@ config FUNCTION_PROFILER config BPF_KPROBE_OVERRIDE bool "Enable BPF programs to override a kprobed function" depends on BPF_EVENTS - depends on KPROBES_ON_FTRACE depends on HAVE_KPROBE_OVERRIDE - depends on DYNAMIC_FTRACE_WITH_REGS default n help Allows BPF to override the execution of a probed function and diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index f6d2327ecb59..d663660f8392 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -800,11 +800,11 @@ int perf_event_attach_bpf_prog(struct perf_event *event, int ret = -EEXIST; /* -* Kprobe override only works for ftrace based kprobes, and only if they -* are on the opt-in list. +* Kprobe override only works if they are on the function entry, +* and only if they are on the opt-in list. */ if (prog->kprobe_override && - (!trace_kprobe_ftrace(event->tp_event) || + (!trace_kprobe_on_func_entry(event->tp_event) || !trace_kprobe_error_injectable(event->tp_event))) return -EINVAL; diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 91f4b57dab82..265e3e27e8dc 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -88,13 +88,15 @@ static nokprobe_inline unsigned long trace_kprobe_nhit(struct trace_kprobe *tk) return nhit; } -int trace_kprobe_ftrace(struct trace_event_call *call) +bool trace_kprobe_on_func_entry(struct trace_event_call *call) { struct trace_kprobe *tk = (struct trace_kprobe *)call->data; - return kprobe_ftrace(&tk->rp.kp); + + return kprobe_on_func_entry(tk->rp.kp.addr, tk->rp.kp.symbol_name, + tk->rp.kp.offset); } -int trace_kprobe_error_injectable(struct trace_event_call *call) +bool trace_kprobe_error_injectable(struct trace_event_call *call) { struct trace_kprobe *tk = (struct trace_kprobe *)call->data; unsigned long addr; diff --git a/kernel/trace/trace_probe.h b/kernel/trace/trace_probe.h index 5e54d748c84c..e101c5bb9eda 100644 --- a/kernel/trace/trace_probe.h +++ b/kernel/trace/trace_probe.h @@ -252,8 +252,8 @@ struct symbol_cache; unsigned long update_symbol_cache(struct symbol_cache *sc); void free_symbol_cache(struct symbol_cache *sc); struct symbol_cache *alloc_symbol_cache(const char *sym, long offset); -int trace_kprobe_ftrace(struct trace_event_call *call); -int trace_kprobe_error_injectable(struct trace_event_call *call); +bool trace_kprobe_on_func_entry(struct trace_event_call *call); +bool trace_kprobe_error_injectable(struct trace_event_call *call); #else /* uprobes do not support symbol fetch methods */ #define fetch_symbol_u8NULL @@ -280,14 +280,14 @@ alloc_symbol_cache(const char *sym, long offset) return NULL; } -static inline int trace_kprobe_ftrace(struct trace_event_call *call) +static inline bool trace_kprobe_on_func_entry(struct trace_event_call *call) { - return 0; + return false; } -static inline int trace_kprobe_error_injectable(struct trace_event_call *call) +static inline bool trace_kprobe_error_injectable(struct trace_event_call *call) { - return 0; + return false; } #endif /* CONFIG_KPROBE_EVENTS */
[RFC PATCH bpf-next v2 2/4] tracing/kprobe: bpf: Compare instruction pointer with original one
Compare instruction pointer with original one on the stack instead using per-cpu bpf_kprobe_override flag. This patch also consolidates reset_current_kprobe() and preempt_enable_no_resched() blocks. Those can be done in one place. Signed-off-by: Masami Hiramatsu --- kernel/trace/bpf_trace.c|1 - kernel/trace/trace_kprobe.c | 21 +++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c index d663660f8392..cefa9b0e396c 100644 --- a/kernel/trace/bpf_trace.c +++ b/kernel/trace/bpf_trace.c @@ -83,7 +83,6 @@ EXPORT_SYMBOL_GPL(trace_call_bpf); #ifdef CONFIG_BPF_KPROBE_OVERRIDE BPF_CALL_2(bpf_override_return, struct pt_regs *, regs, unsigned long, rc) { - __this_cpu_write(bpf_kprobe_override, 1); regs_set_return_value(regs, rc); arch_ftrace_kprobe_override_function(regs); return 0; diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 265e3e27e8dc..a7c7035963f2 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -42,8 +42,6 @@ struct trace_kprobe { (offsetof(struct trace_kprobe, tp.args) + \ (sizeof(struct probe_arg) * (n))) -DEFINE_PER_CPU(int, bpf_kprobe_override); - static nokprobe_inline bool trace_kprobe_is_return(struct trace_kprobe *tk) { return tk->rp.handler != NULL; @@ -1204,6 +1202,7 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) int rctx; if (bpf_prog_array_valid(call)) { + unsigned long orig_ip = instruction_pointer(regs); int ret; ret = trace_call_bpf(call, regs); @@ -1211,12 +1210,13 @@ kprobe_perf_func(struct trace_kprobe *tk, struct pt_regs *regs) /* * We need to check and see if we modified the pc of the * pt_regs, and if so clear the kprobe and return 1 so that we -* don't do the instruction skipping. Also reset our state so -* we are clean the next pass through. +* don't do the single stepping. +* The ftrace kprobe handler leaves it up to us to re-enable +* preemption here before returning if we've modified the ip. */ - if (__this_cpu_read(bpf_kprobe_override)) { - __this_cpu_write(bpf_kprobe_override, 0); + if (orig_ip != instruction_pointer(regs)) { reset_current_kprobe(); + preempt_enable_no_resched(); return 1; } if (!ret) @@ -1324,15 +1324,8 @@ static int kprobe_dispatcher(struct kprobe *kp, struct pt_regs *regs) if (tk->tp.flags & TP_FLAG_TRACE) kprobe_trace_func(tk, regs); #ifdef CONFIG_PERF_EVENTS - if (tk->tp.flags & TP_FLAG_PROFILE) { + if (tk->tp.flags & TP_FLAG_PROFILE) ret = kprobe_perf_func(tk, regs); - /* -* The ftrace kprobe handler leaves it up to us to re-enable -* preemption here before returning if we've modified the ip. -*/ - if (ret) - preempt_enable_no_resched(); - } #endif return ret; }
[RFC PATCH bpf-next v2 0/4] Separate error injection table from kprobes
Hi Josef and Alexei, Here are the 2nd version of patches to moving error injection table from kprobes. In this series I did a small fixes and add function-based fault injection. Here is the previous version: https://lkml.org/lkml/2017/12/22/554 There are 2 main reasons why I separate it from kprobes. - kprobes users can modify execution path not only at error-injection whitelist functions but also other functions. I don't like to suggest user that such limitation is from kprobes itself. - This error injection information is also useful for ftrace (function-hook) and livepatch. It should not be limited by CONFIG_KPROBES. So I introduced CONFIG_FUNCTION_ERROR_INJECTION for this feature. Also CONFIG_FAIL_FUNCTION is added, which provides function-based error injection interface via debugfs following fault-injection framework. See [4/4]. Any thoughts? BTW, I think we should add an error-range description in ALLOW_ERROR_INJECTION() macro. If user sets a success return value and override it by mistake, caller must break data or cause kernel panic. Thank you, --- Masami Hiramatsu (4): tracing/kprobe: bpf: Check error injectable event is on function entry tracing/kprobe: bpf: Compare instruction pointer with original one error-injection: Separate error-injection from kprobe error-injection: Support fault injection framework Documentation/fault-injection/fault-injection.txt |5 + arch/Kconfig |2 arch/x86/Kconfig |2 arch/x86/include/asm/error-injection.h| 12 + arch/x86/kernel/kprobes/ftrace.c | 14 - arch/x86/lib/Makefile |2 arch/x86/lib/error-inject.c | 19 ++ fs/btrfs/disk-io.c|2 fs/btrfs/free-space-cache.c |2 include/asm-generic/error-injection.h | 20 ++ include/asm-generic/vmlinux.lds.h | 14 + include/linux/bpf.h | 12 - include/linux/error-injection.h | 21 ++ include/linux/kprobes.h |1 include/linux/module.h|6 - kernel/Makefile |1 kernel/fail_function.c| 169 ++ kernel/kprobes.c | 163 - kernel/module.c |8 - kernel/trace/Kconfig |4 kernel/trace/bpf_trace.c |9 - kernel/trace/trace_kprobe.c | 32 +-- kernel/trace/trace_probe.h| 12 + lib/Kconfig.debug | 14 + lib/Makefile |1 lib/error-inject.c| 198 + 26 files changed, 506 insertions(+), 239 deletions(-) create mode 100644 arch/x86/include/asm/error-injection.h create mode 100644 arch/x86/lib/error-inject.c create mode 100644 include/asm-generic/error-injection.h create mode 100644 include/linux/error-injection.h create mode 100644 kernel/fail_function.c create mode 100644 lib/error-inject.c -- Masami Hiramatsu (Linaro)
Re: [alsa-devel] [PATCH 15/27] ALSA: hda - Use timecounter_initialize interface
On 12/15/2017 10:40 PM, Takashi Iwai wrote: On Fri, 15 Dec 2017 17:51:25 +0100, Richard Cochran wrote: On Fri, Dec 15, 2017 at 12:10:47PM +0100, Takashi Iwai wrote: - struct cyclecounter *cc = &azx_dev->tc.cc; - cc->read = azx_cc_read; - cc->mask = CLOCKSOURCE_MASK(32); - cc->mult = 125; /* saturation after 195 years */ - cc->shift = 0; I want to get away from this mess of open coded structure initialization and use a proper functional interface instead. I agree that a proper functional interface would be better, too. But not a form like foo(501, 21, 10, 499, 5678). In C syntax, you may more easily pass a wrong value than open codes. nsec = 0; /* audio time is elapsed time since trigger */ - timecounter_init(tc, nsec); + timecounter_initialize(tc, + azx_cc_read, + CLOCKSOURCE_MASK(32), + 125, /* saturation after 195 years */ + 0, + nsec); Hmm, a function with so many arguments is difficult to remember and is often error-prone. By this transition, it becomes harder to read through. Please suggest a better way. I have no good idea ATM, sorry. Or can we provide simpler versions for covering some defaults? At least reducing the number of arguments would make things easier. Thought about specifying 1. cyclecounter read func 2. frequency 3. width of counter as parameters here which can get rid of mult, shift params. But this is not easy as most of the drivers do not specify cyclecounter frequency and instead hard-code the mult/shift factors. How about passing initialized cyclecounter struct? Takashi
Re: [PATCH] mfd: axp20x: Mark axp288 CHRG_BAK_CTRL register volatile
On Fri, Dec 22, 2017 at 8:35 PM, Hans de Goede wrote: > The input current limit bits get updated by the charger detection logic, > so we should not cache the contents of this register. > > Signed-off-by: Hans de Goede Reviewed-by: Chen-Yu Tsai
[PATCH]cpuidle: preventive check in cpuidle_select against crash
When selecting the idle state using cpuidle_select, there is no check on cpuidle_curr_governor. In cpuidle_switch_governor, cpuidle_currr_governor can be set to NULL to specify "disabled". Since cpuidle_select cannot return negative value, it has to return 0 in case of error. Printing logs and returning can help in debugging and preventing possible kernel crash scenarios. Signed-off-by: Gaurav Jindal --- diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c index 68a1682..bf08e3a 100644 --- a/drivers/cpuidle/cpuidle.c +++ b/drivers/cpuidle/cpuidle.c @@ -268,6 +268,19 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv, */ int cpuidle_select(struct cpuidle_driver *drv, struct cpuidle_device *dev) { + + /* Since negative return is not allowed +* we have to return 0 even if the +* framework cannot select the idle state +*/ + if (!cpuidle_curr_governor) { + pr_err("idle governor is disabled\n"); + return 0; + } + if (!cpuidle_curr_governor->select) { + pr_err("idle governor select is NULL\n"); + return 0; + } return cpuidle_curr_governor->select(drv, dev); }
[PATCH] tracing: Fix crash when it fails to alloc ring buffer
From: Jing Xia Double free of the ring buffer happens when it fails to alloc new ring buffer instance for max_buffer if TRACER_MAX_TRACE is configured. The root cause is that the pointer is not set to NULL after the buffer is freed in allocate_trace_buffers(), and the freeing of the ring buffer is invoked again later if the pointer is not equal to Null, as: instance_mkdir() |-allocate_trace_buffers() |-allocate_trace_buffer(tr, &tr->trace_buffer...) |-allocate_trace_buffer(tr, &tr->max_buffer...) // allocate fail(-ENOMEM),first free // and the buffer pointer is not set to null |-ring_buffer_free(tr->trace_buffer.buffer) // out_free_tr |-free_trace_buffers() |-free_trace_buffer(&tr->trace_buffer); //if trace_buffer is not null, free again |-ring_buffer_free(buf->buffer) |-rb_free_cpu_buffer(buffer->buffers[cpu]) // ring_buffer_per_cpu is null, and // crash in ring_buffer_per_cpu->pages Signed-off-by: Jing Xia Signed-off-by: Chunyan Zhang --- kernel/trace/trace.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 73e67b6..ed1c0d1 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -7622,7 +7622,9 @@ static int allocate_trace_buffers(struct trace_array *tr, int size) allocate_snapshot ? size : 1); if (WARN_ON(ret)) { ring_buffer_free(tr->trace_buffer.buffer); + tr->trace_buffer.buffer = NULL; free_percpu(tr->trace_buffer.data); + tr->trace_buffer.data = NULL; return -ENOMEM; } tr->allocated_snapshot = allocate_snapshot; -- 2.7.4
Re: WARNING in do_debug
On Tue, Dec 26, 2017 at 1:55 AM, Wanpeng Li wrote: > 2017-12-26 8:22 GMT+08:00 syzbot > : >> syzkaller has found reproducer for the following crash on >> 464e1d5f23cca236b930ef068c328a64cab78fb1 >> git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master >> compiler: gcc (GCC) 7.1.1 20170620 >> .config is attached >> Raw console output is attached. >> C reproducer is attached >> syzkaller reproducer is attached. See https://goo.gl/kgGztJ >> for information about syzkaller reproducers >> > > https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue&id=ed3b37ac63a060bdc184d126c0655c1af8b6de62 > > There is a fix in kvm/queue. Hi Wanpeng, syzbot does not know about the fix and still thinks that this bug is open. Please tell it about the fix: > syzbot will keep track of this bug report. > Once a fix for this bug is committed, please reply to this email with: > #syz fix: exact-commit-title > Note: all commands must start from beginning of the line. >> WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/traps.c:801 >> cond_local_irq_disable arch/x86/kernel/traps.c:86 [inline] >> WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/traps.c:801 >> do_debug+0x4d8/0x6e0 arch/x86/kernel/traps.c:815 >> Kernel panic - not syncing: panic_on_warn set ... >> >> CPU: 0 PID: 3356 Comm: syzkaller834441 Not tainted 4.15.0-rc5+ #237 >> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS >> Google 01/01/2011 >> Call Trace: >> <#DB> >> __dump_stack lib/dump_stack.c:17 [inline] >> dump_stack+0x194/0x257 lib/dump_stack.c:53 >> panic+0x1e4/0x41c kernel/panic.c:183 >> __warn+0x1dc/0x200 kernel/panic.c:547 >> report_bug+0x211/0x2d0 lib/bug.c:184 >> fixup_bug.part.11+0x37/0x80 arch/x86/kernel/traps.c:178 >> fixup_bug arch/x86/kernel/traps.c:247 [inline] >> do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296 >> do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315 >> invalid_op+0x22/0x40 arch/x86/entry/entry_64.S:1061 >> RIP: 0010:cond_local_irq_disable arch/x86/kernel/traps.c:86 [inline] >> RIP: 0010:do_debug+0x4d8/0x6e0 arch/x86/kernel/traps.c:815 >> RSP: 0018:fe80ee98 EFLAGS: 00010246 >> RAX: dc00 RBX: fe80ef58 RCX: >> RDX: 1fd01dfc RSI: 0001 RDI: 85ec81f8 >> RBP: fe80ef48 R08: fe80efe8 R09: >> R10: R11: R12: e003 >> R13: 8801c2340040 R14: 1fd01dd8 R15: 4000 >> debug+0x34/0x60 arch/x86/entry/entry_64.S:1214 >> RIP: 0010:__put_user_8+0x1f/0x25 arch/x86/lib/putuser.S:83 >> RSP: 0018:8801c9f8ff28 EFLAGS: 0293 >> RAX: 5a4195b6 RBX: 7fffeff9 RCX: 2000 >> RDX: RSI: 0001 RDI: 0282 >> RBP: 8801c9f8ff48 R08: R09: 1100393f1fc2 >> R10: 8801c9f8fdd8 R11: R12: 5a4195b6 >> R13: 2000 R14: 7f2c937f99c0 R15: 0001 >> >> entry_SYSCALL_64_fastpath+0x1f/0x96 >> RIP: 0033:0x44aef9 >> RSP: 002b:7f2c937f8ce8 EFLAGS: 0206 ORIG_RAX: 00c9 >> RAX: ffda RBX: 006dcc24 RCX: 0044aef9 >> RDX: 0044aef9 RSI: 0044aef9 RDI: 2000 >> RBP: 006dcc20 R08: R09: >> R10: R11: 0206 R12: >> R13: 7ffe9191073f R14: 7f2c937f99c0 R15: 0001 >> >> Dumping ftrace buffer: >>(ftrace buffer empty) >> Kernel Offset: disabled >> Rebooting in 86400 seconds.. >>
RE: [PATCH] arm: imx: suspend/resume: use outer_disable/resume
Hi Shawn, > -Original Message- > From: Shawn Guo [mailto:shawn...@kernel.org] > Sent: Tuesday, December 26, 2017 11:31 AM > To: Peng Fan > Cc: A.s. Dong ; linux-kernel@vger.kernel.org; Russell > King ; Fabio Estevam ; > Sascha Hauer ; van.free...@gmail.com; linux-arm- > ker...@lists.infradead.org > Subject: Re: [PATCH] arm: imx: suspend/resume: use outer_disable/resume > > On Sun, Dec 10, 2017 at 08:07:18PM +0800, Peng Fan wrote: > > Use outer_disable/resume for suspend/resume. > > With the two APIs used, code could be simplified and easy to extend to > > introduce l2c_write_sec for i.MX platforms when moving Linux Kernel > > runs in non-secure world. > > > > Signed-off-by: Peng Fan > > Cc: Shawn Guo > > Cc: Sascha Hauer > > Cc: Fabio Estevam > > Cc: Russell King > > Cc: Dong Aisheng > > --- > > arch/arm/mach-imx/pm-imx6.c | 2 ++ > > arch/arm/mach-imx/suspend-imx6.S | 24 > > I'm fine with the patch in general. But this piece of code is running on a > few > i.MX6 platforms, and I'm wondering on which SoCs you have verified the > change work fine. I tested it on 6Q-SDB board. Is it ok? Thanks, Peng. > > Shawn
[PATCH 10/11 v2] ARM: s3c24xx/s3c64xx: constify gpio_led
Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/arm/mach-s3c24xx/mach-h1940.c| 2 +- arch/arm/mach-s3c24xx/mach-rx1950.c | 2 +- arch/arm/mach-s3c64xx/mach-hmt.c | 2 +- arch/arm/mach-s3c64xx/mach-smartq5.c | 2 +- arch/arm/mach-s3c64xx/mach-smartq7.c | 2 +- arch/arm/mach-s3c64xx/mach-smdk6410.c | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/arch/arm/mach-s3c24xx/mach-h1940.c b/arch/arm/mach-s3c24xx/mach-h1940.c index 7ed7861..6a3e0e6 100644 --- a/arch/arm/mach-s3c24xx/mach-h1940.c +++ b/arch/arm/mach-s3c24xx/mach-h1940.c @@ -413,7 +413,7 @@ int h1940_led_blink_set(struct gpio_desc *desc, int state, } EXPORT_SYMBOL(h1940_led_blink_set); -static struct gpio_led h1940_leds_desc[] = { +static const struct gpio_led h1940_leds_desc[] = { { .name = "Green", .default_trigger= "main-battery-full", diff --git a/arch/arm/mach-s3c24xx/mach-rx1950.c b/arch/arm/mach-s3c24xx/mach-rx1950.c index e86ad6a..97bb6a5 100644 --- a/arch/arm/mach-s3c24xx/mach-rx1950.c +++ b/arch/arm/mach-s3c24xx/mach-rx1950.c @@ -295,7 +295,7 @@ static int rx1950_led_blink_set(struct gpio_desc *desc, int state, return 0; } -static struct gpio_led rx1950_leds_desc[] = { +static const struct gpio_led rx1950_leds_desc[] = { { .name = "Green", .default_trigger= "main-battery-full", diff --git a/arch/arm/mach-s3c64xx/mach-hmt.c b/arch/arm/mach-s3c64xx/mach-hmt.c index 59b5531..f8d644f 100644 --- a/arch/arm/mach-s3c64xx/mach-hmt.c +++ b/arch/arm/mach-s3c64xx/mach-hmt.c @@ -207,7 +207,7 @@ static struct s3c2410_platform_nand hmt_nand_info = { .ecc_mode = NAND_ECC_SOFT, }; -static struct gpio_led hmt_leds[] = { +static const struct gpio_led hmt_leds[] = { { /* left function keys */ .name = "left:blue", .gpio = S3C64XX_GPO(12), diff --git a/arch/arm/mach-s3c64xx/mach-smartq5.c b/arch/arm/mach-s3c64xx/mach-smartq5.c index 0972b6c..5a7cd8f 100644 --- a/arch/arm/mach-s3c64xx/mach-smartq5.c +++ b/arch/arm/mach-s3c64xx/mach-smartq5.c @@ -35,7 +35,7 @@ #include "common.h" #include "mach-smartq.h" -static struct gpio_led smartq5_leds[] = { +static const struct gpio_led smartq5_leds[] = { { .name = "smartq5:green", .active_low = 1, diff --git a/arch/arm/mach-s3c64xx/mach-smartq7.c b/arch/arm/mach-s3c64xx/mach-smartq7.c index 51ac1c6..9de9fc2 100644 --- a/arch/arm/mach-s3c64xx/mach-smartq7.c +++ b/arch/arm/mach-s3c64xx/mach-smartq7.c @@ -35,7 +35,7 @@ #include "common.h" #include "mach-smartq.h" -static struct gpio_led smartq7_leds[] = { +static const struct gpio_led smartq7_leds[] = { { .name = "smartq7:red", .active_low = 1, diff --git a/arch/arm/mach-s3c64xx/mach-smdk6410.c b/arch/arm/mach-s3c64xx/mach-smdk6410.c index 92ec8c3..be9d98f 100644 --- a/arch/arm/mach-s3c64xx/mach-smdk6410.c +++ b/arch/arm/mach-s3c64xx/mach-smdk6410.c @@ -497,7 +497,7 @@ static struct wm8350_platform_data __initdata smdk6410_wm8350_pdata = { #endif #ifdef CONFIG_SMDK6410_WM1192_EV1 -static struct gpio_led wm1192_pmic_leds[] = { +static const struct gpio_led wm1192_pmic_leds[] = { { .name = "PMIC:red:power", .gpio = GPIO_BOARD_START + 3, -- 2.7.4
[PATCH 11/11 v2] ARM: pxa: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. Resolve auto build test ERROR. arch/arm/mach-pxa/balloon3.c | 4 ++-- arch/arm/mach-pxa/corgi.c | 2 +- arch/arm/mach-pxa/csb701.c| 2 +- arch/arm/mach-pxa/magician.c | 2 +- arch/arm/mach-pxa/mioa701.c | 2 +- arch/arm/mach-pxa/palmld.c| 2 +- arch/arm/mach-pxa/palmz72.c | 2 +- arch/arm/mach-pxa/pcm027.c| 2 +- arch/arm/mach-pxa/raumfeld.c | 4 ++-- arch/arm/mach-pxa/spitz.c | 2 +- arch/arm/mach-pxa/stargate2.c | 2 +- arch/arm/mach-pxa/tosa.c | 2 +- arch/arm/mach-pxa/trizeps4.c | 2 +- arch/arm/mach-pxa/zeus.c | 2 +- 14 files changed, 16 insertions(+), 16 deletions(-) diff --git a/arch/arm/mach-pxa/balloon3.c b/arch/arm/mach-pxa/balloon3.c index d6d92f3..abcfb19 100644 --- a/arch/arm/mach-pxa/balloon3.c +++ b/arch/arm/mach-pxa/balloon3.c @@ -387,7 +387,7 @@ static unsigned long balloon3_led_pin_config[] __initdata = { GPIO10_GPIO,/* Heartbeat LED */ }; -struct gpio_led balloon3_gpio_leds[] = { +const struct gpio_led balloon3_gpio_leds[] = { { .name = "balloon3:green:idle", .default_trigger= "heartbeat", @@ -414,7 +414,7 @@ static struct platform_device balloon3_leds = { } }; -struct gpio_led balloon3_pcf_gpio_leds[] = { +const struct gpio_led balloon3_pcf_gpio_leds[] = { { .name = "balloon3:green:led0", .gpio = BALLOON3_PCF_GPIO_LED0, diff --git a/arch/arm/mach-pxa/corgi.c b/arch/arm/mach-pxa/corgi.c index 7270f0db..6d6ded0 100644 --- a/arch/arm/mach-pxa/corgi.c +++ b/arch/arm/mach-pxa/corgi.c @@ -450,7 +450,7 @@ static struct platform_device corgi_gpio_keys_device = { /* * Corgi LEDs */ -static struct gpio_led corgi_gpio_leds[] = { +static const struct gpio_led corgi_gpio_leds[] = { { .name = "corgi:amber:charge", .default_trigger= "sharpsl-charge", diff --git a/arch/arm/mach-pxa/csb701.c b/arch/arm/mach-pxa/csb701.c index 527c9fd..b062b50 100644 --- a/arch/arm/mach-pxa/csb701.c +++ b/arch/arm/mach-pxa/csb701.c @@ -24,7 +24,7 @@ static struct gpio_keys_platform_data csb701_gpio_keys_data = { .nbuttons = ARRAY_SIZE(csb701_buttons), }; -static struct gpio_led csb701_leds[] = { +static const struct gpio_led csb701_leds[] = { { .name = "csb701:yellow:heartbeat", .default_trigger = "heartbeat", diff --git a/arch/arm/mach-pxa/magician.c b/arch/arm/mach-pxa/magician.c index 7f3566c..505c9cc 100644 --- a/arch/arm/mach-pxa/magician.c +++ b/arch/arm/mach-pxa/magician.c @@ -424,7 +424,7 @@ static struct platform_device backlight = { * GPIO LEDs, Phone keys backlight, vibra */ -static struct gpio_led gpio_leds[] = { +static const struct gpio_led gpio_leds[] = { { .name = "magician::vibra", .default_trigger = "none", diff --git a/arch/arm/mach-pxa/mioa701.c b/arch/arm/mach-pxa/mioa701.c index 8a5d049..88115f0 100644 --- a/arch/arm/mach-pxa/mioa701.c +++ b/arch/arm/mach-pxa/mioa701.c @@ -274,7 +274,7 @@ static struct gpio_keys_platform_data mioa701_gpio_keys_data = { */ #define ONE_LED(_gpio, _name) \ { .gpio = (_gpio), .name = (_name), .active_low = true } -static struct gpio_led gpio_leds[] = { +static const struct gpio_led gpio_leds[] = { ONE_LED(GPIO10_LED_nCharging, "mioa701:charging"), ONE_LED(GPIO97_LED_nBlue, "mioa701:blue"), ONE_LED(GPIO98_LED_nOrange, "mioa701:orange"), diff --git a/arch/arm/mach-pxa/palmld.c b/arch/arm/mach-pxa/palmld.c index 980f284..eb5992b 100644 --- a/arch/arm/mach-pxa/palmld.c +++ b/arch/arm/mach-pxa/palmld.c @@ -246,7 +246,7 @@ static inline void palmld_keys_init(void) {} * LEDs **/ #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) -struct gpio_led gpio_leds[] = { +const struct gpio_led gpio_leds[] = { { .name = "palmld:green:led", .default_trigger= "none", diff --git a/arch/arm/mach-pxa/palmz72.c b/arch/arm/mach-pxa/palmz72.c index 5877e54..99c5bf2 100644 --- a/arch/arm/mach-pxa/palmz72.c +++ b/arch/arm/mach-pxa/palmz72.c @@ -182,7 +182,7 @@ static inline void palmz72_kpc_init(void) {} * LEDs **/ #if defined(CONFIG_LEDS_GPIO) || defined(CONFIG_LEDS_GPIO_MODULE) -static struct gpio_led gpio_leds[] = { +static const struct gpio_led gpio_leds[] = { { .name
[PATCH 09/11 v2] ARM: orion5x: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/arm/mach-orion5x/board-d2net.c | 2 +- arch/arm/mach-orion5x/dns323-setup.c | 2 +- arch/arm/mach-orion5x/ls_hgl-setup.c | 2 +- arch/arm/mach-orion5x/mv2120-setup.c | 2 +- arch/arm/mach-orion5x/net2big-setup.c| 2 +- arch/arm/mach-orion5x/rd88f5182-setup.c | 2 +- arch/arm/mach-orion5x/ts409-setup.c | 2 +- arch/arm/mach-orion5x/wrt350n-v2-setup.c | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/arch/arm/mach-orion5x/board-d2net.c b/arch/arm/mach-orion5x/board-d2net.c index a89376a..55d6562 100644 --- a/arch/arm/mach-orion5x/board-d2net.c +++ b/arch/arm/mach-orion5x/board-d2net.c @@ -54,7 +54,7 @@ #define D2NET_GPIO_BLUE_LED_BLINK_CTRL 16 #define D2NET_GPIO_BLUE_LED_OFF23 -static struct gpio_led d2net_leds[] = { +static const struct gpio_led d2net_leds[] = { { .name = "d2net:blue:sata", .default_trigger = "default-on", diff --git a/arch/arm/mach-orion5x/dns323-setup.c b/arch/arm/mach-orion5x/dns323-setup.c index cd483bf..6aeab1d 100644 --- a/arch/arm/mach-orion5x/dns323-setup.c +++ b/arch/arm/mach-orion5x/dns323-setup.c @@ -204,7 +204,7 @@ static int __init dns323_read_mac_addr(void) * GPIO LEDs (simple - doesn't use hardware blinking support) */ -static struct gpio_led dns323ab_leds[] = { +static const struct gpio_led dns323ab_leds[] = { { .name = "power:blue", .gpio = DNS323_GPIO_LED_POWER2, diff --git a/arch/arm/mach-orion5x/ls_hgl-setup.c b/arch/arm/mach-orion5x/ls_hgl-setup.c index 47ba6e0..c394281 100644 --- a/arch/arm/mach-orion5x/ls_hgl-setup.c +++ b/arch/arm/mach-orion5x/ls_hgl-setup.c @@ -86,7 +86,7 @@ static struct i2c_board_info __initdata ls_hgl_i2c_rtc = { #define LS_HGL_GPIO_LED_PWR 0 -static struct gpio_led ls_hgl_led_pins[] = { +static const struct gpio_led ls_hgl_led_pins[] = { { .name = "alarm:red", .gpio = LS_HGL_GPIO_LED_ALARM, diff --git a/arch/arm/mach-orion5x/mv2120-setup.c b/arch/arm/mach-orion5x/mv2120-setup.c index 2bf8ec7..724c08a 100644 --- a/arch/arm/mach-orion5x/mv2120-setup.c +++ b/arch/arm/mach-orion5x/mv2120-setup.c @@ -136,7 +136,7 @@ static struct i2c_board_info __initdata mv2120_i2c_rtc = { .irq= 0, }; -static struct gpio_led mv2120_led_pins[] = { +static const struct gpio_led mv2120_led_pins[] = { { .name = "mv2120:blue:health", .gpio = 0, diff --git a/arch/arm/mach-orion5x/net2big-setup.c b/arch/arm/mach-orion5x/net2big-setup.c index bf6be4c..7d59888 100644 --- a/arch/arm/mach-orion5x/net2big-setup.c +++ b/arch/arm/mach-orion5x/net2big-setup.c @@ -214,7 +214,7 @@ static void __init net2big_sata_power_init(void) #define NET2BIG_GPIO_SATA0_BLUE_LED17 #define NET2BIG_GPIO_SATA1_BLUE_LED13 -static struct gpio_led net2big_leds[] = { +static const struct gpio_led net2big_leds[] = { { .name = "net2big:red:power", .gpio = NET2BIG_GPIO_PWR_RED_LED, diff --git a/arch/arm/mach-orion5x/rd88f5182-setup.c b/arch/arm/mach-orion5x/rd88f5182-setup.c index fe3e67c..e2f280d 100644 --- a/arch/arm/mach-orion5x/rd88f5182-setup.c +++ b/arch/arm/mach-orion5x/rd88f5182-setup.c @@ -83,7 +83,7 @@ static struct platform_device rd88f5182_nor_flash = { #define RD88F5182_GPIO_LED 0 -static struct gpio_led rd88f5182_gpio_led_pins[] = { +static const struct gpio_led rd88f5182_gpio_led_pins[] = { { .name = "rd88f5182:cpu", .default_trigger = "cpu0", diff --git a/arch/arm/mach-orion5x/ts409-setup.c b/arch/arm/mach-orion5x/ts409-setup.c index a77613b..a31f6848 100644 --- a/arch/arm/mach-orion5x/ts409-setup.c +++ b/arch/arm/mach-orion5x/ts409-setup.c @@ -169,7 +169,7 @@ static struct i2c_board_info __initdata qnap_ts409_i2c_rtc = { * LEDs attached to GPIO / -static struct gpio_led ts409_led_pins[] = { +static const struct gpio_led ts409_led_pins[] = { { .name = "ts409:red:sata1", .gpio = 4, diff --git a/arch/arm/mach-orion5x/wrt350n-v2-setup.c b/arch/arm/mach-orion5x/wrt350n-v2-setup.c index 9250bb2..5493d73 100644 --- a/arch/arm/mach-orion5x/wrt350n-v2-setup.c +++ b/arch/arm/mach-orion5x/wrt350n-v2-setup.c @@ -29,7 +29,7 @@ /* * LEDs attached to GPIO */ -static struct gpio_led wrt350n_v2_led_pins[] = { +static const struct gpio_led wrt350n_v2_led_pins[]
[PATCH 06/11 v2] ARM: davinci: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/arm/mach-davinci/board-neuros-osd2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/mach-davinci/board-neuros-osd2.c b/arch/arm/mach-davinci/board-neuros-osd2.c index 0c02aaa..4da210a 100644 --- a/arch/arm/mach-davinci/board-neuros-osd2.c +++ b/arch/arm/mach-davinci/board-neuros-osd2.c @@ -128,7 +128,7 @@ static struct platform_device davinci_fb_device = { .num_resources = 0, }; -static struct gpio_led ntosd2_leds[] = { +static const struct gpio_led ntosd2_leds[] = { { .name = "led1_green", .gpio = GPIO(10), }, { .name = "led1_red", .gpio = GPIO(11), }, { .name = "led2_green", .gpio = GPIO(12), }, -- 2.7.4
[PATCH 07/11 v2] ARM: ixp4xx: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/arm/mach-ixp4xx/dsmg600-setup.c | 2 +- arch/arm/mach-ixp4xx/nas100d-setup.c | 2 +- arch/arm/mach-ixp4xx/omixp-setup.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-ixp4xx/dsmg600-setup.c b/arch/arm/mach-ixp4xx/dsmg600-setup.c index 0f5c999..77d894d 100644 --- a/arch/arm/mach-ixp4xx/dsmg600-setup.c +++ b/arch/arm/mach-ixp4xx/dsmg600-setup.c @@ -93,7 +93,7 @@ static struct i2c_board_info __initdata dsmg600_i2c_board_info [] = { }, }; -static struct gpio_led dsmg600_led_pins[] = { +static const struct gpio_led dsmg600_led_pins[] = { { .name = "dsmg600:green:power", .gpio = DSMG600_LED_PWR_GPIO, diff --git a/arch/arm/mach-ixp4xx/nas100d-setup.c b/arch/arm/mach-ixp4xx/nas100d-setup.c index 76dfff0..8d6bab9 100644 --- a/arch/arm/mach-ixp4xx/nas100d-setup.c +++ b/arch/arm/mach-ixp4xx/nas100d-setup.c @@ -72,7 +72,7 @@ static struct i2c_board_info __initdata nas100d_i2c_board_info [] = { }, }; -static struct gpio_led nas100d_led_pins[] = { +static const struct gpio_led nas100d_led_pins[] = { { .name = "nas100d:green:wlan", .gpio = NAS100D_LED_WLAN_GPIO, diff --git a/arch/arm/mach-ixp4xx/omixp-setup.c b/arch/arm/mach-ixp4xx/omixp-setup.c index 2d494b4..42c83a6 100644 --- a/arch/arm/mach-ixp4xx/omixp-setup.c +++ b/arch/arm/mach-ixp4xx/omixp-setup.c @@ -152,7 +152,7 @@ static struct platform_device omixp_uart = { .resource = omixp_uart_resources, }; -static struct gpio_led mic256_led_pins[] = { +static const struct gpio_led mic256_led_pins[] = { { .name = "LED-A", .gpio = 7, -- 2.7.4
[PATCH 08/11 v2] ARM: OMAP1: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/arm/mach-omap1/board-h2.c| 2 +- arch/arm/mach-omap1/board-h3.c| 2 +- arch/arm/mach-omap1/board-htcherald.c | 2 +- arch/arm/mach-omap1/board-osk.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c index ab51f85..9aeb8ad 100644 --- a/arch/arm/mach-omap1/board-h2.c +++ b/arch/arm/mach-omap1/board-h2.c @@ -274,7 +274,7 @@ static struct platform_device h2_kp_device = { .resource = h2_kp_resources, }; -static struct gpio_led h2_gpio_led_pins[] = { +static const struct gpio_led h2_gpio_led_pins[] = { { .name = "h2:red", .default_trigger = "heartbeat", diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c index ad339f5..2edcd63 100644 --- a/arch/arm/mach-omap1/board-h3.c +++ b/arch/arm/mach-omap1/board-h3.c @@ -326,7 +326,7 @@ static struct spi_board_info h3_spi_board_info[] __initdata = { }, }; -static struct gpio_led h3_gpio_led_pins[] = { +static const struct gpio_led h3_gpio_led_pins[] = { { .name = "h3:red", .default_trigger = "heartbeat", diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c index 67d4669..e6a79fd 100644 --- a/arch/arm/mach-omap1/board-htcherald.c +++ b/arch/arm/mach-omap1/board-htcherald.c @@ -292,7 +292,7 @@ static struct platform_device herald_gpiokeys_device = { }; /* LEDs for the Herald. These connect to the HTCPLD GPIO device. */ -static struct gpio_led gpio_leds[] = { +static const struct gpio_led gpio_leds[] = { {"dpad",NULL, HTCPLD_GPIO_LED_DPAD,0, 0, LEDS_GPIO_DEFSTATE_OFF}, {"kbd", NULL, HTCPLD_GPIO_LED_KBD, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, {"vibrate", NULL, HTCPLD_GPIO_LED_VIBRATE, 0, 0, LEDS_GPIO_DEFSTATE_OFF}, diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c index c66372e..e2277b5 100644 --- a/arch/arm/mach-omap1/board-osk.c +++ b/arch/arm/mach-omap1/board-osk.c @@ -167,7 +167,7 @@ static struct platform_device *osk5912_devices[] __initdata = { &osk5912_cf_device, }; -static struct gpio_led tps_leds[] = { +static const struct gpio_led tps_leds[] = { /* NOTE: D9 and D2 have hardware blink support. * Also, D9 requires non-battery power. */ @@ -385,7 +385,7 @@ static struct platform_device osk5912_lcd_device = { .id = -1, }; -static struct gpio_led mistral_gpio_led_pins[] = { +static const struct gpio_led mistral_gpio_led_pins[] = { { .name = "mistral:red", .default_trigger = "heartbeat", -- 2.7.4
[PATCH 05/11 v2] sh: mach-rsk: rsk7203: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/sh/boards/mach-rsk/devices-rsk7203.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/sh/boards/mach-rsk/devices-rsk7203.c b/arch/sh/boards/mach-rsk/devices-rsk7203.c index a8089f7..6676c0e 100644 --- a/arch/sh/boards/mach-rsk/devices-rsk7203.c +++ b/arch/sh/boards/mach-rsk/devices-rsk7203.c @@ -50,7 +50,7 @@ static struct platform_device smsc911x_device = { }, }; -static struct gpio_led rsk7203_gpio_leds[] = { +static const struct gpio_led rsk7203_gpio_leds[] = { { .name = "green", .gpio = GPIO_PE10, -- 2.7.4
[PATCH 04/11 v2] x86: geode: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/x86/platform/geode/alix.c| 2 +- arch/x86/platform/geode/geos.c| 2 +- arch/x86/platform/geode/net5501.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/arch/x86/platform/geode/alix.c b/arch/x86/platform/geode/alix.c index 1865c19..f447ed7 100644 --- a/arch/x86/platform/geode/alix.c +++ b/arch/x86/platform/geode/alix.c @@ -71,7 +71,7 @@ static struct platform_device alix_buttons_dev = { } }; -static struct gpio_led alix_leds[] = { +static const struct gpio_led alix_leds[] = { { .name = "alix:1", .gpio = 6, diff --git a/arch/x86/platform/geode/geos.c b/arch/x86/platform/geode/geos.c index 4fcdb91..146697b 100644 --- a/arch/x86/platform/geode/geos.c +++ b/arch/x86/platform/geode/geos.c @@ -54,7 +54,7 @@ static struct platform_device geos_buttons_dev = { } }; -static struct gpio_led geos_leds[] = { +static const struct gpio_led geos_leds[] = { { .name = "geos:1", .gpio = 6, diff --git a/arch/x86/platform/geode/net5501.c b/arch/x86/platform/geode/net5501.c index a2f6b98..e5e1a64 100644 --- a/arch/x86/platform/geode/net5501.c +++ b/arch/x86/platform/geode/net5501.c @@ -57,7 +57,7 @@ static struct platform_device net5501_buttons_dev = { } }; -static struct gpio_led net5501_leds[] = { +static const struct gpio_led net5501_leds[] = { { .name = "net5501:1", .gpio = 6, -- 2.7.4
Re: [PATCH v6 3/4] iio : Add cm3218 smbus ara and acpi support
Hi Marc, Thank you for the patch! Yet something to improve: [auto build test ERROR on wsa/i2c/for-next] [also build test ERROR on v4.15-rc5 next-20171222] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Marc-CAPDEVILLE/i2c-core-acpi-Add-i2c_acpi_set_connection/20171226-083729 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next config: i386-randconfig-c0-12261310 (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/iio/light/cm32181.o: In function `cm32181_irq': >> drivers/iio/light/cm32181.c:336: undefined reference to >> `i2c_smbus_alert_event' drivers/iio/light/cm32181.o: In function `cm32181_probe': >> drivers/iio/light/cm32181.c:405: undefined reference to >> `i2c_require_smbus_alert' drivers/iio/light/cm32181.o: In function `cm32181_reg_init': drivers/iio/light/cm32181.c:95: undefined reference to `i2c_smbus_alert_event' vim +336 drivers/iio/light/cm32181.c 329 330 static irqreturn_t cm32181_irq(int irq, void *d) 331 { 332 struct cm32181_chip *cm32181 = d; 333 334 if (cm32181->chip_id == CM3218_ID) { 335 /* This is cm3218 chip irq, so handle the smbus alert */ > 336 i2c_smbus_alert_event(cm32181->client); 337 } 338 339 return IRQ_HANDLED; 340 } 341 342 static int cm32181_probe(struct i2c_client *client, 343 const struct i2c_device_id *id) 344 { 345 struct cm32181_chip *cm32181; 346 struct iio_dev *indio_dev; 347 int ret; 348 const struct of_device_id *of_id; 349 const struct acpi_device_id *acpi_id; 350 351 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*cm32181)); 352 if (!indio_dev) { 353 dev_err(&client->dev, "devm_iio_device_alloc failed\n"); 354 return -ENOMEM; 355 } 356 357 cm32181 = iio_priv(indio_dev); 358 i2c_set_clientdata(client, indio_dev); 359 cm32181->client = client; 360 361 mutex_init(&cm32181->lock); 362 indio_dev->dev.parent = &client->dev; 363 indio_dev->channels = cm32181_channels; 364 indio_dev->num_channels = ARRAY_SIZE(cm32181_channels); 365 indio_dev->info = &cm32181_info; 366 indio_dev->name = id->name; 367 indio_dev->modes = INDIO_DIRECT_MODE; 368 369 /* Lookup for chip ID from platform, acpi or of device table */ 370 if (id) { 371 cm32181->chip_id = id->driver_data; 372 } else if (ACPI_COMPANION(&client->dev)) { 373 acpi_id = acpi_match_device(client->dev.driver->acpi_match_table, 374 &client->dev); 375 if (!acpi_id) 376 return -ENODEV; 377 378 cm32181->chip_id = (kernel_ulong_t)acpi_id->driver_data; 379 } else if (client->dev.of_node) { 380 of_id = of_match_device(client->dev.driver->of_match_table, 381 &client->dev); 382 if (!of_id) 383 return -ENODEV; 384 385 cm32181->chip_id = (kernel_ulong_t)of_id->data; 386 } else { 387 return -ENODEV; 388 } 389 390 if (cm32181->chip_id == CM3218_ID) { 391 if (ACPI_COMPANION(&client->dev) && 392 client->addr == SMBUS_ARA_ADDR) { 393 /* 394 * In case this device as been enumerated by acpi 395 * with the reserved smbus ARA address (first acpi 396 * connection), request change of address to the second 397 * connection. 398 */ 399 ret = i2c_acpi_set_connection(client, 1); 400 if (ret) 401 return ret; 402 } 403 404 /* cm3218 chip require an ara device on his adapter */ > 405 ret = i2c_require_smbus_alert(client); 406 if (ret < 0) 407 return ret; 408 409 /* 410 * If irq is given, request a threaded irq handler to manage 411 * smbus alert. 412 */ 413 if (client->irq > 0) { 414
[PATCH 02/11 v2] MIPS: AR7: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/mips/ar7/platform.c | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/mips/ar7/platform.c b/arch/mips/ar7/platform.c index 4674f1e..4694273 100644 --- a/arch/mips/ar7/platform.c +++ b/arch/mips/ar7/platform.c @@ -346,7 +346,7 @@ static struct platform_device ar7_udc = { /* * LEDs / -static struct gpio_led default_leds[] = { +static const struct gpio_led default_leds[] = { { .name = "status", .gpio = 8, @@ -354,12 +354,12 @@ static struct gpio_led default_leds[] = { }, }; -static struct gpio_led titan_leds[] = { +static const struct gpio_led titan_leds[] = { { .name = "status", .gpio = 8, .active_low = 1, }, { .name = "wifi", .gpio = 13, .active_low = 1, }, }; -static struct gpio_led dsl502t_leds[] = { +static const struct gpio_led dsl502t_leds[] = { { .name = "status", .gpio = 9, @@ -377,7 +377,7 @@ static struct gpio_led dsl502t_leds[] = { }, }; -static struct gpio_led dg834g_leds[] = { +static const struct gpio_led dg834g_leds[] = { { .name = "ppp", .gpio = 6, @@ -406,7 +406,7 @@ static struct gpio_led dg834g_leds[] = { }, }; -static struct gpio_led fb_sl_leds[] = { +static const struct gpio_led fb_sl_leds[] = { { .name = "1", .gpio = 7, @@ -433,7 +433,7 @@ static struct gpio_led fb_sl_leds[] = { }, }; -static struct gpio_led fb_fon_leds[] = { +static const struct gpio_led fb_fon_leds[] = { { .name = "1", .gpio = 8, @@ -459,7 +459,7 @@ static struct gpio_led fb_fon_leds[] = { }, }; -static struct gpio_led gt701_leds[] = { +static const struct gpio_led gt701_leds[] = { { .name = "inet:green", .gpio = 13, -- 2.7.4
[PATCH 03/11 v2] MIPS: TXX9: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/mips/txx9/rbtx4927/setup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/mips/txx9/rbtx4927/setup.c b/arch/mips/txx9/rbtx4927/setup.c index f5b367e..31955c1 100644 --- a/arch/mips/txx9/rbtx4927/setup.c +++ b/arch/mips/txx9/rbtx4927/setup.c @@ -319,7 +319,7 @@ static void __init rbtx4927_mtd_init(void) static void __init rbtx4927_gpioled_init(void) { - static struct gpio_led leds[] = { + static const struct gpio_led leds[] = { { .name = "gpioled:green:0", .gpio = 0, .active_low = 1, }, { .name = "gpioled:green:1", .gpio = 1, .active_low = 1, }, }; -- 2.7.4
[PATCH 01/11 v2] MIPS: Alchemy: constify gpio_led
gpio_led are not supposed to change at runtime. struct gpio_led_platform_data working with const gpio_led provided by . So mark the non-const structs as const. Signed-off-by: Arvind Yadav --- changes in v2: The GPIO LED driver can be built as a module, it can be loaded after the init sections have gone away. So removed '__initconst'. arch/mips/alchemy/board-gpr.c | 2 +- arch/mips/alchemy/board-mtx1.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/alchemy/board-gpr.c b/arch/mips/alchemy/board-gpr.c index 328d697..4e79dbd 100644 --- a/arch/mips/alchemy/board-gpr.c +++ b/arch/mips/alchemy/board-gpr.c @@ -190,7 +190,7 @@ static struct platform_device gpr_mtd_device = { /* * LEDs */ -static struct gpio_led gpr_gpio_leds[] = { +static const struct gpio_led gpr_gpio_leds[] = { { /* green */ .name = "gpr:green", .gpio = 4, diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c index 85bb756..aab55aa 100644 --- a/arch/mips/alchemy/board-mtx1.c +++ b/arch/mips/alchemy/board-mtx1.c @@ -145,7 +145,7 @@ static struct platform_device mtx1_wdt = { .resource = mtx1_wdt_res, }; -static struct gpio_led default_leds[] = { +static const struct gpio_led default_leds[] = { { .name = "mtx1:green", .gpio = 211, -- 2.7.4
[PATCH] dm: add asymmetric stripe target device dirver
From: liuchaowei This asymmetric stripe target device driver can achieve better io performance between those devices which possess different io performance There are 2 storage device or flash devices: A and B, their sequential read performance are 220M/s and 315M/s respectively, so their sequential read speed ratio could be approximately equal to 2:3, if we use stripe type to combine these two devices, their layout could be showed below: |A1|A2|B1|B2|B3| If we select asymmetric stripe type, their layout could be illustrated follow: | A1 | B1 | The former has 5 stripe devices and each stripe device has also equal chunk size, e.g.: 256secs. If there is a data block which size is 1280secs, so transfer the data to this stripe device will be split to 5 ios which io size is 256secs. But if we use the asymmetric stripe device, it only has two stripe devices and each one has be setting in optimal chunk size, e.g.: ratio is 2:3, the first one optimal chunk size is 512secs, the second is 768secs. And same 1280secs data block just only be split into two ios, this can be achieved perfect io performance. Signed-off-by: liuchaowei --- Documentation/device-mapper/asymmetric-striped.txt | 85 drivers/md/Kconfig | 11 + drivers/md/Makefile| 1 + drivers/md/dm-asymmetric-stripe.c | 526 + drivers/md/dm.c| 5 + include/linux/device-mapper.h | 15 + 6 files changed, 643 insertions(+) create mode 100644 Documentation/device-mapper/asymmetric-striped.txt create mode 100644 drivers/md/dm-asymmetric-stripe.c diff --git a/Documentation/device-mapper/asymmetric-striped.txt b/Documentation/device-mapper/asymmetric-striped.txt new file mode 100644 index ..fb588535c49b --- /dev/null +++ b/Documentation/device-mapper/asymmetric-striped.txt @@ -0,0 +1,85 @@ +dm-asymmetric-stripe += + +Device-Mapper's "asm-striped" target is used to create a striped (i.e. RAID-0) +device across one or more underlying devices. Data is written in "chunks", +with consecutive chunks rotating among the underlying devices. This can +potentially provide improved I/O throughput by utilizing several physical +devices in parallel. However, in order to gain maximum I/O performance +between slow and fast device, there is a ratio to set up the chunk size +among these device. + +Parameters:[ ]+ +: Number of underlying devices. +: Size of each chunk of data. Must be at least as +large as the system's PAGE_SIZE. +: The proportion of per io size, it is the times as much +as 1 chunk size +: Full pathname to the underlying block-device, or a +"major:minor" device-number. +: Starting sector within the device. + +One or more underlying devices can be specified. The striped device +size must be a multiple of the chunk size multiplied by the number of +underlying devices. However, there is a ratio that can be set, e.g.: 2:3 +means the first one striped device optimal width size is 2 times as +much as 1 chunk size, the second striped device is 3. + + +Example scripts +=== + +[[ +#!/usr/bin/perl -w +# Create a striped device across any number of underlying devices. The device +# will be called "stripe_dev" and have a chunk-size of 128k. + +my $chunk_size = 128 * 2; +my $ratio = "2:3"; +my $dev_name = "stripe_dev"; +my $num_devs = @ARGV; +my @devs = @ARGV; + +if ($num_devs < 2) { +die("Specify at least two devices\n"); +} + + +$stripe_average_size = 1073741824 +$stripe_dev_size = $stripe_average_size * 5; + +$table = "0 $stripe_dev_size asm-striped $num_devs $chunk_size $ratio"; +for ($i = 0; $i < $num_devs; $i++) { +$table .= " $devs[$i] 0"; +} + +`echo $table | dmsetup create $dev_name`; +]] + + +Why asymmetric striped +=== +Considering one case: +There are 2 storage device or flash devices: A and B, their sequential +read performance are 220M/s and 315M/s respectively, so their sequential +read speed could be approximately equal to 2:3, if we use stripe type +to combine these two devices, their layout could be showed below: + +|A1|A2|B1|B2|B3| + + +If we select asymmetric stripe type, their layout could be illustrated +follow: + +| A1 | B1 | + + +The former has 5 stripe devices and each stripe device has also equal +chunk size, e.g.
Re: BUG warnings in 4.14.9
Hi Chris, On Tue, Dec 26, 2017 at 01:49:59AM +, Chris Rankin wrote: (...) > [ 35.100181] Call Trace: > [ 35.102709] dump_stack+0x46/0x59 > [ 35.106095] check_preemption_disabled+0xca/0xda > [ 35.110786] ip6_pol_route+0x46b/0x509 [ipv6] (...) One patch touched this area between 4.14.8 and 4.14.9, you may try to revert it to see if it fixes the issue : 9704f81 ("ipv6: grab rt->rt6i_ref before allocating pcpu rt") Willy
Re: [PATCH -V4 -mm] mm, swap: Fix race between swapoff and some swap operations
Minchan Kim writes: > On Fri, Dec 22, 2017 at 10:14:43PM +0800, Huang, Ying wrote: >> Minchan Kim writes: >> >> > On Thu, Dec 21, 2017 at 03:48:56PM +0800, Huang, Ying wrote: >> >> Minchan Kim writes: >> >> >> >> > On Wed, Dec 20, 2017 at 09:26:32AM +0800, Huang, Ying wrote: >> >> >> From: Huang Ying >> >> >> >> >> >> When the swapin is performed, after getting the swap entry information >> >> >> from the page table, system will swap in the swap entry, without any >> >> >> lock held to prevent the swap device from being swapoff. This may >> >> >> cause the race like below, >> >> >> >> >> >> CPU 1 CPU 2 >> >> >> - - >> >> >>do_swap_page >> >> >> swapin_readahead >> >> >>__read_swap_cache_async >> >> >> swapoff swapcache_prepare >> >> >> p->swap_map = NULL __swap_duplicate >> >> >> p->swap_map[?] /* !!! NULL >> >> >> pointer access */ >> >> >> >> >> >> Because swapoff is usually done when system shutdown only, the race >> >> >> may not hit many people in practice. But it is still a race need to >> >> >> be fixed. >> >> >> >> >> >> To fix the race, get_swap_device() is added to check whether the >> >> >> specified swap entry is valid in its swap device. If so, it will keep >> >> >> the swap entry valid via preventing the swap device from being >> >> >> swapoff, until put_swap_device() is called. >> >> >> >> >> >> Because swapoff() is very race code path, to make the normal path runs >> >> >> as fast as possible, RCU instead of reference count is used to >> >> >> implement get/put_swap_device(). From get_swap_device() to >> >> >> put_swap_device(), the RCU read lock is held, so synchronize_rcu() in >> >> >> swapoff() will wait until put_swap_device() is called. >> >> >> >> >> >> In addition to swap_map, cluster_info, etc. data structure in the >> >> >> struct swap_info_struct, the swap cache radix tree will be freed after >> >> >> swapoff, so this patch fixes the race between swap cache looking up >> >> >> and swapoff too. >> >> >> >> >> >> Cc: Hugh Dickins >> >> >> Cc: Paul E. McKenney >> >> >> Cc: Minchan Kim >> >> >> Cc: Johannes Weiner >> >> >> Cc: Tim Chen >> >> >> Cc: Shaohua Li >> >> >> Cc: Mel Gorman >> >> >> Cc: "Jrme Glisse" >> >> >> Cc: Michal Hocko >> >> >> Cc: Andrea Arcangeli >> >> >> Cc: David Rientjes >> >> >> Cc: Rik van Riel >> >> >> Cc: Jan Kara >> >> >> Cc: Dave Jiang >> >> >> Cc: Aaron Lu >> >> >> Signed-off-by: "Huang, Ying" >> >> >> >> >> >> Changelog: >> >> >> >> >> >> v4: >> >> >> >> >> >> - Use synchronize_rcu() in enable_swap_info() to reduce overhead of >> >> >> normal paths further. >> >> > >> >> > Hi Huang, >> >> >> >> Hi, Minchan, >> >> >> >> > This version is much better than old. To me, it's due to not rcu, >> >> > srcu, refcount thing but it adds swap device dependency(i.e., get/put) >> >> > into every swap related functions so users who don't interested on swap >> >> > don't need to care of it. Good. >> >> > >> >> > The problem is caused by freeing by swap related-data structure >> >> > *dynamically* while old swap logic was based on static data >> >> > structure(i.e., never freed and the verify it's stale). >> >> > So, I reviewed some places where use PageSwapCache and swp_entry_t >> >> > which could make access of swap related data structures. >> >> > >> >> > A example is __isolate_lru_page >> >> > >> >> > It calls page_mapping to get a address_space. >> >> > What happens if the page is on SwapCache and raced with swapoff? >> >> > The mapping got could be disappeared by the race. Right? >> >> >> >> Yes. We should think about that. Considering the file cache pages, the >> >> address_space backing the file cache pages may be freed dynamically too. >> >> So to use page_mapping() return value for the file cache pages, some >> >> kind of locking is needed to guarantee the address_space isn't freed >> >> under us. Page may be locked, or under writeback, or some other locks >> > >> > I didn't look at the code in detail but I guess every file page should >> > be freed before the address space destruction and page_lock/lru_lock makes >> > the work safe, I guess. So, it wouldn't be a problem. >> > >> > However, in case of swapoff, it doesn't remove pages from LRU list >> > so there is no lock to prevent the race at this moment. :( >> >> Take a look at file cache pages and file cache address_space freeing >> code path. It appears that similar situation is possible for them too. >> >> The file cache pages will be delete from file cache address_space before >> address_space (embedded in inode) is freed. But they will be deleted >> from LRU list only when its refcount dropped to zero, please take a look >> at put_page() and release_pages(). While address_space will be freed >> after pu
[lkp-robot] [lib/rbtree,drm/mm] adc8732ba8: WARNING:at_lib/stackdepot.c:#depot_save_stack
FYI, we noticed the following commit (built with gcc-7): commit: adc8732ba8dc55ea7dd226a2edc59a8ef57478cf ("lib/rbtree,drm/mm: Add rbtree_replace_node_cached()") git://anongit.freedesktop.org/drm-intel topic/core-for-CI in testcase: boot on test machine: qemu-system-x86_64 -enable-kvm -m 420M caused below changes (please refer to attached dmesg/kmsg for entire log/backtrace): +---+++ | | 64c8972077 | adc8732ba8 | +---+++ | boot_successes| 50 | 2 | | boot_failures | 4 | 58 | | WARNING:possible_circular_locking_dependency_detected | 3 | | | BUG:kernel_in_stage | 1 | | | WARNING:at_lib/stackdepot.c:#depot_save_stack | 0 | 19 | | RIP:depot_save_stack | 0 | 19 | | BUG:kernel_hang_in_boot_stage | 0 | 42 | +---+++ [ 204.261001] WARNING: CPU: 0 PID: 1 at lib/stackdepot.c:119 depot_save_stack+0x275/0x490 [ 204.262751] Modules linked in: [ 204.263130] CPU: 0 PID: 1 Comm: swapper Not tainted 4.15.0-rc3-5-gadc8732 #2 [ 204.263990] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS 1.10.2-1 04/01/2014 [ 204.264007] RIP: 0010:depot_save_stack+0x275/0x490 [ 204.264007] RSP: :8818b9d0 EFLAGS: 00010082 [ 204.264007] RAX: 0022 RBX: d053170d RCX: 810cc732 [ 204.264007] RDX: RSI: RDI: 810ca57c [ 204.264007] RBP: 8818ba40 R08: 0001 R09: 20f1 [ 204.264007] R10: 0001 R11: R12: 0120 [ 204.264007] R13: 0020 R14: 0020 R15: [ 204.264007] FS: () GS:8222c000() knlGS: [ 204.264007] CS: 0010 DS: ES: CR0: 80050033 [ 204.264007] CR2: CR3: 02216000 CR4: 06b0 [ 204.264007] Call Trace: [ 204.264007] ? save_stack+0x74/0x90 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_add_node+0x103/0x160 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? drm_mm_interval_tree_augment_rotate+0x61/0x70 [ 204.264007] ? add_hole+0x148/0x180 [ 204.264007] ? drm_mm_reserve_node+0x1a0/0x230 [ 204.264007] ? evict_something+0x1b4/0x320 [ 204.264007] ? igt_evict_range+0x1dc/0x450 [ 204.264007] ? test_drm_mm_init+0x1fa/0x2a0 [ 204.264007] ? drm_fb_helper_modinit+0x37/0x37 [ 204.264007] ? do_one_initcall+0x57/0x1e0 [ 204.264007] ? drm_mm_reserve_node+0x1a0/0x230 [ 204.264007] ? evict_something+0x1b4/0x320 [ 204.264007] ? igt_evict_range+0x1dc/0x450 [ 204.264007] ? test_drm_mm_init+0x1fa/0x2a0 [ 204.264007] ? drm_fb_helper_modinit+0x37/0x37 [ 204.264007] ? do_one_initcall+0x57/0x1e0 [ 204.264007] ? kernel_init_freeable+0x19f/0x2ca [ 204.264007] ? rest_init+0x140/0x140 [ 204.264007] ? kernel_init+0xf/0x160 [ 204.264007] ? rest_init+0x140/0x140 [ 204.264007] ? rest_init+0x140/0x140 [ 204.264007] ? ret_from_fork+0x24/0x30 [ 204.264007] Code: c7 60 d2 25 82 e8 8c 68 72 00 e9 d8 fe ff ff 80 3d 5f 52 01 01 00 75 15 48 c7 c7 78 26 f3 81 c6 05 4f 52 01 01 01 e8 cb 2e da ff <0f> ff
RE: [PATCH] usb: gadget: uvc:change the UVC_NUM_REQUESTS value
Hi, > -Original Message- > From: Manu Gautam [mailto:mgau...@codeaurora.org] > Sent: Tuesday, December 26, 2017 1:01 PM > To: Lipengcheng; ba...@kernel.org > Cc: gre...@linuxfoundation.org; linux-kernel@vger.kernel.org; > linux-...@vger.kernel.org > Subject: Re: [PATCH] usb: gadget: uvc:change the UVC_NUM_REQUESTS value > > Hi, > > > On 12/26/2017 8:22 AM, Lipengcheng wrote: > > The value is 4, it can cache four descriptors. When streaming_interval > > = 1, it can tolerate 500us. Some busy scenes, it may be more than > > 500us because cpu scheduling is not timely. There will have some > > problems. It is better set to eight. > > > > Signed-off-by: Pengcheng Li > > --- > > drivers/usb/gadget/function/uvc.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/usb/gadget/function/uvc.h > > b/drivers/usb/gadget/function/uvc.h > > index a64e07e..901487e 100644 > > --- a/drivers/usb/gadget/function/uvc.h > > +++ b/drivers/usb/gadget/function/uvc.h > > @@ -90,7 +90,7 @@ extern unsigned int uvc_gadget_trace_param; > > * Driver specific constants > > */ > > > > -#define UVC_NUM_REQUESTS 4 > > +#define UVC_NUM_REQUESTS 8 > > Can we rather make it 16? > I ran into similar issue on QCOM platform with DWC3 and with 8 requests also > data loss was observed. 16 requests (i.e. ~2msec) worked fine. I think 16 is ok. The value 4 has a bit too small .In hisilicon asic, I set the value 32(4ms) and it is ok. The bad impact is the need to expend more memory space. So therefore need to match with the respective chip platform to find the appropriate value. > > > #define UVC_MAX_REQUEST_SIZE 64 > > #define UVC_MAX_EVENTS 4 > > > > -- > > 2.7.4 > > > > N r y b X ǧv ^ ){.n +{ ^n r z h& G h ( > > 階 ݢj" m z ޖ f h ~ mml== > > -- > The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a > Linux Foundation Collaborative Project
Re: [PATCH] usb: gadget: uvc:change the UVC_NUM_REQUESTS value
Hi, On 12/26/2017 8:22 AM, Lipengcheng wrote: > The value is 4, it can cache four descriptors. When streaming_interval = 1, > it can tolerate 500us. Some busy scenes, it may be more than 500us because > cpu scheduling is not timely. There will have some problems. It is better > set to eight. > > Signed-off-by: Pengcheng Li > --- > drivers/usb/gadget/function/uvc.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/usb/gadget/function/uvc.h > b/drivers/usb/gadget/function/uvc.h > index a64e07e..901487e 100644 > --- a/drivers/usb/gadget/function/uvc.h > +++ b/drivers/usb/gadget/function/uvc.h > @@ -90,7 +90,7 @@ extern unsigned int uvc_gadget_trace_param; > * Driver specific constants > */ > > -#define UVC_NUM_REQUESTS 4 > +#define UVC_NUM_REQUESTS 8 Can we rather make it 16? I ran into similar issue on QCOM platform with DWC3 and with 8 requests also data loss was observed. 16 requests (i.e. ~2msec) worked fine. > #define UVC_MAX_REQUEST_SIZE 64 > #define UVC_MAX_EVENTS 4 > > -- > 2.7.4 > > N�r��y���b�X��ǧv�^�){.n�+{�^n�r���z���h&���G���h�(�階�ݢj"���m�z�ޖ���f���h���~�mml== -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project
[PATCH v3] ARM: dts: ls1021a: add support for Moxa UC-8410A open platform
Add support for Moxa UC-8410A open platform The UC-8410A computing platform is designed for embedded communication-centric industrial applications The features of UC-8410A are: * QSPI flash * SD slot * 3x LAN * 8x RS-232/422/485 ports, software-selectable * Mini PCIe form factor with PCIe/USB signal * 2x USB host * TPM * Watchdog * RTC * User LEDs * Beeper * Push button Signed-off-by: Jimmy Chen Signed-off-by: Harry YJ Jhou Signed-off-by: SZ Lin --- Changes from v2: - Replace underscore with hyphen in node name - Add unit address after nodes with 'reg' property - Sort nodes with unit-address in order of the address - Fix up unit-address in partitions node arch/arm/boot/dts/Makefile | 1 + arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts | 241 2 files changed, 242 insertions(+) create mode 100644 arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index d0381e9caf21..62ce9b27ad30 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -520,6 +520,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \ imx7s-colibri-eval-v3.dtb \ imx7s-warp.dtb dtb-$(CONFIG_SOC_LS1021A) += \ + ls1021a-moxa-uc-8410a.dtb \ ls1021a-qds.dtb \ ls1021a-twr.dtb dtb-$(CONFIG_SOC_VF610) += \ diff --git a/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts b/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts new file mode 100644 index ..d01f64b252b1 --- /dev/null +++ b/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts @@ -0,0 +1,241 @@ +/* + * Copyright (C) 2017 Moxa Inc. - https://www.moxa.com/ + * + * Author: Harry YJ Jhou (周亞諄) + * Jimmy Chen (陳永達) + * SZ Lin (林上智) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +/dts-v1/; + +#include +#include +#include "ls1021a.dtsi" + +/ { + model = "Moxa UC-8410A"; + + aliases { + enet0_rgmii_phy = &rgmii_phy0; + enet1_rgmii_phy = &rgmii_phy1; + enet2_rgmii_phy = &rgmii_phy2; + }; + + sys_mclk: clock-mclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <24576000>; + }; + + reg_3p3v: regulator-3p3v { + compatible = "regulator-fixed"; + regulator-name = "3P3V"; + regulator-min-microvolt = <330>; + regulator-max-microvolt = <330>; + regulator-always-on; + }; + + leds { + compatible = "gpio-leds"; + + cel-pwr { + label = "UC8410A:CEL-PWR"; + gpios = <&gpio3 27 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + cel-reset { + label = "UC8410A:CEL-RESET"; + gpios = <&gpio3 28 GPIO_ACTIVE_LOW>; + default-state = "off"; + }; + + str-led { + label = "UC8410A:RED:PROG"; + gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; + linux,default-trigger = "mmc0"; + }; + + sw-ready { + label = "UC8410A:GREEN:SWRDY"; + gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; + default-state = "on"; + }; + + beeper { + label = "UC8410A:BEEP"; + gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + prog-led0 { + label = "UC8410A:GREEN:PROG2"; + gpios = <&gpio3 14 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + prog-led1 { + label = "UC8410A:GREEN:PROG1"; + gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + prog-led2 { + label = "UC8410A:GREEN:PROG0"; + gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + wifi-signal0 { + label = "UC8410A:GREEN:CEL2"; + gpios = <&gpio3 17 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + wifi-signal1 { + label = "UC8410A:GREEN:CEL1"; + gpios = <&gpio3 18 GPIO_ACTIVE_HIGH>; + default-state = "off"; + }; + + wifi-signal2 { + label = "UC8410A:GREEN:CEL0"; + gpios = <&gpio3 19 GPIO_ACTIVE_HIGH>; +
Re: [PATCH v1 6/9] ufs: sysfs: string descriptors
Hi Stanislav, Thank you for the patch! Yet something to improve: [auto build test ERROR on scsi/for-next] [also build test ERROR on v4.15-rc5 next-20171222] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: x86_64-rhel (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): WARNING: modpost: missing MODULE_LICENSE() in drivers/hid/hid-holtekff.o see include/linux/module.h for more information WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/ufs/ufs-sysfs.o see include/linux/module.h for more information ERROR: "ufs_sysfs_add_device_management" [drivers/scsi/ufs/ufshcd.ko] undefined! ERROR: "ufs_sysfs_remove_device_management" [drivers/scsi/ufs/ufshcd.ko] undefined! >> ERROR: "ufshcd_read_string_desc" [drivers/scsi/ufs/ufs-sysfs.ko] undefined! ERROR: "ufshcd_query_descriptor_retry" [drivers/scsi/ufs/ufs-sysfs.ko] undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[Regression 4.15] Can't kill CONFIG_UNWINDER_ORC with fire or plague.
There is a regression new to 4.15 that happens in a rather common workflow which results in the frustrating situation where the user has clearly disabled UNWINDER_ORC in their ".config" file, and yet they still get the immediate false error saying they need libelf-dev since "CONFIG_UNWINDER_ORC=y" is still set, and hence they can not build. The regression requires UNWINDER_ORC=y (now the default in commit fc72ae40e303) followed by the user subsequently disabling it, which is common if the user doesn't have libelf-dev and doesn't care about ORC. This happens because the recently added test in the top level Makefile assumes that ,config data will be mapped into include/config/auto.conf either by the end user running "make oldconfig" or the Makefile itself detecting that "silentoldconfig" should be run. As the simple reproducer below shows, this clearly does not happen as expected. Note that the test for CONFIG_STACK_VALIDATION and libelf-dev in the same place in the Makefile is broken in the same way, but since it is a warning and not an error, nobody cared about the bogus false positives. Since there is no way I'm going to debug Makefile stuff on Christmas Day, I figured that I should at least report it intstead. The work around is to save your .config and run a "make distclean" or manually clobber the stale include/config/auto.conf or similar. But a frustrated user wouldn't know that w/o the root cause... - reproducer paul@gw:~/git/linux-head$ git describe v4.15-rc5 paul@gw:~/git/linux-head$ make distclean paul@gw:~/git/linux-head$ make defconfig HOSTCC scripts/basic/fixdep HOSTCC scripts/kconfig/conf.o SHIPPED scripts/kconfig/zconf.tab.c SHIPPED scripts/kconfig/zconf.lex.c HOSTCC scripts/kconfig/zconf.tab.o HOSTLD scripts/kconfig/conf *** Default configuration is based on 'x86_64_defconfig' # # configuration written to .config # paul@gw:~/git/linux-head$ make scripts/kconfig/conf --silentoldconfig Kconfig Makefile:926: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop. paul@gw:~/git/linux-head$ vi .config # disable ORC in favour of FRAME_POINTER paul@gw:~/git/linux-head$ make oldconfig scripts/kconfig/conf --oldconfig Kconfig # # configuration written to .config # paul@gw:~/git/linux-head$ grep UNWINDER .config # CONFIG_UNWINDER_ORC is not set CONFIG_UNWINDER_FRAME_POINTER=y paul@gw:~/git/linux-head$ make Makefile:926: *** "Cannot generate ORC metadata for CONFIG_UNWINDER_ORC=y, please install libelf-dev, libelf-devel or elfutils-libelf-devel". Stop. paul@gw:~/git/linux-head$ ls -l .config include/config/auto.conf -rw-rw-r-- 1 paul paul 115953 Dec 25 22:48 .config -rw-rw-r-- 1 paul paul 33069 Dec 25 22:46 include/config/auto.conf paul@gw:~/git/linux-head$ grep UNWINDER include/config/auto.conf CONFIG_UNWINDER_ORC=y paul@gw:~/git/linux-head$ - reproducer
Re: [PATCH] dm: add asymmetric stripe target device dirver
On 12/25/2017 07:52 PM, tgv...@gmail.com wrote: > From: liuchaowei > > This asymmetric stripe target device driver can achieve better io > performance between those devices which possess different io performance > > There are 2 storage device or flash devices: A and B, their sequential > read permance are 220M/s and 315M/s inspectively, so their sequential performancerespectively, > read speed could be approximately equal to 2:3, if we use stripe type > to combine these two devices, their layout could be showed below: > > |A1|A2|B1|B2|B3| > > > If we seletect asymmetric stripe type, their layout could be illustrated select > follow: > > | A1 | B1 | > > > The former has 5 stripe devices and each stripe device has also equal > chunk size, e.g.: 256secs. If there is a data block which size is > 1280secs, so transfer the data to this stripe defvice will be split device > to 5 ios which io size is 256secs. But if we use the asymmetric > stripe device, it only has two stripe devices and each one has be > setting in optimal chunk size, e.g.: ratio is 2:3, the first one > optimal chunk size is 512secs, the second is 768secs. And same > 1280secs data block just only be splited two ios, this can be achieve split into two ios, > perfect io performance. > > Change-Id: Iebaee3480e27022e2b3a7edbfb65425b1166274e > Signed-off-by: liuchaowei > --- > Documentation/device-mapper/asymmetric-striped.txt | 85 > drivers/md/Kconfig | 11 + > drivers/md/Makefile| 1 + > drivers/md/dm-asymmetric-stripe.c | 523 > + > drivers/md/dm.c| 5 + > include/linux/device-mapper.h | 15 + > 6 files changed, 640 insertions(+) > create mode 100644 Documentation/device-mapper/asymmetric-striped.txt > create mode 100644 drivers/md/dm-asymmetric-stripe.c > > diff --git a/Documentation/device-mapper/asymmetric-striped.txt > b/Documentation/device-mapper/asymmetric-striped.txt > new file mode 100644 > index ..0412a224a49e > --- /dev/null > +++ b/Documentation/device-mapper/asymmetric-striped.txt > @@ -0,0 +1,85 @@ > +dm-asymmetric-stripe > += > + > +Device-Mapper's "asm-striped" target is used to create a striped (i.e. > RAID-0) > +device across one or more underlying devices. Data is written in "chunks", > +with consecutive chunks rotating among the underlying devices. This can > +potentially provide improved I/O throughput by utilizing several physical > +devices in parallel. However, in order to gain maximum I/O performance > bewteen between > +slow and fast device, there is a ratio to set up the chunk size among these > +device. > + > +Parameters:[ ]+ > +: Number of underlying devices. > +: Size of each chunk of data. Must be at least as > +large as the system's PAGE_SIZE. > +: The proportion of per io size, it is the times as much > +as 1 chunk size > +: Full pathname to the underlying block-device, or a > +"major:minor" device-number. > +: Starting sector within the device. > + > +One or more underlying devices can be specified. The striped device > +size must be a multiple of the chunk size multiplied by the number of > underlying > +devices. However, there is a ratio can be setting, e.g.: 2:3 means the first > one there is a ratio that can be set, > +striped device optimal width size is 2 time as much as 1 chunk size, the > second times > +striped device is 3. > + > + > +Example scripts > +=== > + > +[[ > +#!/usr/bin/perl -w > +# Create a striped device across any number of underlying devices. The device > +# will be called "stripe_dev" and have a chunk-size of 128k. > + > +my $chunk_size = 128 * 2; > +my $ratio = "2:3"; > +my $dev_name = "stripe_dev"; > +my $num_devs = @ARGV; > +my @devs = @ARGV; > + > +if ($num_devs < 2) { > +die("Specify at least two devices\n"); > +} > + > + > +$stripe_average_size = 1073741824 > +$stripe_dev_size = $stripe_average_size * 5; > + > +$table = "0 $stripe_dev_size asm-striped $num_devs $chunk_size $ratio"; > +for ($i = 0; $i < $num_devs; $i++) { > +$table .= " $devs[$i] 0"; > +} > + > +`echo $table | dmsetup create $dev_name`; > +]] > + > + > +Why asymmetric striped > +=== > +Considering one case: > +There are 2 storage device or flash devices: A and B, their sequential > +read permance are 220M
[PATCH] MIPS: Loongson64: Drop 32-bit support for Loongson 2E/2F devices
Make loongson64 a pure 64-bit mach. Signed-off-by: Jiaxun Yang --- arch/mips/loongson64/Kconfig | 2 -- 1 file changed, 2 deletions(-) diff --git a/arch/mips/loongson64/Kconfig b/arch/mips/loongson64/Kconfig index 0d249fc3cfe9..a7d9a9241ac4 100644 --- a/arch/mips/loongson64/Kconfig +++ b/arch/mips/loongson64/Kconfig @@ -17,7 +17,6 @@ config LEMOTE_FULOONG2E select I8259 select ISA select IRQ_MIPS_CPU - select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_64BIT_KERNEL select SYS_SUPPORTS_LITTLE_ENDIAN select SYS_SUPPORTS_HIGHMEM @@ -49,7 +48,6 @@ config LEMOTE_MACH2F select ISA select SYS_HAS_CPU_LOONGSON2F select SYS_HAS_EARLY_PRINTK - select SYS_SUPPORTS_32BIT_KERNEL select SYS_SUPPORTS_64BIT_KERNEL select SYS_SUPPORTS_HIGHMEM select SYS_SUPPORTS_LITTLE_ENDIAN -- 2.15.1
Re: [PATCH v2] ARM: dts: ls1021a: add support for Moxa UC-8410A open platform
On Mon, Dec 11, 2017 at 07:51:25PM +0800, SZ Lin wrote: > Add support for Moxa UC-8410A open platform > > The UC-8410A computing platform is designed > for embedded communication-centric industrial applications > > The features of UC-8410A are: > * QSPI flash > * SD slot > * 3x LAN > * 8x RS-232/422/485 ports, software-selectable > * Mini PCIe form factor with PCIe/USB signal > * 2x USB host > * TPM > * Watchdog > * RTC > * User LEDs > * Beeper > * Push button > > Signed-off-by: Jimmy Chen > Signed-off-by: Harry YJ Jhou > Signed-off-by: SZ Lin > > -- > Changes from v1: > - Add newline between nodes > - Add push button node > - Insert newline between property list and child node > - Include file of "include/dt-bindings/gpio/gpio.h" > - Include file of "include/dt-bindings/input/input.h" > - Use polartiy defines for gpios to make it more readable > - Put 'status' at the end of property list > - Change GPIO pin number in cel_pwr and cel_reset > - Sort the labeled node alphabetically > - Drop container node of regulator and put fixed regulator directly > under root > --- > arch/arm/boot/dts/Makefile | 1 + > arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts | 241 > > 2 files changed, 242 insertions(+) > create mode 100644 arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts > > diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile > index d0381e9caf21..62ce9b27ad30 100644 > --- a/arch/arm/boot/dts/Makefile > +++ b/arch/arm/boot/dts/Makefile > @@ -520,6 +520,7 @@ dtb-$(CONFIG_SOC_IMX7D) += \ > imx7s-colibri-eval-v3.dtb \ > imx7s-warp.dtb > dtb-$(CONFIG_SOC_LS1021A) += \ > + ls1021a-moxa-uc-8410a.dtb \ > ls1021a-qds.dtb \ > ls1021a-twr.dtb > dtb-$(CONFIG_SOC_VF610) += \ > diff --git a/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts > b/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts > new file mode 100644 > index ..bc73b5187990 > --- /dev/null > +++ b/arch/arm/boot/dts/ls1021a-moxa-uc-8410a.dts > @@ -0,0 +1,241 @@ > +/* > + * Copyright (C) 2017 Moxa Inc. - https://www.moxa.com/ > + * > + * Author: Harry YJ Jhou (周亞諄) > + * Jimmy Chen (陳永達) > + * SZ Lin (林上智) > + * > + * This program is free software; you can redistribute it and/or modify > + * it under the terms of the GNU General Public License version 2 as > + * published by the Free Software Foundation. > + */ > + > +/dts-v1/; > + > +#include > +#include > +#include "ls1021a.dtsi" > + > +/ { > + model = "Moxa UC-8410A"; > + > + aliases { > + enet0_rgmii_phy = &rgmii_phy0; > + enet1_rgmii_phy = &rgmii_phy1; > + enet2_rgmii_phy = &rgmii_phy2; > + }; > + > + sys_mclk: clock-mclk { > + compatible = "fixed-clock"; > + #clock-cells = <0>; > + clock-frequency = <24576000>; > + }; > + > + reg_3p3v: regulator-3p3v { > + compatible = "regulator-fixed"; > + regulator-name = "3P3V"; > + regulator-min-microvolt = <330>; > + regulator-max-microvolt = <330>; > + regulator-always-on; > + }; > + > + leds { > + compatible = "gpio-leds"; > + > + cel_pwr { We generally use hyphen rather than underscore in node name. > + label = "UC8410A:CEL-PWR"; > + gpios = <&gpio3 27 GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + cel_reset { > + label = "UC8410A:CEL-RESET"; > + gpios = <&gpio3 28 GPIO_ACTIVE_LOW>; > + default-state = "off"; > + }; > + > + str_led { > + label = "UC8410A:RED:PROG"; > + gpios = <&gpio0 16 GPIO_ACTIVE_HIGH>; > + linux,default-trigger = "mmc0"; > + }; > + > + sw_ready { > + label = "UC8410A:GREEN:SWRDY"; > + gpios = <&gpio0 18 GPIO_ACTIVE_HIGH>; > + default-state = "on"; > + }; > + > + beeper { > + label = "UC8410A:BEEP"; > + gpios = <&gpio0 20 GPIO_ACTIVE_HIGH>; > + default-state = "off"; > + }; > + > + prog_led0 { > + label = "UC8410A:GREEN:PROG2"; > + gpios = <&gpio3 14 GPIO_ACTIVE_HIGH>; > + default-state = "off"; > + }; > + > + prog_led1 { > + label = "UC8410A:GREEN:PROG1"; > + gpios = <&gpio3 15 GPIO_ACTIVE_HIGH>; > + default-state = "off"; > + }; > + > + prog_led2 { > + label = "UC8410A:GREEN:PROG0"; > + gpios = <&gpio3 16 GPIO_ACTIVE_HIGH>; > + default-state = "off"; > +
[PATCH] dm: add asymmetric stripe target device dirver
From: liuchaowei This asymmetric stripe target device driver can achieve better io performance between those devices which possess different io performance There are 2 storage device or flash devices: A and B, their sequential read permance are 220M/s and 315M/s inspectively, so their sequential read speed could be approximately equal to 2:3, if we use stripe type to combine these two devices, their layout could be showed below: |A1|A2|B1|B2|B3| If we seletect asymmetric stripe type, their layout could be illustrated follow: | A1 | B1 | The former has 5 stripe devices and each stripe device has also equal chunk size, e.g.: 256secs. If there is a data block which size is 1280secs, so transfer the data to this stripe defvice will be split to 5 ios which io size is 256secs. But if we use the asymmetric stripe device, it only has two stripe devices and each one has be setting in optimal chunk size, e.g.: ratio is 2:3, the first one optimal chunk size is 512secs, the second is 768secs. And same 1280secs data block just only be splited two ios, this can be achieve perfect io performance. Change-Id: Iebaee3480e27022e2b3a7edbfb65425b1166274e Signed-off-by: liuchaowei --- Documentation/device-mapper/asymmetric-striped.txt | 85 drivers/md/Kconfig | 11 + drivers/md/Makefile| 1 + drivers/md/dm-asymmetric-stripe.c | 523 + drivers/md/dm.c| 5 + include/linux/device-mapper.h | 15 + 6 files changed, 640 insertions(+) create mode 100644 Documentation/device-mapper/asymmetric-striped.txt create mode 100644 drivers/md/dm-asymmetric-stripe.c diff --git a/Documentation/device-mapper/asymmetric-striped.txt b/Documentation/device-mapper/asymmetric-striped.txt new file mode 100644 index ..0412a224a49e --- /dev/null +++ b/Documentation/device-mapper/asymmetric-striped.txt @@ -0,0 +1,85 @@ +dm-asymmetric-stripe += + +Device-Mapper's "asm-striped" target is used to create a striped (i.e. RAID-0) +device across one or more underlying devices. Data is written in "chunks", +with consecutive chunks rotating among the underlying devices. This can +potentially provide improved I/O throughput by utilizing several physical +devices in parallel. However, in order to gain maximum I/O performance bewteen +slow and fast device, there is a ratio to set up the chunk size among these +device. + +Parameters:[ ]+ +: Number of underlying devices. +: Size of each chunk of data. Must be at least as +large as the system's PAGE_SIZE. +: The proportion of per io size, it is the times as much +as 1 chunk size +: Full pathname to the underlying block-device, or a +"major:minor" device-number. +: Starting sector within the device. + +One or more underlying devices can be specified. The striped device +size must be a multiple of the chunk size multiplied by the number of underlying +devices. However, there is a ratio can be setting, e.g.: 2:3 means the first one +striped device optimal width size is 2 time as much as 1 chunk size, the second +striped device is 3. + + +Example scripts +=== + +[[ +#!/usr/bin/perl -w +# Create a striped device across any number of underlying devices. The device +# will be called "stripe_dev" and have a chunk-size of 128k. + +my $chunk_size = 128 * 2; +my $ratio = "2:3"; +my $dev_name = "stripe_dev"; +my $num_devs = @ARGV; +my @devs = @ARGV; + +if ($num_devs < 2) { +die("Specify at least two devices\n"); +} + + +$stripe_average_size = 1073741824 +$stripe_dev_size = $stripe_average_size * 5; + +$table = "0 $stripe_dev_size asm-striped $num_devs $chunk_size $ratio"; +for ($i = 0; $i < $num_devs; $i++) { +$table .= " $devs[$i] 0"; +} + +`echo $table | dmsetup create $dev_name`; +]] + + +Why asymmetric striped +=== +Considering one case: +There are 2 storage device or flash devices: A and B, their sequential +read permance are 220M/s and 315M/s inspectively, so their sequential +read speed could be approximately equal to 2:3, if we use stripe type +to combine these two devices, their layout could be showed below: + +|A1|A2|B1|B2|B3| + + +If we seletect asymmetric stripe type, their layout could be illustrated +follow: + +| A1 | B1 | + + +The former has 5 stripe devices and each stri
[PATCH] clk: mediatek: adjust dependency of reset.c to avoid unexpectedly being built
From: Sean Wang commit 74cb0d6dde8 ("clk: mediatek: fixup test-building of MediaTek clock drivers") can let the build system looking into the directory where the clock drivers resides and then allow test-building the drivers. But the change also gives rise to certain incorrect behavior which is reset.c being built even not depending on either COMPILE_TEST or ARCH_MEDIATEK alternative dependency. To get rid of reset.c being built unexpectedly on the other platforms, it would be a good change that the file should be built depending on its own specific configuration rather than just on generic RESET_CONTROLLER one. Signed-off-by: Sean Wang Cc: Jean Delvare --- drivers/clk/mediatek/Kconfig | 7 +++ drivers/clk/mediatek/Makefile | 2 +- drivers/clk/mediatek/clk-mtk.h | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/drivers/clk/mediatek/Kconfig b/drivers/clk/mediatek/Kconfig index 7338f81..52d880a 100644 --- a/drivers/clk/mediatek/Kconfig +++ b/drivers/clk/mediatek/Kconfig @@ -9,6 +9,13 @@ config COMMON_CLK_MEDIATEK ---help--- MediaTek SoCs' clock support. +config RESET_MEDIATEK + bool "MediaTek Reset Driver" + depends on ARCH_MEDIATEK || COMPILE_TEST + depends on RESET_CONTROLLER + help + This enables the reset controller driver used on MediaTek SoCs. + config COMMON_CLK_MT2701 bool "Clock driver for MediaTek MT2701" depends on (ARCH_MEDIATEK && ARM) || COMPILE_TEST diff --git a/drivers/clk/mediatek/Makefile b/drivers/clk/mediatek/Makefile index c421ffc..2a48006 100644 --- a/drivers/clk/mediatek/Makefile +++ b/drivers/clk/mediatek/Makefile @@ -1,6 +1,6 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_COMMON_CLK_MEDIATEK) += clk-mtk.o clk-pll.o clk-gate.o clk-apmixed.o clk-cpumux.o -obj-$(CONFIG_RESET_CONTROLLER) += reset.o +obj-$(CONFIG_RESET_MEDIATEK) += reset.o obj-$(CONFIG_COMMON_CLK_MT6797) += clk-mt6797.o obj-$(CONFIG_COMMON_CLK_MT6797_IMGSYS) += clk-mt6797-img.o obj-$(CONFIG_COMMON_CLK_MT6797_MMSYS) += clk-mt6797-mm.o diff --git a/drivers/clk/mediatek/clk-mtk.h b/drivers/clk/mediatek/clk-mtk.h index bf8006d..0322dec 100644 --- a/drivers/clk/mediatek/clk-mtk.h +++ b/drivers/clk/mediatek/clk-mtk.h @@ -229,7 +229,7 @@ void mtk_clk_register_plls(struct device_node *node, struct clk *mtk_clk_register_ref2usb_tx(const char *name, const char *parent_name, void __iomem *reg); -#ifdef CONFIG_RESET_CONTROLLER +#ifdef CONFIG_RESET_MEDIATEK void mtk_register_reset_controller(struct device_node *np, unsigned int num_regs, int regofs); #else -- 2.7.4
Re: [PATCH] arm: imx: suspend/resume: use outer_disable/resume
On Sun, Dec 10, 2017 at 08:07:18PM +0800, Peng Fan wrote: > Use outer_disable/resume for suspend/resume. > With the two APIs used, code could be simplified and easy to extend > to introduce l2c_write_sec for i.MX platforms when moving Linux Kernel > runs in non-secure world. > > Signed-off-by: Peng Fan > Cc: Shawn Guo > Cc: Sascha Hauer > Cc: Fabio Estevam > Cc: Russell King > Cc: Dong Aisheng > --- > arch/arm/mach-imx/pm-imx6.c | 2 ++ > arch/arm/mach-imx/suspend-imx6.S | 24 I'm fine with the patch in general. But this piece of code is running on a few i.MX6 platforms, and I'm wondering on which SoCs you have verified the change work fine. Shawn
[PATCH v6 3/4] MIPS: Loongson64: Load platform device during boot
This patch just add pdev during boot to load the platform driver Signed-off-by: Jiaxun Yang --- arch/mips/loongson64/lemote-2f/Makefile | 2 +- arch/mips/loongson64/lemote-2f/platform.c | 25 + 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 arch/mips/loongson64/lemote-2f/platform.c diff --git a/arch/mips/loongson64/lemote-2f/Makefile b/arch/mips/loongson64/lemote-2f/Makefile index 08b8abcbfef5..31c90737b98c 100644 --- a/arch/mips/loongson64/lemote-2f/Makefile +++ b/arch/mips/loongson64/lemote-2f/Makefile @@ -2,7 +2,7 @@ # Makefile for lemote loongson2f family machines # -obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o +obj-y += clock.o machtype.o irq.o reset.o ec_kb3310b.o platform.o # # Suspend Support diff --git a/arch/mips/loongson64/lemote-2f/platform.c b/arch/mips/loongson64/lemote-2f/platform.c new file mode 100644 index ..e0007f6c456a --- /dev/null +++ b/arch/mips/loongson64/lemote-2f/platform.c @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2017 Jiaxun Yang +* +*/ + +#include +#include + +#include + +static struct platform_device yeeloong_pdev = { + .name = "yeeloong_laptop", + .id = -1, +}; + +static int __init lemote2f_platform_init(void) +{ + if (mips_machtype != MACH_LEMOTE_YL2F89) + return -ENODEV; + + return platform_device_register(&yeeloong_pdev); +} + +arch_initcall(lemote2f_platform_init); -- 2.15.1
[PATCH v6 1/4] MIPS: Loongson64: lemote-2f move ec_kb3310b.h to include dir and clean up
To operate EC from platform driver, this head file need able to be include from anywhere. This patch just move ec_kb3310b.h to include dir and clean up ec_kb3310b.h. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/mach-loongson64/ec_kb3310b.h | 170 +++ arch/mips/loongson64/lemote-2f/ec_kb3310b.c| 2 +- arch/mips/loongson64/lemote-2f/ec_kb3310b.h| 188 - arch/mips/loongson64/lemote-2f/pm.c| 4 +- arch/mips/loongson64/lemote-2f/reset.c | 4 +- 5 files changed, 175 insertions(+), 193 deletions(-) create mode 100644 arch/mips/include/asm/mach-loongson64/ec_kb3310b.h delete mode 100644 arch/mips/loongson64/lemote-2f/ec_kb3310b.h diff --git a/arch/mips/include/asm/mach-loongson64/ec_kb3310b.h b/arch/mips/include/asm/mach-loongson64/ec_kb3310b.h new file mode 100644 index ..2e8690532ea5 --- /dev/null +++ b/arch/mips/include/asm/mach-loongson64/ec_kb3310b.h @@ -0,0 +1,170 @@ +/* + * KB3310B Embedded Controller + * + * Copyright (C) 2008 Lemote Inc. + * Author: liujl , 2008-03-14 + * Copyright (C) 2009 Lemote Inc. + * Author: Wu Zhangjin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + */ + +#ifndef _EC_KB3310B_H +#define _EC_KB3310B_H + +extern unsigned char ec_read(unsigned short addr); +extern void ec_write(unsigned short addr, unsigned char val); +extern int ec_query_seq(unsigned char cmd); +extern int ec_query_event_num(void); +extern int ec_get_event_num(void); + +typedef int (*sci_handler) (int status); +extern sci_handler yeeloong_report_lid_status; + +#define ON 1 +#define OFF0 + +#define SCI_IRQ_NUM 0x0A + +/* + * The following registers are determined by the EC index configuration. + * 1, fill the PORT_HIGH as EC register high part. + * 2, fill the PORT_LOW as EC register low part. + * 3, fill the PORT_DATA as EC register write data or get the data from it. + */ +#defineEC_IO_PORT_HIGH 0x0381 +#defineEC_IO_PORT_LOW 0x0382 +#defineEC_IO_PORT_DATA 0x0383 + +/* + * EC delay time is 500us for register and status access + */ +#defineEC_REG_DELAY500 /* unit : us */ +#defineEC_CMD_TIMEOUT 0x1000 + +/* + * EC access port for SCI communication + */ +#defineEC_CMD_PORT 0x66 +#defineEC_STS_PORT 0x66 +#defineEC_DAT_PORT 0x62 +#defineCMD_INIT_IDLE_MODE 0xdd +#defineCMD_EXIT_IDLE_MODE 0xdf +#defineCMD_INIT_RESET_MODE 0xd8 +#defineCMD_REBOOT_SYSTEM 0x8c +#defineCMD_GET_EVENT_NUM 0x84 +#defineCMD_PROGRAM_PIECE 0xda + +/* Temperature & Fan registers */ +#defineREG_TEMPERATURE_VALUE 0xF458 +#defineREG_FAN_AUTO_MAN_SWITCH 0xF459 +#defineBIT_FAN_AUTO0 +#defineBIT_FAN_MANUAL 1 +#defineREG_FAN_CONTROL 0xF4D2 +#defineREG_FAN_STATUS 0xF4DA +#defineREG_FAN_SPEED_HIGH 0xFE22 +#defineREG_FAN_SPEED_LOW 0xFE23 +#defineREG_FAN_SPEED_LEVEL 0xF4CC +/* Fan speed divider */ +#defineFAN_SPEED_DIVIDER 48 /* (60*1000*1000/62.5/2)*/ + +/* Battery registers */ +#defineREG_BAT_DESIGN_CAP_HIGH 0xF77D +#defineREG_BAT_DESIGN_CAP_LOW 0xF77E +#defineREG_BAT_FULLCHG_CAP_HIGH0xF780 +#defineREG_BAT_FULLCHG_CAP_LOW 0xF781 +#defineREG_BAT_DESIGN_VOL_HIGH 0xF782 +#defineREG_BAT_DESIGN_VOL_LOW 0xF783 +#defineREG_BAT_CURRENT_HIGH0xF784 +#defineREG_BAT_CURRENT_LOW 0xF785 +#defineREG_BAT_VOLTAGE_HIGH0xF786 +#defineREG_BAT_VOLTAGE_LOW 0xF787 +#defineREG_BAT_TEMPERATURE_HIGH0xF788 +#defineREG_BAT_TEMPERATURE_LOW 0xF789 +#defineREG_BAT_RELATIVE_CAP_HIGH 0xF492 +#defineREG_BAT_RELATIVE_CAP_LOW0xF493 +#defineREG_BAT_VENDOR 0xF4C4 +#defineFLAG_BAT_VENDOR_SANYO 0x01 +#defineFLAG_BAT_VENDOR_SIMPLO 0x02 +#defineREG_BAT_CELL_COUNT 0xF4C6 +#defineFLAG_BAT_CELL_3S1P 0x03 +#defineFLAG_BAT_CELL_3S2P 0x06 +#defineREG_BAT_CHARGE 0xF4A2 +#defineFLAG_BAT_CHARGE_DISCHARGE 0x01 +#defineFLAG_BAT_CHARGE_CHARGE 0x02 +#defineFLAG_BAT_CHARGE_ACPOWER 0x00 +#defineREG_BAT_STATUS 0xF4B0 +#defineBIT_BAT_STATUS_LOW (1 << 5) +#defineBIT_BAT_STATUS_DESTROY (1 << 2) +#defineBIT_BAT_STATUS_FULL (1 << 1) +#defineBIT_
Add YeeLoong support v6
Change since v5: Use arcs_cmdline instead of loongson_cmdline Fix GPL copyright issues Change since v4: Use SPDX ids copyright header
[PATCH v6 2/4] MIPS: Loongson64: Yeeloong add platform driver
Yeeloong is a laptop with a MIPS Loongson 2F processor, AMD CS5536 chipset, and KB3310B controller. This yeeloong_laptop module enables access to sensors, battery, video camera switch, external video connector event, and some additional buttons. This driver was orginally from linux-loongson-community. I Just do some clean up and port to mainline kernel tree. Signed-off-by: Jiaxun Yang --- drivers/platform/mips/Kconfig | 19 + drivers/platform/mips/Makefile |3 + drivers/platform/mips/yeeloong_laptop.c | 1141 +++ 3 files changed, 1163 insertions(+) create mode 100755 drivers/platform/mips/yeeloong_laptop.c diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig index b3ae30a4c67b..acd27e36710b 100644 --- a/drivers/platform/mips/Kconfig +++ b/drivers/platform/mips/Kconfig @@ -23,4 +23,23 @@ config CPU_HWMON help Loongson-3A/3B CPU Hwmon (temperature sensor) driver. +config LEMOTE_YEELOONG2F + tristate "Lemote YeeLoong Laptop" + depends on LEMOTE_MACH2F + select BACKLIGHT_LCD_SUPPORT + select LCD_CLASS_DEVICE + select BACKLIGHT_CLASS_DEVICE + select POWER_SUPPLY + select HWMON + select INPUT + select INPUT_MISC + select INPUT_SPARSEKMAP + select INPUT_EVDEV + default m + help + YeeLoong netbook is a mini laptop made by Lemote, which is basically + compatible to FuLoong2F mini PC, but it has an extra Embedded + Controller(kb3310b) for battery, hotkey, backlight, temperature and + fan management. + endif # MIPS_PLATFORM_DEVICES diff --git a/drivers/platform/mips/Makefile b/drivers/platform/mips/Makefile index 8dfd03924c37..b3172b081a2f 100644 --- a/drivers/platform/mips/Makefile +++ b/drivers/platform/mips/Makefile @@ -1 +1,4 @@ obj-$(CONFIG_CPU_HWMON) += cpu_hwmon.o + +obj-$(CONFIG_LEMOTE_YEELOONG2F)+= yeeloong_laptop.o +CFLAGS_yeeloong_laptop.o = -I$(srctree)/arch/mips/loongson/lemote-2f diff --git a/drivers/platform/mips/yeeloong_laptop.c b/drivers/platform/mips/yeeloong_laptop.c new file mode 100755 index ..dc2189e1df26 --- /dev/null +++ b/drivers/platform/mips/yeeloong_laptop.c @@ -0,0 +1,1141 @@ +/* SPDX-License-Identifier: GPL */ + +/* + * Driver for YeeLoong laptop extras + * + * Copyright (C) 2017 Jiaxun Yang + * + * Copyright (C) 2009 Lemote Inc. + * Author: Wu Zhangjin , Liu Junliang + * + * Fixes: Petr Pisar , 2012, 2013, 2014, 2015. + * + */ + +#include +#include +#include/* for backlight subdriver */ +#include +#include/* for hwmon subdriver */ +#include +#include/* for clamp_val() */ +#include/* for hotkey subdriver */ +#include +#include +#include +#include /* for AC & Battery subdriver */ +#include/* For MODULE_DEVICE_TABLE() */ + +#include + +#include + +#include /* for arcs_cmdline */ +#include + +/* common function */ +#define EC_VER_LEN 64 + +static int ec_version_before(char *version) +{ + char *p, ec_ver[EC_VER_LEN]; + + p = strstr(arcs_cmdline, "EC_VER="); + if (!p) + memset(ec_ver, 0, EC_VER_LEN); + else { + strncpy(ec_ver, p, EC_VER_LEN); + p = strstr(ec_ver, " "); + if (p) + *p = '\0'; + } + + return (strncasecmp(ec_ver, version, 64) < 0); +} + +/* backlight subdriver */ +#define MAX_BRIGHTNESS 8 + +static int yeeloong_set_brightness(struct backlight_device *bd) +{ + unsigned int level, current_level; + static unsigned int old_level; + + level = (bd->props.fb_blank == FB_BLANK_UNBLANK && +bd->props.power == FB_BLANK_UNBLANK) ? + bd->props.brightness : 0; + + level = clamp_val(level, 0, MAX_BRIGHTNESS); + + /* Avoid to modify the brightness when EC is tuning it */ + if (old_level != level) { + current_level = ec_read(REG_DISPLAY_BRIGHTNESS); + if (old_level == current_level) + ec_write(REG_DISPLAY_BRIGHTNESS, level); + old_level = level; + } + + return 0; +} + +static int yeeloong_get_brightness(struct backlight_device *bd) +{ + return ec_read(REG_DISPLAY_BRIGHTNESS); +} + +const struct backlight_ops backlight_ops = { + .get_brightness = yeeloong_get_brightness, + .update_status = yeeloong_set_brightness, +}; + +static struct backlight_device *yeeloong_backlight_dev; + +static int yeeloong_backlight_init(void) +{ + int ret; + struct backlight_properties props; + + memset(&props, 0, sizeof(struct backlight_properties)); + props.type = BACKLIGHT_RAW; + props.max_brightness = MAX_BRIGHTNESS; + yeeloong_backlight_dev = backlight_device_register("backlight0", NULL, + NULL, &backlight_ops, &props); + + if (IS_ERR(yeeloong_backlight_dev)) { + ret = PTR_ERR(yeeloo
[PATCH v6 4/4] MAINTAINERS: Add entry for Lemote YeeLoong Extra Driver
Add myself as a maintainer of Lemote YeeLoong Extra driver Signed-off-by: Jiaxun Yang --- MAINTAINERS | 6 ++ 1 file changed, 6 insertions(+) mode change 100644 => 100755 MAINTAINERS diff --git a/MAINTAINERS b/MAINTAINERS old mode 100644 new mode 100755 index a6e86e20761e..5a7c0d4b233a --- a/MAINTAINERS +++ b/MAINTAINERS @@ -7873,6 +7873,12 @@ W: http://legousb.sourceforge.net/ S: Maintained F: drivers/usb/misc/legousbtower.c +Lemote YeeLoong EXTRAS DRIVER +M: Jiaxun Yang +L: linux-m...@linux-mips.org +S: Maintained +F: drivers/platform/mips/yeeloong_laptop.c + LG2160 MEDIA DRIVER M: Michael Krufky L: linux-me...@vger.kernel.org -- 2.15.1
Re: [PATCH v20 4/7] virtio-balloon: VIRTIO_BALLOON_F_SG
On 12/25/2017 10:51 PM, Tetsuo Handa wrote: Wei Wang wrote: @@ -173,8 +292,15 @@ static unsigned fill_balloon(struct virtio_balloon *vb, size_t num) while ((page = balloon_page_pop(&pages))) { balloon_page_enqueue(&vb->vb_dev_info, page); +if (use_sg) { +if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { +__free_page(page); +continue; +} +} else { +set_page_pfns(vb, vb->pfns + vb->num_pfns, page); +} Is this the right behaviour? I don't think so. In the worst case, we can set no bit using xb_set_page(). If we can't record the page in the xb, wouldn't we rather send it across as a single page? I think that we need to be able to fallback to !use_sg path when OOM. I also have different thoughts: 1) For OOM, we have leak_balloon_sg_oom (oom has nothing to do with fill_balloon), which does not use xbitmap to record pages, thus no memory allocation. 2) If the memory is already under pressure, it is pointless to continue inflating memory to the host. We need to give thanks to the memory allocation failure reported by xbitmap, which gets us a chance to release the inflated pages that have been demonstrated to cause the memory pressure of the guest. Forgot to add my conclusion: I think the above behavior is correct. What is the desired behavior when hitting OOM path during inflate/deflate? Once inflation started, the inflation logic is called again and again until the balloon inflates to the requested size. The above is true, but I can't agree with the following. Please see below. Such situation will continue wasting CPU resource between inflate-due-to-host's-request versus deflate-due-to-guest's-OOM. It is pointless but cannot stop doing pointless thing. What we are doing here is to free the pages that were just allocated in this round of inflating. Next round will be sometime later when the balloon work item gets its turn to run. Yes, it will then continue to inflate. Here are the two cases that will happen then: 1) the guest is still under memory pressure, the inflate will fail at memory allocation, which results in a msleep(200), and then it exists for another time to run. 2) the guest isn't under memory pressure any more (e.g. the task which consumes the huge amount of memory is gone), it will continue to inflate as normal till the requested size. I think what we are doing is a quite sensible behavior, except a small change I plan to make: while ((page = balloon_page_pop(&pages))) { - balloon_page_enqueue(&vb->vb_dev_info, page); if (use_sg) { if (xb_set_page(vb, page, &pfn_min, &pfn_max) < 0) { __free_page(page); continue; } } else { set_page_pfns(vb, vb->pfns + vb->num_pfns, page); } + balloon_page_enqueue(&vb->vb_dev_info, page); Also, as of Linux 4.15, only up to VIRTIO_BALLOON_ARRAY_PFNS_MAX pages (i.e. 1MB) are invisible from deflate request. That amount would be an acceptable error. But your patch makes more pages being invisible, for pages allocated by balloon_page_alloc() without holding balloon_lock are stored into a local variable "LIST_HEAD(pages)" (which means that balloon_page_dequeue() with balloon_lock held won't be able to find pages not yet queued by balloon_page_enqueue()), doesn't it? What if all memory pages were held in "LIST_HEAD(pages)" and balloon_page_dequeue() was called before balloon_page_enqueue() is called? If we think of the balloon driver just as a regular driver or application, that will be a pretty nature thing. A regular driver can eat a huge amount of memory for its own usages, would this amount of memory be treated as an error as they are invisible to the balloon_page_enqueue? Best, Wei
Re: [PATCH net-next v8 1/2] dt-bindings: net: add DT bindings for Socionext UniPhier AVE
On December 24, 2017 5:10:37 PM PST, Kunihiko Hayashi wrote: >DT bindings for the AVE ethernet controller found on Socionext's >UniPhier platforms. > >Signed-off-by: Kunihiko Hayashi >Signed-off-by: Jassi Brar >Acked-by: Rob Herring Reviewed-by: Florian Fainelli -- Florian
[PATCH] usb: gadget: uvc:change the UVC_NUM_REQUESTS value
The value is 4, it can cache four descriptors. When streaming_interval = 1, it can tolerate 500us. Some busy scenes, it may be more than 500us because cpu scheduling is not timely. There will have some problems. It is better set to eight. Signed-off-by: Pengcheng Li --- drivers/usb/gadget/function/uvc.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index a64e07e..901487e 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -90,7 +90,7 @@ extern unsigned int uvc_gadget_trace_param; * Driver specific constants */ -#define UVC_NUM_REQUESTS 4 +#define UVC_NUM_REQUESTS 8 #define UVC_MAX_REQUEST_SIZE 64 #define UVC_MAX_EVENTS 4 -- 2.7.4
Re: [PATCH v1 1/9] ufs: sysfs: device descriptor
Hi Stanislav, Thank you for the patch! Yet something to improve: [auto build test ERROR on scsi/for-next] [also build test ERROR on v4.15-rc5 next-20171222] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next config: x86_64-kexec (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): WARNING: modpost: missing MODULE_LICENSE() in drivers/scsi/ufs/ufs-sysfs.o see include/linux/module.h for more information >> ERROR: "ufs_sysfs_remove_device_management" [drivers/scsi/ufs/ufshcd.ko] >> undefined! >> ERROR: "ufs_sysfs_add_device_management" [drivers/scsi/ufs/ufshcd.ko] >> undefined! >> ERROR: "ufshcd_query_descriptor_retry" [drivers/scsi/ufs/ufs-sysfs.ko] >> undefined! --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[PATCH v2] perf report: Fix a no annotate browser displayed issue
v2: -- Fix a crash bug when perform 'perf report --stdio'. The reason is that we init the symbol annotation only in browser mode, it doesn't allocate/init resources for stdio mode. So now in hist_iter__branch_callback(), it will return directly if it's not in browser mode. initial post When enabling '-b' option in perf record, for example, perf record -b ... perf report and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed). It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly. notes = symbol__annotation(act->ms.sym); if (!notes->src) return 0; This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback). Signed-off-by: Jin Yao --- tools/perf/builtin-report.c | 18 +- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index eb9ce63..07827cd 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -162,12 +162,28 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter, struct hist_entry *he = iter->he; struct report *rep = arg; struct branch_info *bi; + struct perf_sample *sample = iter->sample; + struct perf_evsel *evsel = iter->evsel; + int err; + + if (!ui__has_annotation()) + return 0; + + hist__account_cycles(sample->branch_stack, al, sample, +rep->nonany_branch_mode); bi = he->branch_info; + err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx); + if (err) + goto out; + + err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx); + branch_type_count(&rep->brtype_stat, &bi->flags, bi->from.addr, bi->to.addr); - return 0; +out: + return err; } static int process_sample_event(struct perf_tool *tool, -- 2.7.4
[RFC PATCH v12 2/5] of/irq: Adjust of_pci_irq parsing for multiple interrupts
Currently we are considering the first irq as the PCI interrupt pin, but a PCI device may have multiple interrupts(e.g. PCIe WAKE# pin). Only parse the PCI interrupt pin when the irq is unnamed or named as "pci". Signed-off-by: Jeffy Chen --- Changes in v13: None Changes in v12: None Changes in v11: Address Brian's comments. Changes in v10: None Changes in v9: None Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v3: None Changes in v2: None drivers/of/of_pci_irq.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 3a05568f65df..d39565d5477b 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -27,9 +27,25 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq */ dn = pci_device_to_OF_node(pdev); if (dn) { - rc = of_irq_parse_one(dn, 0, out_irq); - if (!rc) - return rc; + struct property *prop; + const char *name; + int index = 0; + + of_property_for_each_string(dn, "interrupt-names", prop, name) { + if (!strcmp(name, "pci")) + break; + index++; + } + + /* +* Only parse from DT if we have no "interrupt-names", +* or if we found an interrupt named "pci". +*/ + if (index == 0 || name) { + rc = of_irq_parse_one(dn, index, out_irq); + if (!rc) + return rc; + } } /* Ok, we don't, time to have fun. Let's start by building up an -- 2.11.0
[RFC PATCH v12 5/5] arm64: dts: rockchip: Move PCIe WAKE# irq to pcie port for Gru
Currently we are handling PCIe WAKE# irq in mrvl wifi driver. Move it to rockchip pcie port since we are going to handle it in the pci core. Also avoid this irq been considered as the PCI interrupt pin in the of_irq_parse_pci(). Signed-off-by: Jeffy Chen --- Changes in v13: None Changes in v12: None Changes in v11: Move to pcie port as Brian suggested. Changes in v10: None Changes in v9: Rewrite the commit message. Changes in v8: Rewrite the commit message. Changes in v7: None Changes in v6: None Changes in v5: Use "wakeup" instead of "wake" Changes in v3: None Changes in v2: None arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi index 03f195025390..be41d363efd8 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi @@ -719,15 +719,16 @@ ap_i2c_audio: &i2c8 { #size-cells = <2>; ranges; + interrupts-extended = <&pcie0 1>, <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "pci", "wakeup"; + pinctrl-names = "default"; + pinctrl-0 = <&wlan_host_wake_l>; + wakeup-source; + mvl_wifi: wifi@0,0 { compatible = "pci1b4b,2b42"; reg = <0x8301 0x0 0x 0x0 0x0010 0x8301 0x0 0x0010 0x0 0x0010>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&wlan_host_wake_l>; - wakeup-source; }; }; }; -- 2.11.0
[RFC PATCH v12 4/5] PCI / PM: Add support for the PCIe WAKE# signal for OF
Add of_pci_setup_wake_irq() and of_pci_teardown_wake_irq() to handle the PCIe WAKE# interrupt. Also use the dedicated wakeirq infrastructure to simplify it. And add pci-of.c to enable/disable the wakeup irq in noirq stage to avoid possible irq storm. Signed-off-by: Jeffy Chen --- Changes in v13: Fix compiler error reported by kbuild test robot Changes in v12: Enable the wake irq in noirq stage to avoid possible irq storm. Changes in v11: Only support 1-per-device PCIe WAKE# pin as suggested. Changes in v10: Use device_set_wakeup_capable() instead of device_set_wakeup_enable(), since dedicated wakeirq will be lost in device_set_wakeup_enable(false). Changes in v9: Fix check error in .cleanup(). Move dedicated wakeirq setup to setup() callback and use device_set_wakeup_enable() to enable/disable. Changes in v8: Add pci-of.c and use platform_pm_ops to handle the PCIe WAKE# signal. Changes in v7: Move PCIE_WAKE handling into pci core. Changes in v6: Fix device_init_wake error handling, and add some comments. Changes in v5: Rebase. Changes in v3: Fix error handling. Changes in v2: Use dev_pm_set_dedicated_wake_irq. drivers/of/of_pci_irq.c | 49 +++ drivers/pci/Makefile | 1 + drivers/pci/pci-driver.c | 10 +++ drivers/pci/pci-of.c | 75 include/linux/of_pci.h | 9 ++ 5 files changed, 144 insertions(+) create mode 100644 drivers/pci/pci-of.c diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index d39565d5477b..abec3a44853b 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -1,8 +1,57 @@ #include #include #include +#include #include +int of_pci_setup_wake_irq(struct pci_dev *pdev) +{ + struct pci_dev *ppdev; + struct device_node *dn; + int ret, irq; + + /* Get the pci_dev of our parent. Hopefully it's a port. */ + ppdev = pdev->bus->self; + /* Nope, it's a host bridge. */ + if (!ppdev) + return 0; + + dn = pci_device_to_OF_node(ppdev); + if (!dn) + return 0; + + irq = of_irq_get_byname(dn, "wakeup"); + if (irq == -EPROBE_DEFER) { + return irq; + } else if (irq < 0) { + /* Ignore other errors, since a missing wakeup is non-fatal. */ + dev_info(&pdev->dev, "cannot get wakeup interrupt: %d\n", irq); + return 0; + } + + device_init_wakeup(&pdev->dev, true); + + ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, irq); + if (ret < 0) { + dev_err(&pdev->dev, "failed to set wake IRQ: %d\n", ret); + device_init_wakeup(&pdev->dev, false); + return ret; + } + + /* Start out disabled to avoid irq storm */ + dev_pm_disable_wake_irq(&pdev->dev); + + return 0; +} +EXPORT_SYMBOL_GPL(of_pci_setup_wake_irq); + +void of_pci_teardown_wake_irq(struct pci_dev *pdev) +{ + dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); +} +EXPORT_SYMBOL_GPL(of_pci_teardown_wake_irq); + /** * of_irq_parse_pci - Resolve the interrupt for a PCI device * @pdev: the device whose interrupt is to be resolved diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index c7819b973df7..d0182c82162a 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_PCI_IOV) += iov.o # ACPI _DSM provided firmware instance and string name # obj-$(CONFIG_ACPI)+= pci-acpi.o +obj-$(CONFIG_OF) += pci-of.o # SMBIOS provided firmware instance and labels obj-$(CONFIG_PCI_LABEL) += pci-label.o diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d79dbc377b9c..b4475ff35d97 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -421,10 +422,17 @@ static int pci_device_probe(struct device *dev) if (error < 0) return error; + error = of_pci_setup_wake_irq(pci_dev); + if (error < 0) { + pcibios_free_irq(pci_dev); + return error; + } + pci_dev_get(pci_dev); if (pci_device_can_probe(pci_dev)) { error = __pci_device_probe(drv, pci_dev); if (error) { + of_pci_teardown_wake_irq(pci_dev); pcibios_free_irq(pci_dev); pci_dev_put(pci_dev); } @@ -438,6 +446,8 @@ static int pci_device_remove(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = pci_dev->driver; + of_pci_teardown_wake_irq(pci_dev); + if (drv) { if (drv->remove) { pm_runtime_get_sync(dev); diff --git a/drivers/pci/pci-of.c b/drivers/pci/pci-of.c new file mode 100644 index ..ad413b2de508 ---
[RFC PATCH v12 3/5] mwifiex: Disable wakeup irq handling for pcie
We are going to handle the wakeup irq in the pci core. Signed-off-by: Jeffy Chen --- Changes in v13: None Changes in v12: None Changes in v11: None Changes in v10: None Changes in v9: None Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v3: None Changes in v2: None drivers/net/wireless/marvell/mwifiex/main.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index a96bd7e653bf..3cc3403b977a 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1567,6 +1567,10 @@ static void mwifiex_probe_of(struct mwifiex_adapter *adapter) goto err_exit; adapter->dt_node = dev->of_node; + + if (adapter->iface_type != MWIFIEX_PCIE) + goto err_exit; + adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); if (!adapter->irq_wakeup) { dev_dbg(dev, "fail to parse irq_wakeup from device tree\n"); -- 2.11.0
[RFC PATCH v12 1/5] dt-bindings: PCI: Add definition of PCIe WAKE# irq and PCI irq
We are going to handle PCIe WAKE# pin for PCI devices in the pci core, so add definitions of the optional PCIe WAKE# pin for PCI devices. Also add an definition of the optional PCI interrupt pin for PCI devices to distinguish it from the PCIe WAKE# pin. Signed-off-by: Jeffy Chen --- Changes in v13: None Changes in v12: Only add irq definitions for PCI devices and rewrite the commit message. Changes in v11: None Changes in v10: None Changes in v9: Add section for PCI devices and rewrite the commit message. Changes in v8: Add optional "pci", and rewrite commit message. Changes in v7: None Changes in v6: None Changes in v5: Move to pci.txt Changes in v3: None Changes in v2: None Documentation/devicetree/bindings/pci/pci.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/pci.txt b/Documentation/devicetree/bindings/pci/pci.txt index c77981c5dd18..3045ac452f27 100644 --- a/Documentation/devicetree/bindings/pci/pci.txt +++ b/Documentation/devicetree/bindings/pci/pci.txt @@ -24,3 +24,13 @@ driver implementation may support the following properties: unsupported link speed, for instance, trying to do training for unsupported link speed, etc. Must be '4' for gen4, '3' for gen3, '2' for gen2, and '1' for gen1. Any other values are invalid. + +PCI devices may support the following properties: + +- interrupts: Interrupt specifier for each name in interrupt-names. +- interrupt-names: +May contain "wakeup" for PCIe WAKE# interrupt and "pci" for PCI interrupt. +The PCI devices may optionally include an 'interrupts' property that +represents the legacy PCI interrupt. And when we try to specify the PCIe +WAKE# pin, a corresponding 'interrupt-names' property is required to +distinguish them. -- 2.11.0
[RFC PATCH v12 0/5] PCI: rockchip: Move PCIe WAKE# handling into pci core
Currently we are handling wake irq in mrvl wifi driver. Move it into pci core. Tested on my chromebook bob(with cros 4.4 kernel and mrvl wifi). Changes in v13: Fix compiler error reported by kbuild test robot Changes in v12: Only add irq definitions for PCI devices and rewrite the commit message. Enable the wake irq in noirq stage to avoid possible irq storm. Changes in v11: Address Brian's comments. Only support 1-per-device PCIe WAKE# pin as suggested. Move to pcie port as Brian suggested. Changes in v10: Use device_set_wakeup_capable() instead of device_set_wakeup_enable(), since dedicated wakeirq will be lost in device_set_wakeup_enable(false). Changes in v9: Add section for PCI devices and rewrite the commit message. Fix check error in .cleanup(). Move dedicated wakeirq setup to setup() callback and use device_set_wakeup_enable() to enable/disable. Rewrite the commit message. Changes in v8: Add optional "pci", and rewrite commit message. Add pci-of.c and use platform_pm_ops to handle the PCIe WAKE# signal. Rewrite the commit message. Changes in v7: Move PCIE_WAKE handling into pci core. Changes in v6: Fix device_init_wake error handling, and add some comments. Changes in v5: Move to pci.txt Rebase. Use "wakeup" instead of "wake" Changes in v3: Fix error handling. Changes in v2: Use dev_pm_set_dedicated_wake_irq. Jeffy Chen (5): dt-bindings: PCI: Add definition of PCIe WAKE# irq and PCI irq of/irq: Adjust of_pci_irq parsing for multiple interrupts mwifiex: Disable wakeup irq handling for pcie PCI / PM: Add support for the PCIe WAKE# signal for OF arm64: dts: rockchip: Move PCIe WAKE# irq to pcie port for Gru Documentation/devicetree/bindings/pci/pci.txt | 10 arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 11 ++-- drivers/net/wireless/marvell/mwifiex/main.c | 4 ++ drivers/of/of_pci_irq.c | 71 +++-- drivers/pci/Makefile | 1 + drivers/pci/pci-driver.c | 10 drivers/pci/pci-of.c | 75 +++ include/linux/of_pci.h| 9 8 files changed, 183 insertions(+), 8 deletions(-) create mode 100644 drivers/pci/pci-of.c -- 2.11.0
Re: [PATCH] leaking_addresses: add generic 32-bit support
The script attempts to detect the architecture it's running upon; as of now, we explicitly support x86_64, PPC64 and x86_32. If it's one of them, we proceed "normally". If we fail to detect the arch, we fallback to 64-bit scanning, unless the user has passed either of these option switches: "--opt-32bit" and/or "--page-offset-32bit=". If so, we switch to scanning for leaked addresses based on the value of PAGE_OFFSET (via an auto-detected or fallback mechanism). As of now, we have code (or "rules") to detect special cases for x86_64 and PPC64 (in the get_address_re sub). Also, we now have also builtin "stubs", for lack of a better term, where additional rules for other 64-bit arch's can be plugged into the code, in future, as applicable. Signed-off-by: Kaiwan N Billimoria --- scripts/leaking_addresses.pl | 190 +++ 1 file changed, 156 insertions(+), 34 deletions(-) This patch is based on Tobin's suggestions and my replies to them (see prev email in this thread). diff --git a/scripts/leaking_addresses.pl b/scripts/leaking_addresses.pl index a29e13e577a7..b0807b3a3c7c 100755 --- a/scripts/leaking_addresses.pl +++ b/scripts/leaking_addresses.pl @@ -1,10 +1,10 @@ #!/usr/bin/env perl # # (c) 2017 Tobin C. Harding - +# (c) 2017 Kaiwan N Billimoria # Licensed under the terms of the GNU GPL License version 2 # -# leaking_addresses.pl: Scan 64 bit kernel for potential leaking addresses. +# leaking_addresses.pl: Scan kernel for potential leaking addresses. # - Scans dmesg output. # - Walks directory tree and parses each file (for each directory in @DIRS). # @@ -32,11 +32,6 @@ my @DIRS = ('/proc', '/sys'); # Timer for parsing each file, in seconds. my $TIMEOUT = 10; -# Script can only grep for kernel addresses on the following architectures. If -# your architecture is not listed here and has a grep'able kernel address please -# consider submitting a patch. -my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64'); - # Command line options. my $help = 0; my $debug = 0; @@ -48,7 +43,9 @@ my $suppress_dmesg = 0; # Don't show dmesg in output. my $squash_by_path = 0;# Summary report grouped by absolute path. my $squash_by_filename = 0;# Summary report grouped by filename. -my $kernel_config_file = ""; # Kernel configuration file. +my $opt_32_bit = 0;# Detect (only) 32-bit kernel leaking addresses. +my $page_offset_32bit = 0; # 32-bit: value of CONFIG_PAGE_OFFSET. +my $kernel_config_file = ""; # Kernel configuration file. # Do not parse these files (absolute path). my @skip_parse_files_abs = ('/proc/kmsg', @@ -104,10 +101,12 @@ Options: --squash-by-path Show one result per unique path. --squash-by-filename Show one result per unique filename. --kernel-config-file= Kernel configuration file (e.g /boot/config) + --opt-32bit Detect (only) 32-bit kernel leaking addresses. + --page-offset-32bit= PAGE_OFFSET value (for 32-bit kernels). -d, --debug Display debugging output. - -h, --help, --versionq Display this help and exit. + -h, --help, --version Display this help and exit. -Scans the running (64 bit) kernel for potential leaking addresses. +Scans the running kernel for potential leaking addresses. EOM exit($exitcode); @@ -123,7 +122,9 @@ GetOptions( 'squash-by-path'=> \$squash_by_path, 'squash-by-filename'=> \$squash_by_filename, 'raw' => \$raw, - 'kernel-config-file=s' => \$kernel_config_file, + 'opt-32bit' => \$opt_32_bit, + 'page-offset-32bit=o' => \$page_offset_32bit, + 'kernel-config-file=s' => \$kernel_config_file, ) or help(1); help(0) if ($help); @@ -139,16 +140,15 @@ if (!$input_raw and ($squash_by_path or $squash_by_filename)) { exit(128); } -if (!is_supported_architecture()) { - printf "\nScript does not support your architecture, sorry.\n"; - printf "\nCurrently we support: \n\n"; - foreach(@SUPPORTED_ARCHITECTURES) { - printf "\t%s\n", $_; - } +show_detected_architecture() if $debug; - my $archname = $Config{archname}; - printf "\n\$ perl -MConfig -e \'print \"\$Config{archname}\\n\"\'\n"; - printf "%s\n", $archname; +if (!is_known_architecture()) { + printf STDERR "\nFATAL: Script does not recognize your architecture\n"; + + my $arch = `uname -m`; + chomp $arch; + printf "\n\$ uname -m\n"; + printf "%s\n", $arch; exit(129); } @@ -168,21 +168,45 @@ sub dprint printf(STDERR @_) if $debug; } -sub is_supported_architecture +sub is_known_architecture { - return (is_x86_64() or is_ppc64()); + return (is_64bit() or is_32bit()); } -sub is_x86_64 +sub is_32bit { - my $archname = $Config{archn
arch/c6x/platforms/plldata.c:279:33: error: implicit declaration of function 'get_coreid'; did you mean 'get_order'?
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master head: 328b4ed93b69a6f2083d52f31a240a09e5de386a commit: 71af2ed5eeea639339e3a1497a0196bab7de4b57 kasan, sched/headers: Remove from date: 9 months ago config: c6x-evmc6472_defconfig (attached as .config) compiler: c6x-elf-gcc (GCC) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross git checkout 71af2ed5eeea639339e3a1497a0196bab7de4b57 # save the attached .config to linux build tree make.cross ARCH=c6x All errors (new ones prefixed by >>): arch/c6x/platforms/plldata.c: In function 'c6472_setup_clocks': >> arch/c6x/platforms/plldata.c:279:33: error: implicit declaration of function >> 'get_coreid'; did you mean 'get_order'? >> [-Werror=implicit-function-declaration] c6x_core_clk.parent = &sysclks[get_coreid() + 1]; ^~ get_order cc1: some warnings being treated as errors # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=71af2ed5eeea639339e3a1497a0196bab7de4b57 git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git git remote update linus git checkout 71af2ed5eeea639339e3a1497a0196bab7de4b57 vim +279 arch/c6x/platforms/plldata.c 81ec9889 Mark Salter 2011-10-04 257 81ec9889 Mark Salter 2011-10-04 258 static void __init c6472_setup_clocks(struct device_node *node) 81ec9889 Mark Salter 2011-10-04 259 { 81ec9889 Mark Salter 2011-10-04 260struct pll_data *pll = &c6x_soc_pll1; 81ec9889 Mark Salter 2011-10-04 261struct clk *sysclks = pll->sysclks; 81ec9889 Mark Salter 2011-10-04 262int i; 81ec9889 Mark Salter 2011-10-04 263 81ec9889 Mark Salter 2011-10-04 264pll->flags = PLL_HAS_MUL; 81ec9889 Mark Salter 2011-10-04 265 81ec9889 Mark Salter 2011-10-04 266for (i = 1; i <= 6; i++) { 81ec9889 Mark Salter 2011-10-04 267sysclks[i].flags |= FIXED_DIV_PLL; 81ec9889 Mark Salter 2011-10-04 268sysclks[i].div = 1; 81ec9889 Mark Salter 2011-10-04 269} 81ec9889 Mark Salter 2011-10-04 270 81ec9889 Mark Salter 2011-10-04 271sysclks[7].flags |= FIXED_DIV_PLL; 81ec9889 Mark Salter 2011-10-04 272sysclks[7].div = 3; 81ec9889 Mark Salter 2011-10-04 273sysclks[8].flags |= FIXED_DIV_PLL; 81ec9889 Mark Salter 2011-10-04 274sysclks[8].div = 6; 81ec9889 Mark Salter 2011-10-04 275sysclks[9].flags |= FIXED_DIV_PLL; 81ec9889 Mark Salter 2011-10-04 276sysclks[9].div = 2; 81ec9889 Mark Salter 2011-10-04 277sysclks[10].div = PLLDIV10; 81ec9889 Mark Salter 2011-10-04 278 81ec9889 Mark Salter 2011-10-04 @279c6x_core_clk.parent = &sysclks[get_coreid() + 1]; 81ec9889 Mark Salter 2011-10-04 280c6x_i2c_clk.parent = &sysclks[8]; 81ec9889 Mark Salter 2011-10-04 281c6x_watchdog_clk.parent = &sysclks[8]; 81ec9889 Mark Salter 2011-10-04 282c6x_mdio_clk.parent = &sysclks[5]; 81ec9889 Mark Salter 2011-10-04 283 81ec9889 Mark Salter 2011-10-04 284c6x_clks_init(c6472_clks); 81ec9889 Mark Salter 2011-10-04 285 } 81ec9889 Mark Salter 2011-10-04 286 #endif /* CONFIG_SOC_TMS320C6472 */ 81ec9889 Mark Salter 2011-10-04 287 81ec9889 Mark Salter 2011-10-04 288 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
[RFC PATCH v12 1/5] dt-bindings: PCI: Add definition of PCIe WAKE# irq and PCI irq
We are going to handle PCIe WAKE# pin for PCI devices in the pci core, so add definitions of the optional PCIe WAKE# pin for PCI devices. Also add an definition of the optional PCI interrupt pin for PCI devices to distinguish it from the PCIe WAKE# pin. Signed-off-by: Jeffy Chen --- Changes in v12: None Changes in v11: Only add irq definitions for PCI devices and rewrite the commit message. Changes in v10: None Changes in v9: Add section for PCI devices and rewrite the commit message. Changes in v8: Add optional "pci", and rewrite commit message. Changes in v7: None Changes in v6: None Changes in v5: Move to pci.txt Changes in v3: None Changes in v2: None Documentation/devicetree/bindings/pci/pci.txt | 10 ++ 1 file changed, 10 insertions(+) diff --git a/Documentation/devicetree/bindings/pci/pci.txt b/Documentation/devicetree/bindings/pci/pci.txt index c77981c5dd18..3045ac452f27 100644 --- a/Documentation/devicetree/bindings/pci/pci.txt +++ b/Documentation/devicetree/bindings/pci/pci.txt @@ -24,3 +24,13 @@ driver implementation may support the following properties: unsupported link speed, for instance, trying to do training for unsupported link speed, etc. Must be '4' for gen4, '3' for gen3, '2' for gen2, and '1' for gen1. Any other values are invalid. + +PCI devices may support the following properties: + +- interrupts: Interrupt specifier for each name in interrupt-names. +- interrupt-names: +May contain "wakeup" for PCIe WAKE# interrupt and "pci" for PCI interrupt. +The PCI devices may optionally include an 'interrupts' property that +represents the legacy PCI interrupt. And when we try to specify the PCIe +WAKE# pin, a corresponding 'interrupt-names' property is required to +distinguish them. -- 2.11.0
[RFC PATCH v12 5/5] arm64: dts: rockchip: Move PCIe WAKE# irq to pcie port for Gru
Currently we are handling PCIe WAKE# irq in mrvl wifi driver. Move it to rockchip pcie port since we are going to handle it in the pci core. Also avoid this irq been considered as the PCI interrupt pin in the of_irq_parse_pci(). Signed-off-by: Jeffy Chen --- Changes in v12: None Changes in v11: Move to pcie port as Brian suggested. Changes in v10: None Changes in v9: Rewrite the commit message. Changes in v8: Rewrite the commit message. Changes in v7: None Changes in v6: None Changes in v5: Use "wakeup" instead of "wake" Changes in v3: None Changes in v2: None arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 11 ++- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi index 03f195025390..be41d363efd8 100644 --- a/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi +++ b/arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi @@ -719,15 +719,16 @@ ap_i2c_audio: &i2c8 { #size-cells = <2>; ranges; + interrupts-extended = <&pcie0 1>, <&gpio0 8 IRQ_TYPE_LEVEL_LOW>; + interrupt-names = "pci", "wakeup"; + pinctrl-names = "default"; + pinctrl-0 = <&wlan_host_wake_l>; + wakeup-source; + mvl_wifi: wifi@0,0 { compatible = "pci1b4b,2b42"; reg = <0x8301 0x0 0x 0x0 0x0010 0x8301 0x0 0x0010 0x0 0x0010>; - interrupt-parent = <&gpio0>; - interrupts = <8 IRQ_TYPE_LEVEL_LOW>; - pinctrl-names = "default"; - pinctrl-0 = <&wlan_host_wake_l>; - wakeup-source; }; }; }; -- 2.11.0
[RFC PATCH v12 3/5] mwifiex: Disable wakeup irq handling for pcie
We are going to handle the wakeup irq in the pci core. Signed-off-by: Jeffy Chen --- Changes in v12: None Changes in v11: None Changes in v10: None Changes in v9: None Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v3: None Changes in v2: None drivers/net/wireless/marvell/mwifiex/main.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/marvell/mwifiex/main.c b/drivers/net/wireless/marvell/mwifiex/main.c index a96bd7e653bf..3cc3403b977a 100644 --- a/drivers/net/wireless/marvell/mwifiex/main.c +++ b/drivers/net/wireless/marvell/mwifiex/main.c @@ -1567,6 +1567,10 @@ static void mwifiex_probe_of(struct mwifiex_adapter *adapter) goto err_exit; adapter->dt_node = dev->of_node; + + if (adapter->iface_type != MWIFIEX_PCIE) + goto err_exit; + adapter->irq_wakeup = irq_of_parse_and_map(adapter->dt_node, 0); if (!adapter->irq_wakeup) { dev_dbg(dev, "fail to parse irq_wakeup from device tree\n"); -- 2.11.0
[RFC PATCH v12 4/5] PCI / PM: Add support for the PCIe WAKE# signal for OF
Add of_pci_setup_wake_irq() and of_pci_teardown_wake_irq() to handle the PCIe WAKE# interrupt. Also use the dedicated wakeirq infrastructure to simplify it. And add pci-of.c to enable/disable the wakeup irq in noirq stage to avoid possible irq storm. Signed-off-by: Jeffy Chen --- Changes in v12: Enable the wake irq in noirq stage to avoid possible irq storm. Changes in v11: Only support 1-per-device PCIe WAKE# pin as suggested. Changes in v10: Use device_set_wakeup_capable() instead of device_set_wakeup_enable(), since dedicated wakeirq will be lost in device_set_wakeup_enable(false). Changes in v9: Fix check error in .cleanup(). Move dedicated wakeirq setup to setup() callback and use device_set_wakeup_enable() to enable/disable. Changes in v8: Add pci-of.c and use platform_pm_ops to handle the PCIe WAKE# signal. Changes in v7: Move PCIE_WAKE handling into pci core. Changes in v6: Fix device_init_wake error handling, and add some comments. Changes in v5: Rebase. Changes in v3: Fix error handling. Changes in v2: Use dev_pm_set_dedicated_wake_irq. drivers/of/of_pci_irq.c | 52 + drivers/pci/Makefile | 1 + drivers/pci/pci-driver.c | 10 +++ drivers/pci/pci-of.c | 75 include/linux/of_pci.h | 9 ++ 5 files changed, 147 insertions(+) create mode 100644 drivers/pci/pci-of.c diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index d39565d5477b..af7afe6cbce2 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -1,8 +1,60 @@ #include #include #include +#include #include +int of_pci_setup_wake_irq(struct pci_dev *pdev) +{ + struct pci_dev *ppdev; + struct device_node *dn; + int ret, irq; + + /* Get the pci_dev of our parent. Hopefully it's a port. */ + ppdev = pdev->bus->self; + /* Nope, it's a host bridge. */ + if (!ppdev) + return 0; + + dn = pci_device_to_OF_node(ppdev); + if (!dn) + return 0; + + irq = of_irq_get_byname(dn, "wakeup"); + if (irq == -EPROBE_DEFER) { + return irq; + } else if (irq < 0) { + /* Ignore other errors, since a missing wakeup is non-fatal. */ + dev_info(&pdev->dev, "cannot get wakeup interrupt: %d\n", irq); + return 0; + } + + device_init_wakeup(&pdev->dev, true); + + ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, irq); + if (ret < 0) { + dev_err(&pdev->dev, "failed to set wake IRQ: %d\n", ret); + device_init_wakeup(&pdev->dev, false); + return ret; + } + + /* Start out disabled to avoid irq storm */ + dev_pm_disable_wake_irq(&pdev->dev); + + return 0; +} +EXPORT_SYMBOL_GPL(of_pci_setup_wake_irq); + +void of_pci_teardown_wake_irq(struct pci_dev *pdev) +{ + if (!pdev->dev.power.wakeirq) + return; + + dev_pm_clear_wake_irq(&pdev->dev); + device_init_wakeup(&pdev->dev, false); +} +EXPORT_SYMBOL_GPL(of_pci_teardown_wake_irq); + /** * of_irq_parse_pci - Resolve the interrupt for a PCI device * @pdev: the device whose interrupt is to be resolved diff --git a/drivers/pci/Makefile b/drivers/pci/Makefile index c7819b973df7..d0182c82162a 100644 --- a/drivers/pci/Makefile +++ b/drivers/pci/Makefile @@ -29,6 +29,7 @@ obj-$(CONFIG_PCI_IOV) += iov.o # ACPI _DSM provided firmware instance and string name # obj-$(CONFIG_ACPI)+= pci-acpi.o +obj-$(CONFIG_OF) += pci-of.o # SMBIOS provided firmware instance and labels obj-$(CONFIG_PCI_LABEL) += pci-label.o diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index d79dbc377b9c..b4475ff35d97 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -421,10 +422,17 @@ static int pci_device_probe(struct device *dev) if (error < 0) return error; + error = of_pci_setup_wake_irq(pci_dev); + if (error < 0) { + pcibios_free_irq(pci_dev); + return error; + } + pci_dev_get(pci_dev); if (pci_device_can_probe(pci_dev)) { error = __pci_device_probe(drv, pci_dev); if (error) { + of_pci_teardown_wake_irq(pci_dev); pcibios_free_irq(pci_dev); pci_dev_put(pci_dev); } @@ -438,6 +446,8 @@ static int pci_device_remove(struct device *dev) struct pci_dev *pci_dev = to_pci_dev(dev); struct pci_driver *drv = pci_dev->driver; + of_pci_teardown_wake_irq(pci_dev); + if (drv) { if (drv->remove) { pm_runtime_get_sync(dev); diff --git a/drivers/pci/pci-of.c b/drivers/pci/pci-of.c new file mode 100644 index ..ad413b2de508 --- /
[RFC PATCH v12 2/5] of/irq: Adjust of_pci_irq parsing for multiple interrupts
Currently we are considering the first irq as the PCI interrupt pin, but a PCI device may have multiple interrupts(e.g. PCIe WAKE# pin). Only parse the PCI interrupt pin when the irq is unnamed or named as "pci". Signed-off-by: Jeffy Chen --- Changes in v12: None Changes in v11: Address Brian's comments. Changes in v10: None Changes in v9: None Changes in v8: None Changes in v7: None Changes in v6: None Changes in v5: None Changes in v3: None Changes in v2: None drivers/of/of_pci_irq.c | 22 +++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c index 3a05568f65df..d39565d5477b 100644 --- a/drivers/of/of_pci_irq.c +++ b/drivers/of/of_pci_irq.c @@ -27,9 +27,25 @@ int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq */ dn = pci_device_to_OF_node(pdev); if (dn) { - rc = of_irq_parse_one(dn, 0, out_irq); - if (!rc) - return rc; + struct property *prop; + const char *name; + int index = 0; + + of_property_for_each_string(dn, "interrupt-names", prop, name) { + if (!strcmp(name, "pci")) + break; + index++; + } + + /* +* Only parse from DT if we have no "interrupt-names", +* or if we found an interrupt named "pci". +*/ + if (index == 0 || name) { + rc = of_irq_parse_one(dn, index, out_irq); + if (!rc) + return rc; + } } /* Ok, we don't, time to have fun. Let's start by building up an -- 2.11.0
[RFC PATCH v12 0/5] PCI: rockchip: Move PCIe WAKE# handling into pci core
Currently we are handling wake irq in mrvl wifi driver. Move it into pci core. Tested on my chromebook bob(with cros 4.4 kernel and mrvl wifi). Changes in v12: Enable the wake irq in noirq stage to avoid possible irq storm. Changes in v11: Only add irq definitions for PCI devices and rewrite the commit message. Address Brian's comments. Only support 1-per-device PCIe WAKE# pin as suggested. Move to pcie port as Brian suggested. Changes in v10: Use device_set_wakeup_capable() instead of device_set_wakeup_enable(), since dedicated wakeirq will be lost in device_set_wakeup_enable(false). Changes in v9: Add section for PCI devices and rewrite the commit message. Fix check error in .cleanup(). Move dedicated wakeirq setup to setup() callback and use device_set_wakeup_enable() to enable/disable. Rewrite the commit message. Changes in v8: Add optional "pci", and rewrite commit message. Add pci-of.c and use platform_pm_ops to handle the PCIe WAKE# signal. Rewrite the commit message. Changes in v7: Move PCIE_WAKE handling into pci core. Changes in v6: Fix device_init_wake error handling, and add some comments. Changes in v5: Move to pci.txt Rebase. Use "wakeup" instead of "wake" Changes in v3: Fix error handling. Changes in v2: Use dev_pm_set_dedicated_wake_irq. Jeffy Chen (5): dt-bindings: PCI: Add definition of PCIe WAKE# irq and PCI irq of/irq: Adjust of_pci_irq parsing for multiple interrupts mwifiex: Disable wakeup irq handling for pcie PCI / PM: Add support for the PCIe WAKE# signal for OF arm64: dts: rockchip: Move PCIe WAKE# irq to pcie port for Gru Documentation/devicetree/bindings/pci/pci.txt | 10 arch/arm64/boot/dts/rockchip/rk3399-gru.dtsi | 11 ++-- drivers/net/wireless/marvell/mwifiex/main.c | 4 ++ drivers/of/of_pci_irq.c | 74 -- drivers/pci/Makefile | 1 + drivers/pci/pci-driver.c | 10 drivers/pci/pci-of.c | 75 +++ include/linux/of_pci.h| 9 8 files changed, 186 insertions(+), 8 deletions(-) create mode 100644 drivers/pci/pci-of.c -- 2.11.0
Re: [PATCH] leaking_addresses: add generic 32-bit support
Hey, Merry Xmas all !! :-) Re inline below, Updated patch to follow.. On Mon, 18 Dec 2017 16:57:46 +1100 "Tobin C. Harding" wrote: > On Mon, Dec 18, 2017 at 09:24:47AM +0530, kaiwan.billimo...@gmail.com > wrote: > > The script attempts to detect the architecture it's running upon; > > as of now, we explicitly support x86_64, PPC64 and x86_32. > > If it's one of them, we proceed "normally". If we fail to detect > > the arch, we fallback to 64-bit scanning, unless the user has > > passed either of these option switches: "--32-bit" and/or > > "--page-offset-32bit=". > > > > If so, we switch to scanning for leaked addresses based on the > > value of PAGE_OFFSET (via an auto-detected or fallback mechanism). > > > > As of now, we have code (or "rules") to detect special cases for > > x86_64 and ppc64 (in the get_address_re sub). Also, we now have > > also builtin "stubs", for lack of a better term, where additional > > rules for other 64-bit arch's can be plugged in, in future, as > > applicable. > > > > Signed-off-by: Kaiwan N Billimoria > > --- > > > > This is a patch based on Tobin's latest tree, 'leaks' branch. > > Applies on top of commit 6c3942594657 (leaking_addresses: add > > support for 5 page table levels (origin/leaks)) > > That commit is not the tip of the branch. leaks branch is currently at > > commit 266891c62bf0 (leaking_addresses: add support for 5 page table > levels) > > > > > Thanks, > > Kaiwan. > > > > scripts/leaking_addresses.pl | 213 > > +-- 1 file changed, 184 > > insertions(+), 29 deletions(-) > > > > diff --git a/scripts/leaking_addresses.pl > > b/scripts/leaking_addresses.pl index a29e13e577a7..a667f243c95b > > 100755 --- a/scripts/leaking_addresses.pl > > +++ b/scripts/leaking_addresses.pl > > @@ -1,10 +1,10 @@ > > #!/usr/bin/env perl > > # > > # (c) 2017 Tobin C. Harding > > - > > +# (c) 2017 Kaiwan N Billimoria > > # Licensed under the terms of the GNU GPL License version 2 > > # > > -# leaking_addresses.pl: Scan 64 bit kernel for potential leaking > > addresses. +# leaking_addresses.pl: Scan kernel for potential > > leaking addresses. # - Scans dmesg output. > > # - Walks directory tree and parses each file (for each directory > > in @DIRS). # > > @@ -35,7 +35,7 @@ my $TIMEOUT = 10; > > # Script can only grep for kernel addresses on the following > > architectures. If # your architecture is not listed here and has a > > grep'able kernel address please # consider submitting a patch. > > -my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64'); > > +my @SUPPORTED_ARCHITECTURES = ('x86_64', 'ppc64', 'i[3456]86'); > > > > # Command line options. > > my $help = 0; > > @@ -48,7 +48,9 @@ my $suppress_dmesg = 0; # Don't > > show dmesg in output. my $squash_by_path = 0;# > > Summary report grouped by absolute path. my $squash_by_filename = > > 0;# Summary report grouped by filename. > > -my $kernel_config_file = ""; # Kernel configuration file. > > +my $opt_32_bit = 0;# Detect 32-bit kernel leaking > > addresses. +my $page_offset_32bit = 0; # 32-bit: value of > > CONFIG_PAGE_OFFSET. +my $kernel_config_file = ""; # Kernel > > configuration file. > > # Do not parse these files (absolute path). > > my @skip_parse_files_abs = ('/proc/kmsg', > > @@ -97,17 +99,19 @@ Version: $V > > > > Options: > > > > - -o, --output-raw= Save results for future > > processing. > > - -i, --input-raw= Read results from file > > instead of scanning. > > - --raw Show raw results (default). > > - --suppress-dmesg Do not show dmesg results. > > - --squash-by-path Show one result per unique > > path. > > - --squash-by-filename Show one result per unique > > filename. > > - --kernel-config-file= Kernel configuration file > > (e.g /boot/config) > > - -d, --debug Display debugging output. > > - -h, --help, --versionq Display this help and exit. > > + -o, --output-raw= Save results for future > > processing. > > + -i, --input-raw= Read results from file > > instead of scanning. > > + --raw Show raw results > > (default). > > + --suppress-dmesgDo not show dmesg > > results. > > + --squash-by-pathShow one result per > > unique path. > > + --squash-by-filenameShow one result per > > unique filename. > > + --32-bitDetect 32-bit kernel > > leaking addresses. > > + --page-offset-32bit= PAGE_OFFSET value (for > > 32-bit kernels). > > + --kernel-config-file= Kernel configuration file > > (e.g /boot/config). > > + -d, --debug Display debugging output. > > + -h, --help, --version Display this help and > >
v4.14.9 BUG, regression
Hi, the machine started dying reliably shortly after boot after upgrading to 4.14.9 from 4.14.8. Debian stretch, xfs on md raid10, btrfs. [ 230.855352] BUG: unable to handle kernel paging request at 00010001 [ 230.862449] IP: free_block+0x135/0x1f0 [ 230.866301] PGD 0 P4D 0 [ 230.868939] Oops: 0002 [#1] SMP [ 230.872178] Modules linked in: xfs x86_pkg_temp_thermal coretemp kvm_intel kvm irqbypass crc32_pclmul ghash_clmulni_intel pcbc aesni_intel mei_me iTCO_wdt aes_x86_64 crypto_simd cryptd glue_helper pcspkr iTCO_vendor_support ipmi_si tpm_tis mei evdev tpm_tis_core ipmi_devintf ipmi_msghandler battery sg video tpm acpi_power_meter button ie31200_edac shpchp nfsd auth_rpcgss oid_registry nfs_acl lockd grace sunrpc loop ip_tables x_tables autofs4 btrfs zstd_decompress zstd_compress xxhash raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor raid6_pq libcrc32c crc32c_generic raid1 raid0 multipath linear raid10 md_mod uas usb_storage hid_generic usbhid hid sd_mod igb ahci xhci_pci i2c_algo_bit libahci mpt3sas xhci_hcd dca raid_class ptp libata i2c_i801 scsi_transport_sas crc32c_intel usbcore [ 230.943379] i2c_core pps_core usb_common scsi_mod fan thermal [ 230.949317] CPU: 0 PID: 57 Comm: kworker/0:1 Not tainted 4.14.9 #23 [ 230.955688] Hardware name: Supermicro Super Server/X11SSL-CF, BIOS 1.0a 01/29/2016 [ 230.963357] Workqueue: events cache_reap [ 230.967380] task: 8864b362c000 task.stack: 9f0d4338 [ 230.973420] RIP: 0010:free_block+0x135/0x1f0 [ 230.977806] RSP: 0018:9f0d43383d88 EFLAGS: 00010006 [ 230.983146] RAX: e8625d2e3908 RBX: 8000 RCX: 0003 [ 230.990398] RDX: fffe RSI: 8864b7822df0 RDI: 8864b6c00480 [ 230.997654] RBP: dead0200 R08: 8864b6c01558 R09: 8864b6c01540 [ 231.004909] R10: 006fe8f1 R11: 886496597e00 R12: dead0100 [ 231.012162] R13: 8000 R14: 8864b7822e28 R15: e8625d2e3928 [ 231.019416] FS: () GS:8864b780() knlGS: [ 231.027643] CS: 0010 DS: ES: CR0: 80050033 [ 231.033509] CR2: 00010001 CR3: 0005e680b006 CR4: 003606f0 [ 231.040763] DR0: DR1: DR2: [ 231.048017] DR3: DR6: fffe0ff0 DR7: 0400 [ 231.055272] Call Trace: [ 231.057840] drain_array_locked+0x5a/0x90 [ 231.061963] drain_array+0x60/0x80 [ 231.065484] cache_reap+0x67/0x1d0 [ 231.069004] process_one_work+0x1c0/0x3e0 [ 231.073128] worker_thread+0x42/0x3e0 [ 231.076907] kthread+0xf7/0x130 [ 231.080167] ? create_worker+0x180/0x180 [ 231.084206] ? kthread_create_on_node+0x40/0x40 [ 231.088850] ret_from_fork+0x1f/0x30 [ 231.092542] Code: 4f 1c 49 c1 ea 20 44 29 d2 d3 ea 0f b6 4f 1d 41 01 d2 41 d3 ea 8b 48 18 8d 51 ff 48 8b 48 10 89 50 18 48 85 c9 0f 84 a3 00 00 00 <44> 88 14 11 8b 50 18 85 d2 0f 84 26 ff ff ff 49 8b 51 20 48 83 [ 231.111583] RIP: free_block+0x135/0x1f0 RSP: 9f0d43383d88 [ 231.117443] CR2: 00010001 [ 231.120875] ---[ end trace e4cdf71e69fa010e ]--- Thanks, Petr
Re: [PATCH v1 1/9] ufs: sysfs: device descriptor
Hi Stanislav, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on scsi/for-next] [also build test WARNING on v4.15-rc5 next-20171222] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Stanislav-Nijnikov/ufs-sysfs-read-only-access-to-device-descriptors-attributes-and-flags/20171226-075252 base: https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__ sparse warnings: (new ones prefixed by >>) vim +40 drivers/scsi/ufs/ufs-sysfs.c 15 16 static inline ssize_t ufs_sysfs_read_desc_param( 17 struct ufs_hba *hba, u8 desc_idn, u8 index, char *buf, u8 off, 18 enum ufs_desc_param_size param_size) 19 { 20 int desc_len; 21 int ret; 22 u8 *desc_buf; 23 24 if (ufshcd_map_desc_id_to_length(hba, desc_idn, &desc_len) || 25 off >= desc_len) 26 return -EINVAL; 27 desc_buf = kzalloc(desc_len, GFP_ATOMIC); 28 if (!desc_buf) 29 return -ENOMEM; 30 ret = ufshcd_query_descriptor_retry(hba, UPIU_QUERY_OPCODE_READ_DESC, 31 desc_idn, index, 0, desc_buf, &desc_len); 32 if (ret) 33 return -EINVAL; 34 switch (param_size) { 35 case UFS_PARAM_BYTE_SIZE: 36 ret = sprintf(buf, "0x%02X\n", desc_buf[off]); 37 break; 38 case UFS_PARAM_WORD_SIZE: 39 ret = sprintf(buf, "0x%04X\n", > 40 be16_to_cpu(*((u16 *)(desc_buf + off; 41 break; 42 case UFS_PARAM_DWORD_SIZE: 43 ret = sprintf(buf, "0x%08X\n", > 44 be32_to_cpu(*((u32 *)(desc_buf + off; 45 break; 46 case UFS_PARAM_QWORD_SIZE: 47 ret = sprintf(buf, "0x%016llX\n", > 48 be64_to_cpu(*((u64 *)(desc_buf + off; 49 break; 50 } 51 kfree(desc_buf); 52 53 return ret; 54 } 55 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
BUG warnings in 4.14.9
Hi, I've just raised https://bugzilla.kernel.org/show_bug.cgi?id=198271 because the new 4.14.9 kernel is generating lots of BUG warnings, e.g. [ 35.069924] BUG: using smp_processor_id() in preemptible [] code: avahi-daemon/761 [ 35.078187] caller is ip6_pol_route+0x46b/0x509 [ipv6] [ 35.083340] CPU: 5 PID: 761 Comm: avahi-daemon Tainted: G I 4.14.9 #1 [ 35.091176] Hardware name: Gigabyte Technology Co., Ltd. EX58-UD3R/EX58-UD3R, BIOS FB 05/04/2009 [ 35.100181] Call Trace: [ 35.102709] dump_stack+0x46/0x59 [ 35.106095] check_preemption_disabled+0xca/0xda [ 35.110786] ip6_pol_route+0x46b/0x509 [ipv6] [ 35.115224] fib6_rule_lookup+0x15/0x4b [ipv6] [ 35.119745] ip6_dst_lookup_tail+0x11d/0x18f [ipv6] [ 35.124702] ip6_dst_lookup_flow+0x30/0x6f [ipv6] [ 35.129481] udpv6_sendmsg+0x5c5/0xa10 [ipv6] [ 35.133914] ? ip_reply_glue_bits+0x48/0x48 [ 35.138187] ? rw_copy_check_uvector+0x6d/0xf9 [ 35.142701] ? sock_sendmsg+0x28/0x34 [ 35.146393] sock_sendmsg+0x28/0x34 [ 35.149912] ___sys_sendmsg+0x1b4/0x246 [ 35.153821] ? poll_select_copy_remaining+0x104/0x104 [ 35.158995] ? current_time+0x11/0x52 [ 35.162738] ? pipe_write+0x353/0x365 [ 35.166483] ? __sys_sendmsg+0x3c/0x5d [ 35.170304] __sys_sendmsg+0x3c/0x5d [ 35.173909] do_syscall_64+0x4a/0xe1 [ 35.177482] entry_SYSCALL64_slow_path+0x25/0x25 [ 35.177484] RIP: 0033:0x7f963d7097b7 [ 35.177485] RSP: 002b:77ffbd18 EFLAGS: 0246 ORIG_RAX: 002e [ 35.177486] RAX: ffda RBX: 000d RCX: 7f963d7097b7 [ 35.177487] RDX: RSI: 77ffbde0 RDI: 000d [ 35.177487] RBP: R08: 0001 R09: 77ffbd42 [ 35.177488] R10: 0002 R11: 0246 R12: 77ffbde0 [ 35.177489] R13: 55e4e1af29cc R14: 000d R15: 0002 [ 35.177565] IN=eth0 OUT= MAC= SRC=fe80::::0224:1dff:fecd:0f3a DST=ff02:::::::00fb LEN=245 TC=0 HOPLIMIT=255 FLOWLBL=147873 PROTO=UDP SPT=5353 DPT=5353 LEN=205 Cheers, Chris
[PATCH v3] x86/microcode/intel: Blacklist the specific BDW-EP for late loading
Instead of blacklisting all Broadwell processorsi for running a late loading, only BDW-EP (signature 406f1) with the microcode version less than 0x0b21 needs to be blacklisted. This is documented in the the public documentation #334165 (See the item BDF90 for details). Signed-off-by: Jia Zhang --- arch/x86/kernel/cpu/microcode/intel.c | 11 +-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/intel.c b/arch/x86/kernel/cpu/microcode/intel.c index 8ccdca6..d2c1638 100644 --- a/arch/x86/kernel/cpu/microcode/intel.c +++ b/arch/x86/kernel/cpu/microcode/intel.c @@ -910,8 +910,15 @@ static bool is_blacklisted(unsigned int cpu) { struct cpuinfo_x86 *c = &cpu_data(cpu); - if (c->x86 == 6 && c->x86_model == INTEL_FAM6_BROADWELL_X) { - pr_err_once("late loading on model 79 is disabled.\n"); + /* +* The Broadwell-EP processor with the microcode version less +* then 0x0b21 may reault in system hang when running a late +* loading. This behavior is documented in item BDF90, #334165 +* (Intel Xeon Processor E7-8800/4800 v4 Product Family). +*/ + if (c->x86 == 6 && c->x86_model == INTEL_FAM6_BROADWELL_X && + c->x86_mask == 0x01 && c->microcode < 0x0b21U) { + pr_err_once("late loading on model 79 (sig 64f1) is disabled.\n"); return true; } -- 1.8.3.1
Re: [PATCH v6 2/4] i2c-smbus : Add client discovered ARA support
Hi Marc, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on wsa/i2c/for-next] [also build test WARNING on v4.15-rc5 next-20171222] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Marc-CAPDEVILLE/i2c-core-acpi-Add-i2c_acpi_set_connection/20171226-083729 base: https://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux.git i2c/for-next config: ia64-defconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 7.2.0 reproduce: wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree make.cross ARCH=ia64 All warnings (new ones prefixed by >>): In file included from include/uapi/linux/posix_types.h:5:0, from include/uapi/linux/types.h:14, from include/linux/compiler.h:164, from include/linux/ioport.h:13, from include/linux/acpi.h:25, from drivers//i2c/i2c-core-base.c:24: include/linux/i2c-smbus.h: In function 'i2c_require_smbus_alert': >> include/linux/stddef.h:8:14: warning: return makes integer from pointer >> without a cast [-Wint-conversion] #define NULL ((void *)0) ^ >> include/linux/i2c-smbus.h:67:9: note: in expansion of macro 'NULL' return NULL; ^~~~ include/linux/i2c-smbus.h: In function 'i2c_smbus_alert_event': >> include/linux/stddef.h:8:14: warning: return makes integer from pointer >> without a cast [-Wint-conversion] #define NULL ((void *)0) ^ include/linux/i2c-smbus.h:72:9: note: in expansion of macro 'NULL' return NULL; ^~~~ vim +/NULL +67 include/linux/i2c-smbus.h 60 61 #if IS_ENABLED(CONFIG_I2C_SMBUS) 62 int i2c_require_smbus_alert(struct i2c_client *client); 63 int i2c_smbus_alert_event(struct i2c_client *client); 64 #else 65 static inline int i2c_require_smbus_alert(struct i2c_client *client) 66 { > 67 return NULL; 68 } 69 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH v4 2/2] PCI: mediatek: Set up class type and vendor ID for MT7622
On Mon, 2017-12-25 at 18:27 +0800, Ryder Lee wrote: > On Fri, 2017-12-22 at 13:39 +0800, honghui.zh...@mediatek.com wrote: > > From: Honghui Zhang > > > > The hardware default value of IDs and class type is not correct, > > fix that by setup the correct values before start up. > > > > Signed-off-by: Honghui Zhang > > --- > > drivers/pci/host/pcie-mediatek.c | 12 > > include/linux/pci_ids.h | 3 +++ > > 2 files changed, 15 insertions(+) > > > > diff --git a/drivers/pci/host/pcie-mediatek.c > > b/drivers/pci/host/pcie-mediatek.c > > index fc29a9a..0ef33e4 100644 > > --- a/drivers/pci/host/pcie-mediatek.c > > +++ b/drivers/pci/host/pcie-mediatek.c > > @@ -74,6 +74,10 @@ > > > > /* PCIe V2 per-port registers */ > > #define PCIE_MSI_VECTOR0x0c0 > > + > > +#define PCIE_CONF_ID 0x100 > > +#define PCIE_CONF_CLASS0x104 > > + > > #define PCIE_INT_MASK 0x420 > > #define INTX_MASK GENMASK(19, 16) > > #define INTX_SHIFT 16 > > @@ -393,6 +397,14 @@ static int mtk_pcie_startup_port_v2(struct > > mtk_pcie_port *port) > > val |= PCIE_CSR_LTSSM_EN(port->slot) | > >PCIE_CSR_ASPM_L1_EN(port->slot); > > writel(val, pcie->base + PCIE_SYS_CFG_V2); > > + > > + /* Set up vendor ID and device ID for MT7622*/ > > + val = PCI_VENDOR_ID_MEDIATEK | (PCI_DEVICE_ID_MT7622 << 16); > > + writel(val, port->base + PCIE_CONF_ID); > > IMHO, this is a general function so you can ignore "device ID for > MT7622" here, but just make sure class code/vendor ID correct. Hmm, this condition is only for MT7622 for now. Well, host driver and framework does not cares about the device ID for host bridge. I guess I can bypass the setting of device ID. thanks. > > > + /* Set up class code for MT7622 */ > > + val = PCI_CLASS_BRIDGE_PCI << 16; > > + writel(val, port->base + PCIE_CONF_CLASS); > > } > > > > /* Assert all reset signals */ > > diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h > > index ab20dc5..000c5df 100644 >
Re: [RFC PATCH v11 4/5] PCI / PM: Add support for the PCIe WAKE# signal for OF
Hi Rafael, Thanks for your reply :) On 12/26/2017 08:11 AM, Rafael J. Wysocki wrote: >+ >+ dn = pci_device_to_OF_node(ppdev); >+ if (!dn) >+ return 0; >+ >+ irq = of_irq_get_byname(dn, "wakeup"); Why is this a property of the bridge and not of the device itself? That is suggested by Brian, because in that way, the wakeup pin would not "tied to what exact device is installed (or no device, if it's a slot)." >+ if (irq == -EPROBE_DEFER) Braces here, please. ok, will fix in the next version. >+ return irq; >+ /* Ignore other errors, since a missing wakeup is non-fatal. */ >+ else if (irq < 0) { >+ dev_info(&pdev->dev, "cannot get wakeup interrupt: %d\n", irq); >+ return 0; >+ } >+ >+ device_init_wakeup(&pdev->dev, true); Why do you call this before dev_pm_set_dedicated_wake_irq()? hmmm, i thought so too, but it turns out the dedicated wake irq framework requires device_init_wakeup(dev, true) before attach the wake irq: int device_wakeup_attach_irq(struct device *dev, struct wake_irq *wakeirq) { struct wakeup_source *ws; ws = dev->power.wakeup; if (!ws) { dev_err(dev, "forgot to call device_init_wakeup?\n"); return -EINVAL; >+ >+ ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, irq); >+ if (ret < 0) { >+ dev_err(&pdev->dev, "failed to set wake IRQ: %d\n", ret); >+ device_init_wakeup(&pdev->dev, false); >+ return ret; >+ } >+ It would be more straightforward to call device_init_wakeup() here. >+ return 0; >+} >+EXPORT_SYMBOL_GPL(of_pci_setup_wake_irq); >+ >+void of_pci_teardown_wake_irq(struct pci_dev *pdev) >+{ >+ if (!pdev->dev.power.wakeirq) >+ return; >+ >+ dev_pm_clear_wake_irq(&pdev->dev); >+ device_init_wakeup(&pdev->dev, false); >+} >+EXPORT_SYMBOL_GPL(of_pci_teardown_wake_irq); >+ > /** > * of_irq_parse_pci - Resolve the interrupt for a PCI device > * @pdev: the device whose interrupt is to be resolved Thanks, Rafael
Re: WARNING in do_debug
2017-12-26 8:22 GMT+08:00 syzbot : > syzkaller has found reproducer for the following crash on > 464e1d5f23cca236b930ef068c328a64cab78fb1 > git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/master > compiler: gcc (GCC) 7.1.1 20170620 > .config is attached > Raw console output is attached. > C reproducer is attached > syzkaller reproducer is attached. See https://goo.gl/kgGztJ > for information about syzkaller reproducers > https://git.kernel.org/pub/scm/virt/kvm/kvm.git/commit/?h=queue&id=ed3b37ac63a060bdc184d126c0655c1af8b6de62 There is a fix in kvm/queue. Regards, Wanpeng Li > > WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/traps.c:801 > cond_local_irq_disable arch/x86/kernel/traps.c:86 [inline] > WARNING: CPU: 0 PID: 3356 at arch/x86/kernel/traps.c:801 > do_debug+0x4d8/0x6e0 arch/x86/kernel/traps.c:815 > Kernel panic - not syncing: panic_on_warn set ... > > CPU: 0 PID: 3356 Comm: syzkaller834441 Not tainted 4.15.0-rc5+ #237 > Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS > Google 01/01/2011 > Call Trace: > <#DB> > __dump_stack lib/dump_stack.c:17 [inline] > dump_stack+0x194/0x257 lib/dump_stack.c:53 > panic+0x1e4/0x41c kernel/panic.c:183 > __warn+0x1dc/0x200 kernel/panic.c:547 > report_bug+0x211/0x2d0 lib/bug.c:184 > fixup_bug.part.11+0x37/0x80 arch/x86/kernel/traps.c:178 > fixup_bug arch/x86/kernel/traps.c:247 [inline] > do_error_trap+0x2d7/0x3e0 arch/x86/kernel/traps.c:296 > do_invalid_op+0x1b/0x20 arch/x86/kernel/traps.c:315 > invalid_op+0x22/0x40 arch/x86/entry/entry_64.S:1061 > RIP: 0010:cond_local_irq_disable arch/x86/kernel/traps.c:86 [inline] > RIP: 0010:do_debug+0x4d8/0x6e0 arch/x86/kernel/traps.c:815 > RSP: 0018:fe80ee98 EFLAGS: 00010246 > RAX: dc00 RBX: fe80ef58 RCX: > RDX: 1fd01dfc RSI: 0001 RDI: 85ec81f8 > RBP: fe80ef48 R08: fe80efe8 R09: > R10: R11: R12: e003 > R13: 8801c2340040 R14: 1fd01dd8 R15: 4000 > debug+0x34/0x60 arch/x86/entry/entry_64.S:1214 > RIP: 0010:__put_user_8+0x1f/0x25 arch/x86/lib/putuser.S:83 > RSP: 0018:8801c9f8ff28 EFLAGS: 0293 > RAX: 5a4195b6 RBX: 7fffeff9 RCX: 2000 > RDX: RSI: 0001 RDI: 0282 > RBP: 8801c9f8ff48 R08: R09: 1100393f1fc2 > R10: 8801c9f8fdd8 R11: R12: 5a4195b6 > R13: 2000 R14: 7f2c937f99c0 R15: 0001 > > entry_SYSCALL_64_fastpath+0x1f/0x96 > RIP: 0033:0x44aef9 > RSP: 002b:7f2c937f8ce8 EFLAGS: 0206 ORIG_RAX: 00c9 > RAX: ffda RBX: 006dcc24 RCX: 0044aef9 > RDX: 0044aef9 RSI: 0044aef9 RDI: 2000 > RBP: 006dcc20 R08: R09: > R10: R11: 0206 R12: > R13: 7ffe9191073f R14: 7f2c937f99c0 R15: 0001 > > Dumping ftrace buffer: >(ftrace buffer empty) > Kernel Offset: disabled > Rebooting in 86400 seconds.. >
Re: [linux-sunxi] [PATCH v4 0/2] Initial Allwinner V3s CSI Support
On Mon, 25 Dec 2017 09:58:02 +0100 Ondřej Jirman wrote: > Hello, > > On Mon, Dec 25, 2017 at 11:15:26AM +0800, Yong wrote: > > Hi, > > > > On Fri, 22 Dec 2017 14:46:48 +0100 > > Ondřej Jirman wrote: > > > > > Hello, > > > > > > Yong Deng píše v Pá 22. 12. 2017 v 17:32 +0800: > > > > > > > > Test input 0: > > > > > > > > Control ioctls: > > > > test VIDIOC_QUERY_EXT_CTRL/QUERYMENU: OK (Not Supported) > > > > test VIDIOC_QUERYCTRL: OK (Not Supported) > > > > test VIDIOC_G/S_CTRL: OK (Not Supported) > > > > test VIDIOC_G/S/TRY_EXT_CTRLS: OK (Not Supported) > > > > test VIDIOC_(UN)SUBSCRIBE_EVENT/DQEVENT: OK (Not > > > > Supported) > > > > test VIDIOC_G/S_JPEGCOMP: OK (Not Supported) > > > > Standard Controls: 0 Private Controls: 0 > > > > > > I'm not sure if your driver passes control queries to the subdev. It > > > did not originally, and I'm not sure you picked up the change from my > > > version of the driver. "Not supported" here seems to indicate that it > > > does not. > > > > > > I'd be interested what's the recommended practice here. It sure helps > > > with some apps that expect to be able to modify various input controls > > > directly on the /dev/video# device. These are then supported out of the > > > box. > > > > > > It's a one-line change. See: > > > > > > https://www.kernel.org/doc/html/latest/media/kapi/v4l2-controls.html#in > > > heriting-controls > > > > I think this is a feature and not affect the driver's main function. > > I just focused on making the CSI main function to work properly in > > the initial version. Is this feature mandatory or most commonly used? > > I grepped the platform/ code and it seems, that inheriting controls > from subdevs is pretty common for input drivers. (there are varying > approaches though, some inherit by hand in the link function, some > just register and empty ctrl_handler on the v4l2_dev and leave the > rest to the core). > > Practically, I haven't found a common app that would allow me to enter > both /dev/video0 and /dev/v4l-subdevX. I'm sure anyone can write one > themselves, but it would be better if current controls were available > at the /dev/video0 device automatically. > > It's much simpler for the userspace apps than the alternative, which > is trying to identify the correct subdev that is currently > associated with the CSI driver at runtime, which is not exactly > straightforward and requires much more code, than a few lines in > the kernel, that are required to inherit controls: > > > ret = v4l2_ctrl_handler_init(&csi->ctrl_handler, 0); > if (ret) { > dev_err(csi->dev, > "V4L2 controls handler init failed (%d)\n", > ret); > goto handle_error; > } > > csi->v4l2_dev.ctrl_handler = &csi->ctrl_handler; > > See: > https://github.com/megous/linux/blob/linux-tbs/drivers/media/platform/sun6i-csi/sun6i_csi.c#L1005 Ok, I will add this. Thanks for your explication. > > regards, > o.j. > > > Thanks, > > Yong Thanks, Yong
[PATCH] PM / wakeup: Drop redundant check from device_set_wakeup_enable()
From: Rafael J. Wysocki Since both device_wakeup_enable() and device_wakeup_disable() check if dev is not NULL and whether or not power.can_wakeup is set for it, device_set_wakeup_enable() doesn't have to do that, so drop that check from it. No intentional changes in functionality. Signed-off-by: Rafael J. Wysocki --- drivers/base/power/wakeup.c |3 --- 1 file changed, 3 deletions(-) Index: linux-pm/drivers/base/power/wakeup.c === --- linux-pm.orig/drivers/base/power/wakeup.c +++ linux-pm/drivers/base/power/wakeup.c @@ -464,9 +464,6 @@ EXPORT_SYMBOL_GPL(device_init_wakeup); */ int device_set_wakeup_enable(struct device *dev, bool enable) { - if (!dev || !dev->power.can_wakeup) - return -EINVAL; - return enable ? device_wakeup_enable(dev) : device_wakeup_disable(dev); } EXPORT_SYMBOL_GPL(device_set_wakeup_enable);
Re: [PATCH kernel-tests] ignore compiler errors
applied On Mon, Dec 25, 2017 at 07:53:32PM +0800, Fengguang Wu wrote: > This looks more like some odd compiler regression than a kernel one. > >Linus > > The original report is: > > To: Linus Torvalds > Cc: LKML > Subject: [linus:master] BUILD REGRESSION > d1f854ac240ea3928a99294390048e9b2aa6fa0e > > tree/branch: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master > branch HEAD: d1f854ac240ea3928a99294390048e9b2aa6fa0e Merge branch > 'libnvdimm-fixes' of > git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm > > Regressions in current branch: > > arch/c6x/platforms/plldata.c:279:33: error: implicit declaration of function > 'get_coreid'; did you mean 'get_order'? > [-Werror=implicit-function-declaration] > drivers/tty/serial/8250/8250_core.c:1094:1: error: unrecognizable insn: > drivers/tty/serial/8250/8250_core.c:1094:1: internal compiler error: in > extract_insn, at recog.c:2311 > fs//xfs/xfs_ioctl.c:1624:1: internal compiler error: in change_address_1, at > emit-rtl.c:2150 > fs/xfs/xfs_ioctl.c:1629:1: internal compiler error: in change_address_1, at > emit-rtl.c:2150 > Please submit a full bug report, > {standard input}:1226: Error: displacement to undefined symbol .L329 > overflows 12-bit field > {standard input}:1233: Error: displacement to undefined symbol .L331 > overflows 12-bit field > {standard input}:1253: Error: displacement to undefined symbol .L359 > overflows 12-bit field > {standard input}:1278: Error: displacement to undefined symbol .L360 > overflows 12-bit field > {standard input}:1405: Error: displacement to undefined symbol .L255 > overflows 12-bit field > {standard input}:1408: Error: invalid operands for opcode > {standard input}:1408: Error: missing operand > {standard input}:1453: Error: displacement to undefined symbol .L285 > overflows 12-bit field > {standard input}:1457: Error: displacement to undefined symbol .L286 > overflows 12-bit field > {standard input}:1467: Error: displacement to undefined symbol .L257 > overflows 12-bit field > {standard input}:1893: Error: displacement to undefined symbol .L229 > overflows 12-bit field > {standard input}:199: Error: unknown opcode > {standard input}:2013: Error: displacement to undefined symbol .L235 > overflows 12-bit field > {standard input}:9613: Error: invalid operands for opcode > {standard input}:9613: Error: missing operand > {standard input}: Error: open CFI at the end of file; missing .cfi_endproc > directive > verifier.c:(.text+0x31ec): undefined reference to `__multi3' > > Error ids grouped by kconfigs: > > recent_errors > ├── c6x-evmc6472_defconfig > │ └── > arch-c6x-platforms-plldata.c:error:implicit-declaration-of-function-get_coreid-did-you-mean-get_order > ├── cris-allyesconfig > │ ├── drivers-tty-serial-8250_core.c:error:unrecognizable-insn: > │ └── > drivers-tty-serial-8250_core.c:internal-compiler-error:in-extract_insn-at-recog.c > ├── mips-64r6el_defconfig > │ └── verifier.c:(.text):undefined-reference-to-__multi3 > ├── sh-allyesconfig > │ ├── > fs-xfs-xfs_ioctl.c:internal-compiler-error:in-change_address_1-at-emit-rtl.c > │ ├── Please-submit-a-full-bug-report > │ ├── > standard-input:Error:displacement-to-undefined-symbol-.L229-overflows-bit-field > │ ├── > standard-input:Error:displacement-to-undefined-symbol-.L235-overflows-bit-field > │ ├── standard-input:Error:invalid-operands-for-opcode > │ ├── standard-input:Error:missing-operand > │ └── > standard-input:Error:open-CFI-at-the-end-of-file-missing-.cfi_endproc-directive > ├── sh-j2_defconfig > │ └── standard-input:Error:unknown-opcode > ├── sh-sdk7786_defconfig > │ ├── > standard-input:Error:displacement-to-undefined-symbol-.L255-overflows-bit-field > │ ├── > standard-input:Error:displacement-to-undefined-symbol-.L257-overflows-bit-field > │ ├── > standard-input:Error:displacement-to-undefined-symbol-.L285-overflows-bit-field > │ └── > standard-input:Error:displacement-to-undefined-symbol-.L286-overflows-bit-field > └── sh-titan_defconfig > ├── > fs-xfs-xfs_ioctl.c:internal-compiler-error:in-change_address_1-at-emit-rtl.c > ├── Please-submit-a-full-bug-report > ├── > standard-input:Error:displacement-to-undefined-symbol-.L329-overflows-bit-field > ├── > standard-input:Error:displacement-to-undefined-symbol-.L331-overflows-bit-field > ├── > standard-input:Error:displacement-to-undefined-symbol-.L359-overflows-bit-field > ├── > standard-input:Error:displacement-to-undefined-symbol-.L360-overflows-bit-field > ├── standard-input:Error:invalid-operands-for-opcode > └── standard-input:Error:missing-operand > > Signed-off-by: Fengguang Wu > --- > ignore-errors | 11 +-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/ignore-errors b/ignore-errors > index 02e0163..c56e228 100755 > --- a/ignore-errors > +++ b/ignore-errors > @@ -1,7 +1,9 @@ > \[-Werror\] > \[-Werror=return-type
Re: [RFC PATCH v11 4/5] PCI / PM: Add support for the PCIe WAKE# signal for OF
On Monday, December 25, 2017 12:47:41 PM CET Jeffy Chen wrote: > Add of_pci_setup_wake_irq() and of_pci_teardown_wake_irq() to handle > the PCIe WAKE# interrupt. > > Also use the dedicated wakeirq infrastructure to simplify it. > > Signed-off-by: Jeffy Chen > --- > > Changes in v11: > Only support 1-per-device PCIe WAKE# pin as suggested. > > Changes in v10: > Use device_set_wakeup_capable() instead of device_set_wakeup_enable(), > since dedicated wakeirq will be lost in device_set_wakeup_enable(false). > > Changes in v9: > Fix check error in .cleanup(). > Move dedicated wakeirq setup to setup() callback and use > device_set_wakeup_enable() to enable/disable. > > Changes in v8: > Add pci-of.c and use platform_pm_ops to handle the PCIe WAKE# signal. > > Changes in v7: > Move PCIE_WAKE handling into pci core. > > Changes in v6: > Fix device_init_wake error handling, and add some comments. > > Changes in v5: > Rebase. > > Changes in v3: > Fix error handling. > > Changes in v2: > Use dev_pm_set_dedicated_wake_irq. > > drivers/of/of_pci_irq.c | 49 > > drivers/pci/pci-driver.c | 10 ++ > include/linux/of_pci.h | 9 + > 3 files changed, 68 insertions(+) > > diff --git a/drivers/of/of_pci_irq.c b/drivers/of/of_pci_irq.c > index d39565d5477b..def884c1a37a 100644 > --- a/drivers/of/of_pci_irq.c > +++ b/drivers/of/of_pci_irq.c > @@ -1,8 +1,57 @@ > #include > #include > #include > +#include > #include > > +int of_pci_setup_wake_irq(struct pci_dev *pdev) > +{ > + struct pci_dev *ppdev; > + struct device_node *dn; > + int ret, irq; > + > + /* Get the pci_dev of our parent. Hopefully it's a port. */ > + ppdev = pdev->bus->self; > + /* Nope, it's a host bridge. */ > + if (!ppdev) > + return 0; > + > + dn = pci_device_to_OF_node(ppdev); > + if (!dn) > + return 0; > + > + irq = of_irq_get_byname(dn, "wakeup"); Why is this a property of the bridge and not of the device itself? > + if (irq == -EPROBE_DEFER) Braces here, please. > + return irq; > + /* Ignore other errors, since a missing wakeup is non-fatal. */ > + else if (irq < 0) { > + dev_info(&pdev->dev, "cannot get wakeup interrupt: %d\n", irq); > + return 0; > + } > + > + device_init_wakeup(&pdev->dev, true); Why do you call this before dev_pm_set_dedicated_wake_irq()? > + > + ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, irq); > + if (ret < 0) { > + dev_err(&pdev->dev, "failed to set wake IRQ: %d\n", ret); > + device_init_wakeup(&pdev->dev, false); > + return ret; > + } > + It would be more straightforward to call device_init_wakeup() here. > + return 0; > +} > +EXPORT_SYMBOL_GPL(of_pci_setup_wake_irq); > + > +void of_pci_teardown_wake_irq(struct pci_dev *pdev) > +{ > + if (!pdev->dev.power.wakeirq) > + return; > + > + dev_pm_clear_wake_irq(&pdev->dev); > + device_init_wakeup(&pdev->dev, false); > +} > +EXPORT_SYMBOL_GPL(of_pci_teardown_wake_irq); > + > /** > * of_irq_parse_pci - Resolve the interrupt for a PCI device > * @pdev: the device whose interrupt is to be resolved Thanks, Rafael
Re: [patch v15 0/4] JTAG driver introduction
Le 12/25/17 à 03:53, Oleksandr Shamray a écrit : > When a need raise up to use JTAG interface for system's devices > programming or CPU debugging, usually the user layer > application implements jtag protocol by bit-bang or using a > proprietary connection to vendor hardware. > This method can be slow and not generic. > > We propose to implement general JTAG interface and infrastructure > to communicate with user layer application. In such way, we can > have the standard JTAG interface core part and separation from > specific HW implementation. Well, the framework in its current shape is still extremely simplistic, therefore leaving a lot of room (read: bugs, inconsistencies) within the hands of the driver, so while the user-space interface is standard through the proposed character device, the user experience, likely might not. > This allow new capability to debug the CPU or program system's > device via BMC without additional devices nor cost. If that is the case, should not we leverage the kernel's device driver model and expect the JTAG framework to create specific devices for the different pieces of HW discovered on the scan chain? That would also presumably allow the core JTAG framework to retain the necessary state changes in order to address one particular device within the scan chain. > > This patch purpose is to add JTAG master core infrastructure by > defining new JTAG class and provide generic JTAG interface > to allow hardware specific drivers to connect this interface. > This will enable all JTAG drivers to use the common interface > part and will have separate for hardware implementation. Let's consider I want to get rid of OpenOCD, or rather, move its driver interface within the kernel and replace it on the OpenOCD side with a generic character device interface. I could presumably amortize the costly operations which are currently I/O and/or system call limiting when running in user-space, what would it look like with your proposed framework, have you given some thoughts about that? Thanks! -- Florian
Re: [PATCH] ASoC: max98373: Added Amplifier Driver
Hi Ryan > >About this max98373->codec. > >This user is only max98373_set_clock(), and it is called from > >max98373_dai_hw_params(). > >You are getting *codec from dai->codec in this function, and max98373 is > >came from it. > >This means, we can remove max98373->codec ? > > Thanks for your feedback. > I will remove max98373->codec and change related things. Thanks > I'm sorry but I don't fully understand the benefit of this. > Keeping regmap information in private driver data is very common and I can > see many ASoC drivers are using it. > I was able to see only a few driver use ' snd_soc_component_read'. > I would like to keep regmap_read/write if it is still acceptable. I checked other drivers. Having private regmap seems a little bit duplicate for me, because we can get it from component or dev. But sometimes, in some drivers, it seems can be difficult. Sorry for my noise. Best regards --- Kuninori Morimoto
Re: [patch v15 1/4] drivers: jtag: Add JTAG core driver
Le 12/25/17 à 03:53, Oleksandr Shamray a écrit : > Initial patch for JTAG driver > JTAG class driver provide infrastructure to support hardware/software > JTAG platform drivers. It provide user layer API interface for flashing > and debugging external devices which equipped with JTAG interface > using standard transactions. > > Driver exposes set of IOCTL to user space for: > - XFER: > - SIR (Scan Instruction Register, IEEE 1149.1 Data Register scan); > - SDR (Scan Data Register, IEEE 1149.1 Instruction Register scan); > - RUNTEST (Forces the IEEE 1149.1 bus to a run state for a specified > number of clocks). > - SIOCFREQ/GIOCFREQ for setting and reading JTAG frequency. > > Driver core provides set of internal APIs for allocation and > registration: > - jtag_register; > - jtag_unregister; > - jtag_alloc; > - jtag_free; > > Platform driver on registration with jtag-core creates the next > entry in dev folder: > /dev/jtagX Just some general comment, I am really surprised to see that there is not a whole lot of generic code, actually, there is none, which tries to manage the JTAG devices command queue, e.g: ala OpenOCD. All that this is doing here is create a special character device with a bunch of custom ioctl(), which means that a lot of code is going to be put within in individual drivers. Have you given some thoughts on how you would expand this framework for non ASPEED JTAG adapters? For instance, one expectation is to see a bit-banged GPIO master, since that's quite common, what would it look like here? How much code would I have to write? [snip] > + > +void *jtag_priv(struct jtag *jtag) > +{ > + return jtag->priv; > +} > +EXPORT_SYMBOL_GPL(jtag_priv); Can't you just create a static inline function in the public header for that? This is usually what subsystems do, I can understand why you would not want to expose struct jtag to other parts of the kernel, but still, this looks ugly, so maybe consider splitting the header between provider and consumer? > + > +static long jtag_ioctl(struct file *file, unsigned int cmd, unsigned long > arg) > +{ > + struct jtag *jtag = file->private_data; > + struct jtag_run_test_idle idle; > + struct jtag_xfer xfer; > + u8 *xfer_data; > + u32 data_size; > + u32 value; > + int err; > + > + if (!arg) > + return -EINVAL; > + > + switch (cmd) { > + case JTAG_GIOCFREQ: > + > + if (jtag->ops->freq_get) > + err = jtag->ops->freq_get(jtag, &value); > + else > + err = -EOPNOTSUPP; > + if (err) > + break; > + > + if (put_user(value, (__u32 *)arg)) > + err = -EFAULT; > + break; > + > + case JTAG_SIOCFREQ: > + if (get_user(value, (__u32 *)arg)) > + return -EFAULT; > + if (value == 0) > + return -EINVAL; > + > + if (jtag->ops->freq_set) > + err = jtag->ops->freq_set(jtag, value); > + else > + err = -EOPNOTSUPP; You should check that before get_user() > + break; > + > + case JTAG_IOCRUNTEST: > + if (copy_from_user(&idle, (void *)arg, > +sizeof(struct jtag_run_test_idle))) > + return -EFAULT; > + > + if (idle.endstate > JTAG_STATE_PAUSEDR) > + return -EINVAL; > + > + if (jtag->ops->idle) > + err = jtag->ops->idle(jtag, &idle); > + else > + err = -EOPNOTSUPP; > + break; Same here. > + > + case JTAG_IOCXFER: > + if (copy_from_user(&xfer, (void *)arg, > +sizeof(struct jtag_xfer))) > + return -EFAULT; > + > + if (xfer.length >= JTAG_MAX_XFER_DATA_LEN) > + return -EINVAL; > + > + if (xfer.type > JTAG_SDR_XFER) > + return -EINVAL; > + > + if (xfer.direction > JTAG_WRITE_XFER) > + return -EINVAL; > + > + if (xfer.endstate > JTAG_STATE_PAUSEDR) > + return -EINVAL; > + > + data_size = DIV_ROUND_UP(xfer.length, BITS_PER_BYTE); > + xfer_data = memdup_user(u64_to_user_ptr(xfer.tdio), data_size); > + > + if (!xfer_data) > + return -EFAULT; > + > + if (jtag->ops->xfer) { > + err = jtag->ops->xfer(jtag, &xfer, xfer_data); > + } else { > + kfree(xfer_data); > + return -EOPNOTSUPP; > + } Why don't you move all of the code here into a function which will make the error handling consistent? Also, checking whether the jtag adapter implements ops->xfer should probably be done before you do the memdup_user(). > + > + if (err) { > +
Re: [PATCH] perf report: Fix a no annotate browser displayed issue
On 12/26/2017 5:44 AM, Jiri Olsa wrote: On Mon, Dec 25, 2017 at 11:58:39AM +0800, Jin, Yao wrote: Hi, Any comments for this bug fix? getting segfault with this [jolsa@krava perf]$ sudo ./perf record -b ls [jolsa@krava perf]$ sudo ./perf report --stdio Segmentation fault (core dumped) jirka Sorry about that. My fault, I will debug this issue. Thanks Jin Yao Thanks Jin Yao On 12/18/2017 9:26 PM, Jin Yao wrote: When enabling '-b' option in perf record, for example, perf record -b ... perf report and then browsing the annotate browser from perf report, it would be failed (annotate browser can't be displayed). It's because the '.add_entry_cb' op of struct report is overwritten by hist_iter__branch_callback() in builtin-report.c. But this function doesn't do something like mapping symbols and sources. So next, do_annotate() will return directly. notes = symbol__annotation(act->ms.sym); if (!notes->src) return 0; This patch adds the lost code to hist_iter__branch_callback ( refer to hist_iter__report_callback). Signed-off-by: Jin Yao --- tools/perf/builtin-report.c | 15 ++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index eb9ce63..0bd0aef 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c @@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter, struct hist_entry *he = iter->he; struct report *rep = arg; struct branch_info *bi; + struct perf_sample *sample = iter->sample; + struct perf_evsel *evsel = iter->evsel; + int err; + + hist__account_cycles(sample->branch_stack, al, sample, +rep->nonany_branch_mode); bi = he->branch_info; + err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx); + if (err) + goto out; + + err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx); + branch_type_count(&rep->brtype_stat, &bi->flags, bi->from.addr, bi->to.addr); - return 0; +out: + return err; } static int process_sample_event(struct perf_tool *tool,
[PATCH bpf-next 0/3] add XDP loading support to libbpf
Hello, This patchset adds a function to load XDP eBPF file in the libbpf library. It gets the netlink extended ack from the driver in case of failure and print the error to stderr. Best regards, -- Eric Leblond
[PATCH bpf-next 3/3] libbpf: break loop earlier
Get out of the loop when we have a match. Signed-off-by: Eric Leblond --- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 5fe8aaa2123e..d263748aa341 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -412,6 +412,7 @@ bpf_object__init_prog_names(struct bpf_object *obj) prog->section_name); return -LIBBPF_ERRNO__LIBELF; } + break; } if (!name) { -- 2.15.1
[PATCH bpf-next 2/3] libbpf: add error reporting in XDP
Parse netlink ext attribute to get the error message returned by the card. Signed-off-by: Eric Leblond --- tools/lib/bpf/Build| 2 +- tools/lib/bpf/bpf.c| 9 +++ tools/lib/bpf/nlattr.c | 188 + tools/lib/bpf/nlattr.h | 164 ++ 4 files changed, 362 insertions(+), 1 deletion(-) create mode 100644 tools/lib/bpf/nlattr.c create mode 100644 tools/lib/bpf/nlattr.h diff --git a/tools/lib/bpf/Build b/tools/lib/bpf/Build index d8749756352d..64c679d67109 100644 --- a/tools/lib/bpf/Build +++ b/tools/lib/bpf/Build @@ -1 +1 @@ -libbpf-y := libbpf.o bpf.o +libbpf-y := libbpf.o bpf.o nlattr.o diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 1e3cfe6b9fce..cfd30a0cbce4 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -26,6 +26,7 @@ #include #include "bpf.h" #include "libbpf.h" +#include "nlattr.h" #include #include #include @@ -436,6 +437,7 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) struct nlmsghdr *nh; struct nlmsgerr *err; socklen_t addrlen; + int one; memset(&sa, 0, sizeof(sa)); sa.nl_family = AF_NETLINK; @@ -445,6 +447,12 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) return -errno; } + if (setsockopt(sock, SOL_NETLINK, NETLINK_EXT_ACK, + &one, sizeof(one)) < 0) { + /* debug/verbose message that it is not supported */ + fprintf(stderr, "Netlink error reporting not supported\n"); + } + if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { ret = -errno; goto cleanup; @@ -521,6 +529,7 @@ int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) if (!err->error) continue; ret = err->error; + nla_dump_errormsg(nh); goto cleanup; case NLMSG_DONE: break; diff --git a/tools/lib/bpf/nlattr.c b/tools/lib/bpf/nlattr.c new file mode 100644 index ..962de14f74e3 --- /dev/null +++ b/tools/lib/bpf/nlattr.c @@ -0,0 +1,188 @@ + +/* + * NETLINK Netlink attributes + * + * Authors:Thomas Graf + * Alexey Kuznetsov + */ + +#include +#include "nlattr.h" +#include +#include +#include + +static const __u8 nla_attr_minlen[NLA_TYPE_MAX+1] = { + [NLA_U8]= sizeof(__u8), + [NLA_U16] = sizeof(__u16), + [NLA_U32] = sizeof(__u32), + [NLA_U64] = sizeof(__u64), + [NLA_MSECS] = sizeof(__u64), + [NLA_NESTED]= NLA_HDRLEN, + [NLA_S8]= sizeof(__s8), + [NLA_S16] = sizeof(__s16), + [NLA_S32] = sizeof(__s32), + [NLA_S64] = sizeof(__s64), +}; + +static int validate_nla(const struct nlattr *nla, int maxtype, + const struct nla_policy *policy) +{ + const struct nla_policy *pt; + int minlen = 0, attrlen = nla_len(nla), type = nla_type(nla); + + if (type <= 0 || type > maxtype) + return 0; + + pt = &policy[type]; + + if (pt->type > NLA_TYPE_MAX) + return -EINVAL; + + switch (pt->type) { + case NLA_FLAG: + if (attrlen > 0) + return -ERANGE; + break; + + case NLA_NUL_STRING: + if (pt->len) + minlen = min(attrlen, pt->len + 1); + else + minlen = attrlen; + + if (!minlen || memchr(nla_data(nla), '\0', minlen) == NULL) + return -EINVAL; + /* fall through */ + + case NLA_STRING: + if (attrlen < 1) + return -ERANGE; + + if (pt->len) { + char *buf = nla_data(nla); + + if (buf[attrlen - 1] == '\0') + attrlen--; + + if (attrlen > pt->len) + return -ERANGE; + } + break; + + case NLA_BINARY: + if (pt->len && attrlen > pt->len) + return -ERANGE; + break; + + case NLA_NESTED_COMPAT: + if (attrlen < pt->len) + return -ERANGE; + if (attrlen < NLA_ALIGN(pt->len)) + break; + if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN) + return -ERANGE; + nla = nla_data(nla) + NLA_ALIGN(pt->len); + if (attrlen < NLA_ALIGN(pt->len) + NLA_HDRLEN + nla_len(nla)) + return -ERANGE; + break; + case NLA_NESTED: + /* a nested attributes is allowed to be empty; if its not, +*
[PATCH bpf-next 1/3] libbpf: add function to setup XDP
Most of the code is taken from set_link_xdp_fd() in bpf_load.c and slightly modified to be library compliant. Signed-off-by: Eric Leblond --- tools/lib/bpf/bpf.c| 126 - tools/lib/bpf/libbpf.c | 2 + tools/lib/bpf/libbpf.h | 4 ++ 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/tools/lib/bpf/bpf.c b/tools/lib/bpf/bpf.c index 5128677e4117..1e3cfe6b9fce 100644 --- a/tools/lib/bpf/bpf.c +++ b/tools/lib/bpf/bpf.c @@ -25,6 +25,16 @@ #include #include #include "bpf.h" +#include "libbpf.h" +#include +#include +#include + +#ifndef IFLA_XDP_MAX +#define IFLA_XDP 43 +#define IFLA_XDP_FD1 +#define IFLA_XDP_FLAGS 3 +#endif /* * When building perf, unistd.h is overridden. __NR_bpf is @@ -46,8 +56,6 @@ # endif #endif -#define min(x, y) ((x) < (y) ? (x) : (y)) - static inline __u64 ptr_to_u64(const void *ptr) { return (__u64) (unsigned long) ptr; @@ -413,3 +421,117 @@ int bpf_obj_get_info_by_fd(int prog_fd, void *info, __u32 *info_len) return err; } + +int bpf_set_link_xdp_fd(int ifindex, int fd, __u32 flags) +{ + struct sockaddr_nl sa; + int sock, seq = 0, len, ret = -1; + char buf[4096]; + struct nlattr *nla, *nla_xdp; + struct { + struct nlmsghdr nh; + struct ifinfomsg ifinfo; + char attrbuf[64]; + } req; + struct nlmsghdr *nh; + struct nlmsgerr *err; + socklen_t addrlen; + + memset(&sa, 0, sizeof(sa)); + sa.nl_family = AF_NETLINK; + + sock = socket(AF_NETLINK, SOCK_RAW, NETLINK_ROUTE); + if (sock < 0) { + return -errno; + } + + if (bind(sock, (struct sockaddr *)&sa, sizeof(sa)) < 0) { + ret = -errno; + goto cleanup; + } + + addrlen = sizeof(sa); + if (getsockname(sock, (struct sockaddr *)&sa, &addrlen) < 0) { + ret = errno; + goto cleanup; + } + + if (addrlen != sizeof(sa)) { + ret = errno; + goto cleanup; + } + + memset(&req, 0, sizeof(req)); + req.nh.nlmsg_len = NLMSG_LENGTH(sizeof(struct ifinfomsg)); + req.nh.nlmsg_flags = NLM_F_REQUEST | NLM_F_ACK; + req.nh.nlmsg_type = RTM_SETLINK; + req.nh.nlmsg_pid = 0; + req.nh.nlmsg_seq = ++seq; + req.ifinfo.ifi_family = AF_UNSPEC; + req.ifinfo.ifi_index = ifindex; + + /* started nested attribute for XDP */ + nla = (struct nlattr *)(((char *)&req) + + NLMSG_ALIGN(req.nh.nlmsg_len)); + nla->nla_type = NLA_F_NESTED | IFLA_XDP; + nla->nla_len = NLA_HDRLEN; + + /* add XDP fd */ + nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); + nla_xdp->nla_type = IFLA_XDP_FD; + nla_xdp->nla_len = NLA_HDRLEN + sizeof(int); + memcpy((char *)nla_xdp + NLA_HDRLEN, &fd, sizeof(fd)); + nla->nla_len += nla_xdp->nla_len; + + /* if user passed in any flags, add those too */ + if (flags) { + nla_xdp = (struct nlattr *)((char *)nla + nla->nla_len); + nla_xdp->nla_type = IFLA_XDP_FLAGS; + nla_xdp->nla_len = NLA_HDRLEN + sizeof(flags); + memcpy((char *)nla_xdp + NLA_HDRLEN, &flags, sizeof(flags)); + nla->nla_len += nla_xdp->nla_len; + } + + req.nh.nlmsg_len += NLA_ALIGN(nla->nla_len); + + if (send(sock, &req, req.nh.nlmsg_len, 0) < 0) { + ret = -errno; + goto cleanup; + } + + len = recv(sock, buf, sizeof(buf), 0); + if (len < 0) { + ret = -errno; + goto cleanup; + } + + for (nh = (struct nlmsghdr *)buf; NLMSG_OK(nh, len); +nh = NLMSG_NEXT(nh, len)) { + if (nh->nlmsg_pid != sa.nl_pid) { + ret = -LIBBPF_ERRNO__WRNGPID; + goto cleanup; + } + if (nh->nlmsg_seq != seq) { + ret = -LIBBPF_ERRNO__INVSEQ; + goto cleanup; + } + switch (nh->nlmsg_type) { + case NLMSG_ERROR: + err = (struct nlmsgerr *)NLMSG_DATA(nh); + if (!err->error) + continue; + ret = err->error; + goto cleanup; + case NLMSG_DONE: + break; + default: + break; + } + } + + ret = 0; + +cleanup: + close(sock); + return ret; +} diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index e9c4b7cabcf2..5fe8aaa2123e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -106,6 +106,8 @@ static const char *libbpf_strerror_table[NR_ERRNO] = { [ERRCODE_OFFSET(PROG2BIG)] = "Program too big",
Re: [PATCH/RFC] perf report: Add option to change offset format when address is specified as a sort_key
On Sun, Dec 24, 2017 at 06:23:15PM +, Aaron Tomlin wrote: > On Sat 2017-12-23 00:59 +0100, Jiri Olsa wrote: > [ ... ] > > not sure we've already discussed that, but this could be default? > > Probably it is best to keep the default behaviour. > > I'd prefer a hexadecimal address offset, as the default, however perhaps > someone is happy with the current default (decimal). Arnaldo? > > > if not, I think the hex option should be part of -g option arg, maybe like: > > Does it have to be? > > > -g graph,callee,xaddress > > Not sure - adding another sort_key seems odd to me. it's not sort key, it's -g option key.. but if we go for default there's no need.. let's see ;-) > > But if you insist, perhaps address[=hex] would be cleaner? but yes, that looks better to me jirka
Re: [PATCH] perf report: Fix a no annotate browser displayed issue
On Mon, Dec 25, 2017 at 11:58:39AM +0800, Jin, Yao wrote: > Hi, > > Any comments for this bug fix? getting segfault with this [jolsa@krava perf]$ sudo ./perf record -b ls [jolsa@krava perf]$ sudo ./perf report --stdio Segmentation fault (core dumped) jirka > > Thanks > Jin Yao > > On 12/18/2017 9:26 PM, Jin Yao wrote: > > When enabling '-b' option in perf record, for example, > > > > perf record -b ... > > perf report > > > > and then browsing the annotate browser from perf report, it would > > be failed (annotate browser can't be displayed). > > > > It's because the '.add_entry_cb' op of struct report is overwritten > > by hist_iter__branch_callback() in builtin-report.c. But this function > > doesn't do something like mapping symbols and sources. So next, > > do_annotate() will return directly. > > > > notes = symbol__annotation(act->ms.sym); > > if (!notes->src) > > return 0; > > > > This patch adds the lost code to hist_iter__branch_callback ( > > refer to hist_iter__report_callback). > > > > Signed-off-by: Jin Yao > > --- > > tools/perf/builtin-report.c | 15 ++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c > > index eb9ce63..0bd0aef 100644 > > --- a/tools/perf/builtin-report.c > > +++ b/tools/perf/builtin-report.c > > @@ -162,12 +162,25 @@ static int hist_iter__branch_callback(struct > > hist_entry_iter *iter, > > struct hist_entry *he = iter->he; > > struct report *rep = arg; > > struct branch_info *bi; > > + struct perf_sample *sample = iter->sample; > > + struct perf_evsel *evsel = iter->evsel; > > + int err; > > + > > + hist__account_cycles(sample->branch_stack, al, sample, > > +rep->nonany_branch_mode); > > bi = he->branch_info; > > + err = addr_map_symbol__inc_samples(&bi->from, sample, evsel->idx); > > + if (err) > > + goto out; > > + > > + err = addr_map_symbol__inc_samples(&bi->to, sample, evsel->idx); > > + > > branch_type_count(&rep->brtype_stat, &bi->flags, > > bi->from.addr, bi->to.addr); > > - return 0; > > +out: > > + return err; > > } > > static int process_sample_event(struct perf_tool *tool, > >
Re: Php-fpm will crash when perf runs with call graph option
On Mon, Dec 25, 2017 at 07:56:43AM +0100, ufo19890607 wrote: > From: yuzhoujian > > #0 0x7f044ff447bd in re_compile_fastmap_iter (bufp=0x7f044ff447bd > , > fastmap=0x46 , > init_state=, init_state=) at regcomp.c:407 > 407 if (__wcrtomb (buf, towlower (cset->mbchars[i]), > &state) > (gdb) bt > #0 0x7f044ff447bd in re_compile_fastmap_iter (bufp=0x7f044ff447bd > , > fastmap=0x46 , init_state= out>, init_state=) at regcomp.c:407 > #1 0x00831160 in virtual_file_ex (state=0x7fff9c1a4f70, > path=, verify_path=0x0, use_realpath=1) > at /home/xiaoju/phpng/php-7.0.6/Zend/zend_virtual_cwd.c:1335 > #2 0x007aacee in expand_filepath_with_mode ( > filepath=0x7f044d6020d8 > "/home/xiaoju/ep/as/store//toggles/beatles_api_discovery_is_open_by_app", > real_path=0x7fff9c1a4fc0 "\360X\032\234\377\177", > relative_to=, relative_to_len=0, realpath_mode=1) > at > /home/xiaoju/phpng/php-7.0.6/main/fopen_wrappers.c:812 > #3 0x007c1536 in _php_stream_fopen ( > filename=0x7f044d6020d8 > "/home/xiaoju/ep/as/store//toggles/beatles_api_discovery_is_open_by_app", > mode=0xdbb1f1 "rb", > opened_path=0x0, options=0) at > /home/xiaoju/phpng/php-7.0.6/main/streams/plain_wrapper.c:970 > #4 0x007bd084 in _php_stream_open_wrapper_ex ( > path=0x7f044d6020d8 > "/home/xiaoju/ep/as/store//toggles/beatles_api_discovery_is_open_by_app", > mode=0xdbb1f1 "rb", options=8, > opened_path=0x0, context=0x7f044d65f4c0) at > /home/xiaoju/phpng/php-7.0.6/main/streams/streams.c:2060 > #5 0x0071722b in zif_file_get_contents (execute_data= out>, return_value=0x7f044d615540) > at > /home/xiaoju/phpng/php-7.0.6/ext/standard/file.c:544 > #6 0x0065387c in phar_file_get_contents > (execute_data=0x7f044d615570, return_value=0x7f044d615540) > at > /home/xiaoju/phpng/php-7.0.6/ext/phar/func_interceptors.c:224)) > > I add some output info in the php source code, and found that virtual_file_ex > functions's rbp value is really strange,etc 0x1, 0x31. I guess when the perf > collects samples for all the cpus with -g option, it may destroy the > php-fpm's stack. When the perf is running without -g option, the php-fpm is > normal. Who have ever encountered similar problems? hum, except for speed there shouldn't be other influence on perf-ed program, does it happen always? whats the perf record's command line? it's possible you're hitting some php-fpm race issue due to the speed degradation > BTW, OS in the server: Centos7.3 , Kernel version: > 3.10.0-514.16.1.el7.x86_64. php-fpm version: 7.0.6 > Processor info: Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz is there a single way to reproduce? As already mentioned by Wang, does it happen on recent kernel? thanks, jirka
Re: PROBLEM: consolidated IDT invalidation causes kexec to reboot
Thanks for that! On Mon, Dec 25, 2017 at 06:40:14AM -0800, Andy Lutomirski wrote: > On Sat, Dec 23, 2017 at 7:30 PM, Linus Torvalds > wrote: > > On Sat, Dec 23, 2017 at 5:44 PM, Alexandru Chirvasitu > > wrote: > >> > >> For testing purposes, I've altered machine_kexec_32.c making the > >> following toy commit. It naively undoes part of e802a51, solely to > >> confirm that's where it goes awry in my setup. > > > > That's really funky. > > > > The idt_invalidate() seems to do *exactly* the same thing. It uses > > "load_idt()" on an IDT with size 0, and the supplied address. > > > > Can you disassemble your "set_idt()" code vs the "idt_invalidate()"? > > > >> Is this expected behaviour? > > > > No. The code literally seems identical. The only difference is > > > > (a) where the 0 limit comes from > > > > (b) perhaps build flags and whether it is inlined or not due to being > > in a different file > > > > and neither of those should matter, but maybe they do. > > > > Which is why I'd like you to actually look at the generated code and > > see if you can see any difference.. > > > > This is presumably the same call-tracing-without-TLS-working problem. > idt_invalidate() is out-of-line and is compiled with full tracing on, > and we're calling it from a context without TLS working (it's > explicitly disabled in load_segments()) in machine_kexec_32.c. The > right fix is probably to inline idt_invalidate() and to add a comment. > This works.. I went back to the troublesome commit e802a51 and modified it as follows: make idt_invalidate static inline in header file diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h index 33aff45..87ca363 100644 --- a/arch/x86/include/asm/desc.h +++ b/arch/x86/include/asm/desc.h @@ -504,6 +504,17 @@ static inline void load_current_idt(void) load_idt((const struct desc_ptr *)&idt_descr); } -extern void idt_invalidate(void *addr); + +/** + * idt_invalidate - Invalidate interrupt descriptor table + * @addr: The virtual address of the 'invalid' IDT + */ +static inline void idt_invalidate(void *addr) +{ +struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 }; + +load_idt(&idt); +} + #endif /* _ASM_X86_DESC_H */ diff --git a/arch/x86/kernel/idt.c b/arch/x86/kernel/idt.c index cd4658c..fec44c6 100644 --- a/arch/x86/kernel/idt.c +++ b/arch/x86/kernel/idt.c @@ -25,13 +25,3 @@ const struct desc_ptr debug_idt_descr = { }; #endif -/** - * idt_invalidate - Invalidate interrupt descriptor table - * @addr: The virtual address of the 'invalid' IDT - */ -void idt_invalidate(void *addr) -{ - struct desc_ptr idt = { .address = (unsigned long) addr, .size = 0 }; - - load_idt(&idt); -} kexec now works as expected; tested repeatedly, both with direct execution and crash triggering. I had to google 'inline function' :)). > Also, why idt_invalidate(phys_to_virt(0))? That makes rather little > sense to me. > > --Andy
Re: [GIT PULL] tee dynamic shm for v4.16
On 2017年12月21日 08:30, Arnd Bergmann wrote: On Fri, Dec 15, 2017 at 2:21 PM, Jens Wiklander wrote: Hello arm-soc maintainers, Please pull these tee driver changes. This implements support for dynamic shared memory support in OP-TEE. More specifically is enables mapping of user space memory in secure world to be used as shared memory. This has been reviewed and refined by the OP-TEE community at various places on Github during the last year. An earlier version of this pull request is used in the latest OP-TEE release (2.6.0). This has also been reviewed recently at the kernel mailing lists, with all comments from Mark Rutland and Yury Norov addressed as far as I can tell. This isn't a bugfix so I'm aiming for the next merge window. Given that Mark and Yury reviewed this, I'm assuming this is all good and have now merged it. However I missed the entire discussion about it, so I have one question about the implementation: What happens when user space passes a buffer that is not backed by regular memory but instead is something it has itself mapped from a device with special page attributes or physical properties? Could this be inconsistent when optee and user space disagree on the caching attributes? Can you get into trouble if you pass an area from a device that is read-only in user space but writable from secure world? Just recently, we have started to kick the tires of these "shm" related Gen Tee Driver patches. And we have in the past encountered real world scenarios requiring some of the shared memory regions to be marked as "normal IC=0 and OC=0" in EL2 or SEL1, or else HW would misbehave. We worked around by hacking the boot code but that works if the regions are pre-allocated. Since now these regions can also be managed dynamically, we definitely agree with Arnd Bergmann that the dynamic registration SMC commands, and potention the SHM IOCTL commands, must convey cache intentions. Is it possible to take this requirement into consideration, in this iteration or the follow on? Arnd ___ linux-arm-kernel mailing list linux-arm-ker...@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Re: [PATCH v5 1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86
On 25 December 2017 at 21:05, Sam Ravnborg wrote: > Hi Ard. > > On Mon, Dec 25, 2017 at 08:54:33PM +, Ard Biesheuvel wrote: >> Before updating certain subsystems to use place relative 32-bit >> relocations in special sections, to save space and reduce the >> number of absolute relocations that need to be processed at runtime >> by relocatable kernels, introduce the Kconfig symbol and define it >> for some architectures that should be able to support and benefit >> from it. >> >> Cc: Catalin Marinas >> Cc: Will Deacon >> Cc: Benjamin Herrenschmidt >> Cc: Paul Mackerras >> Cc: Michael Ellerman >> Cc: Martin Schwidefsky >> Cc: Heiko Carstens >> Cc: Thomas Gleixner >> Cc: Ingo Molnar >> Cc: "H. Peter Anvin" >> Cc: x...@kernel.org >> Signed-off-by: Ard Biesheuvel >> --- >> arch/Kconfig| 10 ++ >> arch/arm64/Kconfig | 1 + > >> arch/arm64/kernel/vmlinux.lds.S | 2 +- > The change to arch/arm64/kernel/vmlinux.lds.S is > not justified in the changelog. > Did you add it by mistake? > No. The PREL32 support adds a __ADDRESSABLE() macro that emits code into .discard.text, and on arm64, the EFI object sections get a .init prefix so we need to discard .init.discard.* explicitly as well. I will add this as a note. Thanks, Ard.
Re: [PATCH v5 1/8] arch: enable relative relocations for arm64, power, x86, s390 and x86
Hi Ard. On Mon, Dec 25, 2017 at 08:54:33PM +, Ard Biesheuvel wrote: > Before updating certain subsystems to use place relative 32-bit > relocations in special sections, to save space and reduce the > number of absolute relocations that need to be processed at runtime > by relocatable kernels, introduce the Kconfig symbol and define it > for some architectures that should be able to support and benefit > from it. > > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Martin Schwidefsky > Cc: Heiko Carstens > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: "H. Peter Anvin" > Cc: x...@kernel.org > Signed-off-by: Ard Biesheuvel > --- > arch/Kconfig| 10 ++ > arch/arm64/Kconfig | 1 + > arch/arm64/kernel/vmlinux.lds.S | 2 +- The change to arch/arm64/kernel/vmlinux.lds.S is not justified in the changelog. Did you add it by mistake? Sam
[PATCH] pinctrl: xway: Delete two error messages for a failed memory allocation in pinmux_xway_probe()
From: Markus Elfring Date: Mon, 25 Dec 2017 21:51:26 +0100 Omit extra messages for a memory allocation failure in this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/pinctrl/pinctrl-xway.c | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index f9e98a7d4f0c..cd0f402c1164 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -1730,18 +1730,16 @@ static int pinmux_xway_probe(struct platform_device *pdev) xway_info.pads = devm_kzalloc(&pdev->dev, sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio, GFP_KERNEL); - if (!xway_info.pads) { - dev_err(&pdev->dev, "Failed to allocate pads\n"); + if (!xway_info.pads) return -ENOMEM; - } + for (i = 0; i < xway_chip.ngpio; i++) { /* strlen("ioXY") + 1 = 5 */ char *name = devm_kzalloc(&pdev->dev, 5, GFP_KERNEL); - if (!name) { - dev_err(&pdev->dev, "Failed to allocate pad name\n"); + if (!name) return -ENOMEM; - } + snprintf(name, 5, "io%d", i); xway_info.pads[i].number = GPIO0 + i; xway_info.pads[i].name = name; -- 2.15.1
[PATCH v5 2/8] module: use relative references for __ksymtab entries
An ordinary arm64 defconfig build has ~64 KB worth of __ksymtab entries, each consisting of two 64-bit fields containing absolute references, to the symbol itself and to a char array containing its name, respectively. When we build the same configuration with KASLR enabled, we end up with an additional ~192 KB of relocations in the .init section, i.e., one 24 byte entry for each absolute reference, which all need to be processed at boot time. Given how the struct kernel_symbol that describes each entry is completely local to module.c (except for the references emitted by EXPORT_SYMBOL() itself), we can easily modify it to contain two 32-bit relative references instead. This reduces the size of the __ksymtab section by 50% for all 64-bit architectures, and gets rid of the runtime relocations entirely for architectures implementing KASLR, either via standard PIE linking (arm64) or using custom host tools (x86). Note that the binary search involving __ksymtab contents relies on each section being sorted by symbol name. This is implemented based on the input section names, not the names in the ksymtab entries, so this patch does not interfere with that. Given that the use of place-relative relocations requires support both in the toolchain and in the module loader, we cannot enable this feature for all architectures. So make it dependent on whether CONFIG_HAVE_ARCH_PREL32_RELOCATIONS is defined. Cc: Arnd Bergmann Cc: Andrew Morton Cc: Ingo Molnar Cc: Kees Cook Cc: Thomas Garnier Cc: Nicolas Pitre Acked-by: Jessica Yu Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/Kbuild | 1 + arch/x86/include/asm/export.h | 5 --- include/asm-generic/export.h | 12 - include/linux/compiler.h | 11 + include/linux/export.h| 46 +++- kernel/module.c | 33 +++--- 6 files changed, 84 insertions(+), 24 deletions(-) diff --git a/arch/x86/include/asm/Kbuild b/arch/x86/include/asm/Kbuild index 5d6a53fd7521..3e8a88dcaa1d 100644 --- a/arch/x86/include/asm/Kbuild +++ b/arch/x86/include/asm/Kbuild @@ -9,5 +9,6 @@ generated-y += xen-hypercalls.h generic-y += clkdev.h generic-y += dma-contiguous.h generic-y += early_ioremap.h +generic-y += export.h generic-y += mcs_spinlock.h generic-y += mm-arch-hooks.h diff --git a/arch/x86/include/asm/export.h b/arch/x86/include/asm/export.h deleted file mode 100644 index 2a51d66689c5.. --- a/arch/x86/include/asm/export.h +++ /dev/null @@ -1,5 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -#ifdef CONFIG_64BIT -#define KSYM_ALIGN 16 -#endif -#include diff --git a/include/asm-generic/export.h b/include/asm-generic/export.h index 719db1968d81..97ce606459ae 100644 --- a/include/asm-generic/export.h +++ b/include/asm-generic/export.h @@ -5,12 +5,10 @@ #define KSYM_FUNC(x) x #endif #ifdef CONFIG_64BIT -#define __put .quad #ifndef KSYM_ALIGN #define KSYM_ALIGN 8 #endif #else -#define __put .long #ifndef KSYM_ALIGN #define KSYM_ALIGN 4 #endif @@ -25,6 +23,16 @@ #define KSYM(name) name #endif +.macro __put, val, name +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS + .long \val - ., \name - . +#elif defined(CONFIG_64BIT) + .quad \val, \name +#else + .long \val, \name +#endif +.endm + /* * note on .section use: @progbits vs %progbits nastiness doesn't matter, * since we immediately emit into those sections anyway. diff --git a/include/linux/compiler.h b/include/linux/compiler.h index 52e611ab9a6c..fe752d365334 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -327,4 +327,15 @@ static __always_inline void __write_once_size(volatile void *p, void *res, int s compiletime_assert(__native_word(t),\ "Need native word sized stores/loads for atomicity.") +/* + * Force the compiler to emit 'sym' as a symbol, so that we can reference + * it from inline assembler. Necessary in case 'sym' could be inlined + * otherwise, or eliminated entirely due to lack of references that are + * visibile to the compiler. + */ +#define __ADDRESSABLE(sym) \ + static void *__attribute__((section(".discard.text"), used))\ + __PASTE(__discard_##sym, __LINE__)(void)\ + { return (void *)&sym; }\ + #endif /* __LINUX_COMPILER_H */ diff --git a/include/linux/export.h b/include/linux/export.h index 1a1dfdb2a5c6..5112d0c41512 100644 --- a/include/linux/export.h +++ b/include/linux/export.h @@ -24,12 +24,6 @@ #define VMLINUX_SYMBOL_STR(x) __VMLINUX_SYMBOL_STR(x) #ifndef __ASSEMBLY__ -struct kernel_symbol -{ - unsigned long value; - const char *name; -}; - #ifdef MODULE extern struct module __this_module; #define THIS_MODULE (&__this_module) @@ -60,17 +54,47 @@ extern struct module __this_module; #define __CRC_SYMBOL(sym, sec) #endif +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#include +/* + * Emit the ksymtab entry as a pair
[PATCH v5 4/8] PCI: Add support for relative addressing in quirk tables
Allow the PCI quirk tables to be emitted in a way that avoids absolute references to the hook functions. This reduces the size of the entries, and, more importantly, makes them invariant under runtime relocation (e.g., for KASLR) Acked-by: Bjorn Helgaas Signed-off-by: Ard Biesheuvel --- drivers/pci/quirks.c | 13 ++--- include/linux/pci.h | 20 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 10684b17d0bd..b6d51b4d5ce1 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c @@ -3556,9 +3556,16 @@ static void pci_do_fixups(struct pci_dev *dev, struct pci_fixup *f, f->vendor == (u16) PCI_ANY_ID) && (f->device == dev->device || f->device == (u16) PCI_ANY_ID)) { - calltime = fixup_debug_start(dev, f->hook); - f->hook(dev); - fixup_debug_report(dev, calltime, f->hook); + void (*hook)(struct pci_dev *dev); +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS + hook = (void *)((unsigned long)&f->hook_offset + + f->hook_offset); +#else + hook = f->hook; +#endif + calltime = fixup_debug_start(dev, hook); + hook(dev); + fixup_debug_report(dev, calltime, hook); } } diff --git a/include/linux/pci.h b/include/linux/pci.h index c170c9250c8b..e8c34afb5d4a 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1792,7 +1792,11 @@ struct pci_fixup { u16 device; /* You can use PCI_ANY_ID here of course */ u32 class; /* You can use PCI_ANY_ID here too */ unsigned int class_shift; /* should be 0, 8, 16 */ +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS + signed int hook_offset; +#else void (*hook)(struct pci_dev *dev); +#endif }; enum pci_fixup_pass { @@ -1806,12 +1810,28 @@ enum pci_fixup_pass { pci_fixup_suspend_late, /* pci_device_suspend_late() */ }; +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#define __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ + class_shift, hook) \ + __ADDRESSABLE(hook) \ + asm(".section " #sec ", \"a\" \n" \ + ".balign16 \n" \ + ".short " #vendor ", " #device " \n" \ + ".long "#class ", " #class_shift " \n" \ + ".long "VMLINUX_SYMBOL_STR(hook) " - . \n" \ + ".previous \n"); +#define DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class,\ + class_shift, hook)\ + __DECLARE_PCI_FIXUP_SECTION(sec, name, vendor, device, class, \ + class_shift, hook) +#else /* Anonymous variables would be nice... */ #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, class, \ class_shift, hook)\ static const struct pci_fixup __PASTE(__pci_fixup_##name,__LINE__) __used \ __attribute__((__section__(#section), aligned((sizeof(void *)\ = { vendor, device, class, class_shift, hook }; +#endif #define DECLARE_PCI_FIXUP_CLASS_EARLY(vendor, device, class, \ class_shift, hook) \ -- 2.11.0
[PATCH v5 6/8] kernel/jump_label: abstract jump_entry member accessors
In preparation of allowing architectures to use relative references in jump_label entries [which can dramatically reduce the memory footprint], introduce abstractions for references to the 'code' and 'key' members of struct jump_entry. Signed-off-by: Ard Biesheuvel --- arch/arm/include/asm/jump_label.h | 27 ++ arch/arm64/include/asm/jump_label.h | 27 ++ arch/mips/include/asm/jump_label.h| 27 ++ arch/powerpc/include/asm/jump_label.h | 27 ++ arch/s390/include/asm/jump_label.h| 20 +++ arch/sparc/include/asm/jump_label.h | 27 ++ arch/tile/include/asm/jump_label.h| 27 ++ arch/x86/include/asm/jump_label.h | 27 ++ kernel/jump_label.c | 38 +--- 9 files changed, 225 insertions(+), 22 deletions(-) diff --git a/arch/arm/include/asm/jump_label.h b/arch/arm/include/asm/jump_label.h index e12d7d096fc0..7b05b404063a 100644 --- a/arch/arm/include/asm/jump_label.h +++ b/arch/arm/include/asm/jump_label.h @@ -45,5 +45,32 @@ struct jump_entry { jump_label_t key; }; +static inline jump_label_t jump_entry_code(const struct jump_entry *entry) +{ + return entry->code; +} + +static inline struct static_key *jump_entry_key(const struct jump_entry *entry) +{ + return (struct static_key *)((unsigned long)entry->key & ~1UL); +} + +static inline bool jump_entry_is_branch(const struct jump_entry *entry) +{ + return (unsigned long)entry->key & 1UL; +} + +static inline bool jump_entry_is_module_init(const struct jump_entry *entry) +{ + return entry->code == 0; +} + +static inline void jump_entry_set_module_init(struct jump_entry *entry) +{ + entry->code = 0; +} + +#define jump_label_swapNULL + #endif /* __ASSEMBLY__ */ #endif diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 1b5e0e843c3a..9d6e46355c89 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h @@ -62,5 +62,32 @@ struct jump_entry { jump_label_t key; }; +static inline jump_label_t jump_entry_code(const struct jump_entry *entry) +{ + return entry->code; +} + +static inline struct static_key *jump_entry_key(const struct jump_entry *entry) +{ + return (struct static_key *)((unsigned long)entry->key & ~1UL); +} + +static inline bool jump_entry_is_branch(const struct jump_entry *entry) +{ + return (unsigned long)entry->key & 1UL; +} + +static inline bool jump_entry_is_module_init(const struct jump_entry *entry) +{ + return entry->code == 0; +} + +static inline void jump_entry_set_module_init(struct jump_entry *entry) +{ + entry->code = 0; +} + +#define jump_label_swapNULL + #endif /* __ASSEMBLY__ */ #endif /* __ASM_JUMP_LABEL_H */ diff --git a/arch/mips/include/asm/jump_label.h b/arch/mips/include/asm/jump_label.h index e77672539e8e..70df9293dc49 100644 --- a/arch/mips/include/asm/jump_label.h +++ b/arch/mips/include/asm/jump_label.h @@ -66,5 +66,32 @@ struct jump_entry { jump_label_t key; }; +static inline jump_label_t jump_entry_code(const struct jump_entry *entry) +{ + return entry->code; +} + +static inline struct static_key *jump_entry_key(const struct jump_entry *entry) +{ + return (struct static_key *)((unsigned long)entry->key & ~1UL); +} + +static inline bool jump_entry_is_branch(const struct jump_entry *entry) +{ + return (unsigned long)entry->key & 1UL; +} + +static inline bool jump_entry_is_module_init(const struct jump_entry *entry) +{ + return entry->code == 0; +} + +static inline void jump_entry_set_module_init(struct jump_entry *entry) +{ + entry->code = 0; +} + +#define jump_label_swapNULL + #endif /* __ASSEMBLY__ */ #endif /* _ASM_MIPS_JUMP_LABEL_H */ diff --git a/arch/powerpc/include/asm/jump_label.h b/arch/powerpc/include/asm/jump_label.h index 9a287e0ac8b1..412b2699c9f6 100644 --- a/arch/powerpc/include/asm/jump_label.h +++ b/arch/powerpc/include/asm/jump_label.h @@ -59,6 +59,33 @@ struct jump_entry { jump_label_t key; }; +static inline jump_label_t jump_entry_code(const struct jump_entry *entry) +{ + return entry->code; +} + +static inline struct static_key *jump_entry_key(const struct jump_entry *entry) +{ + return (struct static_key *)((unsigned long)entry->key & ~1UL); +} + +static inline bool jump_entry_is_branch(const struct jump_entry *entry) +{ + return (unsigned long)entry->key & 1UL; +} + +static inline bool jump_entry_is_module_init(const struct jump_entry *entry) +{ + return entry->code == 0; +} + +static inline void jump_entry_set_module_init(struct jump_entry *entry) +{ + entry->code = 0; +} + +#define jump_label_swapNULL + #else #define ARCH_STATIC_BRANCH(LABEL, KEY) \ 1098: nop;\ diff --git a/arch/s390/include/asm/jump_label.
[PATCH v5 5/8] kernel: tracepoints: add support for relative references
To avoid the need for relocating absolute references to tracepoint structures at boot time when running relocatable kernels (which may take a disproportionate amount of space), add the option to emit these tables as relative references instead. Cc: Steven Rostedt Cc: Ingo Molnar Signed-off-by: Ard Biesheuvel --- include/linux/tracepoint.h | 19 ++-- kernel/tracepoint.c| 50 +++- 2 files changed, 42 insertions(+), 27 deletions(-) diff --git a/include/linux/tracepoint.h b/include/linux/tracepoint.h index a26ffbe09e71..d02bf1a695e8 100644 --- a/include/linux/tracepoint.h +++ b/include/linux/tracepoint.h @@ -228,6 +228,19 @@ extern void syscall_unregfunc(void); return static_key_false(&__tracepoint_##name.key); \ } +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#define __TRACEPOINT_ENTRY(name)\ + asm(" .section \"__tracepoints_ptrs\", \"a\" \n" \ + " .balign 4\n" \ + " .long " VMLINUX_SYMBOL_STR(__tracepoint_##name) " - .\n" \ + " .previous\n") +#else +#define __TRACEPOINT_ENTRY(name)\ + static struct tracepoint * const __tracepoint_ptr_##name __used \ + __attribute__((section("__tracepoints_ptrs"))) = \ + &__tracepoint_##name +#endif + /* * We have no guarantee that gcc and the linker won't up-align the tracepoint * structures, so we create an array of pointers that will be used for iteration @@ -237,11 +250,9 @@ extern void syscall_unregfunc(void); static const char __tpstrtab_##name[]\ __attribute__((section("__tracepoints_strings"))) = #name; \ struct tracepoint __tracepoint_##name\ - __attribute__((section("__tracepoints"))) = \ + __attribute__((section("__tracepoints"), used)) =\ { __tpstrtab_##name, STATIC_KEY_INIT_FALSE, reg, unreg, NULL };\ - static struct tracepoint * const __tracepoint_ptr_##name __used \ - __attribute__((section("__tracepoints_ptrs"))) = \ - &__tracepoint_##name; + __TRACEPOINT_ENTRY(name); #define DEFINE_TRACE(name) \ DEFINE_TRACE_FN(name, NULL, NULL); diff --git a/kernel/tracepoint.c b/kernel/tracepoint.c index 685c50ae6300..05649fef106c 100644 --- a/kernel/tracepoint.c +++ b/kernel/tracepoint.c @@ -327,6 +327,28 @@ int tracepoint_probe_unregister(struct tracepoint *tp, void *probe, void *data) } EXPORT_SYMBOL_GPL(tracepoint_probe_unregister); +static void for_each_tracepoint_range(struct tracepoint * const *begin, + struct tracepoint * const *end, + void (*fct)(struct tracepoint *tp, void *priv), + void *priv) +{ + if (!begin) + return; + + if (IS_ENABLED(CONFIG_HAVE_ARCH_PREL32_RELOCATIONS)) { + const int *iter; + + for (iter = (const int *)begin; iter < (const int *)end; iter++) + fct((struct tracepoint *)((unsigned long)iter + *iter), + priv); + } else { + struct tracepoint * const *iter; + + for (iter = begin; iter < end; iter++) + fct(*iter, priv); + } +} + #ifdef CONFIG_MODULES bool trace_module_has_bad_taint(struct module *mod) { @@ -391,15 +413,9 @@ EXPORT_SYMBOL_GPL(unregister_tracepoint_module_notifier); * Ensure the tracer unregistered the module's probes before the module * teardown is performed. Prevents leaks of probe and data pointers. */ -static void tp_module_going_check_quiescent(struct tracepoint * const *begin, - struct tracepoint * const *end) +static void tp_module_going_check_quiescent(struct tracepoint *tp, void *priv) { - struct tracepoint * const *iter; - - if (!begin) - return; - for (iter = begin; iter < end; iter++) - WARN_ON_ONCE((*iter)->funcs); + WARN_ON_ONCE(tp->funcs); } static int tracepoint_module_coming(struct module *mod) @@ -450,8 +466,9 @@ static void tracepoint_module_going(struct module *mod) * Called the going notifier before checking for * quiescence. */ - tp_module_going_check_quiescent(mod->tracepoints_ptrs, - mod->tracepoints_ptrs + mod->num_tracepoints); + for_each_tracepoint_range(mod->tracepoints_ptrs, + mod->tracepoints_ptrs + mod->num_tracepoints, + tp_module_going_check_quiescent, NULL); break; } } @@ -503,1
[PATCH v5 8/8] x86/kernel: jump_table: use relative references
Similar to the arm64 case, 64-bit x86 can benefit from using 32-bit relative references rather than 64-bit absolute ones when emitting struct jump_entry instances. Not only does this reduce the memory footprint of the entries themselves by 50%, it also removes the need for carrying relocation metadata on relocatable builds (i.e., for KASLR) which saves a fair chunk of .init space as well (although the savings are not as dramatic as on arm64) Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/jump_label.h | 35 +++- arch/x86/kernel/jump_label.c | 59 ++-- tools/objtool/special.c | 4 +- 3 files changed, 65 insertions(+), 33 deletions(-) diff --git a/arch/x86/include/asm/jump_label.h b/arch/x86/include/asm/jump_label.h index 009ff2699d07..91c01af96907 100644 --- a/arch/x86/include/asm/jump_label.h +++ b/arch/x86/include/asm/jump_label.h @@ -36,8 +36,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran asm_volatile_goto("1:" ".byte " __stringify(STATIC_KEY_INIT_NOP) "\n\t" ".pushsection __jump_table, \"aw\" \n\t" - _ASM_ALIGN "\n\t" - _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t" + ".balign 4\n\t" + ".long 1b - ., %l[l_yes] - ., %c0 + %c1 - .\n\t" ".popsection \n\t" : : "i" (key), "i" (branch) : : l_yes); @@ -52,8 +52,8 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool ".byte 0xe9\n\t .long %l[l_yes] - 2f\n\t" "2:\n\t" ".pushsection __jump_table, \"aw\" \n\t" - _ASM_ALIGN "\n\t" - _ASM_PTR "1b, %l[l_yes], %c0 + %c1 \n\t" + ".balign 4\n\t" + ".long 1b - ., %l[l_yes] - ., %c0 + %c1 - .\n\t" ".popsection \n\t" : : "i" (key), "i" (branch) : : l_yes); @@ -69,19 +69,26 @@ typedef u32 jump_label_t; #endif struct jump_entry { - jump_label_t code; - jump_label_t target; - jump_label_t key; + s32 code; + s32 target; + s32 key; }; static inline jump_label_t jump_entry_code(const struct jump_entry *entry) { - return entry->code; + return (jump_label_t)&entry->code + entry->code; +} + +static inline jump_label_t jump_entry_target(const struct jump_entry *entry) +{ + return (jump_label_t)&entry->target + entry->target; } static inline struct static_key *jump_entry_key(const struct jump_entry *entry) { - return (struct static_key *)((unsigned long)entry->key & ~1UL); + unsigned long key = (unsigned long)&entry->key + entry->key; + + return (struct static_key *)(key & ~1UL); } static inline bool jump_entry_is_branch(const struct jump_entry *entry) @@ -99,7 +106,7 @@ static inline void jump_entry_set_module_init(struct jump_entry *entry) entry->code = 0; } -#define jump_label_swapNULL +void jump_label_swap(void *a, void *b, int size); #else /* __ASSEMBLY__ */ @@ -114,8 +121,8 @@ static inline void jump_entry_set_module_init(struct jump_entry *entry) .byte STATIC_KEY_INIT_NOP .endif .pushsection __jump_table, "aw" - _ASM_ALIGN - _ASM_PTR.Lstatic_jump_\@, \target, \key + .balign 4 + .long .Lstatic_jump_\@ - ., \target - ., \key - . .popsection .endm @@ -130,8 +137,8 @@ static inline void jump_entry_set_module_init(struct jump_entry *entry) .Lstatic_jump_after_\@: .endif .pushsection __jump_table, "aw" - _ASM_ALIGN - _ASM_PTR.Lstatic_jump_\@, \target, \key + 1 + .balign 4 + .long .Lstatic_jump_\@ - ., \target - ., \key - . + 1 .popsection .endm diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c index e56c95be2808..cc5034b42335 100644 --- a/arch/x86/kernel/jump_label.c +++ b/arch/x86/kernel/jump_label.c @@ -52,22 +52,24 @@ static void __jump_label_transform(struct jump_entry *entry, * Jump label is enabled for the first time. * So we expect a default_nop... */ - if (unlikely(memcmp((void *)entry->code, default_nop, 5) -!= 0)) - bug_at((void *)entry->code, __LINE__); + if (unlikely(memcmp((void *)jump_entry_code(entry), + default_nop, 5) != 0)) + bug_at((void *)jump_entry_code(entry), + __LINE__); } else { /* * ...otherwise expect an ideal_nop. Otherwise * something went horribly wrong. */ - if (unlikely(memcmp((voi
[PATCH v5 3/8] init: allow initcall tables to be emitted using relative references
Allow the initcall tables to be emitted using relative references that are only half the size on 64-bit architectures and don't require fixups at runtime on relocatable kernels. Cc: Petr Mladek Cc: Sergey Senozhatsky Cc: Steven Rostedt Cc: James Morris Cc: "Serge E. Hallyn" Signed-off-by: Ard Biesheuvel --- include/linux/init.h | 44 +++- init/main.c| 32 +++--- kernel/printk/printk.c | 4 +- security/security.c| 4 +- 4 files changed, 53 insertions(+), 31 deletions(-) diff --git a/include/linux/init.h b/include/linux/init.h index ea1b31101d9e..125bbea99c6b 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -109,8 +109,24 @@ typedef int (*initcall_t)(void); typedef void (*exitcall_t)(void); -extern initcall_t __con_initcall_start[], __con_initcall_end[]; -extern initcall_t __security_initcall_start[], __security_initcall_end[]; +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +typedef signed int initcall_entry_t; + +static inline initcall_t initcall_from_entry(initcall_entry_t *entry) +{ + return (initcall_t)((unsigned long)entry + *entry); +} +#else +typedef initcall_t initcall_entry_t; + +static inline initcall_t initcall_from_entry(initcall_entry_t *entry) +{ + return *entry; +} +#endif + +extern initcall_entry_t __con_initcall_start[], __con_initcall_end[]; +extern initcall_entry_t __security_initcall_start[], __security_initcall_end[]; /* Used for contructor calls. */ typedef void (*ctor_fn_t)(void); @@ -160,9 +176,20 @@ extern bool initcall_debug; * as KEEP() in the linker script. */ -#define __define_initcall(fn, id) \ +#ifdef CONFIG_HAVE_ARCH_PREL32_RELOCATIONS +#define ___define_initcall(fn, id, __sec) \ + __ADDRESSABLE(fn) \ + asm(".section \"" #__sec ".init\", \"a\" \n" \ + "__initcall_" #fn #id ":\n" \ + ".long "VMLINUX_SYMBOL_STR(fn) " - .\n" \ + ".previous \n"); +#else +#define ___define_initcall(fn, id, __sec) \ static initcall_t __initcall_##fn##id __used \ - __attribute__((__section__(".initcall" #id ".init"))) = fn; + __attribute__((__section__(#__sec ".init"))) = fn; +#endif + +#define __define_initcall(fn, id) ___define_initcall(fn, id, .initcall##id) /* * Early initcalls run before initializing SMP. @@ -201,13 +228,8 @@ extern bool initcall_debug; #define __exitcall(fn) \ static exitcall_t __exitcall_##fn __exit_call = fn -#define console_initcall(fn) \ - static initcall_t __initcall_##fn \ - __used __section(.con_initcall.init) = fn - -#define security_initcall(fn) \ - static initcall_t __initcall_##fn \ - __used __section(.security_initcall.init) = fn +#define console_initcall(fn) ___define_initcall(fn,, .con_initcall) +#define security_initcall(fn) ___define_initcall(fn,, .security_initcall) struct obs_kernel_param { const char *str; diff --git a/init/main.c b/init/main.c index 7b606fc48482..2cbe3c2804ab 100644 --- a/init/main.c +++ b/init/main.c @@ -845,18 +845,18 @@ int __init_or_module do_one_initcall(initcall_t fn) } -extern initcall_t __initcall_start[]; -extern initcall_t __initcall0_start[]; -extern initcall_t __initcall1_start[]; -extern initcall_t __initcall2_start[]; -extern initcall_t __initcall3_start[]; -extern initcall_t __initcall4_start[]; -extern initcall_t __initcall5_start[]; -extern initcall_t __initcall6_start[]; -extern initcall_t __initcall7_start[]; -extern initcall_t __initcall_end[]; - -static initcall_t *initcall_levels[] __initdata = { +extern initcall_entry_t __initcall_start[]; +extern initcall_entry_t __initcall0_start[]; +extern initcall_entry_t __initcall1_start[]; +extern initcall_entry_t __initcall2_start[]; +extern initcall_entry_t __initcall3_start[]; +extern initcall_entry_t __initcall4_start[]; +extern initcall_entry_t __initcall5_start[]; +extern initcall_entry_t __initcall6_start[]; +extern initcall_entry_t __initcall7_start[]; +extern initcall_entry_t __initcall_end[]; + +static initcall_entry_t *initcall_levels[] __initdata = { __initcall0_start, __initcall1_start, __initcall2_start, @@ -882,7 +882,7 @@ static char *initcall_level_names[] __initdata = { static void __init do_initcall_level(int level) { - initcall_t *fn; + initcall_entry_t *fn; strcpy(initcall_command_line, saved_command_line); parse_args(initcall_level_names[level], @@ -892,7 +892,7 @@ static void __init do_initcall_level(int level) NULL, &repair_env_string); for (fn = initcall_levels[level]; fn < initcall_levels[level+1]; fn++) - do_one_initcall(*fn); + do_one_ini
[PATCH v5 7/8] arm64/kernel: jump_label: use relative references
On a randomly chosen distro kernel build for arm64, vmlinux.o shows the following sections, containing jump label entries, and the associated RELA relocation records, respectively: ... [38088] __jump_table PROGBITS 00e19f30 0002ea10 WA 0 0 8 [38089] .rela__jump_table RELA 01fd8bb0 0008be30 0018 I 38178 38088 8 ... In other words, we have 190 KB worth of 'struct jump_entry' instances, and 573 KB worth of RELA entries to relocate each entry's code, target and key members. This means the RELA section occupies 10% of the .init segment, and the two sections combined represent 5% of vmlinux's entire memory footprint. So let's switch from 64-bit absolute references to 32-bit relative references: this reduces the size of the __jump_table by 50%, and gets rid of the RELA section entirely. Note that this requires some extra care in the sorting routine, given that the offsets change when entries are moved around in the jump_entry table. Signed-off-by: Ard Biesheuvel --- arch/arm64/include/asm/jump_label.h | 27 arch/arm64/kernel/jump_label.c | 22 +--- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/arch/arm64/include/asm/jump_label.h b/arch/arm64/include/asm/jump_label.h index 9d6e46355c89..5cec68616125 100644 --- a/arch/arm64/include/asm/jump_label.h +++ b/arch/arm64/include/asm/jump_label.h @@ -30,8 +30,8 @@ static __always_inline bool arch_static_branch(struct static_key *key, bool bran { asm goto("1: nop\n\t" ".pushsection __jump_table, \"aw\"\n\t" -".align 3\n\t" -".quad 1b, %l[l_yes], %c0\n\t" +".align 2\n\t" +".long 1b - ., %l[l_yes] - ., %c0 - .\n\t" ".popsection\n\t" : : "i"(&((char *)key)[branch]) : : l_yes); @@ -44,8 +44,8 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool { asm goto("1: b %l[l_yes]\n\t" ".pushsection __jump_table, \"aw\"\n\t" -".align 3\n\t" -".quad 1b, %l[l_yes], %c0\n\t" +".align 2\n\t" +".long 1b - ., %l[l_yes] - ., %c0 - .\n\t" ".popsection\n\t" : : "i"(&((char *)key)[branch]) : : l_yes); @@ -57,19 +57,26 @@ static __always_inline bool arch_static_branch_jump(struct static_key *key, bool typedef u64 jump_label_t; struct jump_entry { - jump_label_t code; - jump_label_t target; - jump_label_t key; + s32 code; + s32 target; + s32 key; }; static inline jump_label_t jump_entry_code(const struct jump_entry *entry) { - return entry->code; + return (jump_label_t)&entry->code + entry->code; +} + +static inline jump_label_t jump_entry_target(const struct jump_entry *entry) +{ + return (jump_label_t)&entry->target + entry->target; } static inline struct static_key *jump_entry_key(const struct jump_entry *entry) { - return (struct static_key *)((unsigned long)entry->key & ~1UL); + unsigned long key = (unsigned long)&entry->key + entry->key; + + return (struct static_key *)(key & ~1UL); } static inline bool jump_entry_is_branch(const struct jump_entry *entry) @@ -87,7 +94,7 @@ static inline void jump_entry_set_module_init(struct jump_entry *entry) entry->code = 0; } -#define jump_label_swapNULL +void jump_label_swap(void *a, void *b, int size); #endif /* __ASSEMBLY__ */ #endif /* __ASM_JUMP_LABEL_H */ diff --git a/arch/arm64/kernel/jump_label.c b/arch/arm64/kernel/jump_label.c index c2dd1ad3e648..2b8e459e91f7 100644 --- a/arch/arm64/kernel/jump_label.c +++ b/arch/arm64/kernel/jump_label.c @@ -25,12 +25,12 @@ void arch_jump_label_transform(struct jump_entry *entry, enum jump_label_type type) { - void *addr = (void *)entry->code; + void *addr = (void *)jump_entry_code(entry); u32 insn; if (type == JUMP_LABEL_JMP) { - insn = aarch64_insn_gen_branch_imm(entry->code, - entry->target, + insn = aarch64_insn_gen_branch_imm(jump_entry_code(entry), + jump_entry_target(entry), AARCH64_INSN_BRANCH_NOLINK); } else { insn = aarch64_insn_gen_nop(); @@ -50,4 +50,20 @@ void arch_jump_label_transform_static(struct jump_entry *entry, */ } +void jump_label_swap(void *a, void *b, int size) +{ + long delta = (unsigned long)a - (unsigned long)b; + struct jump_entry *jea = a; + struct jump_entry *jeb = b; + struct jump_entry tmp = *jea; + + jea->code = jeb->code - delta; + jea->t
[PATCH v5 0/8] add support for relative references in special sections
This adds support for emitting special sections such as initcall arrays, PCI fixups and tracepoints as relative references rather than absolute references. This reduces the size by 50% on 64-bit architectures, but more importantly, it removes the need for carrying relocation metadata for these sections in relocatables kernels (e.g., for KASLR) that need to fix up these absolute references at boot time. On arm64, this reduces the vmlinux footprint of such a reference by 8x (8 byte absolute reference + 24 byte RELA entry vs 4 byte relative reference) Patch #2 was sent out before as a single patch. This series supersedes the previous submission. This version makes relative ksymtab entries dependent on the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS rather than trying to infer from kbuild test robot replies for which architectures it should be blacklisted. Patch #1 introduces the new Kconfig symbol HAVE_ARCH_PREL32_RELOCATIONS, and sets it for the main architectures that are expected to benefit the most from this feature, i.e., 64-bit architectures or ones that use runtime relocations. Patches #3 - #5 implement relative references for initcalls, PCI fixups and tracepoints, respectively, all of which produce sections with order ~1000 entries on an arm64 defconfig kernel with tracing enabled. This means we save about 28 KB of vmlinux space for each of these patches. Patches #6 - #8 have been added in v5, and implement relative references in jump tables for arm64 and x86. On arm64, this results in significant space savings (650+ KB on a typical distro kernel). On x86, the savings are not as impressive, but still worthwhile. (Note that these patches do not rely on CONFIG_HAVE_ARCH_PREL32_RELOCATIONS, given that the inline asm that is emitted is already per-arch) For the arm64 kernel, all patches combined reduce the memory footprint of vmlinux by about 1.3 MB (using a config copied from Ubuntu that has KASLR enabled), of which ~1 MB is the size reduction of the RELA section in .init, and the remaining 300 KB is reduction of .text/.data. Branch: git://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git relative-special-sections-v5 Changes since v4: - add patches to convert x86 and arm64 to use relative references for jump tables (#6 - #8) - rename PCI patch and add Bjorn's ack (#4) - rebase onto v4.15-rc5 Changes since v3: - fix module unload issue in patch #5 reported by Jessica, by reusing the updated routine for_each_tracepoint_range() for the quiescent check at module unload time; this requires this routine to be moved before tracepoint_module_going() in kernel/tracepoint.c - add Jessica's ack to #2 - rebase onto v4.14-rc1 Changes since v2: - Revert my slightly misguided attempt to appease checkpatch, which resulted in needless churn and worse code. This v3 is based on v1 with a few tweaks that were actually reasonable checkpatch warnings: unnecessary braces (as pointed out by Ingo) and other minor whitespace misdemeanors. Changes since v1: - Remove checkpatch errors to the extent feasible: in some cases, this involves moving extern declarations into C files, and switching to struct definitions rather than typedefs. Some errors are impossible to fix: please find the remaining ones after the diffstat. - Used 'int' instead if 'signed int' for the various offset fields: there is no ambiguity between architectures regarding its signedness (unlike 'char') - Refactor the different patches to be more uniform in the way they define the section entry type and accessors in the .h file, and avoid the need to add #ifdefs to the C code. Cc: "H. Peter Anvin" Cc: Ralf Baechle Cc: Arnd Bergmann Cc: Heiko Carstens Cc: Kees Cook Cc: Will Deacon Cc: Michael Ellerman Cc: Thomas Garnier Cc: Thomas Gleixner Cc: "Serge E. Hallyn" Cc: Bjorn Helgaas Cc: Benjamin Herrenschmidt Cc: Russell King Cc: Paul Mackerras Cc: Catalin Marinas Cc: "David S. Miller" Cc: Petr Mladek Cc: Ingo Molnar Cc: James Morris Cc: Andrew Morton Cc: Nicolas Pitre Cc: Josh Poimboeuf Cc: Steven Rostedt Cc: Martin Schwidefsky Cc: Sergey Senozhatsky Cc: Linus Torvalds Cc: Jessica Yu Cc: linux-arm-ker...@lists.infradead.org Cc: linux-kernel@vger.kernel.org Cc: linux-m...@linux-mips.org Cc: linuxppc-...@lists.ozlabs.org Cc: linux-s...@vger.kernel.org Cc: sparcli...@vger.kernel.org Cc: x...@kernel.org Ard Biesheuvel (8): arch: enable relative relocations for arm64, power, x86, s390 and x86 module: use relative references for __ksymtab entries init: allow initcall tables to be emitted using relative references PCI: Add support for relative addressing in quirk tables kernel: tracepoints: add support for relative references kernel/jump_label: abstract jump_entry member accessors arm64/kernel: jump_label: use relative references x86/kernel: jump_table: use relative references arch/Kconfig | 10 arch/arm/include/asm/jump_label.h | 27 + arch/