Re: [PATCH 1/2] staging, mt7621-eth: fix api for linkmode bitmap
On Sat, Mar 09, 2019 at 12:53:59PM +0300, Maxim Zhukov wrote: > Start using new api for linkmode bitmap > > Fixed build after 3c1bcc8614db ("net: ethernet: Convert phydev advertize and > supported from u32 to link mode") > > Signed-off-by: Maxim Zhukov > --- > drivers/staging/mt7621-eth/mdio.c | 12 +--- > 1 file changed, 9 insertions(+), 3 deletions(-) This driver is now dropped from the tree, so no need to fix any build issues :) thanks, greg k-h
Re: [RFC][PATCH 00/16] sched: Core scheduling
On Tue, Mar 12, 2019 at 7:36 AM Subhra Mazumdar wrote: > > > On 3/11/19 11:34 AM, Subhra Mazumdar wrote: > > > > On 3/10/19 9:23 PM, Aubrey Li wrote: > >> On Sat, Mar 9, 2019 at 3:50 AM Subhra Mazumdar > >> wrote: > >>> expected. Most of the performance recovery happens in patch 15 which, > >>> unfortunately, is also the one that introduces the hard lockup. > >>> > >> After applied Subhra's patch, the following is triggered by enabling > >> core sched when a cgroup is > >> under heavy load. > >> > > It seems you are facing some other deadlock where printk is involved. > > Can you > > drop the last patch (patch 16 sched: Debug bits...) and try? > > > > Thanks, > > Subhra > > > Never Mind, I am seeing the same lockdep deadlock output even w/o patch > 16. Btw > the NULL fix had something missing, following works. > okay, here is another one, on my system, the boot up CPUs don't match the possible cpu map, so the not onlined CPU rq->core are not initialized, which causes NULL pointer dereference panic in online_fair_sched_group(): And here is a quick fix. - @@ -10488,7 +10493,8 @@ void online_fair_sched_group(struct task_group *tg) for_each_possible_cpu(i) { rq = cpu_rq(i); se = tg->se[i]; - + if (!rq->core) + continue; raw_spin_lock_irq(rq_lockp(rq)); update_rq_clock(rq); attach_entity_cfs_rq(se); Thanks, -Aubrey
Re: [PATCH] staging: comedi: ni_mio_common: Fix divide-by-zero for DIO cmdtest
On Wed, Mar 13, 2019 at 06:57:17PM +, Ian Abbott wrote: > On 04/03/2019 14:33, Ian Abbott wrote: > > `ni_cdio_cmdtest()` validates Comedi asynchronous commands for the DIO > > subdevice (subdevice 2) of supported National Instruments M-series > > cards. It is called when handling the `COMEDI_CMD` and `COMEDI_CMDTEST` > > ioctls for this subdevice. There are two causes for a possible > > divide-by-zero error when validating that the `stop_arg` member of the > > passed-in command is not too large. > > > > The first cause for the divide-by-zero is that calls to > > `comedi_bytes_per_scan()` are only valid once the command has been > > copied to `s->async->cmd`, but that copy is only done for the > > `COMEDI_CMD` ioctl. For the `COMEDI_CMDTEST` ioctl, it will use > > whatever was left there by the previous `COMEDI_CMD` ioctl, if any. > > (This is very likely, as it is usual for the application to use > > `COMEDI_CMDTEST` before `COMEDI_CMD`.) If there has been no previous, > > valid `COMEDI_CMD` for this subdevice, then `comedi_bytes_per_scan()` > > will return 0, so the subsequent division in `ni_cdio_cmdtest()` of > > `s->async->prealloc_bufsz / comedi_bytes_per_scan(s)` will be a > > divide-by-zero error. To fix this error, call a new function > > `comedi_bytes_per_scan_cmd(s, cmd)`, based on the existing > > `comedi_bytes_per_scan(s)` but using a specified `struct comedi_cmd` for > > its calculations. (Also refactor `comedi_bytes_per_scan()` to call the > > new function.) > > > > Once the first cause for the divide-by-zero has been fixed, the second > > cause is that `comedi_bytes_per_scan_cmd()` can legitimately return 0 if > > the `scan_end_arg` member of the `struct comedi_cmd` being tested is 0. > > Fix it by only performing the division (and validating that `stop_arg` > > is no more than the maximum value) if `comedi_bytes_per_scan_cmd()` > > returns a non-zero value. > > > > The problem was reported on the COMEDI mailing list here: > > https://groups.google.com/forum/#!topic/comedi_list/4t9WlHzMhKM > > > > Fixes: f164cbf98fa8 ("staging: comedi: ni_mio_common: add finite > > regeneration to dio output") > > Greg, > If it's not too late, it would be nice if the following "Reported-by:" and > "Tested-by:" lines could be added (or I can resend with these lines included > if necessary). It's no big deal if this is too late. I'll live with it. > Thanks. > > Reported-by: Ivan Vasilyev > Tested-by: Ivan Vasilyev Not too late, I'll go add it now, thanks. greg k-h
[PATCH] genirq: Fix typo in comment of IRQD_MOVE_PCNTXT
CC: Marc Zyngier CC: Thomas Gleixner CC: Dou Liyang CC: Julien Thierry CC: Peter Xu CC: linux-kernel@vger.kernel.org Signed-off-by: Peter Xu --- include/linux/irq.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index 5e91f6bcaacd..965613abe93b 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -195,7 +195,7 @@ struct irq_data { * IRQD_LEVEL - Interrupt is level triggered * IRQD_WAKEUP_STATE - Interrupt is configured for wakeup * from suspend - * IRDQ_MOVE_PCNTXT- Interrupt can be moved in process + * IRQD_MOVE_PCNTXT- Interrupt can be moved in process * context * IRQD_IRQ_DISABLED - Disabled state of the interrupt * IRQD_IRQ_MASKED - Masked state of the interrupt -- 2.17.1
[RFC PATCH v6 2/6] uaccess: Add non-pagefault user-space read functions
Add probe_user_read(), strncpy_from_unsafe_user() and strnlen_unsafe_user() which allows caller to access user-space in IRQ context. Current probe_kernel_read() and strncpy_from_unsafe() are not available for user-space memory, because it sets KERNEL_DS while accessing data. On some arch, user address space and kernel address space can be co-exist, but others can not. In that case, setting KERNEL_DS means given address is treated as a kernel address space. Also strnlen_user() is only available from user context since it can sleep if pagefault is enabled. To access user-space memory without pagefault, we need these new functions which sets USER_DS while accessing the data. Signed-off-by: Masami Hiramatsu --- Changes in v6: - Remove user_access_ok() Changes in v5: - Simplify probe_user_read() (Thanks, Peter!) - Add strnlen_unsafe_user() Changes in v3: - Use user_access_ok() for probe_user_read(). Changes in v2: - Simplify strncpy_from_unsafe_user() using strncpy_from_user() according to Linus's suggestion. - Simplify probe_user_read() not using intermediate function. --- include/linux/uaccess.h | 14 ++ mm/maccess.c| 117 +-- 2 files changed, 125 insertions(+), 6 deletions(-) diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index ef3032db1aef..80d35d880f56 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -242,6 +242,17 @@ static inline unsigned long __copy_from_user_inatomic_nocache(void *to, extern long probe_kernel_read(void *dst, const void *src, size_t size); extern long __probe_kernel_read(void *dst, const void *src, size_t size); +/* + * probe_user_read(): safely attempt to read from a location in user space + * @dst: pointer to the buffer that shall take the data + * @src: address to read from + * @size: size of the data chunk + * + * Safely read from address @src to the buffer at @dst. If a kernel fault + * happens, handle that and return -EFAULT. + */ +extern long probe_user_read(void *dst, const void __user *src, size_t size); + /* * probe_kernel_write(): safely attempt to write to a location * @dst: address to write to @@ -255,6 +266,9 @@ extern long notrace probe_kernel_write(void *dst, const void *src, size_t size); extern long notrace __probe_kernel_write(void *dst, const void *src, size_t size); extern long strncpy_from_unsafe(char *dst, const void *unsafe_addr, long count); +extern long strncpy_from_unsafe_user(char *dst, const void __user *unsafe_addr, +long count); +extern long strnlen_unsafe_user(const void __user *unsafe_addr, long count); /** * probe_kernel_address(): safely attempt to read from a location diff --git a/mm/maccess.c b/mm/maccess.c index ec00be51a24f..4e720b173d8a 100644 --- a/mm/maccess.c +++ b/mm/maccess.c @@ -5,8 +5,20 @@ #include #include +static __always_inline long +probe_read_common(void *dst, const void __user *src, size_t size) +{ + long ret; + + pagefault_disable(); + ret = __copy_from_user_inatomic(dst, src, size); + pagefault_enable(); + + return ret ? -EFAULT : 0; +} + /** - * probe_kernel_read(): safely attempt to read from a location + * probe_kernel_read(): safely attempt to read from a kernel-space location * @dst: pointer to the buffer that shall take the data * @src: address to read from * @size: size of the data chunk @@ -29,16 +41,39 @@ long __probe_kernel_read(void *dst, const void *src, size_t size) mm_segment_t old_fs = get_fs(); set_fs(KERNEL_DS); - pagefault_disable(); - ret = __copy_from_user_inatomic(dst, - (__force const void __user *)src, size); - pagefault_enable(); + ret = probe_read_common(dst, (__force const void __user *)src, size); set_fs(old_fs); - return ret ? -EFAULT : 0; + return ret; } EXPORT_SYMBOL_GPL(probe_kernel_read); +/** + * probe_user_read(): safely attempt to read from a user-space location + * @dst: pointer to the buffer that shall take the data + * @src: address to read from. This must be a user address. + * @size: size of the data chunk + * + * Safely read from user address @src to the buffer at @dst. If a kernel fault + * happens, handle that and return -EFAULT. + */ + +long __weak probe_user_read(void *dst, const void __user *src, size_t size) +__attribute__((alias("__probe_user_read"))); + +long __probe_user_read(void *dst, const void __user *src, size_t size) +{ + long ret = -EFAULT; + mm_segment_t old_fs = get_fs(); + + set_fs(USER_DS); + if (access_ok(src, size)) + ret = probe_read_common(dst, src, size); + set_fs(old_fs); + return ret; +} +EXPORT_SYMBOL_GPL(probe_user_read); + /** * probe_kernel_write(): safely attempt to write to a location * @dst: address to write to @@ -66,6 +101,7 @@ long __probe_kernel_write(void *dst, const void
[RFC PATCH v6 6/6] perf-probe: Add user memory access attribute support
Add user memory access attribute for kprobe event arguments. If a given 'local variable' is in user-space, User can specify memory access method by '@user' suffix. This is not only for string but also for data structure. If we access a field of data structure in user memory from kernel on some arch, it will fail. e.g. perf probe -a "sched_setscheduler param->sched_priority" This will fail to access the "param->sched_priority" because the param is __user pointer. Instead, we can now specify @user suffix for such argument. perf probe -a "sched_setscheduler param->sched_priority@user" Note that kernel memory access with "@user" must always fail on any arch. Signed-off-by: Masami Hiramatsu --- tools/perf/Documentation/perf-probe.txt |3 ++- tools/perf/util/probe-event.c | 11 +++ tools/perf/util/probe-event.h |2 ++ tools/perf/util/probe-file.c|7 +++ tools/perf/util/probe-file.h|1 + tools/perf/util/probe-finder.c | 19 --- 6 files changed, 35 insertions(+), 8 deletions(-) diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt index b6866a05edd2..ed3ecfa422e1 100644 --- a/tools/perf/Documentation/perf-probe.txt +++ b/tools/perf/Documentation/perf-probe.txt @@ -194,12 +194,13 @@ PROBE ARGUMENT -- Each probe argument follows below syntax. - [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE] + [NAME=]LOCALVAR|$retval|%REG|@SYMBOL[:TYPE][@user] 'NAME' specifies the name of this argument (optional). You can use the name of local variable, local data structure member (e.g. var->field, var.field2), local array with fixed index (e.g. array[1], var->array[0], var->pointer[2]), or kprobe-tracer argument format (e.g. $retval, %ax, etc). Note that the name of this argument will be set as the last member name if you specify a local data structure member (e.g. field2 for 'var->field1.field2'.) '$vars' and '$params' special arguments are also available for NAME, '$vars' is expanded to the local variables (including function parameters) which can access at given probe point. '$params' is expanded to only the function parameters. 'TYPE' casts the type of this argument (optional). If omitted, perf probe automatically set the type based on debuginfo (*). Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal integers (x/x8/x16/x32/x64), signedness casting (u/s), "string" and bitfield are supported. (see TYPES for detail) On x86 systems %REG is always the short form of the register: for example %AX. %RAX or %EAX is not valid. +"@user" is a special attribute which means the LOCALVAR will be treated as a user-space memory. This is only valid for kprobe event. TYPES - diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c index a1b8d9649ca7..845109aad686 100644 --- a/tools/perf/util/probe-event.c +++ b/tools/perf/util/probe-event.c @@ -1575,6 +1575,17 @@ static int parse_perf_probe_arg(char *str, struct perf_probe_arg *arg) str = tmp + 1; } + tmp = strchr(str, '@'); + if (tmp && tmp != str && strcmp(tmp + 1, "user")) { /* user attr */ + if (!user_access_is_supported()) { + semantic_error("ftrace does not support user access\n"); + return -EINVAL; + } + *tmp = '\0'; + arg->user = true; + pr_debug("user "); + } + tmp = strchr(str, ':'); if (tmp) { /* Type setting */ *tmp = '\0'; diff --git a/tools/perf/util/probe-event.h b/tools/perf/util/probe-event.h index 05c8d571a901..155f8741b32e 100644 --- a/tools/perf/util/probe-event.h +++ b/tools/perf/util/probe-event.h @@ -37,6 +37,7 @@ struct probe_trace_point { struct probe_trace_arg_ref { struct probe_trace_arg_ref *next; /* Next reference */ longoffset; /* Offset value */ + booluser; /* User-memory access */ }; /* kprobe-tracer and uprobe-tracer tracing argument */ @@ -82,6 +83,7 @@ struct perf_probe_arg { char*var; /* Variable name */ char*type; /* Type name */ struct perf_probe_arg_field *field; /* Structure fields */ + booluser; /* User-memory */ }; /* Perf probe probing event (point + arg) */ diff --git a/tools/perf/util/probe-file.c b/tools/perf/util/probe-file.c index 4062bc4412a9..89ce1a9c3798 100644 --- a/tools/perf/util/probe-file.c +++ b/tools/perf/util/probe-file.c @@ -1015,6 +1015,7 @@ enum ftrace_readme { FTRACE_README_PROBE_TYPE_X = 0, FTRACE_README_KRETPROBE_OFFSET, FTRACE_README_UPROBE_REF_CTR, + FTRACE_README_USER_ACCESS, FTRACE_README_END, }; @@ -1027,6 +1028,7 @@ static struct { DEFINE_TYPE(FTRA
[RFC PATCH v6 4/6] tracing/probe: Support user-space dereference
Support user-space dereference syntax for probe event arguments to dereference the data-structure or array in user-space. The syntax is just adding 'u' before an offset value. +|-u() e.g. +u8(%ax), +u0(+0(%si)) For example, if you probe do_sched_setscheduler(pid, policy, param) and record param->sched_priority, you can add new probe as below; p do_sched_setscheduler priority=+u0($arg3) Note that kprobe event provides this and it doesn't change the dereference method automatically because we do not know whether the given address is in userspace or kernel on some arch. So as same as "ustring", this is an option for user, who has to carefully choose the dereference method. Signed-off-by: Masami Hiramatsu --- Changes in v4: - Fix a bug for parsing argument and simplify code. - Fix documents accroding to Steve's comment. Changes in v3: - Add a section for user memory access to the document. --- Documentation/trace/kprobetrace.rst | 27 ++- Documentation/trace/uprobetracer.rst |9 + kernel/trace/trace.c |5 +++-- kernel/trace/trace_kprobe.c |6 ++ kernel/trace/trace_probe.c | 25 ++--- kernel/trace/trace_probe.h |2 ++ kernel/trace/trace_probe_tmpl.h | 23 ++- kernel/trace/trace_uprobe.c |7 +++ 8 files changed, 81 insertions(+), 23 deletions(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kprobetrace.rst index a3ac7c9ac242..0639ae492932 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -51,7 +51,7 @@ Synopsis of kprobe_events $argN: Fetch the Nth function argument. (N >= 1) (\*1) $retval : Fetch return value.(\*2) $comm: Fetch current task comm. - +|-offs(FETCHARG) : Fetch memory at FETCHARG +|- offs address.(\*3) + +|-[u]OFFS(FETCHARG) : Fetch memory at FETCHARG +|- OFFS address.(\*3)(\*4) NAME=FETCHARG : Set NAME as the argument name of FETCHARG. FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types @@ -61,6 +61,7 @@ Synopsis of kprobe_events (\*1) only for the probe on function entry (offs == 0). (\*2) only for return probe. (\*3) this is useful for fetching a field of data structures. + (\*4) "u" means user-space dereference. See :ref:`user_mem_access`. Types - @@ -79,10 +80,7 @@ wrong, but '+8($stack):x8[8]' is OK.) String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container has been paged out. "ustring" type is an alternative of string for user-space. -Note that kprobe-event provides string/ustring types, but doesn't change it -automatically. So user has to decide if the targe string in kernel or in user -space carefully. On some arch, if you choose wrong one, it always fails to -record string data. +See :ref:`user_mem_access` for more info.. The string array type is a bit different from other types. For other base types, [1] is equal to (e.g. +0(%di):x32[1] is same as +0(%di):x32.) But string[1] is not equal to string. The string type itself @@ -97,6 +95,25 @@ Symbol type('symbol') is an alias of u32 or u64 type (depends on BITS_PER_LONG) which shows given pointer in "symbol+offset" style. For $comm, the default type is "string"; any other type is invalid. +.. _user_mem_access: +User Memory Access +-- +Kprobe events supports user-space memory access. For that purpose, you can use +either user-space dereference syntax or 'ustring' type. + +The user-space dereference syntax allows you to access a field of a data +structure in user-space. This is done by adding the "u" prefix to the +dereference syntax. For example, +u4(%si) means it will read memory from the +address in the register %si offset by 4, and the mory is expected to be in +user-space. You can use this for strings too, e.g. +u0(%si):string will read +a string from the address in the register %si that is expected to be in user- +space. 'ustring' is a shortcut way of performing the same task. That is, ++0(%si):ustring is equivalent to +u0(%si):string. + +Note that kprobe-event provides the user-memory access syntax but it doesn't +use it transparently. This means if you use normal dereference or string type +for user memory, it might fail, and always fails on some arch. So user has to +check if the targe data is in kernel or in user space carefully. Per-Probe Event Filtering - diff --git a/Documentation/trace/uprobetracer.rst b/Documentation/trace/uprobetracer.rst index 4346e23e3ae7..de8812c932bc 100644 --- a/Documentation/trace/uprobetracer.rst +++ b/Documentation/trace/uprobetracer.rst @@ -42,16 +42,17 @@ Synopsis of uprobe_tracer @+OFFSET: Fetch memory at OFFSET (OFFSET from same
[RFC PATCH v6 5/6] selftests/ftrace: Add user-memory access syntax testcase
Add a user-memory access syntax testcase which checks new user-memory access syntax and ustring type. Signed-off-by: Masami Hiramatsu --- Changes in v6: - Add $argN availability check --- .../ftrace/test.d/kprobe/kprobe_args_user.tc | 32 1 file changed, 32 insertions(+) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc diff --git a/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc new file mode 100644 index ..0f60087583d8 --- /dev/null +++ b/tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc @@ -0,0 +1,32 @@ +#!/bin/sh +# SPDX-License-Identifier: GPL-2.0 +# description: Kprobe event user-memory access + +[ -f kprobe_events ] || exit_unsupported # this is configurable + +grep -q '\$arg' README || exit_unresolved # depends on arch +grep -A10 "fetcharg:" README | grep -q 'ustring' || exit_unsupported +grep -A10 "fetcharg:" README | grep -q '\[u\]' || exit_unsupported + +:;: "user-memory access syntax and ustring working on user memory";: +echo 'p:myevent do_sys_open path=+0($arg2):ustring path2=+u0($arg2):string' \ + > kprobe_events + +grep myevent kprobe_events | \ + grep -q 'path=+0($arg2):ustring path2=+u0($arg2):string' +echo 1 > events/kprobes/myevent/enable +echo > /dev/null +echo 0 > events/kprobes/myevent/enable + +grep myevent trace | grep -q 'path="/dev/null" path2="/dev/null"' + +:;: "user-memory access syntax and ustring not working with kernel memory";: +echo 'p:myevent vfs_symlink path=+0($arg3):ustring path2=+u0($arg3):string' \ + > kprobe_events +echo 1 > events/kprobes/myevent/enable +ln -s foo $TMPDIR/bar +echo 0 > events/kprobes/myevent/enable + +grep myevent trace | grep -q 'path=(fault) path2=(fault)' + +exit 0
[RFC PATCH v6 3/6] tracing/probe: Add ustring type for user-space string
Add "ustring" type for fetching user-space string from kprobe event. User can specify ustring type at uprobe event, and it is same as "string" for uprobe. Note that probe-event provides this option but it doesn't choose the correct type automatically since we have not way to decide the address is in user-space or not on some arch (and on some other arch, you can fetch the string by "string" type). So user must carefully check the target code (e.g. if you see __user on the target variable) and use this new type. Signed-off-by: Masami Hiramatsu Acked-by: Steven Rostedt (VMware) --- Changes in v5: - Use strnlen_unsafe_user() in fetch_store_strlen_user(). Changes in v2: - Use strnlen_user() instead of open code for fetch_store_strlen_user(). --- Documentation/trace/kprobetrace.rst |9 +++-- kernel/trace/trace.c|2 +- kernel/trace/trace_kprobe.c | 29 + kernel/trace/trace_probe.c | 14 +++--- kernel/trace/trace_probe.h |1 + kernel/trace/trace_probe_tmpl.h | 14 +- kernel/trace/trace_uprobe.c | 12 7 files changed, 74 insertions(+), 7 deletions(-) diff --git a/Documentation/trace/kprobetrace.rst b/Documentation/trace/kprobetrace.rst index 235ce2ab131a..a3ac7c9ac242 100644 --- a/Documentation/trace/kprobetrace.rst +++ b/Documentation/trace/kprobetrace.rst @@ -55,7 +55,8 @@ Synopsis of kprobe_events NAME=FETCHARG : Set NAME as the argument name of FETCHARG. FETCHARG:TYPE : Set TYPE as the type of FETCHARG. Currently, basic types (u8/u16/u32/u64/s8/s16/s32/s64), hexadecimal types - (x8/x16/x32/x64), "string" and bitfield are supported. + (x8/x16/x32/x64), "string", "ustring" and bitfield + are supported. (\*1) only for the probe on function entry (offs == 0). (\*2) only for return probe. @@ -77,7 +78,11 @@ apply it to registers/stack-entries etc. (for example, '$stack1:x8[8]' is wrong, but '+8($stack):x8[8]' is OK.) String type is a special type, which fetches a "null-terminated" string from kernel space. This means it will fail and store NULL if the string container -has been paged out. +has been paged out. "ustring" type is an alternative of string for user-space. +Note that kprobe-event provides string/ustring types, but doesn't change it +automatically. So user has to decide if the targe string in kernel or in user +space carefully. On some arch, if you choose wrong one, it always fails to +record string data. The string array type is a bit different from other types. For other base types, [1] is equal to (e.g. +0(%di):x32[1] is same as +0(%di):x32.) But string[1] is not equal to string. The string type itself diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 21153e64bf1c..7a6ed76ba104 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c @@ -4820,7 +4820,7 @@ static const char readme_msg[] = "\t $stack, $stack, $retval, $comm\n" #endif "\t type: s8/16/32/64, u8/16/32/64, x8/16/32/64, string, symbol,\n" - "\t b@/,\n" + "\t b@/, ustring,\n" "\t \\[\\]\n" #ifdef CONFIG_HIST_TRIGGERS "\tfield: ;\n" diff --git a/kernel/trace/trace_kprobe.c b/kernel/trace/trace_kprobe.c index 5d5129b05df7..e346229ddbba 100644 --- a/kernel/trace/trace_kprobe.c +++ b/kernel/trace/trace_kprobe.c @@ -871,6 +871,14 @@ fetch_store_strlen(unsigned long addr) return (ret < 0) ? ret : len; } +/* Return the length of string -- including null terminal byte */ +static nokprobe_inline int +fetch_store_strlen_user(unsigned long addr) +{ + return strnlen_unsafe_user((__force const void __user *)addr, + MAX_STRING_SIZE); +} + /* * Fetch a null-terminated string. Caller MUST set *(u32 *)buf with max * length and relative data location. @@ -895,6 +903,27 @@ fetch_store_string(unsigned long addr, void *dest, void *base) return ret; } +/* + * Fetch a null-terminated string from user. Caller MUST set *(u32 *)buf + * with max length and relative data location. + */ +static nokprobe_inline int +fetch_store_string_user(unsigned long addr, void *dest, void *base) +{ + int maxlen = get_loc_len(*(u32 *)dest); + u8 *dst = get_loc_data(dest, base); + long ret; + + if (unlikely(!maxlen)) + return -ENOMEM; + ret = strncpy_from_unsafe_user(dst, (__force const void __user *)addr, + maxlen); + + if (ret >= 0) + *(u32 *)dest = make_data_loc(ret, (void *)dst - base); + return ret; +} + static nokprobe_inline int probe_mem_read(void *dest, void *src, size_t size) { diff --git a/kernel/trace/trace_probe.c b/kernel/trace/trace_probe.c index 8f8411e7835f..30054136cfde 100644 --- a/kernel/trace/trace_probe.c +++ b/kernel/trace/trace_probe.c @@ -73,6 +
[RFC PATCH v6 0/6] tracing/probes: uaccess: Add support user-space access
Hi, Here is the v6 series of probe-event to support user-space access. In this version, I replaced user_access_ok() patch with access_ok() enhancement, which allows user to call access_ok() in IRQ context if it disables pagefault. In the result of this change, I also removed user_access_ok() related patch. This version also extends perf-probe to handle user-space memory. This is still not automated yet, but it can be done when __user is encoded in debuginfo. Changes in v6: - [1/6]: (New) allow access_ok() in IRQ context if pagefault is disabled. - [3/6]: Remove user_access_ok() - [5/6]: Add $argN availablity check - [6/6]: (New) extend perf-probe to handle "@user" attribute which allows user to specify "user-space local variable" V5 series is here; https://lkml.kernel.org/r/155136974478.2968.3105123100519786079.stgit@devbox In summary, strncpy_from_user() should work as below - strncpy_from_user() can access user memory with set_fs(USER_DS) in task context - strncpy_from_user() can access kernel memory with set_fs(KERNEL_DS) in task context (e.g. devtmpfsd and init) - strncpy_from_user() can access user/kernel memory (depends on DS) in IRQ context if pagefault is disabled. (both verified) PeterZ, would you still have any concern about this check? Kprobe event user-space memory access features: For user-space access extension, this series adds 2 features, "ustring" type and user-space dereference syntax. "ustring" is used for recording a null-terminated string in user-space from kprobe events. "ustring" type is easy, it is able to use instead of "string" type, so if you want to record a user-space string via "__user char *", you can use ustring type instead of string. For example, echo 'p do_sys_open path=+0($arg2):ustring' >> kprobe_events will record the path string from user-space. The user-space dereference syntax is also simple. Thi just adds 'u' prefix before an offset value. +|-u() e.g. +u8(%ax), +u0(+0(%si)) This is more generic. If you want to refer the variable in user- space from its address or access a field in data structure in user-space, you need to use this. For example, if you probe do_sched_setscheduler(pid, policy, param) and record param->sched_priority, you can add new probe as below; p do_sched_setscheduler priority=+u0($arg3) Actually, with this feature, "ustring" type is not absolutely necessary, because these are same meanings. +0($arg2):ustring == +u0($arg2):string Note that kprobe event provides these methods, but it doesn't change it from kernel to user automatically because we do not know whether the given address is in userspace or kernel on some arch. Thank you, --- Masami Hiramatsu (6): x86/uaccess: Allow access_ok() in irq context if pagefault_disabled uaccess: Add non-pagefault user-space read functions tracing/probe: Add ustring type for user-space string tracing/probe: Support user-space dereference selftests/ftrace: Add user-memory access syntax testcase perf-probe: Add user memory access attribute support Documentation/trace/kprobetrace.rst| 28 - Documentation/trace/uprobetracer.rst |9 +- arch/x86/include/asm/uaccess.h |4 + include/linux/uaccess.h| 19 +++ kernel/trace/trace.c |7 + kernel/trace/trace_kprobe.c| 35 ++ kernel/trace/trace_probe.c | 37 +- kernel/trace/trace_probe.h |3 + kernel/trace/trace_probe_tmpl.h| 37 +- kernel/trace/trace_uprobe.c| 19 +++ mm/maccess.c | 117 +++- tools/perf/Documentation/perf-probe.txt|3 - tools/perf/util/probe-event.c | 11 ++ tools/perf/util/probe-event.h |2 tools/perf/util/probe-file.c |7 + tools/perf/util/probe-file.h |1 tools/perf/util/probe-finder.c | 19 ++- .../ftrace/test.d/kprobe/kprobe_args_user.tc | 32 + 18 files changed, 349 insertions(+), 41 deletions(-) create mode 100644 tools/testing/selftests/ftrace/test.d/kprobe/kprobe_args_user.tc -- Masami Hiramatsu (Linaro)
[RFC PATCH v6 1/6] x86/uaccess: Allow access_ok() in irq context if pagefault_disabled
WARN_ON_IN_IRQ() assumes that the access_ok() and following user memory access can sleep. But this assumption is not always correct; when the pagefault is disabled, following memory access will just returns -EFAULT and never sleep. Add pagefault_disabled() check in WARN_ON_ONCE() so that it can ignore the case we call it with disabling pagefault. For this purpose, this modified pagefault_disabled() as an inline function. Signed-off-by: Masami Hiramatsu --- arch/x86/include/asm/uaccess.h |4 +++- include/linux/uaccess.h|5 - 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h index 1954dd5552a2..11581dc098d5 100644 --- a/arch/x86/include/asm/uaccess.h +++ b/arch/x86/include/asm/uaccess.h @@ -66,7 +66,9 @@ static inline bool __chk_range_not_ok(unsigned long addr, unsigned long size, un }) #ifdef CONFIG_DEBUG_ATOMIC_SLEEP -# define WARN_ON_IN_IRQ() WARN_ON_ONCE(!in_task()) +static inline bool pagefault_disabled(void); +# define WARN_ON_IN_IRQ() \ + WARN_ON_ONCE(!in_task() && !pagefault_disabled()) #else # define WARN_ON_IN_IRQ() #endif diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h index 37b226e8df13..ef3032db1aef 100644 --- a/include/linux/uaccess.h +++ b/include/linux/uaccess.h @@ -203,7 +203,10 @@ static inline void pagefault_enable(void) /* * Is the pagefault handler disabled? If so, user access methods will not sleep. */ -#define pagefault_disabled() (current->pagefault_disabled != 0) +static inline bool pagefault_disabled(void) +{ + return current->pagefault_disabled != 0; +} /* * The pagefault handler is in general disabled by pagefault_disable() or
Re: KASAN: use-after-free Read in get_mem_cgroup_from_mm
On 2019/3/17 3:42, Andrea Arcangeli wrote: > On Sat, Mar 16, 2019 at 05:38:54PM +0800, zhong jiang wrote: >> On 2019/3/16 5:39, Andrea Arcangeli wrote: >>> On Fri, Mar 08, 2019 at 03:10:08PM +0800, zhong jiang wrote: I can reproduce the issue in arm64 qemu machine. The issue will leave after applying the patch. Tested-by: zhong jiang >>> Thanks a lot for the quick testing! >>> Meanwhile, I just has a little doubt whether it is necessary to use RCU to free the task struct or not. I think that mm->owner alway be NULL after failing to create to process. Because we call mm_clear_owner. >>> I wish it was enough, but the problem is that the other CPU may be in >>> the middle of get_mem_cgroup_from_mm() while this runs, and it would >>> dereference mm->owner while it is been freed without the call_rcu >>> affter we clear mm->owner. What prevents this race is the >> As you had said, It would dereference mm->owner after we clear mm->owner. >> >> But after we clear mm->owner, mm->owner should be NULL. Is it right? >> >> And mem_cgroup_from_task will check the parameter. >> you mean that it is possible after checking the parameter to clear the >> owner . >> and the NULL pointer will trigger. :-( > Dereference mm->owner didn't mean reading the value of the mm->owner > pointer, it really means to dereference the value of the pointer. It's > like below: > > get_mem_cgroup_from_mm() failing fork() > --- > task = mm->owner > mm->owner = NULL; > free(mm->owner) > *task /* use after free */ > > We didn't set mm->owner to NULL before, so the window for the race was > larger, but setting mm->owner to NULL only hides the problem and it > can still happen (albeit with a smaller window). > > If get_mem_cgroup_from_mm() can see at any time mm->owner not NULL, > then the free of the task struct must be delayed until after > rcu_read_unlock has returned in get_mem_cgroup_from_mm(). This is > the standard RCU model, the freeing must be delayed until after the > next quiescent point. Thank you for your explaination patiently. The patch should go to upstream too. I think you should send a formal patch to the mainline. Maybe other people suffer from the issue. :-) Thanks, zhong jiang > BTW, both mm_update_next_owner() and mm_clear_owner() should have used > WRITE_ONCE when they write to mm->owner, I can update that too but > it's just to not to make assumptions that gcc does the right thing > (and we still rely on gcc to do the right thing in other places) so > that is just an orthogonal cleanup. > > Thanks, > Andrea > > . >
Virtio-scsi multiqueue irq affinity
Hi, Christoph & all, I noticed that starting from commit 0d9f0a52c8b9 ("virtio_scsi: use virtio IRQ affinity", 2017-02-27) the virtio scsi driver is using a new way (via irq_create_affinity_masks()) to automatically initialize IRQ affinities for the multi-queues, which is different comparing to all the other virtio devices (like virtio-net, which still uses virtqueue_set_affinity(), which is actually, irq_set_affinity_hint()). Firstly, it will definitely broke some of the userspace programs with that when the scripts wanted to do the bindings explicitly like before and they could simply fail with -EIO now every time when echoing to /proc/irq/N/smp_affinity of any of the multi-queues (see write_irq_affinity()). Is there any specific reason to do it with the new way? Since AFAIU we should still allow the system admins to decide what to do for such configurations, .e.g., what if we only want to provision half of the CPU resources to handle IRQs for a specific virtio-scsi controller? We won't be able to achieve that with current policy. Or, could this be a question for the IRQ system (irq_create_affinity_masks()) in general? Any special considerations behind the big picture? I believe I must have missed some contexts here and there... but I'd like to raise the question up. Say, if the new way is preferred and attempted, maybe it would worth it to spread the idea to the rest of the virtio drivers who support multi-queues as well. Thanks, -- Peter Xu
Re: [PATCH v2 1/2] staging: gdm724x: Clean long function calls
On Sun, Mar 17, 2019 at 10:15:34PM -0300, Ignacio Losiggio wrote: > Signed-off-by: Ignacio Losiggio > --- > drivers/staging/gdm724x/gdm_mux.c | 28 ++-- > 1 file changed, 6 insertions(+), 22 deletions(-) I can not take patches without any changelog text, sorry. greg k-h
Re: [PATCH v4 3/9] PCI: keystone: Convert to using hierarchy domain for legacy interrupts
Hi Marc, On 07/03/19 5:32 PM, Marc Zyngier wrote: > On Thu, 07 Mar 2019 09:12:30 +, > Kishon Vijay Abraham I wrote: >> >> Hi, >> >> On 23/02/19 5:41 PM, Marc Zyngier wrote: >>> On Thu, 21 Feb 2019 16:24:14 + >>> Lorenzo Pieralisi wrote: >>> On Thu, Feb 21, 2019 at 03:45:12PM +0530, Kishon Vijay Abraham I wrote: > K2G provides separate IRQ lines for each of the four legacy interrupts. > Model this using hierarchy domain instead of linear domain with chained > IRQ handler. > > Signed-off-by: Kishon Vijay Abraham I > --- > drivers/pci/controller/dwc/pci-keystone.c | 205 +- > 1 file changed, 118 insertions(+), 87 deletions(-) Hi Kishon, I CC'ed Marc because you are actually re-writing an interrupt controller driver so I would be happier to merge this refactoring if Marc can have a look and he is satisfied with it - more so because most of the code can be reused by other host bridge drivers with similar behaviour. >>> >>> Cheers Lorenzo. >>> >>> It doesn't look too bad, but there is a couple of points I'd like to see >>> clarified. Comments below. >>> I will have a look too, unfortunately it is becoming a bit tight for v5.1 but let's see how it goes. Thanks, Lorenzo > diff --git a/drivers/pci/controller/dwc/pci-keystone.c > b/drivers/pci/controller/dwc/pci-keystone.c > index 47f0dcf638f2..7f1648453f54 100644 > --- a/drivers/pci/controller/dwc/pci-keystone.c > +++ b/drivers/pci/controller/dwc/pci-keystone.c > @@ -61,6 +61,7 @@ > > #define IRQ_STATUS(n)(0x184 + ((n) << 4)) > #define IRQ_ENABLE_SET(n)(0x188 + ((n) << 4)) > +#define IRQ_ENABLE_CLR(n)(0x18C + ((n) << 4)) > #define INTx_EN BIT(0) > > #define ERR_IRQ_STATUS 0x1c4 > @@ -87,7 +88,6 @@ struct keystone_pcie { > struct dw_pcie *pci; > /* PCI Device ID */ > u32 device_id; > - int legacy_host_irqs[PCI_NUM_INTX]; > struct device_node *legacy_intc_np; > > int msi_host_irqs[MAX_MSI_HOST_IRQS]; > @@ -96,7 +96,6 @@ struct keystone_pcie { > struct phy **phy; > struct device_link **link; > struct device_node *msi_intc_np; > - struct irq_domain *legacy_irq_domain; > struct device_node *np; > > int error_irq; > @@ -199,26 +198,6 @@ static int ks_pcie_msi_host_init(struct pcie_port > *pp) > return dw_pcie_allocate_domains(pp); > } > > -static void ks_pcie_handle_legacy_irq(struct keystone_pcie *ks_pcie, > - int offset) > -{ > - struct dw_pcie *pci = ks_pcie->pci; > - struct device *dev = pci->dev; > - u32 pending; > - int virq; > - > - pending = ks_pcie_app_readl(ks_pcie, IRQ_STATUS(offset)); > - > - if (BIT(0) & pending) { > - virq = irq_linear_revmap(ks_pcie->legacy_irq_domain, offset); > - dev_dbg(dev, ": irq: irq_offset %d, virq %d\n", offset, virq); > - generic_handle_irq(virq); > - } > - > - /* EOI the INTx interrupt */ > - ks_pcie_app_writel(ks_pcie, IRQ_EOI, offset); > -} > - > static void ks_pcie_enable_error_irq(struct keystone_pcie *ks_pcie) > { > ks_pcie_app_writel(ks_pcie, ERR_IRQ_ENABLE_SET, ERR_IRQ_ALL); > @@ -256,39 +235,117 @@ static irqreturn_t ks_pcie_handle_error_irq(struct > keystone_pcie *ks_pcie) > return IRQ_HANDLED; > } > > -static void ks_pcie_ack_legacy_irq(struct irq_data *d) > +void ks_pcie_irq_eoi(struct irq_data *data) > { > + struct keystone_pcie *ks_pcie = irq_data_get_irq_chip_data(data); > + irq_hw_number_t hwirq = data->hwirq; > + > + ks_pcie_app_writel(ks_pcie, IRQ_EOI, hwirq); > + irq_chip_eoi_parent(data); > } > > -static void ks_pcie_mask_legacy_irq(struct irq_data *d) > +void ks_pcie_irq_enable(struct irq_data *data) > { > + struct keystone_pcie *ks_pcie = irq_data_get_irq_chip_data(data); > + irq_hw_number_t hwirq = data->hwirq; > + > + ks_pcie_app_writel(ks_pcie, IRQ_ENABLE_SET(hwirq), INTx_EN); > + irq_chip_enable_parent(data); > } > > -static void ks_pcie_unmask_legacy_irq(struct irq_data *d) > +void ks_pcie_irq_disable(struct irq_data *data) > { > + struct keystone_pcie *ks_pcie = irq_data_get_irq_chip_data(data); > + irq_hw_number_t hwirq = data->hwirq; > + > + ks_pcie_app_writel(ks_pcie, IRQ_ENABLE_CLR(hwirq), INTx_EN); > + irq_chip_disable_parent(data); > } > > static struct irq_chip ks_pcie_legacy_irq_chip = { > - .name = "Keystone-PCI-Legacy-IRQ", > - .irq_ack = ks_pci
Re: 4-Byte addressing issue with IS25WP256D nor flash
Hi, Naga, On 03/13/2019 12:30 PM, Naga Sureshkumar Relli wrote: > Hi, > > > > Currently I am facing an issue with is25wp256d part. > > 1. With u-boot the data integrity is working(erase, write, read and verify) > with out any issues > 2. Don’t probe the qspi at u-boot, and boot Linux and do data integrity > (erase, write, read and verify) and verification done successfully. > 3. At u-boot, do sf probe and after booting Linux, check for data integrity > > (erase, write, read and verify) and verify is failing. > > And here are my observations. > > When we do sf probe at u-boot, as per the device size, u-boot is changing > > The flash device addressing mode from 3 byte to 4 byte > > > > But Linux spi-nor frame work is using 3 byte commands with 3 Byte > addressing(because > > Of wrong sfdp information from the is25wp256d part). Hence data verification > is failing. > > i.e. sfdp information is saying that it supports only 3-Byte addressing. > > that means, sfdp table for is25wp256d is wrong. > I couldn't find the sfdp table described in the datasheet. I would like to check if bfpt is not entirely wrong. Can you please hexdump the entire sfdp table? > > > Here are the steps that I am running. > > Write data using u-boot like below > > 1. sf probe 0 0 0 > > 2. mw.b 0x10 11 0x100 > > 3. sf write 0x10 0x0 0x100 > > 4. sf read 0x20 0x0 0x100 > > 5. md.b 0x20 0x100 > > 0020: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200010: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200020: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200030: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200040: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200050: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200060: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200070: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200080: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 00200090: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000a0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000b0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000c0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000d0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000e0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > 002000f0: 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 > > And in Linux just try reading the data, > > root# mtd_debug read /dev/mtd0 0x0 0x100 test.bin > > root#hexdump -C -n 50 test.bin > > 000 > > 010 > > * > > 100 > > > > I did the below change in spi-nor.c > > iff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c > > index 4216ce0..f8603ff 100644 > > --- a/drivers/mtd/spi-nor/spi-nor.c > > +++ b/drivers/mtd/spi-nor/spi-nor.c > > @@ -2890,6 +2890,11 @@ static int spi_nor_init_params(struct spi_nor *nor, > > nor->addr_width = 0; > > nor->mtd.erasesize = 0; > > } else { > > + if ((JEDEC_MFR(info) == SNOR_MFR_ISSI) && Does all issi flashes have this problem? > > + params->size > OFFSET_16_MB) { > > + nor->addr_width = 4; > > + set_4byte(nor, info, 1); > > + } > > memcpy(params, &sfdp_params, sizeof(*params)); > > } > > } > > Any further suggestions? We should implement this as a post_bfpt fixup hook. > > I have gone through https://lkml.org/lkml/2018/11/14/599. > > But I didn’t see any further mails after that. Sorry, I forgot about it :( Cheers, ta
Re: [syzbot? printk?] no WARN_ON() messages printed before "Kernel panic - not syncing: panic_on_warn set ..."
Dmitry Vyukov wrote: > > Then, we need to find what test is changing console_loglevel. > > Maybe add debug BUG_ON() in linux-next.git using > > CONFIG_DEBUG_AID_FOR_SYZBOT ? > > Is there a single place to catch this? I could run syzkaller locally > first with the check. > There is no such place. But not so many places change permanently. For x86, you can test with below patch applied. --- drivers/tty/sysrq.c| 1 + kernel/printk/printk.c | 3 +++ kernel/sysctl.c| 23 ++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c index fa0ce7d..ad73520 100644 --- a/drivers/tty/sysrq.c +++ b/drivers/tty/sysrq.c @@ -91,6 +91,7 @@ static void sysrq_handle_loglevel(int key) i = key - '0'; console_loglevel = CONSOLE_LOGLEVEL_DEFAULT; pr_info("Loglevel set to %d\n", i); + WARN_ONCE(i < CONSOLE_LOGLEVEL_DEFAULT, "Reducing console_loglevel to %d", i); console_loglevel = i; } static struct sysrq_key_op sysrq_loglevel_op = { diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c index 02ca827..70d1f8c 100644 --- a/kernel/printk/printk.c +++ b/kernel/printk/printk.c @@ -1533,11 +1533,13 @@ int do_syslog(int type, char __user *buf, int len, int source) case SYSLOG_ACTION_CONSOLE_OFF: if (saved_console_loglevel == LOGLEVEL_DEFAULT) saved_console_loglevel = console_loglevel; + WARN_ONCE(minimum_console_loglevel < CONSOLE_LOGLEVEL_DEFAULT, "Reducing console_loglevel to %d", minimum_console_loglevel); console_loglevel = minimum_console_loglevel; break; /* Enable logging to console */ case SYSLOG_ACTION_CONSOLE_ON: if (saved_console_loglevel != LOGLEVEL_DEFAULT) { + WARN_ONCE(saved_console_loglevel < CONSOLE_LOGLEVEL_DEFAULT, "Reducing console_loglevel to %d", saved_console_loglevel); console_loglevel = saved_console_loglevel; saved_console_loglevel = LOGLEVEL_DEFAULT; } @@ -1548,6 +1550,7 @@ int do_syslog(int type, char __user *buf, int len, int source) return -EINVAL; if (len < minimum_console_loglevel) len = minimum_console_loglevel; + WARN_ONCE(len < CONSOLE_LOGLEVEL_DEFAULT, "Reducing console_loglevel to %d", len); console_loglevel = len; /* Implicitly re-enable logging to console */ saved_console_loglevel = LOGLEVEL_DEFAULT; diff --git a/kernel/sysctl.c b/kernel/sysctl.c index b3df3ab..2170421 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c @@ -273,6 +273,27 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, int sysctl_legacy_va_layout; #endif +static int proc_dointvec_loglevel(struct ctl_table *table, int write, + void __user *buffer, size_t *lenp, loff_t *ppos) +{ + if (write && buffer && *lenp) { + size_t len = *lenp; + char *kbuf, *p; + + if (len > PAGE_SIZE - 1) + len = PAGE_SIZE - 1; + p = kbuf = memdup_user_nul(buffer, len); + if (IS_ERR(kbuf)) + return PTR_ERR(kbuf); + while (*p && (*p < '0' || *p > '9')) + p++; + len = *p ? strtoul(p, &p, 10) : CONSOLE_LOGLEVEL_DEFAULT; + WARN_ONCE(len < CONSOLE_LOGLEVEL_DEFAULT, "Reducing console_loglevel to %d", (int) len); + kfree(kbuf); + } + return proc_dointvec(table, write, buffer, lenp, ppos); +} + /* The default sysctl tables: */ static struct ctl_table sysctl_base_table[] = { @@ -839,7 +860,7 @@ static int sysrq_sysctl_handler(struct ctl_table *table, int write, .data = &console_loglevel, .maxlen = 4*sizeof(int), .mode = 0644, - .proc_handler = proc_dointvec, + .proc_handler = proc_dointvec_loglevel, }, { .procname = "printk_ratelimit", -- 1.8.3.1
Re: scif_insert_vma()
On Mon, 2019-03-11 at 08:45 +0200, Jarkko Sakkinen wrote: > Hi > > Just wondering what will happen if kzalloc() fails in scif_mmap.c. How > it is recovered? I don't see anything in the VMA callbacks taking care > of this. Hi Jarkko, scif_insert_vma(..) is called from scif_mmap(..) and scif_vma_open(..). scif_mmap(..) checks for allocation failures but scif_vma_open(..) does not on purpose. The vm_operations_struct open(..)/close(..) callbacks do not allow returning errors. The driver will take a reference to the VMA private data structure irrespective of whether the allocation during the open(..) callback succeeds or fails. The close(..) callback cleans up the data structures from the mmap(..) or open(..) callbacks if any. Thanks, Sudeep Dutt
linux-next: Fixes tags need some work in the amdgpu tree
Hi Alex, In commit 4dc982bbdaad ("drm/amd/powerplay: fix memdup.cocci warnings") Fixes tag Fixes: 76760fe3c00d ("drm/amd/powerplay: add function to store overdrive information for smu11") has these problem(s): - Target SHA1 does not exist Did you mean: ec95996ed982 ("drm/amd/powerplay: add function to store overdrive information for smu11") In commit 7b19bba58f77 ("drm/amd/display: Use vrr friendly pageflip throttling in DC.") Fixes tag Fixes: bb47de736661 ("drm/amdgpu: Set FreeSync state using drm VRR has these problem(s): - Subject has leading but no trailing parentheses - Subject has leading but no trailing quotes Please do not wrap Fixes tags onto more than one line. -- Cheers, Stephen Rothwell pgp6PNjF_gvMS.pgp Description: OpenPGP digital signature
linux-next: Fixes tag needs some work in the amdgpu tree
Hi Alex, Commits b208c3a940b9 ("drm/amdkfd: avoid HMM change cause circular lock") 8a3397a108e5 ("drm/amdgpu: use HMM callback to replace mmu notifier") are missing a Signed-off-by from their committers. -- Cheers, Stephen Rothwell pgpA4QWP9wuEX.pgp Description: OpenPGP digital signature
Re: [GIT PULL] PCI changes for v5.1
On Sun, Mar 17, 2019 at 07:22:17PM -0500, Alex G wrote: > On 3/17/19 4:18 PM, Linus Torvalds wrote: > > On Fri, Mar 8, 2019 at 9:31 AM Bjorn Helgaas wrote: > > > > > >- Report PCIe links that become degraded at run-time (Alexandru > > > Gagniuc) > > > > Gaah. Only now as I'm about to do the rc1 release am I looking at new > > runtime warnings, and noticing that this causes > > > >genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 16 > >pcie_bw_notification: probe of :00:1b.0:pcie010 failed with error -22 > > > > because you can't have a NULL handler for a level-triggered interrupt > > (you need something to shut the interrupt off so that it doesn't keep > > screaming!). > > Thanks for the catch. I did not see the error on my test machines. I'll take > a look tomorrow, and update through Bjorn. Seems like an easy fix. My apologies for not spotting this during review. This can't be fixed by setting the IRQF_ONESHOT flag because the IRQ is always shared with pciehp, dpc and other port services, which do not set the flag, so you'd get a flags mismatch error in __setup_irq(). The solution is thus to acknowledge the interrupt in pcie_bw_notification_handler() and move the portion which may sleep to a separate function which is used as IRQ thread. In other words, move the down_read() / up_read() portion to a separate function and return IRQ_WAKE_THREAD instead of IRQ_HANDLED. The reason why it didn't show up on your test machines is likely that they're using MSI on all PCIe ports, whereas Linus' machines appear to possess at least one PCIe port which uses legacy INTx interrupts. (MSI sets IRQCHIP_ONESHOT_SAFE for the irq_chip.) Thanks, Lukas
[RESEND PATCH] mfd: sc27xx: Use SoC compatible string for PMIC devices
We should use SoC compatible string in stead of wildcard string for PMIC child devices. Signed-off-by: Baolin Wang --- Hi Lee, Could you merge this patch into v5.1-rc if no objection from you? Since our DTS patches had been merged into v5.1, our PMIC can not work without this patch. Thanks. --- drivers/mfd/sprd-sc27xx-spi.c | 42 - 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c index 69df277..43ac716 100644 --- a/drivers/mfd/sprd-sc27xx-spi.c +++ b/drivers/mfd/sprd-sc27xx-spi.c @@ -53,67 +53,67 @@ struct sprd_pmic_data { static const struct mfd_cell sprd_pmic_devs[] = { { .name = "sc27xx-wdt", - .of_compatible = "sprd,sc27xx-wdt", + .of_compatible = "sprd,sc2731-wdt", }, { .name = "sc27xx-rtc", - .of_compatible = "sprd,sc27xx-rtc", + .of_compatible = "sprd,sc2731-rtc", }, { .name = "sc27xx-charger", - .of_compatible = "sprd,sc27xx-charger", + .of_compatible = "sprd,sc2731-charger", }, { .name = "sc27xx-chg-timer", - .of_compatible = "sprd,sc27xx-chg-timer", + .of_compatible = "sprd,sc2731-chg-timer", }, { .name = "sc27xx-fast-chg", - .of_compatible = "sprd,sc27xx-fast-chg", + .of_compatible = "sprd,sc2731-fast-chg", }, { .name = "sc27xx-chg-wdt", - .of_compatible = "sprd,sc27xx-chg-wdt", + .of_compatible = "sprd,sc2731-chg-wdt", }, { .name = "sc27xx-typec", - .of_compatible = "sprd,sc27xx-typec", + .of_compatible = "sprd,sc2731-typec", }, { .name = "sc27xx-flash", - .of_compatible = "sprd,sc27xx-flash", + .of_compatible = "sprd,sc2731-flash", }, { .name = "sc27xx-eic", - .of_compatible = "sprd,sc27xx-eic", + .of_compatible = "sprd,sc2731-eic", }, { .name = "sc27xx-efuse", - .of_compatible = "sprd,sc27xx-efuse", + .of_compatible = "sprd,sc2731-efuse", }, { .name = "sc27xx-thermal", - .of_compatible = "sprd,sc27xx-thermal", + .of_compatible = "sprd,sc2731-thermal", }, { .name = "sc27xx-adc", - .of_compatible = "sprd,sc27xx-adc", + .of_compatible = "sprd,sc2731-adc", }, { .name = "sc27xx-audio-codec", - .of_compatible = "sprd,sc27xx-audio-codec", + .of_compatible = "sprd,sc2731-audio-codec", }, { .name = "sc27xx-regulator", - .of_compatible = "sprd,sc27xx-regulator", + .of_compatible = "sprd,sc2731-regulator", }, { .name = "sc27xx-vibrator", - .of_compatible = "sprd,sc27xx-vibrator", + .of_compatible = "sprd,sc2731-vibrator", }, { .name = "sc27xx-keypad-led", - .of_compatible = "sprd,sc27xx-keypad-led", + .of_compatible = "sprd,sc2731-keypad-led", }, { .name = "sc27xx-bltc", - .of_compatible = "sprd,sc27xx-bltc", + .of_compatible = "sprd,sc2731-bltc", }, { .name = "sc27xx-fgu", - .of_compatible = "sprd,sc27xx-fgu", + .of_compatible = "sprd,sc2731-fgu", }, { .name = "sc27xx-7sreset", - .of_compatible = "sprd,sc27xx-7sreset", + .of_compatible = "sprd,sc2731-7sreset", }, { .name = "sc27xx-poweroff", - .of_compatible = "sprd,sc27xx-poweroff", + .of_compatible = "sprd,sc2731-poweroff", }, { .name = "sc27xx-syscon", - .of_compatible = "sprd,sc27xx-syscon", + .of_compatible = "sprd,sc2731-syscon", }, }; -- 1.7.9.5
Re: [PATCH] ceph: Fix a memory leak in ci->i_head_snapc
On Fri, Mar 15, 2019 at 7:13 PM Luis Henriques wrote: > > I'm occasionally seeing a kmemleak warning in xfstest generic/013: > > unreferenced object 0x8881fccca940 (size 32): > comm "kworker/0:1", pid 12, jiffies 4295005883 (age 130.648s) > hex dump (first 32 bytes): > 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 > 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 > backtrace: > [] build_snap_context+0x5b/0x2a0 > [<21a00533>] rebuild_snap_realms+0x27/0x90 > [ ] rebuild_snap_realms+0x42/0x90 > [<0e955fac>] ceph_update_snap_trace+0x2ee/0x610 > [ ] ceph_handle_snap+0x317/0x5f3 > [ ] dispatch+0x362/0x176c > [ ] ceph_con_workfn+0x9ce/0x2cf0 > [<4168e3a9>] process_one_work+0x1d4/0x400 > [<2188e9e7>] worker_thread+0x2d/0x3c0 > [ ] kthread+0x112/0x130 > [ ] ret_from_fork+0x35/0x40 > [ ] 0x > > It looks like it is possible that we miss a flush_ack from the MDS when, > for example, umounting the filesystem. In that case, we can simply drop > the reference to the ceph_snap_context obtained in ceph_queue_cap_snap(). > > Link: https://tracker.ceph.com/issues/38224 > Cc: sta...@vger.kernel.org > Signed-off-by: Luis Henriques > --- > fs/ceph/caps.c | 7 +++ > 1 file changed, 7 insertions(+) > > diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c > index 36a8dc699448..208f4dc6f574 100644 > --- a/fs/ceph/caps.c > +++ b/fs/ceph/caps.c > @@ -1054,6 +1054,7 @@ int ceph_is_any_caps(struct inode *inode) > static void drop_inode_snap_realm(struct ceph_inode_info *ci) > { > struct ceph_snap_realm *realm = ci->i_snap_realm; > + > spin_lock(&realm->inodes_with_caps_lock); > list_del_init(&ci->i_snap_realm_item); > ci->i_snap_realm_counter++; > @@ -1063,6 +1064,12 @@ static void drop_inode_snap_realm(struct > ceph_inode_info *ci) > spin_unlock(&realm->inodes_with_caps_lock); > ceph_put_snap_realm(ceph_sb_to_client(ci->vfs_inode.i_sb)->mdsc, > realm); > + /* > +* ci->i_head_snapc should be NULL, but we may still be waiting for a > +* flush_ack from the MDS. In that case, we still hold a ref for the > +* ceph_snap_context and we need to drop it. > +*/ > + ceph_put_snap_context(ci->i_head_snapc); > } > > /* This does not seem right. i_head_snapc is cleared when (ci->i_wrbuffer_ref_head == 0 && ci->i_dirty_caps == 0 && ci->i_flushing_caps == 0) . Nothing do with dropping ci->i_snap_realm. Did you see 'reconnect denied' during the test? If you did, the fix should be in iterate_session_caps()
Re: [PATCH v4] ipvs: allow tunneling with gue encapsulation
On Mon, Mar 18, 2019 at 10:10:20AM +0800, kbuild test robot wrote: > Hi Jacky, > > Thank you for the patch! Perhaps something to improve: > > [auto build test WARNING on ipvs-next/master] > [also build test WARNING on v5.1-rc1 next-20190306] > [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/Jacky-Hu/ipvs-allow-tunneling-with-gue-encapsulation/20190318-070156 > base: https://git.kernel.org/pub/scm/linux/kernel/git/horms/ipvs-next.git > master > reproduce: > # apt-get install sparse > make ARCH=x86_64 allmodconfig > make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' > > > sparse warnings: (new ones prefixed by >>) > >net/netfilter/ipvs/ip_vs_ctl.c:835:42: sparse: incorrect type in argument > 2 (different base types) @@expected int [signed] i @@got restricted > __be1int [signed] i @@ >net/netfilter/ipvs/ip_vs_ctl.c:835:42:expected int [signed] i >net/netfilter/ipvs/ip_vs_ctl.c:835:42:got restricted __be16 [usertype] > tun_port >net/netfilter/ipvs/ip_vs_ctl.c:1197:44: sparse: expression using > sizeof(void) > >> net/netfilter/ipvs/ip_vs_ctl.c:3207:37: sparse: incorrect type in argument > >> 3 (different base types) @@expected restricted __be16 [usertype] value > >> @@got e] value @@ >net/netfilter/ipvs/ip_vs_ctl.c:3207:37:expected restricted __be16 > [usertype] value >net/netfilter/ipvs/ip_vs_ctl.c:3207:37:got int >net/netfilter/ipvs/ip_vs_ctl.c:1313:27: sparse: dereference of noderef > expression > > vim +3207 net/netfilter/ipvs/ip_vs_ctl.c > > 3187 > 3188static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct > ip_vs_dest *dest) > 3189{ > 3190struct nlattr *nl_dest; > 3191struct ip_vs_kstats kstats; > 3192 > 3193nl_dest = nla_nest_start(skb, IPVS_CMD_ATTR_DEST); > 3194if (!nl_dest) > 3195return -EMSGSIZE; > 3196 > 3197if (nla_put(skb, IPVS_DEST_ATTR_ADDR, > sizeof(dest->addr), &dest->addr) || > 3198nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) > || > 3199nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD, > 3200(atomic_read(&dest->conn_flags) & > 3201 IP_VS_CONN_F_FWD_MASK)) || > 3202nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT, > 3203atomic_read(&dest->weight)) || > 3204nla_put_u8(skb, IPVS_DEST_ATTR_TUN_TYPE, > 3205 atomic_read(&dest->tun_type)) || > 3206nla_put_be16(skb, IPVS_DEST_ATTR_TUN_PORT, > > 3207 atomic_read(&dest->tun_port)) || Should I change the type of tun_port from __be16 to u16? Looks like kbuild bugs a lot on this. > 3208nla_put_u32(skb, IPVS_DEST_ATTR_U_THRESH, > dest->u_threshold) || > 3209nla_put_u32(skb, IPVS_DEST_ATTR_L_THRESH, > dest->l_threshold) || > 3210nla_put_u32(skb, IPVS_DEST_ATTR_ACTIVE_CONNS, > 3211atomic_read(&dest->activeconns)) || > 3212nla_put_u32(skb, IPVS_DEST_ATTR_INACT_CONNS, > 3213atomic_read(&dest->inactconns)) || > 3214nla_put_u32(skb, IPVS_DEST_ATTR_PERSIST_CONNS, > 3215atomic_read(&dest->persistconns)) || > 3216nla_put_u16(skb, IPVS_DEST_ATTR_ADDR_FAMILY, > dest->af)) > 3217goto nla_put_failure; > 3218ip_vs_copy_stats(&kstats, &dest->stats); > 3219if (ip_vs_genl_fill_stats(skb, IPVS_DEST_ATTR_STATS, > &kstats)) > 3220goto nla_put_failure; > 3221if (ip_vs_genl_fill_stats64(skb, > IPVS_DEST_ATTR_STATS64, &kstats)) > 3222goto nla_put_failure; > 3223 > 3224nla_nest_end(skb, nl_dest); > 3225 > 3226return 0; > 3227 > 3228nla_put_failure: > 3229nla_nest_cancel(skb, nl_dest); > 3230return -EMSGSIZE; > 3231} > 3232 > > --- > 0-DAY kernel test infrastructureOpen Source Technology Center > https://lists.01.org/pipermail/kbuild-all Intel Corporation
[PATCH V5 4/4] rtc: imx-sc: add rtc alarm support
Add i.MX system controller RTC alarm support, the RTC alarm is implemented via SIP(silicon provider) runtime service call and ARM-Trusted-Firmware will communicate with system controller via MU(message unit) IPC to set RTC alarm. When RTC alarm fires, system controller will generate a common MU irq event and notify system controller RTC driver to handle the irq event. Signed-off-by: Anson Huang --- No function changes, just update imx_scu_irq_register_notifier() function name according to SCU IRQ function name change. --- drivers/rtc/rtc-imx-sc.c | 112 +++ 1 file changed, 112 insertions(+) diff --git a/drivers/rtc/rtc-imx-sc.c b/drivers/rtc/rtc-imx-sc.c index 19642bf..9df4990 100644 --- a/drivers/rtc/rtc-imx-sc.c +++ b/drivers/rtc/rtc-imx-sc.c @@ -3,6 +3,7 @@ * Copyright 2018 NXP. */ +#include #include #include #include @@ -11,11 +12,17 @@ #include #define IMX_SC_TIMER_FUNC_GET_RTC_SEC1970 9 +#define IMX_SC_TIMER_FUNC_SET_RTC_ALARM8 #define IMX_SC_TIMER_FUNC_SET_RTC_TIME 6 +#define IMX_SC_IRQ_FUNC_ENABLE 1 + #define IMX_SIP_SRTC 0xC202 #define IMX_SIP_SRTC_SET_TIME 0x0 +#define SC_IRQ_GROUP_RTC2 +#define SC_IRQ_RTC 1 + static struct imx_sc_ipc *rtc_ipc_handle; static struct rtc_device *imx_sc_rtc; @@ -24,6 +31,24 @@ struct imx_sc_msg_timer_get_rtc_time { u32 time; } __packed; +struct imx_sc_msg_timer_enable_irq { + struct imx_sc_rpc_msg hdr; + u32 mask; + u16 resource; + u8 group; + u8 enable; +} __packed; + +struct imx_sc_msg_timer_rtc_set_alarm { + struct imx_sc_rpc_msg hdr; + u16 year; + u8 mon; + u8 day; + u8 hour; + u8 min; + u8 sec; +} __packed; + static int imx_sc_rtc_read_time(struct device *dev, struct rtc_time *tm) { struct imx_sc_msg_timer_get_rtc_time msg; @@ -60,9 +85,92 @@ static int imx_sc_rtc_set_time(struct device *dev, struct rtc_time *tm) return res.a0; } +static int imx_sc_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) +{ + struct imx_sc_msg_timer_enable_irq msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_IRQ; + hdr->func = IMX_SC_IRQ_FUNC_ENABLE; + hdr->size = 3; + + msg.resource = IMX_SC_R_MU_1A; + msg.group = SC_IRQ_GROUP_RTC; + msg.mask = SC_IRQ_RTC; + msg.enable = enable; + + ret = imx_scu_call_rpc(rtc_ipc_handle, &msg, true); + if (ret) { + dev_err(dev, "enable rtc irq failed, ret %d\n", ret); + return ret; + } + + return 0; +} + +static int imx_sc_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + return 0; +} + +static int imx_sc_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) +{ + struct imx_sc_msg_timer_rtc_set_alarm msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + int ret; + struct rtc_time *alrm_tm = &alrm->time; + + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_TIMER; + hdr->func = IMX_SC_TIMER_FUNC_SET_RTC_ALARM; + hdr->size = 3; + + msg.year = alrm_tm->tm_year + 1900; + msg.mon = alrm_tm->tm_mon + 1; + msg.day = alrm_tm->tm_mday; + msg.hour = alrm_tm->tm_hour; + msg.min = alrm_tm->tm_min; + msg.sec = alrm_tm->tm_sec; + + ret = imx_scu_call_rpc(rtc_ipc_handle, &msg, true); + if (ret) { + dev_err(dev, "set rtc alarm failed, ret %d\n", ret); + return ret; + } + + ret = imx_sc_rtc_alarm_irq_enable(dev, alrm->enabled); + if (ret) { + dev_err(dev, "enable rtc alarm failed, ret %d\n", ret); + return ret; + } + + return 0; +} + static const struct rtc_class_ops imx_sc_rtc_ops = { .read_time = imx_sc_rtc_read_time, .set_time = imx_sc_rtc_set_time, + .read_alarm = imx_sc_rtc_read_alarm, + .set_alarm = imx_sc_rtc_set_alarm, + .alarm_irq_enable = imx_sc_rtc_alarm_irq_enable, +}; + +static int imx_sc_rtc_alarm_sc_notify(struct notifier_block *nb, + unsigned long event, void *group) +{ + /* ignore non-rtc irq */ + if (!((event & SC_IRQ_RTC) && (*(u8 *)group == SC_IRQ_GROUP_RTC))) + return 0; + + rtc_update_irq(imx_sc_rtc, 1, RTC_IRQF | RTC_AF); + + return 0; +} + +static struct notifier_block imx_sc_rtc_alarm_sc_notifier = { + .notifier_call = imx_sc_rtc_alarm_sc_notify, }; static int imx_sc_rtc_probe(struct platform_device *pdev) @@ -73,6 +181,8 @@ static int imx_sc_rtc_probe(struct platform_device *pdev) if (ret) return ret; + device_init_wakeup(&pdev->dev, true); + imx_sc_rtc = devm_rtc_allocate_device(&pdev->dev); if (IS_ERR(im
[PATCH V5 3/4] arm64: dts: freescale: imx8qxp: enable scu general irq channel
On i.MX8QXP, SCU uses MU1 general interrupt channel #3 to notify user for IRQs of RTC alarm, thermal alarm and WDOG etc., mailbox RX doorbell mode is used for this function, this patch adds support for it. Signed-off-by: Anson Huang Reviewed-by: Dong Aisheng --- No changes. --- arch/arm64/boot/dts/freescale/imx8qxp.dtsi | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi index 4c3dd95..f0a9224 100644 --- a/arch/arm64/boot/dts/freescale/imx8qxp.dtsi +++ b/arch/arm64/boot/dts/freescale/imx8qxp.dtsi @@ -21,6 +21,7 @@ mmc1 = &usdhc2; mmc2 = &usdhc3; serial0 = &adma_lpuart0; + mu1 = &lsio_mu1; }; cpus { @@ -87,7 +88,8 @@ scu { compatible = "fsl,imx-scu"; mbox-names = "tx0", "tx1", "tx2", "tx3", -"rx0", "rx1", "rx2", "rx3"; +"rx0", "rx1", "rx2", "rx3", +"gip3"; mboxes = <&lsio_mu1 0 0 &lsio_mu1 0 1 &lsio_mu1 0 2 @@ -95,7 +97,8 @@ &lsio_mu1 1 0 &lsio_mu1 1 1 &lsio_mu1 1 2 - &lsio_mu1 1 3>; + &lsio_mu1 1 3 + &lsio_mu1 3 3>; clk: clock-controller { compatible = "fsl,imx8qxp-clk"; -- 2.7.4
Re: [BUG] scsi: ses: out of bound accessing in ses_enclosure_data_process
Would anyone please give some suggestions ? It looks like there somethings wrong in the read-in data, /* skip all the enclosure descriptors */ for (i = 0; i < num_enclosures && type_ptr < buf + len; i++) { types += type_ptr[2]; type_ptr += type_ptr[3] + 4; > here } Then the typr_ptr got out of bound of the buffer. Thanks Jianchao On 3/14/19 11:19 AM, jianchao.wang wrote: > Dear all > > When our customer probe the lpfc devices, they encountered odd memory > corruption issues, > and we get 'out of bound' access warning at following position after open > KASAN > > ses_enclosure_data_process > > for (i = 0; i < types; i++, type_ptr += 4) { > for (j = 0; j < type_ptr[1]; j++) { >^^^ >out of bound > > With some debug log, I got following, > > page1 88042d1aad20 len 32 types 5 type_ptr 88042d1aad64 > > Would anyone please give some suggestions on this ? > > Thanks > Jianchao >
[PATCH V5 1/4] dt-bindings: fsl: scu: add general interrupt support
Add scu general interrupt function support. Signed-off-by: Anson Huang Reviewed-by: Rob Herring Reviewed-by: Dong Aisheng --- Changes since V4: - add mu aliase info and example in binding doc. --- .../devicetree/bindings/arm/freescale/fsl,scu.txt | 29 +- 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt b/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt index 72d481c..5d7dbab 100644 --- a/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt +++ b/Documentation/devicetree/bindings/arm/freescale/fsl,scu.txt @@ -22,9 +22,11 @@ Required properties: --- - compatible: should be "fsl,imx-scu". - mbox-names: should include "tx0", "tx1", "tx2", "tx3", - "rx0", "rx1", "rx2", "rx3". -- mboxes: List of phandle of 4 MU channels for tx and 4 MU channels - for rx. All 8 MU channels must be in the same MU instance. + "rx0", "rx1", "rx2", "rx3"; + include "gip3" if want to support general MU interrupt. +- mboxes: List of phandle of 4 MU channels for tx, 4 MU channels for + rx, and 1 optional MU channel for general interrupt. + All MU channels must be in the same MU instance. Cross instances are not allowed. The MU instance can only be one of LSIO MU0~M4 for imx8qxp and imx8qm. Users need to make sure use the one which is not conflict with other @@ -34,6 +36,7 @@ Required properties: Channel 1 must be "tx1" or "rx1". Channel 2 must be "tx2" or "rx2". Channel 3 must be "tx3" or "rx3". + General interrupt rx channel must be "gip3". e.g. mboxes = <&lsio_mu1 0 0 &lsio_mu1 0 1 @@ -42,10 +45,18 @@ Required properties: &lsio_mu1 1 0 &lsio_mu1 1 1 &lsio_mu1 1 2 - &lsio_mu1 1 3>; + &lsio_mu1 1 3 + &lsio_mu1 3 3>; See Documentation/devicetree/bindings/mailbox/fsl,mu.txt for detailed mailbox binding. +Note: Each mu which supports general interrupt should have an alias correctly +numbered in "aliases" node. +e.g. +aliases { + mu1 = &lsio_mu1; +}; + i.MX SCU Client Device Node: @@ -124,6 +135,10 @@ Required properties: Example (imx8qxp): - +aliases { + mu1 = &lsio_mu1; +}; + lsio_mu1: mailbox@5d1c { ... #mbox-cells = <2>; @@ -133,7 +148,8 @@ firmware { scu { compatible = "fsl,imx-scu"; mbox-names = "tx0", "tx1", "tx2", "tx3", -"rx0", "rx1", "rx2", "rx3"; +"rx0", "rx1", "rx2", "rx3", +"gip3"; mboxes = <&lsio_mu1 0 0 &lsio_mu1 0 1 &lsio_mu1 0 2 @@ -141,7 +157,8 @@ firmware { &lsio_mu1 1 0 &lsio_mu1 1 1 &lsio_mu1 1 2 - &lsio_mu1 1 3>; + &lsio_mu1 1 3 + &lsio_mu1 3 3>; clk: clk { compatible = "fsl,imx8qxp-clk", "fsl,scu-clk"; -- 2.7.4
[PATCH V5 2/4] firmware: imx: enable imx scu general irq function
The System Controller Firmware (SCFW) controls RTC, thermal and WDOG etc., these resources' interrupt function are managed by SCU. When any IRQ pending, SCU will notify Linux via MU general interrupt channel #3, and Linux kernel needs to call SCU APIs to get IRQ status and notify each module to handle the interrupt. Since there is no data transmission for SCU IRQ notification, so doorbell mode is used for this MU channel, and SCU driver will use notifier mechanism to broadcast to every module which registers the SCU block notifier. Signed-off-by: Anson Huang --- Changes since V4: - move scu irq support to a new file imx-scu-irq.c; - improve the function name with "imx_scu_irq_" as prefix for irq related functions; - move MU IRQ sources id out of sc ipc struct; - add IRQ group info message print when get irq status fail; - move MU ID parse into imx_scu_enable_general_irq_channel() function and ONLY do it when irq channel enable successfully. - change max IRQ group supported to 4, ONLY support for those kernel features. --- drivers/firmware/imx/Makefile | 2 +- drivers/firmware/imx/imx-scu-irq.c | 133 + drivers/firmware/imx/imx-scu.c | 6 ++ include/linux/firmware/imx/sci.h | 4 ++ 4 files changed, 144 insertions(+), 1 deletion(-) create mode 100644 drivers/firmware/imx/imx-scu-irq.c diff --git a/drivers/firmware/imx/Makefile b/drivers/firmware/imx/Makefile index 1b2e15b..802c4ad 100644 --- a/drivers/firmware/imx/Makefile +++ b/drivers/firmware/imx/Makefile @@ -1,3 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 -obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o +obj-$(CONFIG_IMX_SCU) += imx-scu.o misc.o imx-scu-irq.o obj-$(CONFIG_IMX_SCU_PD) += scu-pd.o diff --git a/drivers/firmware/imx/imx-scu-irq.c b/drivers/firmware/imx/imx-scu-irq.c new file mode 100644 index 000..0e20aa7 --- /dev/null +++ b/drivers/firmware/imx/imx-scu-irq.c @@ -0,0 +1,133 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2019 NXP + * + * Implementation of the SCU IRQ functions using MU. + * + */ + +#include +#include +#include + +#define IMX_SC_IRQ_FUNC_STATUS 2 +#define IMX_SC_IRQ_NUM_GROUP 4 + +static u32 mu_resource_id; + +struct imx_sc_msg_irq_get_status { + struct imx_sc_rpc_msg hdr; + union { + struct { + u16 resource; + u8 group; + u8 reserved; + } __packed req; + struct { + u32 status; + } resp; + } data; +}; + +static struct imx_sc_ipc *imx_sc_irq_ipc_handle; +static struct work_struct imx_sc_irq_work; +static BLOCKING_NOTIFIER_HEAD(imx_scu_irq_notifier_chain); + +int imx_scu_irq_register_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_register( + &imx_scu_irq_notifier_chain, nb); +} +EXPORT_SYMBOL(imx_scu_irq_register_notifier); + +int imx_scu_irq_unregister_notifier(struct notifier_block *nb) +{ + return blocking_notifier_chain_unregister( + &imx_scu_irq_notifier_chain, nb); +} +EXPORT_SYMBOL(imx_scu_irq_unregister_notifier); + +static int imx_scu_irq_notifier_call_chain(unsigned long status, u8 *group) +{ + return blocking_notifier_call_chain(&imx_scu_irq_notifier_chain, + status, (void *)group); +} + +static void imx_scu_irq_work_handler(struct work_struct *work) +{ + struct imx_sc_msg_irq_get_status msg; + struct imx_sc_rpc_msg *hdr = &msg.hdr; + u32 irq_status; + int ret; + u8 i; + + for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) { + hdr->ver = IMX_SC_RPC_VERSION; + hdr->svc = IMX_SC_RPC_SVC_IRQ; + hdr->func = IMX_SC_IRQ_FUNC_STATUS; + hdr->size = 2; + + msg.data.req.resource = mu_resource_id; + msg.data.req.group = i; + + ret = imx_scu_call_rpc(imx_sc_irq_ipc_handle, &msg, true); + if (ret) { + pr_err("get irq group %d status failed, ret %d\n", + i, ret); + return; + } + + irq_status = msg.data.resp.status; + if (!irq_status) + continue; + + imx_scu_irq_notifier_call_chain(irq_status, &i); + } +} + +static void imx_scu_irq_callback(struct mbox_client *c, void *msg) +{ + schedule_work(&imx_sc_irq_work); +} + +int imx_scu_enable_general_irq_channel(struct device *dev) +{ + struct of_phandle_args spec; + struct mbox_client *cl; + struct mbox_chan *ch; + int ret = 0, i = 0; + + cl = devm_kzalloc(dev, sizeof(*cl), GFP_KERNEL); + if (!cl) + return -ENOMEM; + + cl->dev = dev; + cl->rx_callback = imx_scu_irq_callback; + + /* SCU general IRQ uses general interrupt chan
Re: [PATCH v2 1/1] initrd: move initrd_start calculate within linear mapping range check
Hi Steven, Catalin and Will: > > in the previous case, initrd_start and initrd_end can be successfully > returned either (base < memblock_start_of_DRAM()) or (base + size > > memblock_start_of_DRAM() + linear_region_size). > > That means even linear mapping range check fail for initrd_start and > initrd_end, it still can get virtual address. Here we put > initrd_start/initrd_end to be calculated only when linear mapping check > pass. > > Fixes: c756c592e442 ("arm64: Utilize phys_initrd_start/phys_initrd_size") > Reviewed-by: Steven Price > Signed-off-by: pierre Kuo > --- > Changes in v2: > - add Fixes tag > Would you mind to give some comment and suggestion for this v2 patch? If there is anything that are not noticed, please let me know. Sincerely appreciate ur kind help.
RE: [RESEND PATCH] Make Fujitsu Erratum 010001 patch can be applied on A64FX v1r0
Hi guys, > -Original Message- > From: linux-arm-kernel On > Behalf Of Mark Rutland > Sent: Saturday, March 16, 2019 12:13 AM > To: Okamoto, Takayuki/岡本 高幸 > Cc: 'Catalin Marinas' ; 'Will Deacon' > ; 'linux-kernel@vger.kernel.org' > ; Zhang, Lei/張 雷 ; > 'James Morse' ; hange-folder>? > ; > 'linux-arm-ker...@lists.infradead.org' > Subject: Re: [RESEND PATCH] Make Fujitsu Erratum 010001 patch can be > applied on A64FX v1r0 > > On Fri, Mar 15, 2019 at 12:22:36PM +, Okamoto, Takayuki wrote: > > I resend the patch due to whitespace munging. > > > > > -Original Message- > > > From: James Morse > > > Sent: Wednesday, February 27, 2019 3:44 AM > > > To: james.mo...@arm.com; linux-arm-ker...@lists.infradead.org > > > Cc: linux-kernel@vger.kernel.org; Catalin Marinas > > > ; Mark Rutland ; Will > > > Deacon ; Zhang, Lei > > > Subject: [PATCH v5] arm64: Add workaround for Fujitsu A64FX erratum > > > 010001 > > > > > > +/* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and > > > +v1r0) */ #define MIDR_FUJITSU_ERRATUM_010001 > > > MIDR_FUJITSU_A64FX > > > +#define MIDR_FUJITSU_ERRATUM_010001_MASK > > > (~MIDR_VARIANT(1)) > > > > This workaround for the erratum should be applied for both A64FX v1r0 > > and v0r0, however, the patch v5 is only enabled on A64FX > > v0r0(MIDR.Variant == 0 && MIDR.Revision == 0). > > This issue is caused by the macro MIDR_FUJITSU_ERRATUM_010001_MASK. > > > > I have tested on both A64FX v1r0 and v0r0. This new patch will effect > > only for A64FX. > > > > -- > > Changed to be applied for not only A64FX v0r0 but also v1r0. > > > > Signed-off-by: Zhang Lei > > --- > > arch/arm64/include/asm/cputype.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/arch/arm64/include/asm/cputype.h > > b/arch/arm64/include/asm/cputype.h > > index 2afb133..1fb47b5 100644 > > --- a/arch/arm64/include/asm/cputype.h > > +++ b/arch/arm64/include/asm/cputype.h > > @@ -129,7 +129,7 @@ > > > > /* Fujitsu Erratum 010001 affects A64FX 1.0 and 1.1, (v0r0 and v1r0) */ > > #define MIDR_FUJITSU_ERRATUM_010001 > MIDR_FUJITSU_A64FX > > -#define MIDR_FUJITSU_ERRATUM_010001_MASK > (~MIDR_VARIANT(1)) > > The bug is is that MIDR_VARIANT() is meant to extract the variant from a full > MIDR value, not generate an in-place field value. > > > +#define MIDR_FUJITSU_ERRATUM_010001_MASK (~(0x1 << > MIDR_VARIANT_SHIFT)) > > I beleive this can be: > > #define MIDR_FUJITSU_ERRATUM_010001_MASK (~MIDR_VAR_REV(1, > 0)) Thanks for your comments. I also have considered to use MIDR_CPU_VAR_REV macro, but the implication of (~MIDR_CPU_VAR_REV(1, 0)) is "NOT v1r0". I think it may cause confusion, so I choose the simple way (~(0x1 << MIDR_VARIANT_SHIFT)). > But otherwise this looks fine to me. Will this patch be merged to v5.1? Thanks, Zhang Lei
RE: [PATCH V4 2/4] firmware: imx: enable imx scu general irq function
Best Regards! Anson Huang > -Original Message- > From: Aisheng Dong > Sent: 2019年3月15日 19:05 > To: Anson Huang ; robh...@kernel.org; > mark.rutl...@arm.com; shawn...@kernel.org; s.ha...@pengutronix.de; > ker...@pengutronix.de; feste...@gmail.com; a.zu...@towertech.it; > alexandre.bell...@bootlin.com; ulf.hans...@linaro.org; Daniel Baluta > ; devicet...@vger.kernel.org; linux- > ker...@vger.kernel.org; linux-arm-ker...@lists.infradead.org; linux- > r...@vger.kernel.org > Cc: dl-linux-imx > Subject: RE: [PATCH V4 2/4] firmware: imx: enable imx scu general irq > function > > > From: Anson Huang > > > > The System Controller Firmware (SCFW) controls RTC, thermal and WDOG > > etc., these resources' interrupt function are managed by SCU. When any > > IRQ pending, SCU will notify Linux via MU general interrupt channel > > #3, and Linux kernel needs to call SCU APIs to get IRQ status and > > notify each module to handle the interrupt. > > > > Since there is no data transmission for SCU IRQ notification, so > > doorbell mode is used for this MU channel, and SCU driver will use > > notifier mechanism to broadcast to every module which registers the SCU > block notifier. > > > > Signed-off-by: Anson Huang > > --- > > Changes since V3: > > - use alias to get general MU interrupt channel id and then get > > resource ID, > > this is to support different MU instance; > > - add return value check for imx_scu_enable_general_irq_channel(). > > --- > > drivers/firmware/imx/imx-scu.c | 116 > > +++ > > Generally I would suggest to put scu irq support into another separate file > under The same folder to make code clean from function point of view. OK, I will add a imx-scu-irq.c file to support SCU irq function. > > > include/linux/firmware/imx/sci.h | 3 + > > 2 files changed, 119 insertions(+) > > > > diff --git a/drivers/firmware/imx/imx-scu.c > > b/drivers/firmware/imx/imx-scu.c index 2bb1a19..1dcd7b3 100644 > > --- a/drivers/firmware/imx/imx-scu.c > > +++ b/drivers/firmware/imx/imx-scu.c > > @@ -7,6 +7,7 @@ > > * > > */ > > > > +#include > > #include > > #include #include > > @@ -21,6 +22,8 @@ > > > > #define SCU_MU_CHAN_NUM8 > > #define MAX_RX_TIMEOUT (msecs_to_jiffies(30)) > > +#define IMX_SC_IRQ_FUNC_STATUS 2 > > +#define IMX_SC_IRQ_NUM_GROUP 6 > > > > struct imx_sc_chan { > > struct imx_sc_ipc *sc_ipc; > > @@ -41,6 +44,7 @@ struct imx_sc_ipc { > > u32 *msg; > > u8 rx_size; > > u8 count; > > + u32 mu_resource_id; > > I feel it a bit strange to put this mu id in struct imx_sc_ipc. Since I will create new file imx-sc-irq.c, I will move this out of the struct and use define a static variable for it. > > > }; > > > > /* > > @@ -77,7 +81,23 @@ static int imx_sc_linux_errmap[IMX_SC_ERR_LAST] = > { > > -EIO,/* IMX_SC_ERR_FAIL */ > > }; > > > > +struct imx_sc_msg_irq_get_status { > > + struct imx_sc_rpc_msg hdr; > > + union { > > + struct { > > + u16 resource; > > + u8 group; > > + u8 reserved; > > + } __packed req; > > + struct { > > + u32 status; > > + } __packed resp; > > No packed needed for this one OK > > > + } data; > > +}; > > + > > static struct imx_sc_ipc *imx_sc_ipc_handle; > > +static struct work_struct imx_sc_general_irq_work; static > > +BLOCKING_NOTIFIER_HEAD(imx_scu_notifier_chain); > > Imx_scu_irq_xxx OK > > > > > static inline int imx_sc_to_linux_errno(int errno) { @@ -194,9 > > +214,90 @@ int imx_scu_call_rpc(struct imx_sc_ipc *sc_ipc, void *msg, > > bool have_resp) } EXPORT_SYMBOL(imx_scu_call_rpc); > > > > +int imx_scu_register_notifier(struct notifier_block *nb) { > > + return blocking_notifier_chain_register(&imx_scu_notifier_chain, > > +nb); } EXPORT_SYMBOL(imx_scu_register_notifier); > > + > > +int imx_scu_unregister_notifier(struct notifier_block *nb) { > > + return blocking_notifier_chain_unregister(&imx_scu_notifier_chain, > > +nb); } EXPORT_SYMBOL(imx_scu_unregister_notifier); > > + > > +static int imx_scu_notifier_call_chain(unsigned long status, u8 > > +*group) { > > + return blocking_notifier_call_chain(&imx_scu_notifier_chain, > > + status, (void *)group); > > +} > > + > > +static void imx_scu_general_irq_work_handler(struct work_struct > > +*work) { > > + struct imx_sc_msg_irq_get_status msg; > > + struct imx_sc_rpc_msg *hdr = &msg.hdr; > > + u32 irq_status; > > + int ret; > > + u8 i; > > + > > + for (i = 0; i < IMX_SC_IRQ_NUM_GROUP; i++) { > > Do we need to support all irq group? After further check, maybe we can change the group number to 4, ONLY supporting those kernel related features, others are NOT needed in kernel now. 34 #define SC_IRQ_GROUP_TEMP 0U /* Temp interrupts */ 35 #define SC_IRQ_GROUP_WDOG 1U /* Watchdog interrupts */ 3
linux-next: Tree for Mar 18
Hi all, Changes since 20190306: The cisco tree gained a conflict against Linus' tree. Non-merge commits (relative to Linus' tree): 591 502 files changed, 14759 insertions(+), 4153 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 297 trees (counting Linus' and 69 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (9e98c678c2d6 Linux 5.1-rc1) Merging fixes/master (2648624cfe7f adfs: mark expected switch fall-throughs) Merging kspp-gustavo/for-next/kspp (1f7ae812f87e x86/syscalls: Mark expected switch fall-throughs) Merging kbuild-current/fixes (5453a3df2a5e Merge tag 'kconfig-v5.1' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild) Merging arc-current/for-curr (9a18b5a412ba arch: arc: Kconfig: pedantic formatting) Merging arm-current/fixes (d410a8a49e3e ARM: 8849/1: NOMMU: Fix encodings for PMSAv8's PRBAR4/PRLAR4) Merging arm64-fixes/for-next/fixes (74698f6971f2 arm64: Relax GIC version check during early boot) Merging m68k-current/for-linus (28713169d879 m68k: Add -ffreestanding to CFLAGS) Merging powerpc-fixes/fixes (8f5b27347e88 powerpc/powernv/sriov: Register IOMMU groups for VFs) Merging sparc/master (7d762d69145a afs: Fix manually set volume location server list) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (517ccc2aa50d net: tipc: fix a missing check for nla_nest_start) Merging bpf/master (86be36f6502c powerpc: bpf: Fix generation of load/store DW instructions) Merging ipsec/master (6ee02a54ef99 xfrm6_tunnel: Fix potential panic when unloading xfrm6_tunnel module) Merging netfilter/master (b8b27498659c netfilter: nf_tables: return immediately on empty commit) Merging ipvs/master (b2e3d68d1251 netfilter: nft_compat: destroy function must not have side effects) Merging wireless-drivers/master (688cd8bd2c0f iwlwifi: fix 64-bit division) Merging mac80211/master (d235c48b40d3 net: dsa: mv88e6xxx: power serdes on/off for 10G interfaces on 6390X) Merging rdma-fixes/for-rc (f09ef134a7ca iw_cxgb4: cq/qp mask depends on bar2 pages in a host page) Merging sound-current/for-linus (2d012c65a9ca ALSA: firewire-motu: use 'version' field of unit directory to identify model) Merging sound-asoc-fixes/for-linus (5b4e1c6a68b0 Merge branch 'asoc-5.0' into asoc-linus) CONFLICT (content): Merge conflict in sound/soc/codecs/tlv320aic3x.c Merging regmap-fixes/for-linus (f17b5f06cb92 Linux 5.0-rc4) Merging regulator-fixes/for-linus (078d354f8d7f Merge branch 'regulator-5.0' into regulator-linus) Merging spi-fixes/for-linus (8d0e51ac6f8c Merge branch 'spi-5.0' into spi-linus) Merging pci-current/for-linus (f57a98e1b713 PCI: Work around Synopsys duplicate Device ID (HAPS USB3, NXP i.MX)) Merging driver-core.current/driver-core-linus (a9dce6679d73 Merge tag 'pidfd-v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux) Merging tty.current/tty-linus (a9dce6679d73 Merge tag 'pidfd-v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux) Merging usb.current/usb-linus (a9dce6679d73 Merge tag 'pidfd-v5.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brauner/linux) Merging usb-gadget-fixes/fixes (a53469a68eb8 usb: phy: am335x: fix race condition in _probe) Merging usb-serial-fixes/usb-linus (8d7fa3d4ea3f USB: seria
[PATCH v4 3/3] gcov: docs: add a note on GCC vs Clang differences
Document some things of note to gcov users: 1. GCC gcov and Clang llvm-cov tools are not compatible. 2. The use of GCC vs Clang is transparent at build-time. Also adjust the documentation to account for the removal of config symbol CONFIG_GCOV_FORMAT_AUTODETECT by commit 6a61b70b43c9 ("gcov: remove CONFIG_GCOV_FORMAT_AUTODETECT"). Signed-off-by: Tri Vo Reviewed-by: Peter Oberparleiter --- Documentation/dev-tools/gcov.rst | 18 ++ 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Documentation/dev-tools/gcov.rst b/Documentation/dev-tools/gcov.rst index 69a7d90c320a..46aae52a41d0 100644 --- a/Documentation/dev-tools/gcov.rst +++ b/Documentation/dev-tools/gcov.rst @@ -34,10 +34,6 @@ Configure the kernel with:: CONFIG_DEBUG_FS=y CONFIG_GCOV_KERNEL=y -select the gcc's gcov format, default is autodetect based on gcc version:: - -CONFIG_GCOV_FORMAT_AUTODETECT=y - and to get coverage data for the entire kernel:: CONFIG_GCOV_PROFILE_ALL=y @@ -169,6 +165,20 @@ b) gcov is run on the BUILD machine [user@build] gcov -o /tmp/coverage/tmp/out/init main.c +Note on compilers +- + +GCC and LLVM gcov tools are not necessarily compatible. Use gcov_ to work with +GCC-generated .gcno and .gcda files, and use llvm-cov_ for Clang. + +.. _gcov: http://gcc.gnu.org/onlinedocs/gcc/Gcov.html +.. _llvm-cov: https://llvm.org/docs/CommandGuide/llvm-cov.html + +Build differences between GCC and Clang gcov are handled by Kconfig. It +automatically selects the appropriate gcov format depending on the detected +toolchain. + + Troubleshooting --- -- 2.21.0.225.g810b269d1ac-goog
[PATCH v4 0/3] gcov: add Clang support
This patch series adds Clang support for gcov. Patch 1 refactors existing code in preparation for Clang support. Patch 2 implements necessary LLVM runtime hooks and gcov kernel interfaces. Patch 3 updates documentation. Greg Hackmann (2): gcov: Clang: move common GCC code into gcc_base.c gcov: Clang support Tri Vo (1): gcov: docs: add a note on GCC vs Clang differences Documentation/dev-tools/gcov.rst | 18 +- kernel/gcov/Kconfig | 3 +- kernel/gcov/Makefile | 5 +- kernel/gcov/base.c | 86 + kernel/gcov/clang.c | 586 +++ kernel/gcov/gcc_3_4.c| 12 + kernel/gcov/gcc_4_7.c| 12 + kernel/gcov/gcc_base.c | 86 + kernel/gcov/gcov.h | 5 + 9 files changed, 723 insertions(+), 90 deletions(-) create mode 100644 kernel/gcov/clang.c create mode 100644 kernel/gcov/gcc_base.c v2: - Reorganized config dependencies, as per Masahiro. v3: - Squashed patches 2-4 of v2, as per Nick, Masahiro, and Peter. Addressed comments by Peter: - Moved __gcov_exit() to gcc_base.c - Added missing header to gcc_base.c - Removed unnecessary boundary checks in gcov_info_add(). - Changed counters' allocation to use vmalloc(). - Added check for failed allocation of filename. - Changed list_for_each_entry_safe to list_for_each_entry when traversing without modifying. - Updated Documentation/dev-tools/gcov.rst v4: Made following changes to pass kernel module test cases suggested by Peter: - Generic code in base.c unlinks gcov_info data sets while iterating over the gcov_info list. Changed Clang's gcov_info_unlink() to preserve next and prev links of the unlinked gcov_info instance. - Attributing a given gcov_info to a module is done differently in Clang vs GCC. Generic code in base.c needs to do this. So added gcov_info_within_module() interface to gcov.h to abstract away the difference. - Clang provides checksums for each function. These checksums are used to determine whether the source files of the compiled kernel module have been modified. Changed gcov_info_is_compatible() to account for function-level checksums. Addressed comments by Peter: - Removed unnecessary #define, if-clause, empty line. - Amended commit message to note documentation was adjusted to account for the removal of config symbol CONFIG_GCOV_FORMAT_AUTODETECT. -- 2.21.0.225.g810b269d1ac-goog
[PATCH v4 1/3] gcov: Clang: move common GCC code into gcc_base.c
From: Greg Hackmann base.c contains a few callbacks specific to GCC's gcov implementation. Move these into their own module in preparation for Clang support. Signed-off-by: Greg Hackmann Signed-off-by: Nick Desaulniers Signed-off-by: Tri Vo Tested-by: Trilok Soni Tested-by: Prasad Sodagudi Tested-by: Tri Vo Reviewed-by: Peter Oberparleiter --- kernel/gcov/Makefile | 4 +- kernel/gcov/base.c | 84 + kernel/gcov/gcc_base.c | 86 ++ kernel/gcov/gcov.h | 3 ++ 4 files changed, 93 insertions(+), 84 deletions(-) create mode 100644 kernel/gcov/gcc_base.c diff --git a/kernel/gcov/Makefile b/kernel/gcov/Makefile index ff06d64df397..45431ed679d1 100644 --- a/kernel/gcov/Makefile +++ b/kernel/gcov/Makefile @@ -2,5 +2,5 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o -obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_3_4.o -obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_4_7.o +obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o +obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c index 9c7c8d5c18f2..799d42072727 100644 --- a/kernel/gcov/base.c +++ b/kernel/gcov/base.c @@ -22,88 +22,8 @@ #include #include "gcov.h" -static int gcov_events_enabled; -static DEFINE_MUTEX(gcov_lock); - -/* - * __gcov_init is called by gcc-generated constructor code for each object - * file compiled with -fprofile-arcs. - */ -void __gcov_init(struct gcov_info *info) -{ - static unsigned int gcov_version; - - mutex_lock(&gcov_lock); - if (gcov_version == 0) { - gcov_version = gcov_info_version(info); - /* -* Printing gcc's version magic may prove useful for debugging -* incompatibility reports. -*/ - pr_info("version magic: 0x%x\n", gcov_version); - } - /* -* Add new profiling data structure to list and inform event -* listener. -*/ - gcov_info_link(info); - if (gcov_events_enabled) - gcov_event(GCOV_ADD, info); - mutex_unlock(&gcov_lock); -} -EXPORT_SYMBOL(__gcov_init); - -/* - * These functions may be referenced by gcc-generated profiling code but serve - * no function for kernel profiling. - */ -void __gcov_flush(void) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_flush); - -void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_add); - -void __gcov_merge_single(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_single); - -void __gcov_merge_delta(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_delta); - -void __gcov_merge_ior(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_ior); - -void __gcov_merge_time_profile(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_time_profile); - -void __gcov_merge_icall_topn(gcov_type *counters, unsigned int n_counters) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_merge_icall_topn); - -void __gcov_exit(void) -{ - /* Unused. */ -} -EXPORT_SYMBOL(__gcov_exit); +int gcov_events_enabled; +DEFINE_MUTEX(gcov_lock); /** * gcov_enable_events - enable event reporting through gcov_event() diff --git a/kernel/gcov/gcc_base.c b/kernel/gcov/gcc_base.c new file mode 100644 index ..3cf736b9f880 --- /dev/null +++ b/kernel/gcov/gcc_base.c @@ -0,0 +1,86 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include +#include "gcov.h" + +/* + * __gcov_init is called by gcc-generated constructor code for each object + * file compiled with -fprofile-arcs. + */ +void __gcov_init(struct gcov_info *info) +{ + static unsigned int gcov_version; + + mutex_lock(&gcov_lock); + if (gcov_version == 0) { + gcov_version = gcov_info_version(info); + /* +* Printing gcc's version magic may prove useful for debugging +* incompatibility reports. +*/ + pr_info("version magic: 0x%x\n", gcov_version); + } + /* +* Add new profiling data structure to list and inform event +* listener. +*/ + gcov_info_link(info); + if (gcov_events_enabled) + gcov_event(GCOV_ADD, info); + mutex_unlock(&gcov_lock); +} +EXPORT_SYMBOL(__gcov_init); + +/* + * These functions may be referenced by gcc-generated profiling code but serve + * no function for kernel profiling. + */ +void __gcov_flush(void) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_flush); + +void __gcov_merge_add(gcov_type *counters, unsigned int n_counters) +{ + /* Unused. */ +} +EXPORT_SYMBOL(__gcov_merge_add); + +void __gcov_merge_single(gcov_type
[PATCH v4 2/3] gcov: Clang support
From: Greg Hackmann LLVM uses profiling data that's deliberately similar to GCC, but has a very different way of exporting that data. LLVM calls llvm_gcov_init() once per module, and provides a couple of callbacks that we can use to ask for more data. We care about the "writeout" callback, which in turn calls back into compiler-rt/this module to dump all the gathered coverage data to disk: llvm_gcda_start_file() llvm_gcda_emit_function() llvm_gcda_emit_arcs() llvm_gcda_emit_function() llvm_gcda_emit_arcs() [... repeats for each function ...] llvm_gcda_summary_info() llvm_gcda_end_file() This design is much more stateless and unstructured than gcc's, and is intended to run at process exit. This forces us to keep some local state about which module we're dealing with at the moment. On the other hand, it also means we don't depend as much on how LLVM represents profiling data internally. See LLVM's lib/Transforms/Instrumentation/GCOVProfiling.cpp for more details on how this works, particularly GCOVProfiler::emitProfileArcs(), GCOVProfiler::insertCounterWriteout(), and GCOVProfiler::insertFlush(). Co-authored-by: Nick Desaulniers Co-authored-by: Tri Vo Signed-off-by: Greg Hackmann Signed-off-by: Nick Desaulniers Signed-off-by: Tri Vo Tested-by: Trilok Soni Tested-by: Prasad Sodagudi Tested-by: Tri Vo Tested-by: Daniel Mentz Tested-by: Petri Gynther Reviewed-by: Peter Oberparleiter --- kernel/gcov/Kconfig | 3 +- kernel/gcov/Makefile | 1 + kernel/gcov/base.c| 2 +- kernel/gcov/clang.c | 586 ++ kernel/gcov/gcc_3_4.c | 12 + kernel/gcov/gcc_4_7.c | 12 + kernel/gcov/gcov.h| 2 + 7 files changed, 616 insertions(+), 2 deletions(-) create mode 100644 kernel/gcov/clang.c diff --git a/kernel/gcov/Kconfig b/kernel/gcov/Kconfig index 1e3823fa799b..f71c1adcff31 100644 --- a/kernel/gcov/Kconfig +++ b/kernel/gcov/Kconfig @@ -53,6 +53,7 @@ config GCOV_PROFILE_ALL choice prompt "Specify GCOV format" depends on GCOV_KERNEL + depends on CC_IS_GCC ---help--- The gcov format is usually determined by the GCC version, and the default is chosen according to your GCC version. However, there are @@ -62,7 +63,7 @@ choice config GCOV_FORMAT_3_4 bool "GCC 3.4 format" - depends on CC_IS_GCC && GCC_VERSION < 40700 + depends on GCC_VERSION < 40700 ---help--- Select this option to use the format defined by GCC 3.4. diff --git a/kernel/gcov/Makefile b/kernel/gcov/Makefile index 45431ed679d1..d66a74b0f100 100644 --- a/kernel/gcov/Makefile +++ b/kernel/gcov/Makefile @@ -4,3 +4,4 @@ ccflags-y := -DSRCTREE='"$(srctree)"' -DOBJTREE='"$(objtree)"' obj-y := base.o fs.o obj-$(CONFIG_GCOV_FORMAT_3_4) += gcc_base.o gcc_3_4.o obj-$(CONFIG_GCOV_FORMAT_4_7) += gcc_base.o gcc_4_7.o +obj-$(CONFIG_CC_IS_CLANG) += clang.o diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c index 799d42072727..0ffe9f194080 100644 --- a/kernel/gcov/base.c +++ b/kernel/gcov/base.c @@ -64,7 +64,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event, /* Remove entries located in module from linked list. */ while ((info = gcov_info_next(info))) { - if (within_module((unsigned long)info, mod)) { + if (gcov_info_within_module(info, mod)) { gcov_info_unlink(prev, info); if (gcov_events_enabled) gcov_event(GCOV_REMOVE, info); diff --git a/kernel/gcov/clang.c b/kernel/gcov/clang.c new file mode 100644 index ..125c50397ba2 --- /dev/null +++ b/kernel/gcov/clang.c @@ -0,0 +1,586 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) 2019 Google, Inc. + * modified from kernel/gcov/gcc_4_7.c + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * + * LLVM uses profiling data that's deliberately similar to GCC, but has a + * very different way of exporting that data. LLVM calls llvm_gcov_init() once + * per module, and provides a couple of callbacks that we can use to ask for + * more data. + * + * We care about the "writeout" callback, which in turn calls back into + * compiler-rt/this module to dump all the gathered coverage data to disk: + * + *llvm_gcda_start_file() + * llvm_gcda_emit_function() + * llvm_gcda_emit_arcs() + * llvm_gcda_emit_function() + * llvm_gcda_emit_arcs() + * [... repeats for each function ...] + *llvm_gcda_summary_info() + *llvm_gcda_
Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7]
On Tue, 12 Mar 2019, I wrote: > ... I did another experiment with the latter (forced inline) approach, > to see if some optimizations can still be used with -ffreestanding. > > diff --git a/include/linux/string.h b/include/linux/string.h > index 7927b875f80c..25b5bf689018 100644 > --- a/include/linux/string.h > +++ b/include/linux/string.h > @@ -436,6 +436,58 @@ __FORTIFY_INLINE char *strcpy(char *p, const char *q) > return p; > } > > +#else > + > +//__FORTIFY_INLINE char *strncpy(char *p, const char *q, __kernel_size_t > size) > +//{ > +// return __builtin_strncpy(p, q, size); > +//} > + > +__FORTIFY_INLINE char *strcat(char *p, const char *q) > +{ > + return __builtin_strcat(p, q); > +} > + > +__FORTIFY_INLINE __kernel_size_t strlen(const char *p) > +{ > + return __builtin_strlen(p); > +} > + > +__FORTIFY_INLINE char *strncat(char *p, const char *q, __kernel_size_t count) > +{ > + return __builtin_strncat(p, q, count); > +} > + > +__FORTIFY_INLINE void *memset(void *p, int c, __kernel_size_t size) > +{ > + return __builtin_memset(p, c, size); > +} > + > +//__FORTIFY_INLINE void *memcpy(void *p, const void *q, __kernel_size_t size) > +//{ > +// return __builtin_memcpy(p, q, size); > +//} > + > +__FORTIFY_INLINE void *memmove(void *p, const void *q, __kernel_size_t size) > +{ > + return __builtin_memmove(p, q, size); > +} > + > +__FORTIFY_INLINE int memcmp(const void *p, const void *q, __kernel_size_t > size) > +{ > + return __builtin_memcmp(p, q, size); > +} > + > +__FORTIFY_INLINE void *memchr(const void *p, int c, __kernel_size_t size) > +{ > + return __builtin_memchr(p, c, size); > +} > + > +__FORTIFY_INLINE char *strcpy(char *p, const char *q) > +{ > + return __builtin_strcpy(p, q); > +} > + > #endif > > /** > > > The result of this patch really is confusing. It still suppresses the > warning you raised: > > arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming > offset 8 is out of the bounds [0, 7] [-Warray-bounds] > #define memcpy(d, s, n) __builtin_memcpy(d, s, n) > ^ >include/linux/string.h:456:3: note: in expansion of macro 'memcpy' > memcpy(dest, src, dest_len); > ^~ > > But it also causes new ones, because of __builtin_memset(): > > drivers/video/fbdev/core/fbcvt.c: In function 'fb_find_mode_cvt': > drivers/video/fbdev/core/fbcvt.c:312:16: warning: 'cvt.flags' may be used > uninit > ialized in this function [-Wmaybe-uninitialized] > cvt.flags |= FB_CVT_FLAG_MARGINS; > ^~ > > Apparently the compiler doesn't understand that __builtin_memset() has > the effect of initialization. Weird. > The other weird thing is that this warning doesn't show up when CONFIG_FORTIFY_SOURCE=y, even though the technique is much the same, that is, __builtin_memset() gets wrapped in a static inline memset() function. Anyway, a quick and dirty microbenchmark under qemu-m68k shows that this patch reduces system time for 'time find / -false' by approx. 10%. Interestingly, the -ffreestanding option doesn't make much difference to this particular microbenchmark. --
Re: [PATCH V2] cpufreq: Call transition notifier only once for each policy
On 15-03-19, 13:29, Peter Zijlstra wrote: > On Fri, Mar 15, 2019 at 02:43:07PM +0530, Viresh Kumar wrote: > > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c > > index 3fae23834069..cff8779fc0d2 100644 > > --- a/arch/x86/kernel/tsc.c > > +++ b/arch/x86/kernel/tsc.c > > @@ -956,28 +956,38 @@ static int time_cpufreq_notifier(struct > > notifier_block *nb, unsigned long val, > > void *data) > > { > > struct cpufreq_freqs *freq = data; > > - unsigned long *lpj; > > - > > - lpj = &boot_cpu_data.loops_per_jiffy; > > -#ifdef CONFIG_SMP > > - if (!(freq->flags & CPUFREQ_CONST_LOOPS)) > > - lpj = &cpu_data(freq->cpu).loops_per_jiffy; > > -#endif > > + struct cpumask *cpus = freq->policy->cpus; > > + bool boot_cpu = !IS_ENABLED(CONFIG_SMP) || freq->flags & > > CPUFREQ_CONST_LOOPS; > > + unsigned long lpj; > > + int cpu; > > > > if (!ref_freq) { > > ref_freq = freq->old; > > - loops_per_jiffy_ref = *lpj; > > tsc_khz_ref = tsc_khz; > > + > > + if (boot_cpu) > > + loops_per_jiffy_ref = boot_cpu_data.loops_per_jiffy; > > + else > > + loops_per_jiffy_ref = > > cpu_data(cpumask_first(cpus)).loops_per_jiffy; > > } > > + > > if ((val == CPUFREQ_PRECHANGE && freq->old < freq->new) || > > (val == CPUFREQ_POSTCHANGE && freq->old > freq->new)) { > > - *lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); > > - > > + lpj = cpufreq_scale(loops_per_jiffy_ref, ref_freq, freq->new); > > tsc_khz = cpufreq_scale(tsc_khz_ref, ref_freq, freq->new); > > + > > if (!(freq->flags & CPUFREQ_CONST_LOOPS)) > > mark_tsc_unstable("cpufreq changes"); > > > > - set_cyc2ns_scale(tsc_khz, freq->cpu, rdtsc()); > > + if (boot_cpu) { > > + boot_cpu_data.loops_per_jiffy = lpj; > > + } else { > > + for_each_cpu(cpu, cpus) > > + cpu_data(cpu).loops_per_jiffy = lpj; > > + } > > + > > + for_each_cpu(cpu, cpus) > > + set_cyc2ns_scale(tsc_khz, cpu, rdtsc()); > > This code doesn't make sense, the rdtsc() _must_ be called on the CPU in > question. You mean rdtsc() must be locally on that CPU? The cpufreq core never guaranteed that and it was left for the notifier to do. This patch doesn't change the behavior at all, just that it moves the for-loop to the notifier instead of the cpufreq core. > That's part of the whole problem here, TSC isn't sync'ed when > it's subject to CPUFREQ. > > > } > > > > return 0; -- viresh
RE: [PATCH 1/2] ARM: imx: drop uneccessary of_platform_default_populate
> -Original Message- > From: Aisheng Dong > Sent: 2019年3月15日 21:39 > To: Peng Fan ; shawn...@kernel.org; > s.ha...@pengutronix.de; ker...@pengutronix.de; feste...@gmail.com; > dl-linux-imx ; Anson Huang ; > a...@arndb.de; linux-arm-ker...@lists.infradead.org; > linux-kernel@vger.kernel.org > Cc: van.free...@gmail.com > Subject: RE: [PATCH 1/2] ARM: imx: drop uneccessary > of_platform_default_populate > > [...] > > > > Originally devices are registered in arch_initcall. Now it will be a > > > bit later in arch_initcall_sync and this may cause a bit risk if the > > > code under the default_populate want to access the device service > > > provided > > by early probe. > > > > > > Probably it's more safe to leave as it is unless you can double > > > confirm there're no such code depends on accessing early probed > > > devices as follows before we can make the change. > > > > This has been boot tested on 6Q-SDB/6UL-EVK/6SL-EVK board. > > For i.MX, I only see pinctrl driver use arch_initcall from the link, > > https://elixir.bootlin.com/linux/latest/ident/arch_initcall > > > > From my boot test, the pinctrl driver probe will be delayed a bit, but > > I do not see issues. > > > > From what I saw, imx6q_1588_init() and imx6q_axi_init() will use syscon which > is registered with postcore_initcall. Without having syscon devices populated, > I wonder those calls may fall. > Can you double check it? I do not see failure in imx6q_1588_init by adding a return value check of regmap_update_bits, But the imx6q_pm_init will find ocram device for suspend usage, postpone the device population will make imx6q_pm_init fail, so drop this patch and leave the code as it is. Thanks, Peng. > > Regards > Dong Aisheng
[PATCH] splice: sendfile() softlockup for big files
From: chen jie sendfile() softlockup for big files [34922.213193] [Softlockup Clock][34922213187422] [34922.213204] BUG: soft lockup - CPU#1 stuck for 60008ms! [trinity-c1:20239] [34922.213211] Modules linked in: rtos_snapshot(O) rsm(O) nfsv3 veth(O) higmac(O) comm(O) nand mtdblock mtd_blkdevs nand_ecc nand_ids pramdisk(O) rtos_kbox_panic(O) double_cluster(O) uart_suspend(O) cache_ops(O) nfsd nfs_acl exportfs auth_rpcgss nfs lockd sunrpc oid_registry grace physmap cfi_probe cfi_cmdset_0002 cfi_util mtd gen_probe chipreg ohci_platform ehci_platform ohci_hcd ehci_hcd usb_device_hisi(O) vfat fat sd_mod enable_uart_rx(O) [last unloaded: rtos_snapshot] [34922.213476] CPU: 1 PID: 20239 Comm: trinity-c1 Tainted: GW O 4.1.12 #12 [34922.213484] Hardware name: Hisilicon A9 [34922.213495] task: ef16b2a0 ti: ede92000 task.ti: ede92000 [34922.213512] PC is at eventfd_write+0x250/0x26c [34922.213528] LR is at sched_clock+0x84/0xa4 [34922.213540] pc : []lr : []psr: 2213 sp : ede93d18 ip : 000a fp : c050ab90 [34922.213550] r10: 0008 r9 : c2d432a0 r8 : 0ce0 [34922.213559] r7 : 0008 r6 : c35b4700 r5 : r4 : [34922.213569] r3 : r2 : r1 : 10c4 r0 : [34922.213581] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel [34922.213591] Control: 1ac5387d Table: aecc004a DAC: [34922.213604] CPU: 1 PID: 20239 Comm: trinity-c1 Tainted: GW O 4.1.12 #12 [34922.213612] Hardware name: Hisilicon A9 [34922.213639] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [34922.213664] [] (show_stack) from [] (dump_stack+0xa4/0xdc) [34922.213695] [] (dump_stack) from [] (watchdog_timer_fn+0x33c/0x42c) [34922.213715] [] (watchdog_timer_fn) from [] (hrtimer_run_queues+0x1d0/0x3a8) [34922.213732] [] (hrtimer_run_queues) from [] (run_local_timers+0x8/0x14) [34922.213748] [] (run_local_timers) from [] (update_process_times+0x28/0x5c) [34922.213764] [] (update_process_times) from [] (tick_periodic+0xac/0xcc) [34922.213780] [] (tick_periodic) from [] (tick_handle_periodic+0x24/0x80) [34922.213797] [] (tick_handle_periodic) from [] (twd_handler+0x30/0x44) [34922.213824] [] (twd_handler) from [] (handle_percpu_devid_irq+0xb4/0x1b0) [34922.213842] [] (handle_percpu_devid_irq) from [] (generic_handle_irq+0x20/0x30) [34922.213859] [] (generic_handle_irq) from [] (__handle_domain_irq+0xd8/0x160) [34922.213876] [] (__handle_domain_irq) from [] (gic_handle_irq+0x40/0x6c) [34922.213894] [] (gic_handle_irq) from [] (__irq_svc+0x44/0x5c) [34922.213904] Exception stack(0xede93cd0 to 0xede93d18) [34922.213916] 3cc0: 10c4 [34922.213930] 3ce0: c35b4700 0008 0ce0 c2d432a0 0008 c050ab90 [34922.213943] 3d00: 000a ede93d18 c017afc8 c0258ed8 2213 [34922.213958] [] (__irq_svc) from [] (eventfd_write+0x250/0x26c) [34922.213980] [] (eventfd_write) from [] (__vfs_write+0x2c/0xe8) [34922.213996] [] (__vfs_write) from [] (__kernel_write+0x3c/0xf0) [34922.214016] [] (__kernel_write) from [] (write_pipe_buf+0x38/0x4c) [34922.214032] [] (write_pipe_buf) from [] (__splice_from_pipe+0x138/0x280) [34922.214049] [] (__splice_from_pipe) from [] (splice_from_pipe+0x58/0x70) [34922.214065] [] (splice_from_pipe) from [] (default_file_splice_write+0x1c/0x3c) [34922.214082] [] (default_file_splice_write) from [] (direct_splice_actor+0x34/0x3c) [34922.214098] [] (direct_splice_actor) from [] (splice_direct_to_actor+0x15c/0x278) [34922.214113] [] (splice_direct_to_actor) from [] (do_splice_direct+0x90/0xb8) [34922.214130] [] (do_splice_direct) from [] (do_sendfile+0x188/0x354) [34922.214148] [] (do_sendfile) from [] (SyS_sendfile64+0xcc/0xdc) [34922.214172] [] (SyS_sendfile64) from [] (__sys_trace_return+0x0/0x14) [34922.214182] =SOFTLOCKUP INFO BEGIN=== [34922.214191] --CPU#1--- [34922.214200] [CPU#1] the task [trinity-c1] is not waiting for a lock,maybe a delay or deadcircle! [34922.214209] trinity-c1 R running 0 20239 19220 0x0203 [34922.214241] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [34922.214257] [] (show_stack) from [] (show_lock_info+0xd0/0x29c) [34922.214276] [] (show_lock_info) from [] (watchdog_timer_fn+0x370/0x42c) [34922.214294] [] (watchdog_timer_fn) from [] (hrtimer_run_queues+0x1d0/0x3a8) [34922.214309] [] (hrtimer_run_queues) from [] (run_local_timers+0x8/0x14) [34922.214325] [] (run_local_timers) from [] (update_process_times+0x28/0x5c) [34922.214340] [] (update_process_times) from [] (tick_periodic+0xac/0xcc) [34922.214355] [] (tick_periodic) from [] (tick_handle_periodic+0x24/0x80) [34922.214371] [] (tick_handle_periodic) from [] (twd_handler+0x30/0x44) Signed-off-by: chen jie --- fs/splice.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/splice.c b/fs
[PATCH v2 2/2] staging: gdm724x: Do not break expressions
When the entire expression can be shown in the same line breaking it makes it more difficult to read. Signed-off-by: Ignacio Losiggio --- drivers/staging/gdm724x/gdm_mux.c | 7 +++ 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index fa8585ea1572..ca934dc04d82 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -164,8 +164,7 @@ static int up_to_host(struct mux_rx *r) total_len = ALIGN(MUX_HEADER_SIZE + payload_size, 4); - if (len - packet_size_sum < - total_len) { + if (len - packet_size_sum < total_len) { pr_err("invalid payload : %d %d %04x\n", payload_size, len, packet_type); break; @@ -368,8 +367,8 @@ static int gdm_mux_send(void *priv_dev, void *data, int len, int tty_index, mux_header->packet_type = __cpu_to_le16(packet_type[tty_index]); memcpy(t->buf + MUX_HEADER_SIZE, data, len); - memset(t->buf + MUX_HEADER_SIZE + len, 0, total_len - MUX_HEADER_SIZE - - len); + memset(t->buf + MUX_HEADER_SIZE + len, 0, + total_len - MUX_HEADER_SIZE - len); t->len = total_len; t->callback = cb; -- 2.21.0
[PATCH v2 1/2] staging: gdm724x: Clean long function calls
Signed-off-by: Ignacio Losiggio --- drivers/staging/gdm724x/gdm_mux.c | 28 ++-- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/drivers/staging/gdm724x/gdm_mux.c b/drivers/staging/gdm724x/gdm_mux.c index e2a050ba6fbb..fa8585ea1572 100644 --- a/drivers/staging/gdm724x/gdm_mux.c +++ b/drivers/staging/gdm724x/gdm_mux.c @@ -177,12 +177,8 @@ static int up_to_host(struct mux_rx *r) break; } - ret = r->callback(mux_header->data, - payload_size, - index, - mux_dev->tty_dev, - RECV_PACKET_PROCESS_CONTINUE - ); + ret = r->callback(mux_header->data, payload_size, index, + mux_dev->tty_dev, RECV_PACKET_PROCESS_CONTINUE); if (ret == TO_HOST_BUFFER_REQUEST_FAIL) { r->offset += packet_size_sum; break; @@ -190,12 +186,8 @@ static int up_to_host(struct mux_rx *r) packet_size_sum += total_len; if (len - packet_size_sum <= MUX_HEADER_SIZE + 2) { - ret = r->callback(NULL, - 0, - index, - mux_dev->tty_dev, - RECV_PACKET_PROCESS_COMPLETE - ); + ret = r->callback(NULL, 0, index, mux_dev->tty_dev, + RECV_PACKET_PROCESS_COMPLETE); break; } } @@ -410,16 +402,8 @@ static int gdm_mux_send_control(void *priv_dev, int request, int value, struct usb_device *usbdev = mux_dev->usbdev; int ret; - ret = usb_control_msg(usbdev, - usb_sndctrlpipe(usbdev, 0), - request, - USB_RT_ACM, - value, - 2, - buf, - len, - 5000 -); + ret = usb_control_msg(usbdev, usb_sndctrlpipe(usbdev, 0), request, + USB_RT_ACM, value, 2, buf, len, 5000); if (ret < 0) pr_err("usb_control_msg error: %d\n", ret); -- 2.21.0
Re: [PATHv3] staging: rtl8723bs: do not use __constant_cpu_to_le16
On (03/17/19 16:35), Greg Kroah-Hartman wrote: > On Mon, Mar 18, 2019 at 12:20:14AM +0900, Sergey Senozhatsky wrote: > > cpu_to_le16() is capable enough to detect __builtin_constant_p() > > and to use an appropriate compile time ___constant_swahbXX() > > function. > > > > So we can use cpu_to_le16() instead of __constant_cpu_to_le16(). > > > > Signed-off-by: Sergey Senozhatsky > > --- > > drivers/staging/rtl8723bs/include/wifi.h | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > What changed from the previous versions of this patch? In short - nothing :) Just updated email address. > That always has to go below the --- line. > > v4? :) OK :) -ss
[GIT PULL] Please pull RDMA subsystem changes
Hi Linus, First rc pull request - nothing too special, just some driver bug fixes that have been sitting during the merge window. Thanks, Jason The following changes since commit 9e98c678c2d6ae3a17cb2de55d17f69dddaa231b: Linux 5.1-rc1 (2019-03-17 14:22:26 -0700) are available in the Git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma.git tags/for-linus for you to fetch changes up to ec4fe4bcc584b55e24e8d1768f5510a62c0fd619: i40iw: Avoid panic when handling the inetdev event (2019-03-17 21:40:40 -0300) 5.1 First RC pull request Several driver bug fixes post in the last three weeks - First part of a race condition fix in mlx4 with CATAS errors - Bad interaction with FW causing resource leaks in the mlx5 DCT flow - Bad reporting of link speed/width in new mlx5 devices - Userspace triggable OOPs in i40iw Aya Levin (1): IB/mlx5: Fix mapping of link-mode to IB width and speed Feng Tang (1): i40iw: Avoid panic when handling the inetdev event Jack Morgenstein (1): IB/mlx4: Fix race condition between catas error reset and aliasguid flows Yishai Hadas (2): net/mlx5: Fix DCT creation bad flow IB/mlx5: Use mlx5 core to create/destroy a DEVX DCT drivers/infiniband/hw/i40iw/i40iw_utils.c| 12 - drivers/infiniband/hw/mlx4/alias_GUID.c | 2 +- drivers/infiniband/hw/mlx5/devx.c| 34 + drivers/infiniband/hw/mlx5/main.c| 7 +++ drivers/infiniband/hw/mlx5/qp.c | 4 +- drivers/net/ethernet/mellanox/mlx5/core/qp.c | 72 +++- include/linux/mlx5/qp.h | 3 +- 7 files changed, 89 insertions(+), 45 deletions(-) signature.asc Description: PGP signature
[PATCH 4/5] autofs - update mount control expire desription with AUTOFS_EXP_FORCED
Describe AUTOFS_EXP_FORCED in addition to AUTOFS_EXP_IMMEDIATE in the description of the AUTOFS_DEV_IOCTL_EXPIRE_CMD ioctl. Signed-off-by: Ian Kent --- Documentation/filesystems/autofs-mount-control.txt |6 -- Documentation/filesystems/autofs.txt |5 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/autofs-mount-control.txt b/Documentation/filesystems/autofs-mount-control.txt index 45edad6933cc..acc02fc57993 100644 --- a/Documentation/filesystems/autofs-mount-control.txt +++ b/Documentation/filesystems/autofs-mount-control.txt @@ -354,8 +354,10 @@ this ioctl is called until no further expire candidates are found. The call requires an initialized struct autofs_dev_ioctl with the ioctlfd field set to the descriptor obtained from the open call. In -addition an immediate expire, independent of the mount timeout, can be -requested by setting the how field of struct args_expire to 1. If no +addition an immediate expire that's independent of the mount timeout, +and a forced expire that's independent of whether the mount is busy, +can be requested by setting the how field of struct args_expire to +AUTOFS_EXP_IMMEDIATE or AUTOFS_EXP_FORCED, respectively . If no expire candidates can be found the ioctl returns -1 with errno set to EAGAIN. diff --git a/Documentation/filesystems/autofs.txt b/Documentation/filesystems/autofs.txt index 8fe43c97cb96..409e6411904d 100644 --- a/Documentation/filesystems/autofs.txt +++ b/Documentation/filesystems/autofs.txt @@ -410,6 +410,11 @@ The available ioctl commands are: **AUTOFS_EXP_IMMEDIATE** causes `last_used` time to be ignored and objects are expired if the are not in use. + **AUTOFS_EXP_FORCED** causes the in use status to be ignored + and objects are expired ieven if they are in use. This assumes + that the daemon has requested this because it is capable of + performing the umount. + **AUTOFS_EXP_LEAVES** will select a leaf rather than a top-level name to expire. This is only safe when *maxproto* is 4.
[PATCH 5/5] autofs - add description of ignore pseudo mount option
Add a idescription of the "ignore" pseudo mount option that can be used to provide a generic indicator to applications that the mount entry should be ignored when displaying mount information. Signed-off-by: Ian Kent --- Documentation/filesystems/autofs.txt | 15 +++ 1 file changed, 15 insertions(+) diff --git a/Documentation/filesystems/autofs.txt b/Documentation/filesystems/autofs.txt index 409e6411904d..3af38c7fd26d 100644 --- a/Documentation/filesystems/autofs.txt +++ b/Documentation/filesystems/autofs.txt @@ -526,6 +526,21 @@ directories. Catatonic mode can only be left via the **AUTOFS_DEV_IOCTL_OPENMOUNT_CMD** ioctl on the `/dev/autofs`. +The "ignore" mount option +- + +The "ignore" mount option can be used to provide a generic indicator +to applications that the mount entry should be ignored when displaying +mount information. + +In other OSes that provide autofs and that provide a mount list to user +space based on the kernel mount list a no-op mount option ("ignore" is +the one use on the most common OSes) is allowed so that autofs file +system users can optionally use it. + +This is intended to be used by user space programs to exclude autofs +mounts from consideration when reading the mounts list. + autofs, name spaces, and shared mounts --
[PATCH 3/5] autofs - update AUTOFS_EXP_LEAVES description
Update the description of AUTOFS_EXP_LEAVES to cover its possible future use with amd format mount maps. Signed-off-by: Ian Kent --- Documentation/filesystems/autofs.txt |8 ++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Documentation/filesystems/autofs.txt b/Documentation/filesystems/autofs.txt index ac50b47f02bd..8fe43c97cb96 100644 --- a/Documentation/filesystems/autofs.txt +++ b/Documentation/filesystems/autofs.txt @@ -262,8 +262,12 @@ up. There is an option with indirect mounts to consider each of the leaves that has been mounted on instead of considering the top-level names. -This is intended for compatibility with version 4 of autofs and should -be considered as deprecated. +This was originally intended for compatibility with version 4 of autofs +and should be considered as deprecated for Sun Format automount maps. +However, it may be used again for amd format mount maps (which are +generally indirect maps) because the amd automounter allows for the +setting of an expire timeout for individual mounts. But there are +some difficulties in making the needed changes for this. When autofs considers a directory it checks the `last_used` time and compares it with the "timeout" value set when the filesystem was
[PATCH 2/5] autofs - update autofs.txt for strictexpire mount option
A "strictexpire" mount option has been added to the autofs file system. It is meant to be used in cases where a GUI continually accesses or an application frquently scans an automount directory tree causing an accumulation of otherwise unused mounts. Signed-off-by: Ian Kent --- Documentation/filesystems/autofs.txt | 17 - 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Documentation/filesystems/autofs.txt b/Documentation/filesystems/autofs.txt index 05da806b1e88..ac50b47f02bd 100644 --- a/Documentation/filesystems/autofs.txt +++ b/Documentation/filesystems/autofs.txt @@ -240,11 +240,18 @@ Normally the daemon only wants to remove entries which haven't been used for a while. For this purpose autofs maintains a "`last_used`" time stamp on each directory or symlink. For symlinks it genuinely does record the last time the symlink was "used" or followed to find -out where it points to. For directories the field is a slight -misnomer. It actually records the last time that autofs checked if -the directory or one of its descendants was busy and found that it -was. This is just as useful and doesn't require updating the field so -often. +out where it points to. For directories the field is used slightly +differently. The field is updated at mount time and during expire +checks if it is found to be in use (ie. open file descriptor or +process working directory) and during path walks. The update done +during path walks prevents frequent expire and immediate mount of +frequently accessed automounts. But in the case where a GUI continually +access or an application frequently scans an autofs directory tree +there can be an accumulation of mounts that aren't actually being +used. To cater for this case the "`strictexpire`" autofs mount option +can be used to avoid the "`last_used`" update on path walk thereby +preventing this apparent inability to expire mounts that aren't +really in use. The daemon is able to ask autofs if anything is due to be expired, using an `ioctl` as discussed later. For a *direct* mount, autofs
[PATCH 1/5] autofs - fix some word usage odities in autofs.txt
Alter a few word usages in Documentation/filesystems/autofs.txt and correct some spelling mistakes. Signed-off-by: Ian Kent --- Documentation/filesystems/autofs.txt | 25 - 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Documentation/filesystems/autofs.txt b/Documentation/filesystems/autofs.txt index 373ad25852d3..05da806b1e88 100644 --- a/Documentation/filesystems/autofs.txt +++ b/Documentation/filesystems/autofs.txt @@ -116,7 +116,7 @@ that purpose there is another flag. **DCACHE_MANAGE_TRANSIT** If a dentry has DCACHE_MANAGE_TRANSIT set then two very different but -related behaviors are invoked, both using the `d_op->d_manage()` +related behaviours are invoked, both using the `d_op->d_manage()` dentry operation. Firstly, before checking to see if any filesystem is mounted on the @@ -193,8 +193,8 @@ VFS remain in RCU-walk mode, but can only tell it to get out of RCU-walk mode by returning `-ECHILD`. So `d_manage()`, when called with `rcu_walk` set, should either return --ECHILD if there is any reason to believe it is unsafe to end the -mounted filesystem, and otherwise should return 0. +-ECHILD if there is any reason to believe it is unsafe to enter the +mounted filesystem, otherwise it should return 0. autofs will return `-ECHILD` if an expiry of the filesystem has been initiated or is being considered, otherwise it returns 0. @@ -210,7 +210,7 @@ mounts that were created by `d_automount()` returning a filesystem to be mounted. As autofs doesn't return such a filesystem but leaves the mounting to the automount daemon, it must involve the automount daemon in unmounting as well. This also means that autofs has more control -of expiry. +over expiry. The VFS also supports "expiry" of mounts using the MNT_EXPIRE flag to the `umount` system call. Unmounting with MNT_EXPIRE will fail unless @@ -225,7 +225,7 @@ unmount any filesystems mounted on the autofs filesystem or remove any symbolic links or empty directories any time it likes. If the unmount or removal is successful the filesystem will be returned to the state it was before the mount or creation, so that any access of the name -will trigger normal auto-mount processing. In particlar, `rmdir` and +will trigger normal auto-mount processing. In particular, `rmdir` and `unlink` do not leave negative entries in the dcache as a normal filesystem would, so an attempt to access a recently-removed object is passed to autofs for handling. @@ -242,7 +242,7 @@ time stamp on each directory or symlink. For symlinks it genuinely does record the last time the symlink was "used" or followed to find out where it points to. For directories the field is a slight misnomer. It actually records the last time that autofs checked if -the directory or one of its descendents was busy and found that it +the directory or one of its descendants was busy and found that it was. This is just as useful and doesn't require updating the field so often. @@ -255,7 +255,7 @@ up. There is an option with indirect mounts to consider each of the leaves that has been mounted on instead of considering the top-level names. -This is intended for compatability with version 4 of autofs and should +This is intended for compatibility with version 4 of autofs and should be considered as deprecated. When autofs considers a directory it checks the `last_used` time and @@ -273,7 +273,7 @@ mounts. If it finds something in the root directory to expire it will return the name of that thing. Once a name has been returned the automount daemon needs to unmount any filesystems mounted below the name normally. As described above, this is unsafe for non-toplevel -mounts in a version-5 autofs. For this reason the current `automountd` +mounts in a version-5 autofs. For this reason the current `automount(8)` does not use this ioctl. The second mechanism uses either the **AUTOFS_DEV_IOCTL_EXPIRE_CMD** or @@ -345,7 +345,7 @@ The `wait_queue_token` is a unique number which can identify a particular request to be acknowledged. When a message is sent over the pipe the affected dentry is marked as either "active" or "expiring" and other accesses to it block until the message is -acknowledged using one of the ioctls below and the relevant +acknowledged using one of the ioctls below with the relevant `wait_queue_token`. Communicating with autofs: root directory ioctls @@ -367,15 +367,14 @@ The available ioctl commands are: This mode is also entered if a write to the pipe fails. - **AUTOFS_IOC_PROTOVER**: This returns the protocol version in use. - **AUTOFS_IOC_PROTOSUBVER**: Returns the protocol sub-version which -is really a version number for the implementation. It is -currently 2. +is really a version number for the implementation. - **AUTOFS_IOC_SETTIMEOUT**: This passes a pointer to an unsigned long. The value is used to set the timeout for expiry, and the current
linux-next: manual merge of the cisco tree with Linus' tree
Hi all, Today's linux-next merge of the cisco tree got a conflict in: arch/powerpc/configs/skiroot_defconfig between commit: 805bf3b75529 ("powerpc/configs: Sync skiroot defconfig") from Linus' tree and commit: 5d4514a9c291 ("powerpc: convert config files to generic cmdline") from the cisco tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc arch/powerpc/configs/skiroot_defconfig index 5ba131c30f6b,bf31334efbce.. --- a/arch/powerpc/configs/skiroot_defconfig +++ b/arch/powerpc/configs/skiroot_defconfig @@@ -48,14 -40,22 +43,26 @@@ CONFIG_HZ_100= CONFIG_KEXEC=y CONFIG_IRQ_ALL_CPUS=y CONFIG_NUMA=y +# CONFIG_COMPACTION is not set +# CONFIG_MIGRATION is not set CONFIG_PPC_64K_PAGES=y CONFIG_SCHED_SMT=y +CONFIG_CMDLINE_BOOL=y - CONFIG_CMDLINE="console=tty0 console=hvc0 ipr.fast_reboot=1 quiet" ++CONFIG_CMDLINE_PREPEND="console=tty0 console=hvc0 ipr.fast_reboot=1 quiet" # CONFIG_SECCOMP is not set # CONFIG_PPC_MEM_KEYS is not set + CONFIG_JUMP_LABEL=y + CONFIG_STRICT_KERNEL_RWX=y + CONFIG_MODULES=y + CONFIG_MODULE_UNLOAD=y + CONFIG_MODULE_SIG=y + CONFIG_MODULE_SIG_FORCE=y + CONFIG_MODULE_SIG_SHA512=y + CONFIG_PARTITION_ADVANCED=y + # CONFIG_IOSCHED_DEADLINE is not set + # CONFIG_COMPACTION is not set + # CONFIG_MIGRATION is not set + # CONFIG_BOUNCE is not set CONFIG_NET=y CONFIG_PACKET=y CONFIG_UNIX=y @@@ -164,9 -159,9 +170,10 @@@ CONFIG_MLX4_EN= # CONFIG_MLX4_CORE_GEN2 is not set CONFIG_MLX5_CORE=m # CONFIG_NET_VENDOR_MICREL is not set +# CONFIG_NET_VENDOR_MICROSEMI is not set CONFIG_MYRI10GE=m # CONFIG_NET_VENDOR_NATSEMI is not set + CONFIG_S2IO=m # CONFIG_NET_VENDOR_NETRONOME is not set # CONFIG_NET_VENDOR_NI is not set # CONFIG_NET_VENDOR_NVIDIA is not set pgpErGFaOXEHi.pgp Description: OpenPGP digital signature
Re: [PATCH] staging: gdm724x: Fix alignment in gdm_mux
El dom, 17 de mar 2019 a las 8:23 AM, Greg KH escribió: For some of these, there is no real change needed, it's all up to the author's "taste", so they are not needed. Thanks for the feedback! I will send a revised version.
Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android
On Sun, Mar 17, 2019 at 08:40:19AM -0700, Daniel Colascione wrote: > On Sun, Mar 17, 2019 at 4:42 AM Christian Brauner > wrote: > > > > On Sat, Mar 16, 2019 at 09:53:06PM -0400, Joel Fernandes wrote: > > > On Sat, Mar 16, 2019 at 12:37:18PM -0700, Suren Baghdasaryan wrote: > > > > On Sat, Mar 16, 2019 at 11:57 AM Christian Brauner > > > > wrote: > > > > > > > > > > On Sat, Mar 16, 2019 at 11:00:10AM -0700, Daniel Colascione wrote: > > > > > > On Sat, Mar 16, 2019 at 10:31 AM Suren Baghdasaryan > > > > > > wrote: > > > > > > > > > > > > > > On Fri, Mar 15, 2019 at 11:49 AM Joel Fernandes > > > > > > > wrote: > > > > > > > > > > > > > > > > On Fri, Mar 15, 2019 at 07:24:28PM +0100, Christian Brauner > > > > > > > > wrote: > > > > > > > > [..] > > > > > > > > > > why do we want to add a new syscall (pidfd_wait) though? > > > > > > > > > > Why not just use > > > > > > > > > > standard poll/epoll interface on the proc fd like Daniel > > > > > > > > > > was suggesting. > > > > > > > > > > AFAIK, once the proc file is opened, the struct pid is > > > > > > > > > > essentially pinned > > > > > > > > > > even though the proc number may be reused. Then the caller > > > > > > > > > > can just poll. > > > > > > > > > > We can add a waitqueue to struct pid, and wake up any > > > > > > > > > > waiters on process > > > > > > > > > > death (A quick look shows task_struct can be mapped to its > > > > > > > > > > struct pid) and > > > > > > > > > > also possibly optimize it using Steve's TIF flag idea. No > > > > > > > > > > new syscall is > > > > > > > > > > needed then, let me know if I missed something? > > > > > > > > > > > > > > > > > > Huh, I thought that Daniel was against the poll/epoll > > > > > > > > > solution? > > > > > > > > > > > > > > > > Hmm, going through earlier threads, I believe so now. Here was > > > > > > > > Daniel's > > > > > > > > reasoning about avoiding a notification about process death > > > > > > > > through proc > > > > > > > > directory fd: > > > > > > > > http://lkml.iu.edu/hypermail/linux/kernel/1811.0/00232.html > > > > > > > > > > > > > > > > May be a dedicated syscall for this would be cleaner after all. > > > > > > > > > > > > > > Ah, I wish I've seen that discussion before... > > > > > > > syscall makes sense and it can be non-blocking and we can use > > > > > > > select/poll/epoll if we use eventfd. > > > > > > > > > > > > Thanks for taking a look. > > > > > > > > > > > > > I would strongly advocate for > > > > > > > non-blocking version or at least to have a non-blocking option. > > > > > > > > > > > > Waiting for FD readiness is *already* blocking or non-blocking > > > > > > according to the caller's desire --- users can pass options they > > > > > > want > > > > > > to poll(2) or whatever. There's no need for any kind of special > > > > > > configuration knob or non-blocking option. We already *have* a > > > > > > non-blocking option that works universally for everything. > > > > > > > > > > > > As I mentioned in the linked thread, waiting for process exit should > > > > > > work just like waiting for bytes to appear on a pipe. Process exit > > > > > > status is just another blob of bytes that a process might receive. A > > > > > > process exit handle ought to be just another information source. The > > > > > > reason the unix process API is so awful is that for whatever reason > > > > > > the original designers treated processes as some kind of special > > > > > > kind > > > > > > of resource instead of fitting them into the otherwise > > > > > > general-purpose > > > > > > unix data-handling API. Let's not repeat that mistake. > > > > > > > > > > > > > Something like this: > > > > > > > > > > > > > > evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > > > > > > > // register eventfd to receive death notification > > > > > > > pidfd_wait(pid_to_kill, evfd); > > > > > > > // kill the process > > > > > > > pidfd_send_signal(pid_to_kill, ...) > > > > > > > // tend to other things > > > > > > > > > > > > Now you've lost me. pidfd_wait should return a *new* FD, not wire up > > > > > > an eventfd. > > > > > > > > > > > > > > Ok, I probably misunderstood your post linked by Joel. I though your > > > > original proposal was based on being able to poll a file under > > > > /proc/pid and then you changed your mind to have a separate syscall > > > > which I assumed would be a blocking one to wait for process exit. > > > > Maybe you can describe the new interface you are thinking about in > > > > terms of userspace usage like I did above? Several lines of code would > > > > explain more than paragraphs of text. > > > > > > Hey, Thanks Suren for the eventfd idea. I agree with Daniel on this. The > > > idea > > > from Daniel here is to wait for process death and exit events by just > > > referring to a stable fd, independent of whatever is going on in /proc. > > > > > > What is needed is something like this (in highly pseudo-code form): > > > > > > pidfd = opendir("/proc/",.
Re: [GIT PULL] PCI changes for v5.1
On 3/17/19 4:18 PM, Linus Torvalds wrote: On Fri, Mar 8, 2019 at 9:31 AM Bjorn Helgaas wrote: - Report PCIe links that become degraded at run-time (Alexandru Gagniuc) Gaah. Only now as I'm about to do the rc1 release am I looking at new runtime warnings, and noticing that this causes genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 16 pcie_bw_notification: probe of :00:1b.0:pcie010 failed with error -22 because you can't have a NULL handler for a level-triggered interrupt (you need something to shut the interrupt off so that it doesn't keep screaming!). Thanks for the catch. I did not see the error on my test machines. I'll take a look tomorrow, and update through Bjorn. Seems like an easy fix. Alex
[PATCH v4 2/7] slob: Respect list_head abstraction layer
Currently we reach inside the list_head. This is a violation of the layer of abstraction provided by the list_head. It makes the code fragile. More importantly it makes the code wicked hard to understand. The code logic is based on the page in which an allocation was made, we want to modify the slob_list we are working on to have this page at the front. We already have a function to check if an entry is at the front of the list. Recently a function was added to list.h to do the list rotation. We can use these two functions to reduce line count, reduce code fragility, and reduce cognitive load required to read the code. Use list_head functions to interact with lists thereby maintaining the abstraction provided by the list_head structure. Signed-off-by: Tobin C. Harding --- mm/slob.c | 24 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/mm/slob.c b/mm/slob.c index 307c2c9feb44..39ad9217ffea 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -268,8 +268,7 @@ static void *slob_page_alloc(struct page *sp, size_t size, int align) */ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) { - struct page *sp; - struct list_head *prev; + struct page *sp, *prev, *next; struct list_head *slob_list; slob_t *b = NULL; unsigned long flags; @@ -296,18 +295,27 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) if (sp->units < SLOB_UNITS(size)) continue; + /* +* Cache previous entry because slob_page_alloc() may +* remove sp from slob_list. +*/ + prev = list_prev_entry(sp, lru); + /* Attempt to alloc */ - prev = sp->lru.prev; b = slob_page_alloc(sp, size, align); if (!b) continue; - /* Improve fragment distribution and reduce our average + next = list_next_entry(prev, lru); /* This may or may not be sp */ + + /* +* Improve fragment distribution and reduce our average * search time by starting our next search here. (see -* Knuth vol 1, sec 2.5, pg 449) */ - if (prev != slob_list->prev && - slob_list->next != prev->next) - list_move_tail(slob_list, prev->next); +* Knuth vol 1, sec 2.5, pg 449) +*/ + if (!list_is_first(&next->lru, slob_list)) + list_rotate_to_front(&next->lru, slob_list); + break; } spin_unlock_irqrestore(&slob_lock, flags); -- 2.21.0
[PATCH v4 4/7] slub: Add comments to endif pre-processor macros
SLUB allocator makes heavy use of ifdef/endif pre-processor macros. The pairing of these statements is at times hard to follow e.g. if the pair are further than a screen apart or if there are nested pairs. We can reduce cognitive load by adding a comment to the endif statement of form #ifdef CONFIG_FOO ... #endif /* CONFIG_FOO */ Add comments to endif pre-processor macros if ifdef/endif pair is not immediately apparent. Acked-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- mm/slub.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index 1b08fbcb7e61..b282e22885cd 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1951,7 +1951,7 @@ static void *get_any_partial(struct kmem_cache *s, gfp_t flags, } } } while (read_mems_allowed_retry(cpuset_mems_cookie)); -#endif +#endif /* CONFIG_NUMA */ return NULL; } @@ -2249,7 +2249,7 @@ static void unfreeze_partials(struct kmem_cache *s, discard_slab(s, page); stat(s, FREE_SLAB); } -#endif +#endif /* CONFIG_SLUB_CPU_PARTIAL */ } /* @@ -2308,7 +2308,7 @@ static void put_cpu_partial(struct kmem_cache *s, struct page *page, int drain) local_irq_restore(flags); } preempt_enable(); -#endif +#endif /* CONFIG_SLUB_CPU_PARTIAL */ } static inline void flush_slab(struct kmem_cache *s, struct kmem_cache_cpu *c) @@ -2813,7 +2813,7 @@ void *kmem_cache_alloc_node_trace(struct kmem_cache *s, } EXPORT_SYMBOL(kmem_cache_alloc_node_trace); #endif -#endif +#endif /* CONFIG_NUMA */ /* * Slow path handling. This may still be called frequently since objects @@ -3845,7 +3845,7 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node) return ret; } EXPORT_SYMBOL(__kmalloc_node); -#endif +#endif /* CONFIG_NUMA */ #ifdef CONFIG_HARDENED_USERCOPY /* @@ -4063,7 +4063,7 @@ void __kmemcg_cache_deactivate(struct kmem_cache *s) */ slab_deactivate_memcg_cache_rcu_sched(s, kmemcg_cache_deact_after_rcu); } -#endif +#endif /* CONFIG_MEMCG */ static int slab_mem_going_offline_callback(void *arg) { @@ -4696,7 +4696,7 @@ static int list_locations(struct kmem_cache *s, char *buf, len += sprintf(buf, "No data\n"); return len; } -#endif +#endif /* CONFIG_SLUB_DEBUG */ #ifdef SLUB_RESILIENCY_TEST static void __init resiliency_test(void) @@ -4756,7 +4756,7 @@ static void __init resiliency_test(void) #ifdef CONFIG_SYSFS static void resiliency_test(void) {}; #endif -#endif +#endif /* SLUB_RESILIENCY_TEST */ #ifdef CONFIG_SYSFS enum slab_stat_type { @@ -5413,7 +5413,7 @@ STAT_ATTR(CPU_PARTIAL_ALLOC, cpu_partial_alloc); STAT_ATTR(CPU_PARTIAL_FREE, cpu_partial_free); STAT_ATTR(CPU_PARTIAL_NODE, cpu_partial_node); STAT_ATTR(CPU_PARTIAL_DRAIN, cpu_partial_drain); -#endif +#endif /* CONFIG_SLUB_STATS */ static struct attribute *slab_attrs[] = { &slab_size_attr.attr, @@ -5614,7 +5614,7 @@ static void memcg_propagate_slab_attrs(struct kmem_cache *s) if (buffer) free_page((unsigned long)buffer); -#endif +#endif /* CONFIG_MEMCG */ } static void kmem_cache_release(struct kobject *k) -- 2.21.0
Re: [GIT PULL] 9p updates for 5.1
Linus Torvalds wrote on Sun, Mar 17, 2019: > Hmm. I wonder what makes it valid to have concurrent updates to > i_size? Yes, yes, you added that spinlock to make the update itself > atomic on 32-bit, but it sounds a bit odd in the first place to have > two things possibly changing the size of a file at the same time... If the inode attributes are currently invalid (for example after v9fs_invalidate_inode_attr()) then two concurrent user getattr requests for the same inode will send two network requests which can both update the i_size. With cache=fscache or loose a write could also be concurrent with such an update. I plan on improving the first case with some "being revalidated" logic now this pattern got reported but I don't think the second one can be avoided, so that fix is still necessary in the long run afaict. Thanks, -- Dominique
[PATCH v4 5/7] slub: Use slab_list instead of lru
Currently we use the page->lru list for maintaining lists of slabs. We have a list in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. Use the slab_list instead of the lru list for maintaining lists of slabs. Acked-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- mm/slub.c | 40 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/mm/slub.c b/mm/slub.c index b282e22885cd..d692b5e0163d 100644 --- a/mm/slub.c +++ b/mm/slub.c @@ -1023,7 +1023,7 @@ static void add_full(struct kmem_cache *s, return; lockdep_assert_held(&n->list_lock); - list_add(&page->lru, &n->full); + list_add(&page->slab_list, &n->full); } static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct page *page) @@ -1032,7 +1032,7 @@ static void remove_full(struct kmem_cache *s, struct kmem_cache_node *n, struct return; lockdep_assert_held(&n->list_lock); - list_del(&page->lru); + list_del(&page->slab_list); } /* Tracking of the number of slabs for debugging purposes */ @@ -1773,9 +1773,9 @@ __add_partial(struct kmem_cache_node *n, struct page *page, int tail) { n->nr_partial++; if (tail == DEACTIVATE_TO_TAIL) - list_add_tail(&page->lru, &n->partial); + list_add_tail(&page->slab_list, &n->partial); else - list_add(&page->lru, &n->partial); + list_add(&page->slab_list, &n->partial); } static inline void add_partial(struct kmem_cache_node *n, @@ -1789,7 +1789,7 @@ static inline void remove_partial(struct kmem_cache_node *n, struct page *page) { lockdep_assert_held(&n->list_lock); - list_del(&page->lru); + list_del(&page->slab_list); n->nr_partial--; } @@ -1863,7 +1863,7 @@ static void *get_partial_node(struct kmem_cache *s, struct kmem_cache_node *n, return NULL; spin_lock(&n->list_lock); - list_for_each_entry_safe(page, page2, &n->partial, lru) { + list_for_each_entry_safe(page, page2, &n->partial, slab_list) { void *t; if (!pfmemalloc_match(page, flags)) @@ -2407,7 +2407,7 @@ static unsigned long count_partial(struct kmem_cache_node *n, struct page *page; spin_lock_irqsave(&n->list_lock, flags); - list_for_each_entry(page, &n->partial, lru) + list_for_each_entry(page, &n->partial, slab_list) x += get_count(page); spin_unlock_irqrestore(&n->list_lock, flags); return x; @@ -3702,10 +3702,10 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) BUG_ON(irqs_disabled()); spin_lock_irq(&n->list_lock); - list_for_each_entry_safe(page, h, &n->partial, lru) { + list_for_each_entry_safe(page, h, &n->partial, slab_list) { if (!page->inuse) { remove_partial(n, page); - list_add(&page->lru, &discard); + list_add(&page->slab_list, &discard); } else { list_slab_objects(s, page, "Objects remaining in %s on __kmem_cache_shutdown()"); @@ -3713,7 +3713,7 @@ static void free_partial(struct kmem_cache *s, struct kmem_cache_node *n) } spin_unlock_irq(&n->list_lock); - list_for_each_entry_safe(page, h, &discard, lru) + list_for_each_entry_safe(page, h, &discard, slab_list) discard_slab(s, page); } @@ -3993,7 +3993,7 @@ int __kmem_cache_shrink(struct kmem_cache *s) * Note that concurrent frees may occur while we hold the * list_lock. page->inuse here is the upper limit. */ - list_for_each_entry_safe(page, t, &n->partial, lru) { + list_for_each_entry_safe(page, t, &n->partial, slab_list) { int free = page->objects - page->inuse; /* Do not reread page->inuse */ @@ -4003,10 +4003,10 @@ int __kmem_cache_shrink(struct kmem_cache *s) BUG_ON(free <= 0); if (free == page->objects) { - list_move(&page->lru, &discard); + list_move(&page->slab_list, &discard); n->nr_partial--; } else if (free <= SHRINK_PROMOTE_MAX) - list_move(&page->lru, promote + free - 1); + list_move(&page->slab_list, promote + free - 1); } /* @@ -4019,7 +4019,7 @@ int __kmem_cache_shrink(struct kmem_cache *s) spin_unlock_irqrestore(&n->list_lock, flags); /* Release empty slabs */ -
[PATCH v4 7/7] mm: Remove stale comment from page struct
We now use the slab_list list_head instead of the lru list_head. This comment has become stale. Remove stale comment from page struct slab_list list_head. Acked-by: Christoph Lameter Signed-off-by: Tobin C. Harding --- include/linux/mm_types.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 7eade9132f02..63a34e3d7c29 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -103,7 +103,7 @@ struct page { }; struct {/* slab, slob and slub */ union { - struct list_head slab_list; /* uses lru */ + struct list_head slab_list; struct {/* Partial pages */ struct page *next; #ifdef CONFIG_64BIT -- 2.21.0
[PATCH v4 1/7] list: Add function list_rotate_to_front()
Currently if we wish to rotate a list until a specific item is at the front of the list we can call list_move_tail(head, list). Note that the arguments are the reverse way to the usual use of list_move_tail(list, head). This is a hack, it depends on the developer knowing how the list_head operates internally which violates the layer of abstraction offered by the list_head. Also, it is not intuitive so the next developer to come along must study list.h in order to fully understand what is meant by the call, while this is 'good for' the developer it makes reading the code harder. We should have an function appropriately named that does this if there are users for it intree. By grep'ing the tree for list_move_tail() and list_tail() and attempting to guess the argument order from the names it seems there is only one place currently in the tree that does this - the slob allocatator. Add function list_rotate_to_front() to rotate a list until the specified item is at the front of the list. Signed-off-by: Tobin C. Harding --- include/linux/list.h | 18 ++ 1 file changed, 18 insertions(+) diff --git a/include/linux/list.h b/include/linux/list.h index 79626b5ab36c..8ead813e7f1c 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -270,6 +270,24 @@ static inline void list_rotate_left(struct list_head *head) } } +/** + * list_rotate_to_front() - Rotate list to specific item. + * @list: The desired new front of the list. + * @head: The head of the list. + * + * Rotates list so that @list becomes the new front of the list. + */ +static inline void list_rotate_to_front(struct list_head *list, + struct list_head *head) +{ + /* +* Deletes the list head from the list denoted by @head and +* places it as the tail of @list, this effectively rotates the +* list so that @list is at the front. +*/ + list_move_tail(head, list); +} + /** * list_is_singular - tests whether a list has just one entry. * @head: the list to test. -- 2.21.0
[PATCH v4 0/7] mm: Use slab_list list_head instead of lru
Hi, v4 fixes patch 3 (change _all_ instances of ->lru to ->slab_list) as noticed by Roman. Built, booted, and tested with the test modules mentioned below. Roman, I kept your reviewed-by tag on patch 3 since functionally its the same patch (and the additional changes were pointed out by you :). Thanks. >From v3 ... Currently the slab allocators (ab)use the struct page 'lru' list_head. We have a list head for slab allocators to use, 'slab_list'. During v2 it was noted by Christoph that the SLOB allocator was reaching into a list_head, this version adds 2 patches to the front of the set to fix that. Clean up all three allocators by using the 'slab_list' list_head instead of overloading the 'lru' list_head. Patch 1 - Adds a function to rotate a list to a specified entry. Patch 2 - Removes the code that reaches into list_head and instead uses the list_head API including the newly defined function. Patches 3-7 are unchanged from v3 Patch 3 (v2: patch 4) - Changes the SLOB allocator to use slab_list instead of lru. Patch 4 (v2: patch 1) - Makes no code changes, adds comments to #endif statements. Patch 5 (v2: patch 2) - Use slab_list instead of lru for SLUB allocator. Patch 6 (v2: patch 3) - Use slab_list instead of lru for SLAB allocator. Patch 7 (v2: patch 5) - Removes the now stale comment in the page struct definition. During v2 development patches were checked to see if the object file before and after was identical. Clearly this will no longer be possible for mm/slob.o, however this work is still of use to validate the change from lru -> slab_list. Patch 1 was tested with a module (creates and populates a list then calls list_rotate_to_front() and verifies new order): https://github.com/tcharding/ktest/tree/master/list_head Patch 2 was tested with another module that does some basic slab allocation and freeing to a newly created slab cache: https://github.com/tcharding/ktest/tree/master/slab Tested on a kernel with this in the config: CONFIG_SLOB=y CONFIG_SLAB_MERGE_DEFAULT=y Changes since v3: - Change all ->lru to ->slab_list in slob (thanks Roman). Changes since v2: - Add list_rotate_to_front(). - Fix slob to use list_head API. - Re-order patches to put the list.h changes up front. - Add acks from Christoph. Changes since v1: - Verify object files are the same before and after the patch set is applied (suggested by Matthew). - Add extra explanation to the commit logs explaining why these changes are safe to make (suggested by Roman). - Remove stale comment (thanks Willy). thanks, Tobin. Tobin C. Harding (7): list: Add function list_rotate_to_front() slob: Respect list_head abstraction layer slob: Use slab_list instead of lru slub: Add comments to endif pre-processor macros slub: Use slab_list instead of lru slab: Use slab_list instead of lru mm: Remove stale comment from page struct include/linux/list.h | 18 include/linux/mm_types.h | 2 +- mm/slab.c| 49 mm/slob.c| 32 + mm/slub.c| 60 5 files changed, 94 insertions(+), 67 deletions(-) -- 2.21.0
[PATCH v4 3/7] slob: Use slab_list instead of lru
Currently we use the page->lru list for maintaining lists of slabs. We have a list_head in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. The slab_list is part of a union within the page struct (included here stripped down): union { struct {/* Page cache and anonymous pages */ struct list_head lru; ... }; struct { dma_addr_t dma_addr; }; struct {/* slab, slob and slub */ union { struct list_head slab_list; struct {/* Partial pages */ struct page *next; int pages; /* Nr of pages left */ int pobjects; /* Approximate count */ }; }; ... Here we see that slab_list and lru are the same bits. We can verify that this change is safe to do by examining the object file produced from slob.c before and after this patch is applied. Steps taken to verify: 1. checkout current tip of Linus' tree commit a667cb7a94d4 ("Merge branch 'akpm' (patches from Andrew)") 2. configure and build (select SLOB allocator) CONFIG_SLOB=y CONFIG_SLAB_MERGE_DEFAULT=y 3. dissasemble object file `objdump -dr mm/slub.o > before.s 4. apply patch 5. build 6. dissasemble object file `objdump -dr mm/slub.o > after.s 7. diff before.s after.s Use slab_list list_head instead of the lru list_head for maintaining lists of slabs. Reviewed-by: Roman Gushchin Signed-off-by: Tobin C. Harding --- mm/slob.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/slob.c b/mm/slob.c index 39ad9217ffea..21af3fdb457a 100644 --- a/mm/slob.c +++ b/mm/slob.c @@ -112,13 +112,13 @@ static inline int slob_page_free(struct page *sp) static void set_slob_page_free(struct page *sp, struct list_head *list) { - list_add(&sp->lru, list); + list_add(&sp->slab_list, list); __SetPageSlobFree(sp); } static inline void clear_slob_page_free(struct page *sp) { - list_del(&sp->lru); + list_del(&sp->slab_list); __ClearPageSlobFree(sp); } @@ -282,7 +282,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); /* Iterate through each partially free page, try to find room */ - list_for_each_entry(sp, slob_list, lru) { + list_for_each_entry(sp, slob_list, slab_list) { #ifdef CONFIG_NUMA /* * If there's a node specification, search for a partial @@ -299,22 +299,22 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) * Cache previous entry because slob_page_alloc() may * remove sp from slob_list. */ - prev = list_prev_entry(sp, lru); + prev = list_prev_entry(sp, slab_list); /* Attempt to alloc */ b = slob_page_alloc(sp, size, align); if (!b) continue; - next = list_next_entry(prev, lru); /* This may or may not be sp */ + next = list_next_entry(prev, slab_list); /* This may or may not be sp */ /* * Improve fragment distribution and reduce our average * search time by starting our next search here. (see * Knuth vol 1, sec 2.5, pg 449) */ - if (!list_is_first(&next->lru, slob_list)) - list_rotate_to_front(&next->lru, slob_list); + if (!list_is_first(&next->slab_list, slob_list)) + list_rotate_to_front(&next->slab_list, slob_list); break; } @@ -331,7 +331,7 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node) spin_lock_irqsave(&slob_lock, flags); sp->units = SLOB_UNITS(PAGE_SIZE); sp->freelist = b; - INIT_LIST_HEAD(&sp->lru); + INIT_LIST_HEAD(&sp->slab_list); set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE)); set_slob_page_free(sp, slob_list); b = slob_page_alloc(sp, size, align); -- 2.21.0
[PATCH v4 6/7] slab: Use slab_list instead of lru
Currently we use the page->lru list for maintaining lists of slabs. We have a list in the page structure (slab_list) that can be used for this purpose. Doing so makes the code cleaner since we are not overloading the lru list. Use the slab_list instead of the lru list for maintaining lists of slabs. Signed-off-by: Tobin C. Harding --- mm/slab.c | 49 + 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/mm/slab.c b/mm/slab.c index 28652e4218e0..09cc64ef9613 100644 --- a/mm/slab.c +++ b/mm/slab.c @@ -1710,8 +1710,8 @@ static void slabs_destroy(struct kmem_cache *cachep, struct list_head *list) { struct page *page, *n; - list_for_each_entry_safe(page, n, list, lru) { - list_del(&page->lru); + list_for_each_entry_safe(page, n, list, slab_list) { + list_del(&page->slab_list); slab_destroy(cachep, page); } } @@ -2265,8 +2265,8 @@ static int drain_freelist(struct kmem_cache *cache, goto out; } - page = list_entry(p, struct page, lru); - list_del(&page->lru); + page = list_entry(p, struct page, slab_list); + list_del(&page->slab_list); n->free_slabs--; n->total_slabs--; /* @@ -2726,13 +2726,13 @@ static void cache_grow_end(struct kmem_cache *cachep, struct page *page) if (!page) return; - INIT_LIST_HEAD(&page->lru); + INIT_LIST_HEAD(&page->slab_list); n = get_node(cachep, page_to_nid(page)); spin_lock(&n->list_lock); n->total_slabs++; if (!page->active) { - list_add_tail(&page->lru, &(n->slabs_free)); + list_add_tail(&page->slab_list, &n->slabs_free); n->free_slabs++; } else fixup_slab_list(cachep, n, page, &list); @@ -2841,9 +2841,9 @@ static inline void fixup_slab_list(struct kmem_cache *cachep, void **list) { /* move slabp to correct slabp list: */ - list_del(&page->lru); + list_del(&page->slab_list); if (page->active == cachep->num) { - list_add(&page->lru, &n->slabs_full); + list_add(&page->slab_list, &n->slabs_full); if (OBJFREELIST_SLAB(cachep)) { #if DEBUG /* Poisoning will be done without holding the lock */ @@ -2857,7 +2857,7 @@ static inline void fixup_slab_list(struct kmem_cache *cachep, page->freelist = NULL; } } else - list_add(&page->lru, &n->slabs_partial); + list_add(&page->slab_list, &n->slabs_partial); } /* Try to find non-pfmemalloc slab if needed */ @@ -2880,20 +2880,20 @@ static noinline struct page *get_valid_first_slab(struct kmem_cache_node *n, } /* Move pfmemalloc slab to the end of list to speed up next search */ - list_del(&page->lru); + list_del(&page->slab_list); if (!page->active) { - list_add_tail(&page->lru, &n->slabs_free); + list_add_tail(&page->slab_list, &n->slabs_free); n->free_slabs++; } else - list_add_tail(&page->lru, &n->slabs_partial); + list_add_tail(&page->slab_list, &n->slabs_partial); - list_for_each_entry(page, &n->slabs_partial, lru) { + list_for_each_entry(page, &n->slabs_partial, slab_list) { if (!PageSlabPfmemalloc(page)) return page; } n->free_touched = 1; - list_for_each_entry(page, &n->slabs_free, lru) { + list_for_each_entry(page, &n->slabs_free, slab_list) { if (!PageSlabPfmemalloc(page)) { n->free_slabs--; return page; @@ -2908,11 +2908,12 @@ static struct page *get_first_slab(struct kmem_cache_node *n, bool pfmemalloc) struct page *page; assert_spin_locked(&n->list_lock); - page = list_first_entry_or_null(&n->slabs_partial, struct page, lru); + page = list_first_entry_or_null(&n->slabs_partial, struct page, + slab_list); if (!page) { n->free_touched = 1; page = list_first_entry_or_null(&n->slabs_free, struct page, - lru); + slab_list); if (page) n->free_slabs--; } @@ -3413,29 +3414,29 @@ static void free_block(struct kmem_cache *cachep, void **objpp, objp = objpp[i]; page = virt_to_head_page(objp); - list_del(&page->lru); + list_del(&page->slab_list); check_spinlock_acquired_node(cachep, node); slab_put_obj(cachep, page, objp)
Re: linux-next: build warning after merge of the vfs tree
Hi all, On Mon, 4 Feb 2019 09:33:34 +1100 Stephen Rothwell wrote: > > After merging the vfs tree, today's linux-next build (arm > multi_v7_defconfig) produced this warning: > > In file included from include/linux/printk.h:7, > from include/linux/kernel.h:14, > from include/linux/fs_context.h:15, > from fs/fs_parser.c:13: > fs/fs_parser.c: In function 'fs_validate_description': > include/linux/kern_levels.h:5:18: warning: format '%lu' expects argument of > type 'long unsigned int', but argument 3 has type 'int' [-Wformat=] > #define KERN_SOH "\001" /* ASCII Start Of Header */ > ^~ > include/linux/kern_levels.h:11:18: note: in expansion of macro 'KERN_SOH' > #define KERN_ERR KERN_SOH "3" /* error conditions */ > ^~~~ > include/linux/printk.h:303:9: note: in expansion of macro 'KERN_ERR' > printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) > ^~~~ > fs/fs_parser.c:413:6: note: in expansion of macro 'pr_err' > pr_err("VALIDATE %s: e[%lu] enum val for %s\n", > ^~ > fs/fs_parser.c:413:31: note: format string is defined here > pr_err("VALIDATE %s: e[%lu] enum val for %s\n", > ~~^ > %u > > Introduced by commit > > f512b838c104 ("vfs: Add configuration parser helpers") We are now seeing that warning in Linus' tree :-( -- Cheers, Stephen Rothwell pgpPHoIC8Pk04.pgp Description: OpenPGP digital signature
Re: [PATCH] hostfs: fix mismatch between link_file definition and declaration
Am Montag, 18. März 2019, 00:09:09 CET schrieb Colin King: > From: Colin Ian King > > The function link_file declaration in the header file has the order > of the two arguments (from, to) swapped when compared to the definition > arguments of (to, from). Fix this by swapping them around to match > the definition. > > This error predates the git history, so no idea when this error > was introduced. commit bf4f804738544a95b8bc8d6a7e2629c3fc0240dd Author: jdike Date: Sat Dec 9 22:52:44 2000 + hostfs now mostly works. Almost all of the common operations are now implemented, the main exceptions being mknod and executing files from a hostfs filesystem. Enough archaeology for today. :-) Thanks, //richard
linux-next: build warning after merge of the bluetooth tree
Hi all, After merging the bluetooth tree, today's linux-next build (x86_64 allmodconfig) produced this warning: drivers/bluetooth/btmtksdio.c: In function 'btmtksdio_interrupt': drivers/bluetooth/btmtksdio.c:470:2: warning: 'old_len' may be used uninitialized in this function [-Wmaybe-uninitialized] print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^ old_data, old_len, true); drivers/bluetooth/btmtksdio.c:376:15: note: 'old_len' was declared here unsigned int old_len; ^~~ drivers/bluetooth/btmtksdio.c:470:2: warning: 'old_data' may be used uninitialized in this function [-Wmaybe-uninitialized] print_hex_dump(KERN_ERR, "err sdio rx: ", DUMP_PREFIX_NONE, 4, 1, ^ old_data, old_len, true); drivers/bluetooth/btmtksdio.c:375:17: note: 'old_data' was declared here unsigned char *old_data; ^~~~ Introduced by commit d74eef2834b5 ("Bluetooth: mediatek: add support for MediaTek MT7663S and MT7668S SDIO") -- Cheers, Stephen Rothwell pgpc0rI2S9KU_.pgp Description: OpenPGP digital signature
[PATCH v2 11/13] Move EM_UNICORE to uapi/linux/elf-em.h
This should never have been defined in the arch tree to begin with, and now uapi/linux/audit.h header is going to use EM_UNICORE in order to define AUDIT_ARCH_UNICORE which is needed to implement syscall_get_arch() which in turn is required to extend the generic ptrace API with PTRACE_GET_SYSCALL_INFO request. Acked-by: Paul Moore Cc: Guan Xuetao Cc: Elvira Khabirova Cc: Eugene Syromyatnikov Cc: Oleg Nesterov Cc: Andy Lutomirski Cc: linux-au...@redhat.com Signed-off-by: Dmitry V. Levin --- Notes: v2: unchanged arch/unicore32/include/asm/elf.h | 3 +-- include/uapi/linux/elf-em.h | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/unicore32/include/asm/elf.h b/arch/unicore32/include/asm/elf.h index 829042d07722..ae66dc1be49e 100644 --- a/arch/unicore32/include/asm/elf.h +++ b/arch/unicore32/include/asm/elf.h @@ -19,6 +19,7 @@ * ELF register definitions.. */ #include +#include typedef unsigned long elf_greg_t; typedef unsigned long elf_freg_t[3]; @@ -28,8 +29,6 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG]; typedef struct fp_state elf_fpregset_t; -#define EM_UNICORE 110 - #define R_UNICORE_NONE 0 #define R_UNICORE_PC24 1 #define R_UNICORE_ABS322 diff --git a/include/uapi/linux/elf-em.h b/include/uapi/linux/elf-em.h index 4b8df722330e..f47e853546fa 100644 --- a/include/uapi/linux/elf-em.h +++ b/include/uapi/linux/elf-em.h @@ -37,6 +37,7 @@ #define EM_ARCOMPACT 93 /* ARCompact processor */ #define EM_XTENSA 94 /* Tensilica Xtensa Architecture */ #define EM_BLACKFIN 106 /* ADI Blackfin Processor */ +#define EM_UNICORE 110 /* UniCore-32 */ #define EM_ALTERA_NIOS2113 /* Altera Nios II soft-core processor */ #define EM_TI_C6000140 /* TI C6X DSPs */ #define EM_HEXAGON 164 /* QUALCOMM Hexagon */ -- ldv
[PATCH] ALSA: opl3: fix mismatch between snd_opl3_drum_switch definition and declaration
From: Colin Ian King The function snd_opl3_drum_switch declaration in the header file has the order of the two arguments on_off and vel swapped when compared to the definition arguments of vel and on_off. Fix this by swapping them around to match the definition. This error predates the git history, so no idea when this error was introduced. Signed-off-by: Colin Ian King --- sound/drivers/opl3/opl3_voice.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/drivers/opl3/opl3_voice.h b/sound/drivers/opl3/opl3_voice.h index 5b02bd49fde4..4e4ecc21760b 100644 --- a/sound/drivers/opl3/opl3_voice.h +++ b/sound/drivers/opl3/opl3_voice.h @@ -41,7 +41,7 @@ void snd_opl3_timer_func(struct timer_list *t); /* Prototypes for opl3_drums.c */ void snd_opl3_load_drums(struct snd_opl3 *opl3); -void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int on_off, int vel, struct snd_midi_channel *chan); +void snd_opl3_drum_switch(struct snd_opl3 *opl3, int note, int vel, int on_off, struct snd_midi_channel *chan); /* Prototypes for opl3_oss.c */ #if IS_ENABLED(CONFIG_SND_SEQUENCER_OSS) -- 2.20.1
[PATCH] hostfs: fix mismatch between link_file definition and declaration
From: Colin Ian King The function link_file declaration in the header file has the order of the two arguments (from, to) swapped when compared to the definition arguments of (to, from). Fix this by swapping them around to match the definition. This error predates the git history, so no idea when this error was introduced. Signed-off-by: Colin Ian King --- fs/hostfs/hostfs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/hostfs/hostfs.h b/fs/hostfs/hostfs.h index 33b8423ef0c9..f4295aa19350 100644 --- a/fs/hostfs/hostfs.h +++ b/fs/hostfs/hostfs.h @@ -87,7 +87,7 @@ extern int do_mkdir(const char *file, int mode); extern int hostfs_do_rmdir(const char *file); extern int do_mknod(const char *file, int mode, unsigned int major, unsigned int minor); -extern int link_file(const char *from, const char *to); +extern int link_file(const char *to, const char *from); extern int hostfs_do_readlink(char *file, char *buf, int size); extern int rename_file(char *from, char *to); extern int rename2_file(char *from, char *to, unsigned int flags); -- 2.20.1
[PATCH v2 2/2] ARM: drop -mauto-it
The assembler option -mauto-it is no longer a valid option. The last remaining references have been removed from the documentation in July 2009 [0]. The currently supported binutils version is 2.20 (released in September 2009) or higher where gas supports -mimplicit-it=always. Drop the fallback to -mauto-it and use -mimplicit-it=always only. [0] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=529707530657a333a304c651c808ea630c955223 Signed-off-by: Stefan Agner Reviewed-by: Nick Desaulniers --- Changes in v2: - Drop $(comma) since we are no longer use the call to as-option. arch/arm/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/Makefile b/arch/arm/Makefile index df3ad82d312c..eb9d38e77cf0 100644 --- a/arch/arm/Makefile +++ b/arch/arm/Makefile @@ -113,8 +113,7 @@ CFLAGS_ABI +=-funwind-tables endif ifeq ($(CONFIG_THUMB2_KERNEL),y) -AFLAGS_AUTOIT :=$(call as-option,-Wa$(comma)-mimplicit-it=always,-Wa$(comma)-mauto-it) -CFLAGS_ISA :=-mthumb $(AFLAGS_AUTOIT) +CFLAGS_ISA :=-mthumb -Wa,-mimplicit-it=always AFLAGS_ISA :=$(CFLAGS_ISA) -Wa$(comma)-mthumb # Work around buggy relocation from gas if requested: ifeq ($(CONFIG_THUMB2_AVOID_R_ARM_THM_JUMP11),y) -- 2.21.0
[PATCH v2 1/2] ARM: drop WASM to work around LLVM issue
Currently LLVM's integrated assembler does not recognize .w form of the pld instructions (LLVM Bug 40972 [0]): ./arch/arm/include/asm/processor.h:133:5: error: invalid instruction "pldw.w\t%a0 \n" ^ :2:1: note: instantiated into assembly here pldw.w [r0] ^ 1 error generated. The W macro for generating wide instructions when targeting Thumb-2 is not strictly required for the preload data instructions (pld, pldw) since they are only available as wide instructions. The GNU assembler works with or without the .w appended when compiling an Thumb-2 kernel. Drop the macro to work around LLVM Bug 40972 issue. [0] https://bugs.llvm.org/show_bug.cgi?id=40972 Signed-off-by: Stefan Agner --- Changes in v2: - Reword commit message to reflect the fact that this is a work around for LLVM. arch/arm/include/asm/processor.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/processor.h b/arch/arm/include/asm/processor.h index 57fe73ea0f72..5d06f75ffad4 100644 --- a/arch/arm/include/asm/processor.h +++ b/arch/arm/include/asm/processor.h @@ -135,8 +135,8 @@ static inline void prefetchw(const void *ptr) __asm__ __volatile__( ".arch_extensionmp\n" __ALT_SMP_ASM( - WASM(pldw) "\t%a0", - WASM(pld) "\t%a0" + "pldw\t%a0", + "pld\t%a0" ) :: "p" (ptr)); } -- 2.21.0
[PATCH v10 6/7] ARM: tegra: Always boot CPU in ARM-mode
CPU always jumps into reset handler in ARM-mode from the Trusted Foundations firmware, hence let's make CPU to always jump into kernel in ARM-mode regardless of the firmware presence. This is required to make Thumb-2 kernel working with the Trusted Foundations firmware on Tegra30. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 809fbc200cef..31fb53f9ce13 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -113,6 +113,7 @@ ENTRY(__tegra_cpu_reset_handler_start) * must be position-independent. */ + .arm .align L1_CACHE_SHIFT ENTRY(__tegra_cpu_reset_handler) -- 2.20.1
[PATCH v10 5/7] ARM: tegra: Don't apply CPU erratas in insecure mode
CPU isn't allowed to touch secure registers while running under secure monitor. Hence skip applying of CPU erratas in the reset handler if Trusted Foundations firmware presents. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594768.html Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/reset-handler.S | 23 --- arch/arm/mach-tegra/reset.c | 3 +++ arch/arm/mach-tegra/reset.h | 9 +++-- arch/arm/mach-tegra/sleep-tegra20.S | 4 4 files changed, 26 insertions(+), 13 deletions(-) diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index e22ccf87eded..809fbc200cef 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -29,8 +29,6 @@ #define PMC_SCRATCH41 0x140 -#define RESET_DATA(x) ((TEGRA_RESET_##x)*4) - #ifdef CONFIG_PM_SLEEP /* * tegra_resume @@ -121,6 +119,12 @@ ENTRY(__tegra_cpu_reset_handler) cpsid aif, 0x13 @ SVC mode, interrupts disabled tegra_get_soc_id TEGRA_APB_MISC_BASE, r6 + + adr r12, __tegra_cpu_reset_handler_data + ldr r5, [r12, #RESET_DATA(TF_PRESENT)] + cmp r5, #0 + bne after_errata + #ifdef CONFIG_ARCH_TEGRA_2x_SOC t20_check: cmp r6, #TEGRA20 @@ -155,7 +159,6 @@ after_errata: and r10, r10, #0x3 @ R10 = CPU number mov r11, #1 mov r11, r11, lsl r10 @ R11 = CPU mask - adr r12, __tegra_cpu_reset_handler_data #ifdef CONFIG_SMP /* Does the OS know about this CPU? */ @@ -169,10 +172,9 @@ after_errata: cmp r6, #TEGRA20 bne 1f /* If not CPU0, don't let CPU0 reset CPU1 now that CPU1 is coming up. */ - mov32 r5, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET mov r0, #CPU_NOT_RESETTABLE cmp r10, #0 - strbne r0, [r5, #__tegra20_cpu1_resettable_status_offset] + strbne r0, [r12, #RESET_DATA(RESETTABLE_STATUS)] 1: #endif @@ -277,14 +279,13 @@ ENDPROC(__tegra_cpu_reset_handler) .align L1_CACHE_SHIFT .type __tegra_cpu_reset_handler_data, %object .globl __tegra_cpu_reset_handler_data + .globl __tegra_cpu_reset_handler_data_offset + .equ__tegra_cpu_reset_handler_data_offset, \ + . - __tegra_cpu_reset_handler_start __tegra_cpu_reset_handler_data: - .rept TEGRA_RESET_DATA_SIZE - .long 0 + .rept TEGRA_RESET_DATA_SIZE + .long 0 .endr - .globl __tegra20_cpu1_resettable_status_offset - .equ__tegra20_cpu1_resettable_status_offset, \ - . - __tegra_cpu_reset_handler_start - .byte 0 .align L1_CACHE_SHIFT ENTRY(__tegra_cpu_reset_handler_end) diff --git a/arch/arm/mach-tegra/reset.c b/arch/arm/mach-tegra/reset.c index dc558892753c..b02ae7699842 100644 --- a/arch/arm/mach-tegra/reset.c +++ b/arch/arm/mach-tegra/reset.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "iomap.h" #include "irammap.h" @@ -89,6 +90,8 @@ static void __init tegra_cpu_reset_handler_enable(void) void __init tegra_cpu_reset_handler_init(void) { + __tegra_cpu_reset_handler_data[TEGRA_RESET_TF_PRESENT] = + trusted_foundations_registered(); #ifdef CONFIG_SMP __tegra_cpu_reset_handler_data[TEGRA_RESET_MASK_PRESENT] = diff --git a/arch/arm/mach-tegra/reset.h b/arch/arm/mach-tegra/reset.h index 9c479c7925b8..db0e6b3097ab 100644 --- a/arch/arm/mach-tegra/reset.h +++ b/arch/arm/mach-tegra/reset.h @@ -25,7 +25,11 @@ #define TEGRA_RESET_STARTUP_SECONDARY 3 #define TEGRA_RESET_STARTUP_LP24 #define TEGRA_RESET_STARTUP_LP15 -#define TEGRA_RESET_DATA_SIZE 6 +#define TEGRA_RESET_RESETTABLE_STATUS 6 +#define TEGRA_RESET_TF_PRESENT 7 +#define TEGRA_RESET_DATA_SIZE 8 + +#define RESET_DATA(x) ((TEGRA_RESET_##x)*4) #ifndef __ASSEMBLY__ @@ -49,7 +53,8 @@ void __tegra_cpu_reset_handler_end(void); (u32)__tegra_cpu_reset_handler_start))) #define tegra20_cpu1_resettable_status \ (IO_ADDRESS(TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + \ -(u32)__tegra20_cpu1_resettable_status_offset)) + ((u32)&__tegra_cpu_reset_handler_data[TEGRA_RESET_RESETTABLE_STATUS] - \ +(u32)__tegra_cpu_reset_handler_start))) #endif #define tegra_cpu_reset_handler_offset \ diff --git a/arch/arm/mach-tegra/sleep-tegra20.S b/arch/arm/mach-tegra/sleep-tegra20.S index dedeebfccc55..50d51d3465f6 100644 --- a/arch/arm/mach-tegra/sleep-tegra20.S +++ b/arch/arm/mach-tegra/sleep-tegra20.S @@ -28,6 +28,7 @@ #include #include "irammap.h" +#include "reset.h" #include "sleep.h" #define EMC_
[PATCH v10 7/7] ARM: tegra: Add firmware calls required for suspend-resume on Tegra30
In order to suspend-resume CPU with Trusted Foundations firmware being present on Tegra30, the LP1/LP2 boot vectors and CPU caches need to be set up using the firmware calls and then suspend code shall avoid re-disabling parts that were disabled by the firmware. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/pm.c| 49 + arch/arm/mach-tegra/reset-handler.S | 26 +++ arch/arm/mach-tegra/sleep.S | 14 ++--- 3 files changed, 84 insertions(+), 5 deletions(-) diff --git a/arch/arm/mach-tegra/pm.c b/arch/arm/mach-tegra/pm.c index 1ad5719779b0..abf5f88778f4 100644 --- a/arch/arm/mach-tegra/pm.c +++ b/arch/arm/mach-tegra/pm.c @@ -33,11 +33,13 @@ #include #include +#include #include #include #include #include #include +#include #include "iomap.h" #include "pm.h" @@ -159,6 +161,28 @@ int tegra_cpu_do_idle(void) static int tegra_sleep_cpu(unsigned long v2p) { + /* +* L2 cache disabling using kernel API only allowed when all +* secondary CPU's are offline. Cache have to be disabled with +* MMU-on if cache maintenance is done via Trusted Foundations +* firmware. Note that CPUIDLE won't ever enter powergate on Tegra30 +* if any of secondary CPU's is online and this is the LP2-idle +* code-path only for Tegra20/30. +*/ + if (trusted_foundations_registered()) + outer_disable(); + + /* +* Note that besides of setting up CPU reset vector this firmware +* call may also do the following, depending on the FW version: +* 1) Disable L2. But this doesn't matter since we already +* disabled the L2. +* 2) Disable D-cache. This need to be taken into account in +* particular by the tegra_disable_clean_inv_dcache() which +* shall avoid the re-disable. +*/ + call_firmware_op(prepare_idle, TF_PM_MODE_LP2); + setup_mm_for_reboot(); tegra_sleep_cpu_finish(v2p); @@ -197,6 +221,14 @@ void tegra_idle_lp2_last(void) cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, &tegra_sleep_cpu); + /* +* Resume L2 cache if it wasn't re-enabled early during resume, +* which is the case for Tegra30 that has to re-enable the cache +* via firmware call. In other cases cache is already enabled and +* hence re-enabling is a no-op. This is always a no-op on Tegra114+. +*/ + outer_resume(); + restore_cpu_complex(); cpu_cluster_pm_exit(); } @@ -215,6 +247,15 @@ enum tegra_suspend_mode tegra_pm_validate_suspend_mode( static int tegra_sleep_core(unsigned long v2p) { + /* +* Cache have to be disabled with MMU-on if cache maintenance is done +* via Trusted Foundations firmware. This is a no-op on Tegra114+. +*/ + if (trusted_foundations_registered()) + outer_disable(); + + call_firmware_op(prepare_idle, TF_PM_MODE_LP1); + setup_mm_for_reboot(); tegra_sleep_core_finish(v2p); @@ -342,6 +383,14 @@ static int tegra_suspend_enter(suspend_state_t state) cpu_suspend(PHYS_OFFSET - PAGE_OFFSET, tegra_sleep_func); + /* +* Resume L2 cache if it wasn't re-enabled early during resume, +* which is the case for Tegra30 that has to re-enable the cache +* via firmware call. In other cases cache is already enabled and +* hence re-enabling is a no-op. +*/ + outer_resume(); + switch (mode) { case TEGRA_SUSPEND_LP1: tegra_suspend_exit_lp1(); diff --git a/arch/arm/mach-tegra/reset-handler.S b/arch/arm/mach-tegra/reset-handler.S index 31fb53f9ce13..cd94d7c41fc0 100644 --- a/arch/arm/mach-tegra/reset-handler.S +++ b/arch/arm/mach-tegra/reset-handler.S @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -76,6 +77,7 @@ ENTRY(tegra_resume) orr r1, r1, #1 str r1, [r0] #endif + bl tegra_resume_trusted_foundations #ifdef CONFIG_CACHE_L2X0 /* L2 cache resume & re-enable */ @@ -88,6 +90,30 @@ end_ca9_scu_l2_resume: b cpu_resume ENDPROC(tegra_resume) + +/* + * tegra_resume_trusted_foundations + * + * Trusted Foundations firmware initialization. + * + * Doesn't return if firmware presents. + * Corrupted registers: r1, r2 + */ +ENTRY(tegra_resume_trusted_foundations) + /* Check whether Trusted Foundations firmware presents. */ + mov32 r2, TEGRA_IRAM_BASE + TEGRA_IRAM_RESET_HANDLER_OFFSET + ldr r1, =__tegra_cpu_reset_handler_data_offset + \ + RESET_DATA(TF_PRESENT) + ldr r1, [r2, r1] + cmp r1, #0 + reteq lr + + .arch_extension sec + /* First call after suspend wakes firmware. No arguments required. */ +
[PATCH v10 4/7] ARM: tegra: Set up L2 cache using Trusted Foundations firmware
On Tegra30 L2 cache should be initialized using firmware call if CPU is running in insecure mode. Set up the required outer-cache write_sec() callback early during boot using the firmware API, it is always a NO-OP on T114+ and is NO-OP on T20/30 if Trusted Foundations firmware node isn't present in device-tree. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/mach-tegra/tegra.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm/mach-tegra/tegra.c b/arch/arm/mach-tegra/tegra.c index f9587be48235..1e89cfefbf68 100644 --- a/arch/arm/mach-tegra/tegra.c +++ b/arch/arm/mach-tegra/tegra.c @@ -38,6 +38,7 @@ #include #include +#include #include #include #include @@ -74,6 +75,7 @@ static void __init tegra_init_early(void) { of_register_trusted_foundations(); tegra_cpu_reset_handler_init(); + call_firmware_op(l2x0_init); } static void __init tegra_dt_init_irq(void) -- 2.20.1
[PATCH v10 1/7] ARM: trusted_foundations: Support L2 cache maintenance
Implement L2 cache initialization firmware callback that should be invoked early during boot in order to set up the required outer cache driver's callbacks and add the callback required for L2X0 maintenance. Partially based on work done by Michał Mirosław [1]. [1] https://www.spinics.net/lists/arm-kernel/msg594765.html Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c| 41 ++ arch/arm/include/asm/trusted_foundations.h | 10 ++ 2 files changed, 51 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 689e6565abfc..d7ac05103a52 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -18,8 +18,15 @@ #include #include #include +#include +#include #include +#define TF_CACHE_MAINT 0xf100 + +#define TF_CACHE_ENABLE1 +#define TF_CACHE_DISABLE 2 + #define TF_SET_CPU_BOOT_ADDR_SMC 0xf200 #define TF_CPU_PM 0xfffc @@ -67,9 +74,43 @@ static int tf_prepare_idle(void) return 0; } +#ifdef CONFIG_CACHE_L2X0 +static void tf_cache_write_sec(unsigned long val, unsigned int reg) +{ + u32 l2x0_way_mask = 0xff; + + switch (reg) { + case L2X0_CTRL: + if (l2x0_saved_regs.aux_ctrl & L310_AUX_CTRL_ASSOCIATIVITY_16) + l2x0_way_mask = 0x; + + if (val == L2X0_CTRL_EN) + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_ENABLE, + l2x0_saved_regs.aux_ctrl); + else + tf_generic_smc(TF_CACHE_MAINT, TF_CACHE_DISABLE, + l2x0_way_mask); + break; + + default: + break; + } +} + +static int tf_init_cache(void) +{ + outer_cache.write_sec = tf_cache_write_sec; + + return 0; +} +#endif /* CONFIG_CACHE_L2X0 */ + static const struct firmware_ops trusted_foundations_ops = { .set_cpu_boot_addr = tf_set_cpu_boot_addr, .prepare_idle = tf_prepare_idle, +#ifdef CONFIG_CACHE_L2X0 + .l2x0_init = tf_init_cache, +#endif }; void register_trusted_foundations(struct trusted_foundations_platform_data *pd) diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 00748350cf72..9e6a41e9215e 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -32,6 +32,9 @@ #include #include +#include +#include + struct trusted_foundations_platform_data { unsigned int version_major; unsigned int version_minor; @@ -43,6 +46,9 @@ void register_trusted_foundations(struct trusted_foundations_platform_data *pd); void of_register_trusted_foundations(void); #else /* CONFIG_TRUSTED_FOUNDATIONS */ +static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg) +{ +} static inline void register_trusted_foundations( struct trusted_foundations_platform_data *pd) @@ -53,6 +59,10 @@ static inline void register_trusted_foundations( */ pr_err("No support for Trusted Foundations, continuing in degraded mode.\n"); pr_err("Secondary processors as well as CPU PM will be disabled.\n"); +#if IS_ENABLED(CONFIG_CACHE_L2X0) + pr_err("L2X0 cache will be kept disabled.\n"); + outer_cache.write_sec = tf_dummy_write_sec; +#endif #if IS_ENABLED(CONFIG_SMP) setup_max_cpus = 0; #endif -- 2.20.1
Re: [PATCH v2 1/6] drm: rcar-du: Link CRTCs to the DU device
Hi Kieran, Thank you for the patch. On Fri, Mar 15, 2019 at 05:01:05PM +, Kieran Bingham wrote: > The rcar_du_crtc functions have a heavy reliance on the rcar_du_group > structure, in many cases just to access the DU device context. > > To better separate the groups out of the CRTC handling code, give the > rcar_du_crtc its own pointer to the device and remove the indirection > through the group pointers. I've thought about doing this so many times, every time I had to access the device from the crtc. Reviewed-by: Laurent Pinchart And taken in my tree. > Signed-off-by: Kieran Bingham > --- > drivers/gpu/drm/rcar-du/rcar_du_crtc.c | 48 +- > drivers/gpu/drm/rcar-du/rcar_du_crtc.h | 2 ++ > drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 2 +- > 3 files changed, 27 insertions(+), 25 deletions(-) > > diff --git a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c > b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c > index 57fd5c00494b..471ce464654a 100644 > --- a/drivers/gpu/drm/rcar-du/rcar_du_crtc.c > +++ b/drivers/gpu/drm/rcar-du/rcar_du_crtc.c > @@ -32,21 +32,21 @@ > > static u32 rcar_du_crtc_read(struct rcar_du_crtc *rcrtc, u32 reg) > { > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > > return rcar_du_read(rcdu, rcrtc->mmio_offset + reg); > } > > static void rcar_du_crtc_write(struct rcar_du_crtc *rcrtc, u32 reg, u32 data) > { > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > > rcar_du_write(rcdu, rcrtc->mmio_offset + reg, data); > } > > static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, u32 reg, u32 clr) > { > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > > rcar_du_write(rcdu, rcrtc->mmio_offset + reg, > rcar_du_read(rcdu, rcrtc->mmio_offset + reg) & ~clr); > @@ -54,7 +54,7 @@ static void rcar_du_crtc_clr(struct rcar_du_crtc *rcrtc, > u32 reg, u32 clr) > > static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, u32 reg, u32 set) > { > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > > rcar_du_write(rcdu, rcrtc->mmio_offset + reg, > rcar_du_read(rcdu, rcrtc->mmio_offset + reg) | set); > @@ -62,7 +62,7 @@ static void rcar_du_crtc_set(struct rcar_du_crtc *rcrtc, > u32 reg, u32 set) > > void rcar_du_crtc_dsysr_clr_set(struct rcar_du_crtc *rcrtc, u32 clr, u32 set) > { > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > > rcrtc->dsysr = (rcrtc->dsysr & ~clr) | set; > rcar_du_write(rcdu, rcrtc->mmio_offset + DSYSR, rcrtc->dsysr); > @@ -157,10 +157,9 @@ static void rcar_du_dpll_divider(struct rcar_du_crtc > *rcrtc, > } > > done: > - dev_dbg(rcrtc->group->dev->dev, > + dev_dbg(rcrtc->dev->dev, > "output:%u, fdpll:%u, n:%u, m:%u, diff:%lu\n", > - dpll->output, dpll->fdpll, dpll->n, dpll->m, > - best_diff); > + dpll->output, dpll->fdpll, dpll->n, dpll->m, best_diff); > } > > struct du_clk_params { > @@ -212,7 +211,7 @@ static const struct soc_device_attribute > rcar_du_r8a7795_es1[] = { > static void rcar_du_crtc_set_display_timing(struct rcar_du_crtc *rcrtc) > { > const struct drm_display_mode *mode = &rcrtc->crtc.state->adjusted_mode; > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > unsigned long mode_clock = mode->clock * 1000; > u32 dsmr; > u32 escr; > @@ -277,7 +276,7 @@ static void rcar_du_crtc_set_display_timing(struct > rcar_du_crtc *rcrtc) > rcar_du_escr_divider(rcrtc->extclock, mode_clock, >ESCR_DCLKSEL_DCLKIN, ¶ms); > > - dev_dbg(rcrtc->group->dev->dev, "mode clock %lu %s rate %lu\n", > + dev_dbg(rcrtc->dev->dev, "mode clock %lu %s rate %lu\n", > mode_clock, params.clk == rcrtc->clock ? "cpg" : "ext", > params.rate); > > @@ -285,7 +284,7 @@ static void rcar_du_crtc_set_display_timing(struct > rcar_du_crtc *rcrtc) > escr = params.escr; > } > > - dev_dbg(rcrtc->group->dev->dev, "%s: ESCR 0x%08x\n", __func__, escr); > + dev_dbg(rcrtc->dev->dev, "%s: ESCR 0x%08x\n", __func__, escr); > > rcar_du_crtc_write(rcrtc, rcrtc->index % 2 ? ESCR13 : ESCR02, escr); > rcar_du_crtc_write(rcrtc, rcrtc->index % 2 ? OTAR13 : OTAR02, 0); > @@ -333,7 +332,7 @@ plane_format(struct rcar_du_plane *plane) > static void rcar_du_crtc_update_planes(struct rcar_du_crtc *rcrtc) > { > struct rcar_du_plane *planes[RCAR_DU_NUM_HW_PLANES]; > - struct rcar_du_device *rcdu = rcrtc->group->dev; > + struct rcar_du_device *rcdu = rcrtc->dev; > unsigned int num_pla
[PATCH v10 0/7] Support Trusted Foundations firmware on Tegra30
Hello, This patchset adds support for the Trusted Foundations firmware on NVIDIA Tegra30. Pretty much all of Tegra30 consumer devices have that firmware and upstream kernel can't boot on those devices without the firmware support. This series was tested on Nexus 7, TF300T and Ouya Tegra30 devices. Changelog: v10:- Removed duplicated message about keeping L2C disabled when CONFIG_TRUSTED_FOUNDATIONS=n as was suggested by Michał Mirosław in the review comment to v9. v9: - Rebased on recent linux-next, resolved one conflict. v8: - Replaced BIT() macro with a definition provided by cache-l2x0.h in the "Support L2 cache maintenance" patch as was suggested by Russell King in the review comment to v7. v7: - Fixed kernel booting with CONFIG_TRUSTED_FOUNDATIONS=n by providing a dummy L2C write_sec implementation in the "Support L2 cache maintenance" patch. - Minor clean up: no static variables anymore, replaced white spaces with a tab in one place, etc. - Added Michał's and Robert's Tested-by/Signed-off-by to the patches. v6: - One patch got messed up accidentally in v5, this is fixed now. - Squashed "Support L2 cache maintenance done via firmware" patch into the "Add firmware calls..." patch. - The l2x0_init() firmware callback is now invoked unconditionally because it is always a NO-OP on T114+ and is a NO-OP on T20/30 if firmware node is missed in device-tree, hence there is no need to check the machine's DT compatible as it was done in the previous versions of the series. v5: - Fixed machine hanging on disabling D-cache during suspend, turned out there are slight variations in behaviour between firmware version in regards to cache-management. Thanks to Robert Yang for reporting the problem and helping with the solution. v4: - Fixed Thumb2-kernel hanging on Tegra20, turned out it was not a good idea to switch CPU into Thumb2 mode right after jumping into the reset handler. - Moved LP2-mode-set firmware call invocation to a later stage to better replicate what downstream kernel does. This change was suggested by Robert Yang and fixes system hang on Ouya game console. - Added references to the original work made by Michał Mirosław into commit messages of the relevant patches. v3: - Implemented suspend-resume support. - Reworked arm/firmware/trusted_foundations.c a tad. Now cache is getting properly initialized, cache enabling / disabling is supported. v2: - The "Don't apply CPU erratas in insecure mode" patch got some cleanup, in particular resolved the messiness in __tegra_cpu_reset_handler_data. - Added a comment to tf_cache_write_sec(), justifying the warning message. Dmitry Osipenko (7): ARM: trusted_foundations: Support L2 cache maintenance ARM: trusted_foundations: Make prepare_idle call to take mode argument ARM: trusted_foundations: Provide information about whether firmware is registered ARM: tegra: Set up L2 cache using Trusted Foundations firmware ARM: tegra: Don't apply CPU erratas in insecure mode ARM: tegra: Always boot CPU in ARM-mode ARM: tegra: Add firmware calls required for suspend-resume on Tegra30 arch/arm/firmware/trusted_foundations.c| 75 +- arch/arm/include/asm/firmware.h| 2 +- arch/arm/include/asm/trusted_foundations.h | 23 +++ arch/arm/mach-tegra/cpuidle-tegra114.c | 3 +- arch/arm/mach-tegra/pm.c | 49 ++ arch/arm/mach-tegra/reset-handler.S| 50 +++ arch/arm/mach-tegra/reset.c| 3 + arch/arm/mach-tegra/reset.h| 9 ++- arch/arm/mach-tegra/sleep-tegra20.S| 4 ++ arch/arm/mach-tegra/sleep.S| 14 ++-- arch/arm/mach-tegra/tegra.c| 2 + 11 files changed, 212 insertions(+), 22 deletions(-) -- 2.20.1
[PATCH v10 2/7] ARM: trusted_foundations: Make prepare_idle call to take mode argument
The Trusted Foundations firmware call varies depending on the required suspend-mode. Make the firmware API to take the mode argument in order to expose all of the modes to firmware user. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c| 29 -- arch/arm/include/asm/firmware.h| 2 +- arch/arm/include/asm/trusted_foundations.h | 6 + arch/arm/mach-tegra/cpuidle-tegra114.c | 3 ++- 4 files changed, 36 insertions(+), 4 deletions(-) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index d7ac05103a52..720904a43c00 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -67,9 +67,34 @@ static int tf_set_cpu_boot_addr(int cpu, unsigned long boot_addr) return 0; } -static int tf_prepare_idle(void) +static int tf_prepare_idle(unsigned long mode) { - tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, cpu_boot_addr); + switch (mode) { + case TF_PM_MODE_LP0: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S3, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2, cpu_boot_addr); + break; + + case TF_PM_MODE_LP1_NO_MC_CLK: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S2_NO_MC_CLK, + cpu_boot_addr); + break; + + case TF_PM_MODE_LP2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1, cpu_boot_addr); + break; + + case TF_PM_MODE_LP2_NOFLUSH_L2: + tf_generic_smc(TF_CPU_PM, TF_CPU_PM_S1_NOFLUSH_L2, + cpu_boot_addr); + break; + + default: + return -EINVAL; + } return 0; } diff --git a/arch/arm/include/asm/firmware.h b/arch/arm/include/asm/firmware.h index 34c1d96ef46d..6698272bbcbf 100644 --- a/arch/arm/include/asm/firmware.h +++ b/arch/arm/include/asm/firmware.h @@ -24,7 +24,7 @@ struct firmware_ops { /* * Inform the firmware we intend to enter CPU idle mode */ - int (*prepare_idle)(void); + int (*prepare_idle)(unsigned long mode); /* * Enters CPU idle mode */ diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 9e6a41e9215e..201ceb259e71 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -35,6 +35,12 @@ #include #include +#define TF_PM_MODE_LP0 0 +#define TF_PM_MODE_LP1 1 +#define TF_PM_MODE_LP1_NO_MC_CLK 2 +#define TF_PM_MODE_LP2 3 +#define TF_PM_MODE_LP2_NOFLUSH_L2 4 + struct trusted_foundations_platform_data { unsigned int version_major; unsigned int version_minor; diff --git a/arch/arm/mach-tegra/cpuidle-tegra114.c b/arch/arm/mach-tegra/cpuidle-tegra114.c index e3fbcfedf845..3b9af4766cdf 100644 --- a/arch/arm/mach-tegra/cpuidle-tegra114.c +++ b/arch/arm/mach-tegra/cpuidle-tegra114.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "cpuidle.h" @@ -46,7 +47,7 @@ static int tegra114_idle_power_down(struct cpuidle_device *dev, tegra_set_cpu_in_lp2(); cpu_pm_enter(); - call_firmware_op(prepare_idle); + call_firmware_op(prepare_idle, TF_PM_MODE_LP2_NOFLUSH_L2); /* Do suspend by ourselves if the firmware does not implement it */ if (call_firmware_op(do_idle, 0) == -ENOSYS) -- 2.20.1
[PATCH v10 3/7] ARM: trusted_foundations: Provide information about whether firmware is registered
Add a helper that provides information about whether Trusted Foundations firmware operations have been registered. Tested-by: Robert Yang Tested-by: Michał Mirosław Signed-off-by: Dmitry Osipenko --- arch/arm/firmware/trusted_foundations.c| 5 + arch/arm/include/asm/trusted_foundations.h | 7 +++ 2 files changed, 12 insertions(+) diff --git a/arch/arm/firmware/trusted_foundations.c b/arch/arm/firmware/trusted_foundations.c index 720904a43c00..bb2ee73d9e02 100644 --- a/arch/arm/firmware/trusted_foundations.c +++ b/arch/arm/firmware/trusted_foundations.c @@ -167,3 +167,8 @@ void of_register_trusted_foundations(void) panic("Trusted Foundation: missing version-minor property\n"); register_trusted_foundations(&pdata); } + +bool trusted_foundations_registered(void) +{ + return firmware_ops == &trusted_foundations_ops; +} diff --git a/arch/arm/include/asm/trusted_foundations.h b/arch/arm/include/asm/trusted_foundations.h index 201ceb259e71..54513c533811 100644 --- a/arch/arm/include/asm/trusted_foundations.h +++ b/arch/arm/include/asm/trusted_foundations.h @@ -31,6 +31,7 @@ #include #include #include +#include #include #include @@ -50,6 +51,7 @@ struct trusted_foundations_platform_data { void register_trusted_foundations(struct trusted_foundations_platform_data *pd); void of_register_trusted_foundations(void); +bool trusted_foundations_registered(void); #else /* CONFIG_TRUSTED_FOUNDATIONS */ static inline void tf_dummy_write_sec(unsigned long val, unsigned int reg) @@ -84,6 +86,11 @@ static inline void of_register_trusted_foundations(void) if (of_find_compatible_node(NULL, NULL, "tlm,trusted-foundations")) register_trusted_foundations(NULL); } + +static inline bool trusted_foundations_registered(void) +{ + return false; +} #endif /* CONFIG_TRUSTED_FOUNDATIONS */ #endif -- 2.20.1
Re: [RFC] simple_lmk: Introduce Simple Low Memory Killer for Android
On Sun, Mar 17, 2019 at 10:16 AM Serge E. Hallyn wrote: > > On Sun, Mar 17, 2019 at 10:11:10AM -0700, Daniel Colascione wrote: > > On Sun, Mar 17, 2019 at 9:35 AM Serge E. Hallyn wrote: > > > > > > On Sun, Mar 17, 2019 at 12:42:40PM +0100, Christian Brauner wrote: > > > > On Sat, Mar 16, 2019 at 09:53:06PM -0400, Joel Fernandes wrote: > > > > > On Sat, Mar 16, 2019 at 12:37:18PM -0700, Suren Baghdasaryan wrote: > > > > > > On Sat, Mar 16, 2019 at 11:57 AM Christian Brauner > > > > > > wrote: > > > > > > > > > > > > > > On Sat, Mar 16, 2019 at 11:00:10AM -0700, Daniel Colascione wrote: > > > > > > > > On Sat, Mar 16, 2019 at 10:31 AM Suren Baghdasaryan > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > On Fri, Mar 15, 2019 at 11:49 AM Joel Fernandes > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > On Fri, Mar 15, 2019 at 07:24:28PM +0100, Christian Brauner > > > > > > > > > > wrote: > > > > > > > > > > [..] > > > > > > > > > > > > why do we want to add a new syscall (pidfd_wait) > > > > > > > > > > > > though? Why not just use > > > > > > > > > > > > standard poll/epoll interface on the proc fd like > > > > > > > > > > > > Daniel was suggesting. > > > > > > > > > > > > AFAIK, once the proc file is opened, the struct pid is > > > > > > > > > > > > essentially pinned > > > > > > > > > > > > even though the proc number may be reused. Then the > > > > > > > > > > > > caller can just poll. > > > > > > > > > > > > We can add a waitqueue to struct pid, and wake up any > > > > > > > > > > > > waiters on process > > > > > > > > > > > > death (A quick look shows task_struct can be mapped to > > > > > > > > > > > > its struct pid) and > > > > > > > > > > > > also possibly optimize it using Steve's TIF flag idea. > > > > > > > > > > > > No new syscall is > > > > > > > > > > > > needed then, let me know if I missed something? > > > > > > > > > > > > > > > > > > > > > > Huh, I thought that Daniel was against the poll/epoll > > > > > > > > > > > solution? > > > > > > > > > > > > > > > > > > > > Hmm, going through earlier threads, I believe so now. Here > > > > > > > > > > was Daniel's > > > > > > > > > > reasoning about avoiding a notification about process death > > > > > > > > > > through proc > > > > > > > > > > directory fd: > > > > > > > > > > http://lkml.iu.edu/hypermail/linux/kernel/1811.0/00232.html > > > > > > > > > > > > > > > > > > > > May be a dedicated syscall for this would be cleaner after > > > > > > > > > > all. > > > > > > > > > > > > > > > > > > Ah, I wish I've seen that discussion before... > > > > > > > > > syscall makes sense and it can be non-blocking and we can use > > > > > > > > > select/poll/epoll if we use eventfd. > > > > > > > > > > > > > > > > Thanks for taking a look. > > > > > > > > > > > > > > > > > I would strongly advocate for > > > > > > > > > non-blocking version or at least to have a non-blocking > > > > > > > > > option. > > > > > > > > > > > > > > > > Waiting for FD readiness is *already* blocking or non-blocking > > > > > > > > according to the caller's desire --- users can pass options > > > > > > > > they want > > > > > > > > to poll(2) or whatever. There's no need for any kind of special > > > > > > > > configuration knob or non-blocking option. We already *have* a > > > > > > > > non-blocking option that works universally for everything. > > > > > > > > > > > > > > > > As I mentioned in the linked thread, waiting for process exit > > > > > > > > should > > > > > > > > work just like waiting for bytes to appear on a pipe. Process > > > > > > > > exit > > > > > > > > status is just another blob of bytes that a process might > > > > > > > > receive. A > > > > > > > > process exit handle ought to be just another information > > > > > > > > source. The > > > > > > > > reason the unix process API is so awful is that for whatever > > > > > > > > reason > > > > > > > > the original designers treated processes as some kind of > > > > > > > > special kind > > > > > > > > of resource instead of fitting them into the otherwise > > > > > > > > general-purpose > > > > > > > > unix data-handling API. Let's not repeat that mistake. > > > > > > > > > > > > > > > > > Something like this: > > > > > > > > > > > > > > > > > > evfd = eventfd(0, EFD_NONBLOCK | EFD_CLOEXEC); > > > > > > > > > // register eventfd to receive death notification > > > > > > > > > pidfd_wait(pid_to_kill, evfd); > > > > > > > > > // kill the process > > > > > > > > > pidfd_send_signal(pid_to_kill, ...) > > > > > > > > > // tend to other things > > > > > > > > > > > > > > > > Now you've lost me. pidfd_wait should return a *new* FD, not > > > > > > > > wire up > > > > > > > > an eventfd. > > > > > > > > > > > > > > > > > > > > Ok, I probably misunderstood your post linked by Joel. I though your > > > > > > original proposal was based on being able to poll a file under > > > > > > /proc/pid and then you changed your mind to have a separate syscall > > > > > > which I assu
Linux 5.1-rc1
It's Sunday, and two weeks have passed, and everything is normal. You all know the drill by now - the merge window is closed, and things are supposed to calm down. The merge window felt fairly normal to me. And looking at the stats, nothing really odd stands out either. It's a regular sized release (which obviously means "big" - , but it's not bigger than usual) and the bulk of it (just over 60%) is drivers. All kinds of drivers, the one that stands out for being different is the habanalabs AI accelerator chip driver, but I suspect we'll be starting to see more of that kind of stuff. But there are all the usual suspects too - gpu, networking, block devices etc etc. A somewhat recent development is how the tools/testing/ updates have been quite noticeable lately. That's not new to the 5.1 merge window, it's been going on for a while, but it's maybe just worth a mention that we have more new selftest changes than we have architecture updates, for example. The documentation subdirectory is also quite noticeable. But on the whole, there's really stuff all over, including core VFS updates (in addition to all the usual low-level filesystem updates too, of course). And as always, the shortlog is much too big to post with 11k+ commits (12k+ if counting merges). So below is my usual "mergelog" listing submaintainers and a summary of the git pulls I've done from them.. Go forth and test, Linus --- Al Viro (5): vfs fixes misc vfs updates iov_iter updates vfs mount infrastructure updates vfs mount infrastructure fix Alex Williamson (1): VFIO updates Alexandre Belloni (1): RTC updates Andrew Morton (5): misc updates x3 more updates the left-over patches Arnd Bergmann (8): y2038 build fix for compat mode asm-generic updates ARM SoC platform updates ARM SoC device tree updates ARM SoC driver updates ARM SoC defconfig updates ARM new SoC family support ARM SoC late updates Bartlomiej Zolnierkiewicz (1): fbdev updates Benson Leung (1): chrome platform updates Bjorn Andersson (1): remoteproc updates Bjorn Helgaas (1): PCI updates Bob Peterson (1): gfs2 updates Boris Brezillon (2): MTD updates i3c updates Borislav Petkov (2): EDAC updates RAS updates Bruce Fields (1): NFS server updates Catalin Marinas (1): arm64 updates Christian Brauner (1): pidfd system call Christoph Hellwig (1): DMA mapping updates Corey Minyard (1): IPMI updates Dan Williams (3): filesystem-dax updates libnvdimm updates device-dax updates Darren Hart (1): x86 platform driver updates Darrick Wong (2): xfs updates xfs cleanups Dave Airlie (2): drm updates drm fixes and updates David Miller (4): networking updates networking fixes IDE updates networking fixes David Sterba (2): btrfs updates btrfs fixes Dennis Zhou (1): percpu updates Dmitry Torokhov (1): input updates Dominique Martinet (1): 9p updates Eduardo Valentin (1): thermal soc updates Eric Biggers (1): fscrypt updates Geert Uytterhoeven (1): m68k updates Greg KH (5): char/misc driver updates driver core updates staging/IIO updates tty/serial updates USB/PHY updates Greg Ungerer (1): m68knommu update Guenter Roeck (1): hwmon updates Helge Deller (1): parisc updates Herbert Xu (2): crypto update crypto fixes Ilya Dryomov (1): ceph updates Ingo Molnar (14): RCU updates EFI updates locking updates perf updates scheduler updates x86 alternative instruction updates x86 boot updates x86 build updates x86 cleanups x86 fpu updates x86 kdump update x86 mm cleanup x86 platform update x86 UV updates Jacek Anaszewski (1): LED updates Jaegeuk Kim (1): f2fs updates James Bottomley (2): SCSI updates more SCSI updates James Morris (3): security subsystem updates integrity updates tpm updates Jan Kara (3): dtype handling cleanups ext2 and udf fixes fanotify updates Jason Gunthorpe (1): rdma updates Jassi Brar (1): mailbox updates Jens Axboe (4): libata updates block layer updates io_uring IO interface more block layer changes Jiri Kosina (2): livepatching updates HID updates Joerg Roedel (2): IOMMU updates IOMMU fix John Johansen (1): apparmor fixes Jon Mason (1): NTB updates Jonathan Corbet (1): documentation updates Juergen Gross (2): xen updates xen fix Kees Cook (2): pstore cleanups gcc-plugins updates Konrad Rzeszutek Wilk (2): swiotlb updates ibft updates Lee Jones (2): backlight fixlet MFD updates Ley Foon Tan (1): nios2 updates Linus Walleij (2): GPIO updates pin control updates Mark Brown (3): regmap updates regulator updates spi updates Martin Schwidefsky (1): s390 updates
Re: [GIT PULL] PCI changes for v5.1
On Fri, Mar 8, 2019 at 9:31 AM Bjorn Helgaas wrote: > > - Report PCIe links that become degraded at run-time (Alexandru Gagniuc) Gaah. Only now as I'm about to do the rc1 release am I looking at new runtime warnings, and noticing that this causes genirq: Threaded irq requested with handler=NULL and !ONESHOT for irq 16 pcie_bw_notification: probe of :00:1b.0:pcie010 failed with error -22 because you can't have a NULL handler for a level-triggered interrupt (you need something to shut the interrupt off so that it doesn't keep screaming!). Happens on both my desktop and my laptop, regular intel CPU and chipset, nothing odd in either case. Everything else works, but the new BW notification obviously will never work this way. This is not holding up rc1, obviously, but I thought I'd mention it since I noticed it as part of my "let's see that nothing regressed" checks.. Linus
Re: [GIT PULL] more Kbuild updates for v5.1
The pull request you sent on Mon, 18 Mar 2019 00:59:54 +0900: > git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild.git > tags/kbuild-v5.1-2 has been merged into torvalds/linux.git: https://git.kernel.org/torvalds/c/28d747f266fb73cd28a1b9a174cc3738fc177b00 Thank you! -- Deet-doot-dot, I am a bot. https://korg.wiki.kernel.org/userdoc/prtracker
[PATCH v3 4/4] MAINTAINERS: add maintainer for maxbotix ultrasonic driver
add a maintainer for the newly created ultrasonic driver family of maxbotix Signed-off-by: Andreas Klinger --- MAINTAINERS | 7 +++ 1 file changed, 7 insertions(+) diff --git a/MAINTAINERS b/MAINTAINERS index dce5c099f43c..fa054f8cc7fb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -9234,6 +9234,13 @@ S: Maintained F: Documentation/devicetree/bindings/sound/max9860.txt F: sound/soc/codecs/max9860.* +MAXBOTIX ULTRASONIC RANGER IIO DRIVER +M: Andreas Klinger +L: linux-...@vger.kernel.org +S: Maintained +F: Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt +F: drivers/iio/proximity/mb1232.c + MAXIM MAX77802 PMIC REGULATOR DEVICE DRIVER M: Javier Martinez Canillas L: linux-kernel@vger.kernel.org -- 2.11.0
[PATCH v3 3/4] mb1232.c: add distance iio sensor with i2c
Add I2CXL-MaxSonar ultrasonic distance sensors of types mb1202, mb1212, mb1222, mb1232, mb1242, mb7040, mb7137 using an i2c interface Implemented functionality: - reading the distance via in_distance_raw - buffered mode with trigger - make use of interrupt to announce completion of ranging Add mb1232 driver to Kconfig and Makefile Signed-off-by: Andreas Klinger --- drivers/iio/proximity/Kconfig | 12 ++ drivers/iio/proximity/Makefile | 1 + drivers/iio/proximity/mb1232.c | 274 + 3 files changed, 287 insertions(+) create mode 100644 drivers/iio/proximity/mb1232.c diff --git a/drivers/iio/proximity/Kconfig b/drivers/iio/proximity/Kconfig index b99367a89f81..12a3d3d40a91 100644 --- a/drivers/iio/proximity/Kconfig +++ b/drivers/iio/proximity/Kconfig @@ -45,6 +45,18 @@ config LIDAR_LITE_V2 To compile this driver as a module, choose M here: the module will be called pulsedlight-lite-v2 +config MB1232 + tristate "MaxSonar I2CXL family ultrasonic sensors" + depends on I2C + help + Say Y to build a driver for the ultrasonic sensors I2CXL of + MaxBotix which have an i2c interface. It can be used to measure + the distance of objects. Supported types are mb1202, mb1212, + mb1222, mb1232, mb1242, mb7040, mb7137 + + To compile this driver as a module, choose M here: the + module will be called mb1232. + config RFD77402 tristate "RFD77402 ToF sensor" depends on I2C diff --git a/drivers/iio/proximity/Makefile b/drivers/iio/proximity/Makefile index 6d031f903c4c..0bb5f9de13d6 100644 --- a/drivers/iio/proximity/Makefile +++ b/drivers/iio/proximity/Makefile @@ -7,6 +7,7 @@ obj-$(CONFIG_AS3935) += as3935.o obj-$(CONFIG_ISL29501) += isl29501.o obj-$(CONFIG_LIDAR_LITE_V2)+= pulsedlight-lidar-lite-v2.o +obj-$(CONFIG_MB1232) += mb1232.o obj-$(CONFIG_RFD77402) += rfd77402.o obj-$(CONFIG_SRF04)+= srf04.o obj-$(CONFIG_SRF08)+= srf08.o diff --git a/drivers/iio/proximity/mb1232.c b/drivers/iio/proximity/mb1232.c new file mode 100644 index ..d061cb16da93 --- /dev/null +++ b/drivers/iio/proximity/mb1232.c @@ -0,0 +1,274 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * mb1232.c - Support for MaxBotix I2CXL-MaxSonar-EZ series ultrasonic + * ranger with i2c interface + * actually tested with mb1232 type + * + * Copyright (c) 2019 Andreas Klinger + * + * For details about the device see: + * https://www.maxbotix.com/documents/I2CXL-MaxSonar-EZ_Datasheet.pdf + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* registers of MaxSonar device */ +#define MB1232_RANGE_COMMAND 0x51/* Command for reading range */ +#define MB1232_ADDR_UNLOCK_1 0xAA/* Command 1 for changing address */ +#define MB1232_ADDR_UNLOCK_2 0xA5/* Command 2 for changing address */ + +struct mb1232_data { + struct i2c_client *client; + + struct mutexlock; + + /* +* optionally a gpio can be used to announce when ranging has +* finished +* since we are just using the falling trigger of it we request +* only the interrupt for announcing when data is ready to be read +*/ + struct completion ranging; + int irqnr; +}; + +static irqreturn_t mb1232_handle_irq(int irq, void *dev_id) +{ + struct iio_dev *indio_dev = dev_id; + struct mb1232_data *data = iio_priv(indio_dev); + + complete(&data->ranging); + + return IRQ_HANDLED; +} + +static s16 mb1232_read_distance(struct mb1232_data *data) +{ + struct i2c_client *client = data->client; + int ret; + s16 distance; + __be16 buf; + + mutex_lock(&data->lock); + + reinit_completion(&data->ranging); + + ret = i2c_smbus_write_byte(client, MB1232_RANGE_COMMAND); + if (ret < 0) { + dev_err(&client->dev, "write command - err: %d\n", ret); + goto error_unlock; + } + + if (data->irqnr >= 0) { + /* it cannot take more than 100 ms */ + ret = wait_for_completion_killable_timeout(&data->ranging, + HZ/10); + if (ret < 0) + goto error_unlock; + else if (ret == 0) { + ret = -ETIMEDOUT; + goto error_unlock; + } + } else { + /* use simple sleep if announce irq is not connected */ + msleep(15); + } + + ret = i2c_master_recv(client, (char *)&buf, sizeof(buf)); + if (ret < 0) { + dev_err(&client->dev, "i2c_master_recv: ret=%d\n", ret); + goto error_unlock; + } + + distance = __be16_to_cpu(buf); + /* check
[PATCH v3 2/4] dt-bindings: maxbotix,mb1232: Add MaxBotix i2c ultrasonic rangers
Add doc for dt binding maxbotix,mb1232. This binding is for MaxBotix I2CXL-MaxSonar ultrasonic rangers which share a common i2c interface. Signed-off-by: Andreas Klinger --- .../bindings/iio/proximity/maxbotix,mb1232.txt | 31 ++ 1 file changed, 31 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt diff --git a/Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt b/Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt new file mode 100644 index ..0e9df87eca1d --- /dev/null +++ b/Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt @@ -0,0 +1,31 @@ +* MaxBotix I2CXL-MaxSonar ultrasonic distance sensor of type mb1202, + mb1212, mb1222, mb1232, mb1242, mb7040 or mb7137 using the i2c interface + for ranging + +Required properties: + - compatible: "maxbotix,mb1202", + "maxbotix,mb1212", + "maxbotix,mb1222", + "maxbotix,mb1232", + "maxbotix,mb1242", + "maxbotix,mb7040" or + "maxbotix,mb7137" + + - reg:i2c address of the device, see also i2c/i2c.txt + +Optional properties: + - interrupt-parent: Interrupt controller to use + + - interrupts: Interrupt used to announce the preceding reading + request has finished and that data is available. + If no interrupt is specified the device driver + falls back to wait a fixed amount of time until + data can be retrieved. + +Example: +proximity@70 { + compatible = "maxbotix,mb1232"; + reg = <0x70>; + interrupt-parent = <&gpio2>; + interrupts = <2 IRQ_TYPE_EDGE_FALLING>; +}; -- 2.11.0
[PATCH v3 1/4] dt-bindings: Add vendor prefix for MaxBotix
Add MaxBotix, which is a vendor of ultrasonic rangers in different varieties and interfaces. Signed-off-by: Andreas Klinger Reviewed-by: Andreas Färber Reviewed-by: Rob Herring --- Documentation/devicetree/bindings/vendor-prefixes.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt b/Documentation/devicetree/bindings/vendor-prefixes.txt index 389508584f48..added54a1108 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.txt +++ b/Documentation/devicetree/bindings/vendor-prefixes.txt @@ -225,6 +225,7 @@ lsi LSI Corp. (LSI Logic) lwnLiebherr-Werk Nenzing GmbH macnicaMacnica Americas marvellMarvell Technology Group Ltd. +maxbotix MaxBotix Inc. maxim Maxim Integrated Products mbvl Mobiveil Inc. mcube mCube -- 2.11.0
[PATCH v3 0/4] add MaxBotix I2CXL ultrasonic iio driver
This patch series adds support for I2CXL-MaxSonar ultrasonic distance sensors with i2c interface of vendor MaxBotix Supported types are: mb1202, mb1212, mb1222, mb1232, mb1242, mb7040, mb7137 Implemented and tested functionality: - reading the distance via in_distance_raw - buffered mode with trigger - make use of irq to announce completion of ranging Changes in v3: Thanks to the review of Julia, Jonathan, Rob and Peter there are some changes: - fix missing mutex_unlock() in mb1232_read_distance() - change file and function names to the tested type mb1232 - list all supported types in {of,i2c}_device_id as well as in Kconfig - reduce former status gpio to pure interrupt for announcement of finished read cycle Changes in v2: Thanks to the review of Andreas and Peter there are a couple of changes: - rename type wildcard mb12x2 to i2cxl in dt binding - split changes in vendor list and dt doc into two patches - merge driver source and Kconfig/Makefile change into one patch - reword dt documentation - use directly __be16 datatype to read directly from i2c - use s16 as return value from mb12x2_read_distance() Andreas Klinger (4): dt-bindings: Add vendor prefix for MaxBotix dt-bindings: maxbotix,mb1232: Add MaxBotix i2c ultrasonic rangers mb1232.c: add distance iio sensor with i2c MAINTAINERS: add maintainer for maxbotix ultrasonic driver .../bindings/iio/proximity/maxbotix,mb1232.txt | 31 +++ .../devicetree/bindings/vendor-prefixes.txt| 1 + MAINTAINERS| 7 + drivers/iio/proximity/Kconfig | 12 + drivers/iio/proximity/Makefile | 1 + drivers/iio/proximity/mb1232.c | 274 + 6 files changed, 326 insertions(+) create mode 100644 Documentation/devicetree/bindings/iio/proximity/maxbotix,mb1232.txt create mode 100644 drivers/iio/proximity/mb1232.c -- 2.11.0
Dear Friend,
Dear Friend, I am Mrs Alice Johnson.am sending you this brief letter to solicit your partnership to transfer $23.5 million US Dollars.I shall send you more information and procedures when I receive positive response from you. please send me a message in my Email box (mrsalicejohns...@gmail.com) as i wait to hear from you. Best regard Mrs Alice Johnson
Dear Friend,
Dear Friend, I am Mrs Alice Johnson.am sending you this brief letter to solicit your partnership to transfer $23.5 million US Dollars.I shall send you more information and procedures when I receive positive response from you. please send me a message in my Email box (mrsalicejohns...@gmail.com) as i wait to hear from you. Best regard Mrs Alice Johnson
[PATCH 14/15] habanalabs: keep track of the device's dma mask
This patch refactors the code that is responsible to set the DMA mask for the device. Upon each change of the dma mask, the driver will save the new value that was set. This is needed in order to make sure we don't try to increase the mask a second time, in case we failed in the first time. This is especially relevant for Power machines, as that may cause a change in configuration of the TVT which will break the device. Goya will first try to set the device's dma mask to 39 bits, so that the memory that is allocated on the host machine for communication with the device's cpu will be in a bus address which is lower then 39 bits. Later, Goya will try to increase that mask to 48 bits, but only if setting the mask to 39 bits was successful. Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/goya/goya.c | 32 drivers/misc/habanalabs/habanalabs.h | 5 +- drivers/misc/habanalabs/habanalabs_drv.c | 3 ++ drivers/misc/habanalabs/pci.c| 64 ++-- 4 files changed, 65 insertions(+), 39 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index b474651db0e5..a4bb963e33fa 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -483,7 +483,7 @@ static int goya_early_init(struct hl_device *hdev) prop->dram_pci_bar_size = pci_resource_len(pdev, DDR_BAR_ID); - rc = hl_pci_init(hdev); + rc = hl_pci_init(hdev, 39); if (rc) return rc; @@ -2446,28 +2446,16 @@ static int goya_hw_init(struct hl_device *hdev) goto disable_msix; } - /* CPU initialization is finished, we can now move to 48 bit DMA mask */ - rc = pci_set_dma_mask(hdev->pdev, DMA_BIT_MASK(48)); - if (rc) { - dev_warn(hdev->dev, "Unable to set pci dma mask to 48 bits\n"); - rc = pci_set_dma_mask(hdev->pdev, DMA_BIT_MASK(32)); - if (rc) { - dev_err(hdev->dev, - "Unable to set pci dma mask to 32 bits\n"); - goto disable_pci_access; - } - } - - rc = pci_set_consistent_dma_mask(hdev->pdev, DMA_BIT_MASK(48)); - if (rc) { - dev_warn(hdev->dev, - "Unable to set pci consistent dma mask to 48 bits\n"); - rc = pci_set_consistent_dma_mask(hdev->pdev, DMA_BIT_MASK(32)); - if (rc) { - dev_err(hdev->dev, - "Unable to set pci consistent dma mask to 32 bits\n"); + /* +* Check if we managed to set the DMA mask to more then 32 bits. If so, +* let's try to increase it again because in Goya we set the initial +* dma mask to less then 39 bits so that the allocation of the memory +* area for the device's cpu will be under 39 bits +*/ + if (hdev->dma_mask > 32) { + rc = hl_pci_set_dma_mask(hdev, 48); + if (rc) goto disable_pci_access; - } } /* Perform read from the device to flush all MSI-X configuration */ diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h index 6991a7f260e8..e9253d937bfc 100644 --- a/drivers/misc/habanalabs/habanalabs.h +++ b/drivers/misc/habanalabs/habanalabs.h @@ -1106,6 +1106,7 @@ struct hl_device_reset_work { * @init_done: is the initialization of the device done. * @mmu_enable: is MMU enabled. * @device_cpu_disabled: is the device CPU disabled (due to timeouts) + * @dma_mask: the dma mask that was set for this device */ struct hl_device { struct pci_dev *pdev; @@ -1176,6 +1177,7 @@ struct hl_device { u8 dram_default_page_mapping; u8 init_done; u8 device_cpu_disabled; + u8 dma_mask; /* Parameters for bring-up */ u8 mmu_enable; @@ -1397,8 +1399,9 @@ int hl_pci_set_dram_bar_base(struct hl_device *hdev, u8 inbound_region, u8 bar, u64 addr); int hl_pci_init_iatu(struct hl_device *hdev, u64 sram_base_address, u64 dram_base_address, u64 host_phys_size); -int hl_pci_init(struct hl_device *hdev); +int hl_pci_init(struct hl_device *hdev, u8 dma_mask); void hl_pci_fini(struct hl_device *hdev); +int hl_pci_set_dma_mask(struct hl_device *hdev, u8 dma_mask); long hl_get_frequency(struct hl_device *hdev, u32 pll_index, bool curr); void hl_set_frequency(struct hl_device *hdev, u32 pll_index, u64 freq); diff --git a/drivers/misc/habanalabs/habanalabs_drv.c b/drivers/misc/habanalabs/habanalabs_drv.c index 748601463f11..b697339d3904 100644 --- a/drivers/misc/habanalabs/habanalabs_drv.c +++ b/drivers/misc/habanalabs/habanalabs_drv
[PATCH 06/15] habanalabs: remove unused defines
This patch removes some old defines which are not in use anymore. Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/goya/goyaP.h | 14 ++ 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goyaP.h b/drivers/misc/habanalabs/goya/goyaP.h index 6fdc76b5bde0..ae5e41bc8f7f 100644 --- a/drivers/misc/habanalabs/goya/goyaP.h +++ b/drivers/misc/habanalabs/goya/goyaP.h @@ -54,11 +54,9 @@ /* DRAM Memory Map */ #define CPU_FW_IMAGE_SIZE 0x1000 /* 256MB */ -#define MMU_PAGE_TABLES_SIZE 0x0DE0 /* 222MB */ +#define MMU_PAGE_TABLES_SIZE 0x0FC0 /* 252MB */ #define MMU_DRAM_DEFAULT_PAGE_SIZE 0x0020 /* 2MB */ #define MMU_CACHE_MNG_SIZE 0x1000 /* 4KB */ -#define CPU_PQ_PKT_SIZE0x1000 /* 4KB */ -#define CPU_PQ_DATA_SIZE 0x01FFE000 /* 32MB - 8KB */ #define CPU_FW_IMAGE_ADDR DRAM_PHYS_BASE #define MMU_PAGE_TABLES_ADDR (CPU_FW_IMAGE_ADDR + CPU_FW_IMAGE_SIZE) @@ -66,13 +64,13 @@ MMU_PAGE_TABLES_SIZE) #define MMU_CACHE_MNG_ADDR (MMU_DRAM_DEFAULT_PAGE_ADDR + \ MMU_DRAM_DEFAULT_PAGE_SIZE) -#define CPU_PQ_PKT_ADDR(MMU_CACHE_MNG_ADDR + \ +#define DRAM_KMD_END_ADDR (MMU_CACHE_MNG_ADDR + \ MMU_CACHE_MNG_SIZE) -#define CPU_PQ_DATA_ADDR (CPU_PQ_PKT_ADDR + CPU_PQ_PKT_SIZE) -#define DRAM_BASE_ADDR_USER(CPU_PQ_DATA_ADDR + CPU_PQ_DATA_SIZE) -#if (DRAM_BASE_ADDR_USER != 0x2000) -#error "KMD must reserve 512MB" +#define DRAM_BASE_ADDR_USER0x2000 + +#if (DRAM_KMD_END_ADDR > DRAM_BASE_ADDR_USER) +#error "KMD must reserve no more than 512MB" #endif /* -- 2.17.1
[PATCH 04/15] habanalabs: Move device CPU code into common file
From: Tomer Tayar This patch moves the code that is responsible of the communication vs. the F/W to a dedicated file. This will allow us to share the code between different ASICs. Signed-off-by: Tomer Tayar Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/Makefile | 2 +- drivers/misc/habanalabs/firmware_if.c | 324 +++ drivers/misc/habanalabs/goya/goya.c| 360 - drivers/misc/habanalabs/goya/goyaP.h | 11 - drivers/misc/habanalabs/habanalabs.h | 17 + drivers/misc/habanalabs/include/armcp_if.h | 8 + 6 files changed, 407 insertions(+), 315 deletions(-) create mode 100644 drivers/misc/habanalabs/firmware_if.c diff --git a/drivers/misc/habanalabs/Makefile b/drivers/misc/habanalabs/Makefile index c6592db59b25..598740d235f8 100644 --- a/drivers/misc/habanalabs/Makefile +++ b/drivers/misc/habanalabs/Makefile @@ -6,7 +6,7 @@ obj-m := habanalabs.o habanalabs-y := habanalabs_drv.o device.o context.o asid.o habanalabs_ioctl.o \ command_buffer.o hw_queue.o irq.o sysfs.o hwmon.o memory.o \ - command_submission.o mmu.o + command_submission.o mmu.o firmware_if.o habanalabs-$(CONFIG_DEBUG_FS) += debugfs.o diff --git a/drivers/misc/habanalabs/firmware_if.c b/drivers/misc/habanalabs/firmware_if.c new file mode 100644 index ..9bf5203e8922 --- /dev/null +++ b/drivers/misc/habanalabs/firmware_if.c @@ -0,0 +1,324 @@ +// SPDX-License-Identifier: GPL-2.0 + +/* + * Copyright 2016-2019 HabanaLabs, Ltd. + * All Rights Reserved. + */ + +#include "habanalabs.h" + +#include +#include + +/** + * hl_fw_push_fw_to_device() - Push FW code to device. + * @hdev: pointer to hl_device structure. + * + * Copy fw code from firmware file to device memory. + * + * Return: 0 on success, non-zero for failure. + */ +int hl_fw_push_fw_to_device(struct hl_device *hdev, const char *fw_name, + void __iomem *dst) +{ + const struct firmware *fw; + const u64 *fw_data; + size_t fw_size, i; + int rc; + + rc = request_firmware(&fw, fw_name, hdev->dev); + if (rc) { + dev_err(hdev->dev, "Failed to request %s\n", fw_name); + goto out; + } + + fw_size = fw->size; + if ((fw_size % 4) != 0) { + dev_err(hdev->dev, "illegal %s firmware size %zu\n", + fw_name, fw_size); + rc = -EINVAL; + goto out; + } + + dev_dbg(hdev->dev, "%s firmware size == %zu\n", fw_name, fw_size); + + fw_data = (const u64 *) fw->data; + + if ((fw->size % 8) != 0) + fw_size -= 8; + + for (i = 0 ; i < fw_size ; i += 8, fw_data++, dst += 8) { + if (!(i & (0x8 - 1))) { + dev_dbg(hdev->dev, + "copied so far %zu out of %zu for %s firmware", + i, fw_size, fw_name); + usleep_range(20, 100); + } + + writeq(*fw_data, dst); + } + + if ((fw->size % 8) != 0) + writel(*(const u32 *) fw_data, dst); + +out: + release_firmware(fw); + return rc; +} + +int hl_fw_send_pci_access_msg(struct hl_device *hdev, u32 opcode) +{ + struct armcp_packet pkt = {}; + + pkt.ctl = cpu_to_le32(opcode << ARMCP_PKT_CTL_OPCODE_SHIFT); + + return hdev->asic_funcs->send_cpu_message(hdev, (u32 *) &pkt, + sizeof(pkt), HL_DEVICE_TIMEOUT_USEC, NULL); +} + +int hl_fw_send_cpu_message(struct hl_device *hdev, u32 hw_queue_id, u32 *msg, + u16 len, u32 timeout, long *result) +{ + struct armcp_packet *pkt; + dma_addr_t pkt_dma_addr; + u32 tmp; + int rc = 0; + + if (len > HL_CPU_CB_SIZE) { + dev_err(hdev->dev, "Invalid CPU message size of %d bytes\n", + len); + return -ENOMEM; + } + + pkt = hdev->asic_funcs->cpu_accessible_dma_pool_alloc(hdev, len, + &pkt_dma_addr); + if (!pkt) { + dev_err(hdev->dev, + "Failed to allocate DMA memory for packet to CPU\n"); + return -ENOMEM; + } + + memcpy(pkt, msg, len); + + mutex_lock(&hdev->send_cpu_message_lock); + + if (hdev->disabled) + goto out; + + if (hdev->device_cpu_disabled) { + rc = -EIO; + goto out; + } + + rc = hl_hw_queue_send_cb_no_cmpl(hdev, hw_queue_id, len, pkt_dma_addr); + if (rc) { + dev_err(hdev->dev, "Failed to send CB on CPU PQ (%d)\n", rc); + goto out; + } + + rc = hl_poll_timeout_memory(hdev, (u64) (uintptr_t) &pkt->fence, + timeout, &tmp); + + hl_hw_queue_inc_ci_kernel(hdev,
[PATCH 07/15] habanalabs: ratelimit warnings at start of IOCTLs
At the start of some IOCTLs we check if the device is disabled or in reset. If it is, we return -EBUSY and print a message to kernel log. Because these IOCTLs can be called at very high frequency, use ratelimit to avoid spamming the kernel log. Also use the same type of message - dev_warn - in all the relevant IOCTLs. Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/command_submission.c | 2 +- drivers/misc/habanalabs/habanalabs_ioctl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/misc/habanalabs/command_submission.c b/drivers/misc/habanalabs/command_submission.c index 19c84214a7ea..f908643f871f 100644 --- a/drivers/misc/habanalabs/command_submission.c +++ b/drivers/misc/habanalabs/command_submission.c @@ -604,7 +604,7 @@ int hl_cs_ioctl(struct hl_fpriv *hpriv, void *data) bool need_soft_reset = false; if (hl_device_disabled_or_in_reset(hdev)) { - dev_warn(hdev->dev, + dev_warn_ratelimited(hdev->dev, "Device is %s. Can't submit new CS\n", atomic_read(&hdev->in_reset) ? "in_reset" : "disabled"); rc = -EBUSY; diff --git a/drivers/misc/habanalabs/habanalabs_ioctl.c b/drivers/misc/habanalabs/habanalabs_ioctl.c index 2c2739a3c5ec..19b96afc0308 100644 --- a/drivers/misc/habanalabs/habanalabs_ioctl.c +++ b/drivers/misc/habanalabs/habanalabs_ioctl.c @@ -106,7 +106,7 @@ static int hl_info_ioctl(struct hl_fpriv *hpriv, void *data) int rc; if (hl_device_disabled_or_in_reset(hdev)) { - dev_err(hdev->dev, + dev_warn_ratelimited(hdev->dev, "Device is disabled or in reset. Can't execute INFO IOCTL\n"); return -EBUSY; } -- 2.17.1
[PATCH 13/15] habanalabs: add MMU shadow mapping
From: Omer Shpigelman This patch adds shadow mapping to the MMU module. The shadow mapping allows traversing the page table in host memory rather reading each PTE from the device memory. It brings better performance and avoids reading from invalid device address upon PCI errors. Only at the end of map/unmap flow, writings to the device are performed in order to sync the H/W page tables with the shadow ones. Signed-off-by: Omer Shpigelman Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/habanalabs.h | 24 +- .../include/hw_ip/mmu/mmu_general.h | 16 +- drivers/misc/habanalabs/mmu.c | 597 ++ 3 files changed, 353 insertions(+), 284 deletions(-) diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h index 9cc841777d81..6991a7f260e8 100644 --- a/drivers/misc/habanalabs/habanalabs.h +++ b/drivers/misc/habanalabs/habanalabs.h @@ -51,8 +51,9 @@ /** * struct pgt_info - MMU hop page info. - * @node: hash linked-list node for the pgts hash of pgts. - * @addr: physical address of the pgt. + * @node: hash linked-list node for the pgts shadow hash of pgts. + * @phys_addr: physical address of the pgt. + * @shadow_addr: shadow hop in the host. * @ctx: pointer to the owner ctx. * @num_of_ptes: indicates how many ptes are used in the pgt. * @@ -62,10 +63,11 @@ * page, it is freed with its pgt_info structure. */ struct pgt_info { - struct hlist_node node; - u64 addr; - struct hl_ctx *ctx; - int num_of_ptes; + struct hlist_node node; + u64 phys_addr; + u64 shadow_addr; + struct hl_ctx *ctx; + int num_of_ptes; }; struct hl_device; @@ -595,7 +597,8 @@ struct hl_va_range { * struct hl_ctx - user/kernel context. * @mem_hash: holds mapping from virtual address to virtual memory area * descriptor (hl_vm_phys_pg_list or hl_userptr). - * @mmu_hash: holds a mapping from virtual address to pgt_info structure. + * @mmu_phys_hash: holds a mapping from physical address to pgt_info structure. + * @mmu_shadow_hash: holds a mapping from shadow address to pgt_info structure. * @hpriv: pointer to the private (KMD) data of the process (fd). * @hdev: pointer to the device structure. * @refcount: reference counter for the context. Context is released only when @@ -624,7 +627,8 @@ struct hl_va_range { */ struct hl_ctx { DECLARE_HASHTABLE(mem_hash, MEM_HASH_TABLE_BITS); - DECLARE_HASHTABLE(mmu_hash, MMU_HASH_TABLE_BITS); + DECLARE_HASHTABLE(mmu_phys_hash, MMU_HASH_TABLE_BITS); + DECLARE_HASHTABLE(mmu_shadow_hash, MMU_HASH_TABLE_BITS); struct hl_fpriv *hpriv; struct hl_device*hdev; struct kref refcount; @@ -1066,7 +1070,8 @@ struct hl_device_reset_work { * @asic_specific: ASIC specific information to use only from ASIC files. * @mmu_pgt_pool: pool of available MMU hops. * @vm: virtual memory manager for MMU. - * @mmu_cache_lock: protects MMU cache invalidation as it can serve one context + * @mmu_cache_lock: protects MMU cache invalidation as it can serve one context. + * @mmu_shadow_hop0: shadow mapping of the MMU hop 0 zone. * @hwmon_dev: H/W monitor device. * @pm_mng_profile: current power management profile. * @hl_chip_info: ASIC's sensors information. @@ -1136,6 +1141,7 @@ struct hl_device { struct gen_pool *mmu_pgt_pool; struct hl_vmvm; struct mutexmmu_cache_lock; + void*mmu_shadow_hop0; struct device *hwmon_dev; enum hl_pm_mng_profile pm_mng_profile; struct hwmon_chip_info *hl_chip_info; diff --git a/drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h b/drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h index b680052ee3f0..71ea3c3e8ba3 100644 --- a/drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h +++ b/drivers/misc/habanalabs/include/hw_ip/mmu/mmu_general.h @@ -14,16 +14,16 @@ #define PAGE_SIZE_4KB (_AC(1, UL) << PAGE_SHIFT_4KB) #define PAGE_MASK_2MB (~(PAGE_SIZE_2MB - 1)) -#define PAGE_PRESENT_MASK 0x1 -#define SWAP_OUT_MASK 0x4 -#define LAST_MASK 0x00800 -#define PHYS_ADDR_MASK 0x3F000ull +#define PAGE_PRESENT_MASK 0x1ull +#define SWAP_OUT_MASK 0x4ull +#define LAST_MASK 0x00800ull +#define PHYS_ADDR_MASK 0xF000ull #define HOP0_MASK 0x3ull #define HOP1_MASK 0x0FF80ull #define HOP2_MASK 0x0007FC000ull -#define HOP3_MASK 0x03FE00
[PATCH 09/15] habanalabs: Remove unneeded function pointers
From: Tomer Tayar Remove pointers to ASIC-specific functions and instead call the functions explicitly as they are not accessed from outside the ASIC-specific files. Signed-off-by: Tomer Tayar Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/goya/goya.c | 12 +++- drivers/misc/habanalabs/goya/goyaP.h | 4 +--- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 7e98383ec774..466464c026e0 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -299,7 +299,6 @@ static u32 goya_all_events[] = { GOYA_ASYNC_EVENT_ID_DMA_BM_CH4 }; -static int goya_armcp_info_get(struct hl_device *hdev); static void goya_mmu_prepare(struct hl_device *hdev, u32 asid); static int goya_mmu_clear_pgt_range(struct hl_device *hdev); static int goya_mmu_set_dram_default_page(struct hl_device *hdev); @@ -539,10 +538,9 @@ static void goya_fetch_psoc_frequency(struct hl_device *hdev) static int goya_late_init(struct hl_device *hdev) { struct asic_fixed_properties *prop = &hdev->asic_prop; - struct goya_device *goya = hdev->asic_specific; int rc; - rc = goya->armcp_info_get(hdev); + rc = goya_armcp_info_get(hdev); if (rc) { dev_err(hdev->dev, "Failed to get armcp info\n"); return rc; @@ -629,9 +627,6 @@ static int goya_sw_init(struct hl_device *hdev) if (!goya) return -ENOMEM; - goya->test_cpu_queue = goya_test_cpu_queue; - goya->armcp_info_get = goya_armcp_info_get; - /* according to goya_init_iatu */ goya->ddr_bar_cur_addr = DRAM_PHYS_BASE; @@ -2969,7 +2964,6 @@ int goya_test_cpu_queue(struct hl_device *hdev) static int goya_test_queues(struct hl_device *hdev) { - struct goya_device *goya = hdev->asic_specific; int i, rc, ret_val = 0; for (i = 0 ; i < NUMBER_OF_EXT_HW_QUEUES ; i++) { @@ -2979,7 +2973,7 @@ static int goya_test_queues(struct hl_device *hdev) } if (hdev->cpu_queues_enable) { - rc = goya->test_cpu_queue(hdev); + rc = goya_test_cpu_queue(hdev); if (rc) ret_val = -EINVAL; } @@ -4657,7 +4651,7 @@ int goya_send_heartbeat(struct hl_device *hdev) return hl_fw_send_heartbeat(hdev); } -static int goya_armcp_info_get(struct hl_device *hdev) +int goya_armcp_info_get(struct hl_device *hdev) { struct goya_device *goya = hdev->asic_specific; struct asic_fixed_properties *prop = &hdev->asic_prop; diff --git a/drivers/misc/habanalabs/goya/goyaP.h b/drivers/misc/habanalabs/goya/goyaP.h index ae5e41bc8f7f..b99d92f197eb 100644 --- a/drivers/misc/habanalabs/goya/goyaP.h +++ b/drivers/misc/habanalabs/goya/goyaP.h @@ -143,9 +143,6 @@ enum goya_fw_component { }; struct goya_device { - int (*test_cpu_queue)(struct hl_device *hdev); - int (*armcp_info_get)(struct hl_device *hdev); - /* TODO: remove hw_queues_lock after moving to scheduler code */ spinlock_t hw_queues_lock; @@ -176,6 +173,7 @@ void goya_debugfs_led_set(struct hl_device *hdev, u8 led, u8 state); void goya_set_pll_profile(struct hl_device *hdev, enum hl_pll_frequency freq); void goya_add_device_attr(struct hl_device *hdev, struct attribute_group *dev_attr_grp); +int goya_armcp_info_get(struct hl_device *hdev); void goya_init_security(struct hl_device *hdev); u64 goya_get_max_power(struct hl_device *hdev); void goya_set_max_power(struct hl_device *hdev, u64 value); -- 2.17.1
[PATCH 10/15] uapi/habanalabs: add some comments in habanalabs.h
This patch adds two comments in uapi/habanalabs.h: - From which queue id the internal queues begin - Invalid values that can be returned in the seq field from the CS IOCTL Signed-off-by: Oded Gabbay --- include/uapi/misc/habanalabs.h | 7 +-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/uapi/misc/habanalabs.h b/include/uapi/misc/habanalabs.h index 7fd6f633534c..ab1957e31077 100644 --- a/include/uapi/misc/habanalabs.h +++ b/include/uapi/misc/habanalabs.h @@ -33,7 +33,7 @@ enum goya_queue_id { GOYA_QUEUE_ID_DMA_3, GOYA_QUEUE_ID_DMA_4, GOYA_QUEUE_ID_CPU_PQ, - GOYA_QUEUE_ID_MME, + GOYA_QUEUE_ID_MME, /* Internal queues start here */ GOYA_QUEUE_ID_TPC0, GOYA_QUEUE_ID_TPC1, GOYA_QUEUE_ID_TPC2, @@ -181,7 +181,10 @@ struct hl_cs_in { }; struct hl_cs_out { - /* this holds the sequence number of the CS to pass to wait ioctl */ + /* +* seq holds the sequence number of the CS to pass to wait ioctl. All +* values are valid except for 0 and ULLONG_MAX +*/ __u64 seq; /* HL_CS_STATUS_* */ __u32 status; -- 2.17.1
[PATCH 11/15] habanalabs: Add a printout with the name of a busy engine
From: Tomer Tayar Print the name of a busy engine when checking if a device is idle. The change is done mainly to help a user to pinpoint problems in his topology's recipe. Signed-off-by: Tomer Tayar Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/goya/goya.c| 24 -- drivers/misc/habanalabs/habanalabs.h | 8 +++- drivers/misc/habanalabs/habanalabs_ioctl.c | 2 +- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 466464c026e0..b474651db0e5 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -2784,6 +2784,7 @@ static int goya_send_job_on_qman0(struct hl_device *hdev, struct hl_cs_job *job) dma_addr_t fence_dma_addr; struct hl_cb *cb; u32 tmp, timeout; + char buf[16] = {}; int rc; if (hdev->pldm) @@ -2791,9 +2792,10 @@ static int goya_send_job_on_qman0(struct hl_device *hdev, struct hl_cs_job *job) else timeout = HL_DEVICE_TIMEOUT_USEC; - if (!hdev->asic_funcs->is_device_idle(hdev)) { + if (!hdev->asic_funcs->is_device_idle(hdev, buf, sizeof(buf))) { dev_err_ratelimited(hdev->dev, - "Can't send KMD job on QMAN0 if device is not idle\n"); + "Can't send KMD job on QMAN0 because %s is busy\n", + buf); return -EBUSY; } @@ -4692,7 +4694,7 @@ static void goya_disable_clock_gating(struct hl_device *hdev) } -static bool goya_is_device_idle(struct hl_device *hdev) +static bool goya_is_device_idle(struct hl_device *hdev, char *buf, size_t size) { u64 offset, dma_qm_reg, tpc_qm_reg, tpc_cmdq_reg, tpc_cfg_reg; int i; @@ -4704,7 +4706,7 @@ static bool goya_is_device_idle(struct hl_device *hdev) if ((RREG32(dma_qm_reg) & DMA_QM_IDLE_MASK) != DMA_QM_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "DMA%d_QM", i); } offset = mmTPC1_QM_GLBL_STS0 - mmTPC0_QM_GLBL_STS0; @@ -4716,31 +4718,31 @@ static bool goya_is_device_idle(struct hl_device *hdev) if ((RREG32(tpc_qm_reg) & TPC_QM_IDLE_MASK) != TPC_QM_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "TPC%d_QM", i); if ((RREG32(tpc_cmdq_reg) & TPC_CMDQ_IDLE_MASK) != TPC_CMDQ_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "TPC%d_CMDQ", i); if ((RREG32(tpc_cfg_reg) & TPC_CFG_IDLE_MASK) != TPC_CFG_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "TPC%d_CFG", i); } if ((RREG32(mmMME_QM_GLBL_STS0) & MME_QM_IDLE_MASK) != MME_QM_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "MME_QM"); if ((RREG32(mmMME_CMDQ_GLBL_STS0) & MME_CMDQ_IDLE_MASK) != MME_CMDQ_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "MME_CMDQ"); if ((RREG32(mmMME_ARCH_STATUS) & MME_ARCH_IDLE_MASK) != MME_ARCH_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "MME_ARCH"); if (RREG32(mmMME_SHADOW_0_STATUS) & MME_SHADOW_IDLE_MASK) - return false; + return HL_ENG_BUSY(buf, size, "MME"); return true; } diff --git a/drivers/misc/habanalabs/habanalabs.h b/drivers/misc/habanalabs/habanalabs.h index ed3649d38ff8..9cc841777d81 100644 --- a/drivers/misc/habanalabs/habanalabs.h +++ b/drivers/misc/habanalabs/habanalabs.h @@ -555,7 +555,7 @@ struct hl_asic_funcs { int (*send_heartbeat)(struct hl_device *hdev); void (*enable_clock_gating)(struct hl_device *hdev); void (*disable_clock_gating)(struct hl_device *hdev); - bool (*is_device_idle)(struct hl_device *hdev); + bool (*is_device_idle)(struct hl_device *hdev, char *buf, size_t size); int (*soft_reset_late_init)(struct hl_device *hdev); void (*hw_queues_lock)(struct hl_device *hdev); void (*hw_queues_unlock)(struct hl_device *hdev); @@ -1010,6 +1010,12 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val); WREG32(mm##reg, (RREG32(mm##reg) & ~REG_FIELD_MASK(reg, field)) | \ (val) << REG_FIELD_SHIFT(reg, field)) +#define HL_ENG_BUSY(buf, size, fmt, ...) ({ \ + if (buf) \ + snprintf(buf, size, fmt, ##__VA_ARGS__); \ + false; \ + }) + struct hwmon_chip_info; /** diff --git a/drivers/misc/habanalabs/habanalabs_ioctl.c b/drivers/m
[PATCH 15/15] habanalabs: never fail hard reset of device
Hard-reset of our device should never fail, due to dangers of permanent damage to the H/W. This patch removes the last place in the reset path where the driver might exit before doing the actual reset. Signed-off-by: Oded Gabbay --- drivers/misc/habanalabs/device.c | 19 +-- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/drivers/misc/habanalabs/device.c b/drivers/misc/habanalabs/device.c index 77d51be66c7e..c51d1062d0bc 100644 --- a/drivers/misc/habanalabs/device.c +++ b/drivers/misc/habanalabs/device.c @@ -663,17 +663,9 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, /* Go over all the queues, release all CS and their jobs */ hl_cs_rollback_all(hdev); - if (hard_reset) { - /* Release kernel context */ - if (hl_ctx_put(hdev->kernel_ctx) != 1) { - dev_err(hdev->dev, - "kernel ctx is alive during hard reset\n"); - rc = -EBUSY; - goto out_err; - } - + /* Release kernel context */ + if ((hard_reset) && (hl_ctx_put(hdev->kernel_ctx) == 1)) hdev->kernel_ctx = NULL; - } /* Reset the H/W. It will be in idle state after this returns */ hdev->asic_funcs->hw_fini(hdev, hard_reset); @@ -699,6 +691,13 @@ int hl_device_reset(struct hl_device *hdev, bool hard_reset, if (hard_reset) { hdev->device_cpu_disabled = false; + if (hdev->kernel_ctx) { + dev_crit(hdev->dev, + "kernel ctx was alive during hard reset, something is terribly wrong\n"); + rc = -EBUSY; + goto out_err; + } + /* Allocate the kernel context */ hdev->kernel_ctx = kzalloc(sizeof(*hdev->kernel_ctx), GFP_KERNEL); -- 2.17.1