Commit Graph

49448 Commits

Author SHA1 Message Date
Suren Baghdasaryan
86628dac3f Revert "Move sync logic out of select_energy_cpu_brute"
This reverts commits I1ecd8de6af010248ebc9daa5f80689f521500fc9 and
I4731bd9fdbf278c4ba55f3abc8c9ed4fa54a31cf.

bug: 65016902

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2017-08-29 21:59:19 +00:00
Alexander Potapenko
3aae5d3671 UPSTREAM: llist: clang: introduce member_address_is_nonnull()
Currently llist_for_each_entry() and llist_for_each_entry_safe() iterate
until &pos->member != NULL.  But when building the kernel with Clang,
the compiler assumes &pos->member cannot be NULL if the member's offset
is greater than 0 (which would be equivalent to the object being
non-contiguous in memory).  Therefore the loop condition is always true,
and the loops become infinite.

To work around this, introduce the member_address_is_nonnull() macro,
which casts object pointer to uintptr_t, thus letting the member pointer
to be NULL.

Change-Id: I1f9541591bba1f2ca16ecbb0248555298df4bee5
Fixes: 64082472
Signed-off-by: Alexander Potapenko <glider@google.com>
Tested-by: Sodagudi Prasad <psodagud@codeaurora.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-08-29 01:36:36 +00:00
Nick Desaulniers
605c2ff1ab Revert "Fix for compilation with clang"
This reverts commit 79de094039.

Bug: 64082472
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-08-28 16:44:11 -07:00
David Lin
d3bd509bb7 Revert "Revert "UPSTREAM: lib: update LZ4 compressor module""
This reverts commit 166eb72c6f.

Bug: 62425246
Change-Id: I1cb2317d238fa434cd7dfcbf416c964d1cd09afe
Signed-off-by: David Lin <dtwlin@google.com>
2017-08-21 14:08:12 -07:00
David Lin
b04deafd73 Revert "Revert "UPSTREAM: lz4: fix wrong compress buffer size for 64-bits""
This reverts commit e9fd5d282b.

Bug: 62425246
Change-Id: Ib951a09454b248961c25ffd5ebf9b12e3d665de8
Signed-off-by: David Lin <dtwlin@google.com>
2017-08-21 14:06:24 -07:00
Suren Baghdasaryan
9767a33691 Move sync logic out of select_energy_cpu_brute
Original patch was cherry-picked from 3.18 kernel,
commit 324181821c790ca02a2180ff01576d3c4d15fa6d
("Move sync logic to be run always") and reworked to account for
differences in want_affine calculations.

Lift sync logic out of select_energy_cpu_brute() and run that logic before
select_idle_sibling() or select_energy_cpu_brute().

At high CPU utilization, the scheduler falls back to
select_idle_sibling().  On Marlin, select_idle_sibling() wasn't
respecting the sync flag to force the task to be scheduled on the same
CPU.  This caused the sync flag to be ignored and thrash on binder with
sync enabled.  This fixes the thrash we saw.

Bug 38260530
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1ecd8de6af010248ebc9daa5f80689f521500fc9
2017-08-21 20:51:51 +00:00
Andy Lutomirski
06dbabbcfa UPSTREAM: kdb: use task_cpu() instead of task_thread_info()->cpu
commit e558af65be65713ef2e8b2aa637c6263caeed172 upstream.

We'll need this cleanup to make the cpu field in thread_info be
optional.

Link: http://lkml.kernel.org/r/da298328dc77ea494576c2f20a934218e758a6fa.1468523549.git.luto@kernel.org
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 64672701
Change-Id: I0cd616f086f0eb54ed997ea153382fbf6188dba9
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:28:17 +01:00
Mark Rutland
5fc2fed169 UPSTREAM: thread_info: include <current.h> for THREAD_INFO_IN_TASK
When CONFIG_THREAD_INFO_IN_TASK is selected, the current_thread_info()
macro relies on current having been defined prior to its use. However,
not all users of current_thread_info() include <asm/current.h>, and thus
current is not guaranteed to be defined.

When CONFIG_THREAD_INFO_IN_TASK is not selected, it's possible that
get_current() / current are based upon current_thread_info(), and
<asm/current.h> includes <asm/thread_info.h>. Thus always including
<asm/current.h> would result in circular dependences on some platforms.

To ensure both cases work, this patch includes <asm/current.h>, but only
when CONFIG_THREAD_INFO_IN_TASK is selected.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 64672701
Change-Id: Ia981a829798d60a54d4e3eb679d8e24b01228357
(cherry picked from commit dc3d2a679cd8631b8a570fc8ca5f4712d7d25698)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Mark Rutland
e4c94ca0a8 UPSTREAM: thread_info: factor out restart_block
Since commit f56141e3e2 ("all arches, signal: move restart_block
to struct task_struct"), thread_info and restart_block have been
logically distinct, yet struct restart_block is still defined in
<linux/thread_info.h>.

At least one architecture (erroneously) uses restart_block as part of
its thread_info, and thus the definition of restart_block must come
before the include of <asm/thread_info>. Subsequent patches in this
series need to shuffle the order of includes and definitions in
<linux/thread_info.h>, and will make this ordering fragile.

This patch moves the definition of restart_block out to its own header.
This serves as generic cleanup, logically separating thread_info and
restart_block, and also makes it easier to avoid fragility.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Andy Lutomirski <luto@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Kees Cook <keescook@chromium.org>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>

Bug: 64672701
Change-Id: I4283c87072c092179e2b6c02cbf7248b4a1c2d22
(cherry picked from commit 53d74d056a4e306a72b8883d325b5d853c0618e6)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Andy Lutomirski
dcbbf866f6 UPSTREAM: sched/core: Add try_get_task_stack() and put_task_stack()
There are a few places in the kernel that access stack memory
belonging to a different task.  Before we can start freeing task
stacks before the task_struct is freed, we need a way for those code
paths to pin the stack.

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jann Horn <jann@thejh.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/17a434f50ad3d77000104f21666575e10a9c1fbd.1474003868.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Bug: 64672701
Change-Id: I414853e9b72ecb0967d5e1cbfc77b4929bf3f4f5
(cherry picked from commit c6c314a613cd7d03fb97713e0d642b493de42e69)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Andy Lutomirski
fb96dbf756 UPSTREAM: sched/core: Allow putting thread_info into task_struct
If an arch opts in by setting CONFIG_THREAD_INFO_IN_TASK_STRUCT,
then thread_info is defined as a single 'u32 flags' and is the first
entry of task_struct.  thread_info::task is removed (it serves no
purpose if thread_info is embedded in task_struct), and
thread_info::cpu gets its own slot in task_struct.

This is heavily based on a patch written by Linus.

Originally-from: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jann Horn <jann@thejh.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/a0898196f0476195ca02713691a5037a14f2aac5.1473801993.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>

Bug: 64672701
Change-Id: I25e5a830f2ada5e74fa93661e97e5e701b1b70d2
(cherry picked from commit c65eacbe290b8141554c71b2c94489e73ade8c8d)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Linus Torvalds
3fc908be7d UPSTREAM: fix up initial thread stack pointer vs thread_info confusion
The INIT_TASK() initializer was similarly confused about the stack vs
thread_info allocation that the allocators had, and that were fixed in
commit b235beea9e99 ("Clarify naming of thread info/stack allocators").

The task ->stack pointer only incidentally ends up having the same value
as the thread_info, and in fact that will change.

So fix the initial task struct initializer to point to 'init_stack'
instead of 'init_thread_info', and make sure the ia64 definition for
that exists.

This actually makes the ia64 tsk->stack pointer be sensible for the
initial task, but not for any other task.  As mentioned in commit
b235beea9e99, that whole pointer isn't actually used on ia64, since
task_stack_page() there just points to the (single) allocation.

All the other architectures seem to have copied the 'init_stack'
definition, even if it tended to be generally unusued.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 64672701
Change-Id: Ia96e9225b07e38df2f4af2b9a7eb2aa972d8845a
(cherry picked from commit 7f1a00b6fcd0e3c19beba2e92d157dc0c2cf3494)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Linus Torvalds
059eb79ae9 UPSTREAM: Clarify naming of thread info/stack allocators
We've had the thread info allocated together with the thread stack for
most architectures for a long time (since the thread_info was split off
from the task struct), but that is about to change.

But the patches that move the thread info to be off-stack (and a part of
the task struct instead) made it clear how confused the allocator and
freeing functions are.

Because the common case was that we share an allocation with the thread
stack and the thread_info, the two pointers were identical.  That
identity then meant that we would have things like

	ti = alloc_thread_info_node(tsk, node);
	...
	tsk->stack = ti;

which certainly _worked_ (since stack and thread_info have the same
value), but is rather confusing: why are we assigning a thread_info to
the stack? And if we move the thread_info away, the "confusing" code
just gets to be entirely bogus.

So remove all this confusion, and make it clear that we are doing the
stack allocation by renaming and clarifying the function names to be
about the stack.  The fact that the thread_info then shares the
allocation is an implementation detail, and not really about the
allocation itself.

This is a pure renaming and type fix: we pass in the same pointer, it's
just that we clarify what the pointer means.

The ia64 code that actually only has one single allocation (for all of
task_struct, thread_info and kernel thread stack) now looks a bit odd,
but since "tsk->stack" is actually not even used there, that oddity
doesn't matter.  It would be a separate thing to clean that up, I
intentionally left the ia64 changes as a pure brute-force renaming and
type change.

Acked-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 64672701
Change-Id: I870b5476fc900c9145134f9dd3ed18a32a490162
(cherry picked from commit b235beea9e996a4d36fed6cfef4801a3e7d7a9a5)
Signed-off-by: Zubin Mithra <zsm@google.com>
2017-08-21 16:04:11 +01:00
Andres Oportus
fc4ac15a00 ANDROID: cpufreq: stats: add per task/uid/freq/cluster stats
Adds:
-Per task nodes in /proc/PID/time_in_state showing per
frequency(state)/cluster(policy) times
-Global /proc/uid_time_in_state showing per uid/frequency/cluster
times including uid removal from /proc/uid_cputime/remove_uid_range
-Global all_time_in_state showing per frequency/cluster/cpu times

Bug: 62303881
Bug: 62340637

Tests: Reading /proc/$$/time_in_state, /proc/uid_time_in_state, and
/sys/devices/system/cpu/cpufreq/all_time_in_state. Writing
/proc/uid_cputime/remove_uid_range

Change-Id: I222843b6f714717da9377817c19ac0d5400cb41a
Signed-off-by: Andres Oportus <andresoportus@google.com>
2017-08-11 03:06:50 +00:00
jonghyun26.kim
406c8fa289 input: touch: ftm4: Add awareness of charger connection
When the charger is connected, ta_detect_pin setting high.
When the charger is disconnected, ta_detect_pin setting low.

Bug: 63785418
Change-Id: Iff4e735eac9eb344bfa2734a981f45be6e38a458
Signed-off-by: jonghyun26.kim <jonghyun26.kim@lge.com>
Signed-off-by; Devin Kim <dojip.kim@lge.com>
2017-08-02 22:47:26 +00:00
vivek mehta
2eed597e9c drivers: mfd: implement auto recovery for slim tx ports
Implement auto recovery mechanism for slimbus TX ports
in overflow scenarios for wcd934x audio codec.

Bug: 63692798
CRs-Fixed: 1110511
Change-Id: Ie64eca908afe168d2fccd11ce6e85cf6ff83a064
Signed-off-by: Phani Kumar Uppalapati <phaniu@codeaurora.org>
Signed-off-by: vivek mehta <mvivek@codeaurora.org>
2017-08-01 19:12:56 +00:00
Ian Abbott
bb123be2ff BACKPORT: kernel.h: handle pointers to arrays better in container_of()
If the first parameter of container_of() is a pointer to a
non-const-qualified array type (and the third parameter names a
non-const-qualified array member), the local variable __mptr will be
defined with a const-qualified array type.  In ISO C, these types are
incompatible.  They work as expected in GNU C, but some versions will
issue warnings.  For example, GCC 4.9 produces the warning
"initialization from incompatible pointer type".

Here is an example of where the problem occurs:

-------------------------------------------------------

MODULE_LICENSE("GPL");

struct st {
  int a;
  char b[16];
};

static int __init example_init(void) {
  struct st t = { .a = 101, .b = "hello" };
  char (*p)[16] = &t.b;
  struct st *x = container_of(p, struct st, b);
  printk(KERN_DEBUG "%p %p\n", (void *)&t, (void *)x);
  return 0;
}

static void __exit example_exit(void) {
}

module_init(example_init);
module_exit(example_exit);
-------------------------------------------------------

Building the module with gcc-4.9 results in these warnings (where '{m}'
is the module source and '{k}' is the kernel source):

-------------------------------------------------------
  In file included from {m}/example.c:1:0:
  {m}/example.c: In function `example_init':
  {k}/include/linux/kernel.h:854:48: warning: initialization from
incompatible pointer type
    const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                  ^
  {m}/example.c:14:17: note: in expansion of macro `container_of'
    struct st *x = container_of(p, struct st, b);
                   ^
  {k}/include/linux/kernel.h:854:48: warning: (near initialization
for `x')
    const typeof( ((type *)0)->member ) *__mptr = (ptr); \
                                                  ^
  {m}/example.c:14:17: note: in expansion of macro `container_of'
    struct st *x = container_of(p, struct st, b);
                   ^
-------------------------------------------------------

Replace the type checking performed by the macro to avoid these
warnings.  Make sure `*(ptr)` either has type compatible with the
member, or has type compatible with `void`, ignoring qualifiers.
Raise
compiler errors if this is not true.  This is stronger than the
previous
behaviour, which only resulted in compiler warnings for a type
mismatch.

[arnd@arndb.de: fix new warnings for container_of()]
Link: http://lkml.kernel.org/r/20170620200940.90557-1-arnd@arndb.de
Link: http://lkml.kernel.org/r/20170525120316.24473-7-abbotti@mev.co.uk
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Michal Nazarewicz <mina86@mina86.com>)
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: Borislav Petkov <bp@suse.de>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Johannes Berg <johannes.berg@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Alexander Potapenko <glider@google.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bug: 62057517
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Change-Id: Idab195e2b20ae0ca2e405dd8a0c6744f5e381ef8
2017-07-31 20:36:32 -07:00
Ian Abbott
27dcc91fd5 BACKPORT: bug: split BUILD_BUG stuff out into <linux/build_bug.h>
Including <linux/bug.h> pulls in a lot of bloat from <asm/bug.h> and
<asm-generic/bug.h> that is not needed to call the BUILD_BUG() family of
macros.  Split them out into their own header, <linux/build_bug.h>.

Also correct some checkpatch.pl errors for the BUILD_BUG_ON_ZERO() and
BUILD_BUG_ON_NULL() macros by adding parentheses around the bitfield
widths that begin with a minus sign.

Change-Id: Icb4a456a5fcc21953c4e1df17fe3c4f41105996e
Link: http://lkml.kernel.org/r/20170525120316.24473-6-abbotti@mev.co.uk
Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
Acked-by: Kees Cook <keescook@chromium.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bug: 62057517
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-31 20:36:32 -07:00
Matthias Kaehlcke
100bebfb5c UPSTREAM: jiffies.h: declare jiffies and jiffies_64 with ____cacheline_aligned_in_smp
jiffies_64 is defined in kernel/time/timer.c with
____cacheline_aligned_in_smp, however this macro is not part of the
declaration of jiffies and jiffies_64 in jiffies.h.

As a result clang generates the following warning:

  kernel/time/timer.c:57:26: error: section does not match previous declaration [-Werror,-Wsection]
  __visible u64 jiffies_64 __cacheline_aligned_in_smp = INITIAL_JIFFIES;
                           ^
  include/linux/cache.h:39:36: note: expanded from macro '__cacheline_aligned_in_smp'
                                     ^
  include/linux/cache.h:34:4: note: expanded from macro '__cacheline_aligned'
                   __section__(".data..cacheline_aligned")))
                   ^
  include/linux/jiffies.h:77:12: note: previous attribute is here
  extern u64 __jiffy_data jiffies_64;
             ^
  include/linux/jiffies.h:70:38: note: expanded from macro '__jiffy_data'

Change-Id: I1fa0d6640f9d3a3624c7b3cff5765095fbe89455
Link: http://lkml.kernel.org/r/20170403190200.70273-1-mka@chromium.org
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Cc: "Jason A . Donenfeld" <Jason@zx2c4.com>
Cc: Grant Grundler <grundler@chromium.org>
Cc: Michael Davidson <md@google.com>
Cc: Greg Hackmann <ghackmann@google.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Bug: 62057517
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-31 20:36:32 -07:00
Abhijeet Dharmapurikar
7104732e69 power_supply: introduce PR_SWAP property
Introduce POWER_SUPPLY_PROP_PR_SWAP to notify if the device is in
power role swap.

Bug: 63171186
Change-Id: I8d0cb3a71ec1a646b7ec37405e66cb00ddc40e0d
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
2017-07-26 18:34:11 +00:00
Suren Baghdasaryan
2eff325afd Revert "BACKPORT: Move sync logic to be run always"
This reverts commit 41ab0d98c5.

bug: 64032214
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
2017-07-26 02:04:18 +00:00
Patrick Tjin
b71d012395 fs/pstore/ramoops: add alternate encrypted buffer support
This patch allows the ramoops to read previous logs from an
AES encrypted location while still allowing writes to the
current log.

This is used to allow the backing store to be encrypted and
then written to disk by the bootloader.  The keys to decrypt
are loaded by userspace and then pstore is remounted to
force a reload of the now decrypted backing store.

Bug: 37554629
Bug: 37553996
Change-Id: Ieb7615d22bdfbf2130a0f6ca1b4038ffdf2fe338
Signed-off-by: Patrick Tjin <pattjin@google.com>
2017-07-25 21:29:43 +00:00
Binhao Lin
a3b7c141dd iommu: disable smmu stalls on faulty transactions
Disable the SMMU stalls on faulty transactions by terminating it using
the CB.SCTLR register. Faulty transaction on a CB causes the back
pressure on the QSMMU transaction pipe which inturn affect the other
masters using the same SMMU. Pass the DOMAIN_ATTR_CB_STALL_DISABLE flag
to iommu_domain_set_attr api in order to use this feature.

Bug: 63539182
Change-Id: Ib8fa35854ff24e0295d330c5fb79375f58c3e841
Signed-off-by: Charan Teja Reddy <charante@codeaurora.org>
2017-07-24 18:01:26 +00:00
Suren Baghdasaryan
41ab0d98c5 BACKPORT: Move sync logic to be run always
cherry-picked from 3.18 kernel, commit 324181821c790ca02a2180ff01576d3c4d15fa6d ("Move sync logic to be run always")

Lift sync logic out of select_energy_cpu_brute() and run that logic before
select_idle_sibling() or select_energy_cpu_brute().

At high CPU utilization, the scheduler falls back to
select_idle_sibling().  On Marlin, select_idle_sibling() wasn't
respecting the sync flag to force the task to be scheduled on the same
CPU.  This caused the sync flag to be ignored and thrash on binder with
sync enabled.  This fixes the thrash we saw.

Bug 38260530
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I5b5552e87b76028328b6f6439f11dc7de43fdfc0
Signed-off-by: Joel Fernandes <joelaf@google.com>
2017-07-24 16:42:31 +00:00
Banajit Goswami
7fd21c1213 soc: q6dspv2: add api to vote for upgrading thread priority
For some time critical tasks, the thread priority
might need to be upgraded to Real-Time Thread
priority level. Expose an interface from APR layer
so that clients can vote for a priority upgrade
whenever needed.

Bug: 38234822
Change-Id: Ieb4afa914905750eccdf7672020a8751fdcf6462
Signed-off-by: Banajit Goswami <bgoswami@codeaurora.org>
2017-07-23 22:16:45 +00:00
John Dias
15eb697839 sched: log tasks that are scheduled after long wait
Debugging patch to help look for freezing issues
that are speculatively blamed (based on previous
examples) on the kernel failing to schedule some
threads for long periods of time.

Bug: 63331203
Change-Id: I2c48362aa948275f31776478daf6751f29cd11d0
Signed-off-by: John Dias <joaodias@google.com>
2017-07-20 20:21:43 +00:00
Hugh Dickins
ff47835934 mm: larger stack guard gap, between vmas
commit 1be7107fbe18eed3e319a6c3e83c78254b693acb upstream.

Stack guard page is a useful feature to reduce a risk of stack smashing
into a different mapping. We have been using a single page gap which
is sufficient to prevent having stack adjacent to a different mapping.
But this seems to be insufficient in the light of the stack usage in
userspace. E.g. glibc uses as large as 64kB alloca() in many commonly
used functions. Others use constructs liks gid_t buffer[NGROUPS_MAX]
which is 256kB or stack strings with MAX_ARG_STRLEN.

This will become especially dangerous for suid binaries and the default
no limit for the stack size limit because those applications can be
tricked to consume a large portion of the stack and a single glibc call
could jump over the guard page. These attacks are not theoretical,
unfortunatelly.

Make those attacks less probable by increasing the stack guard gap
to 1MB (on systems with 4k pages; but make it depend on the page size
because systems with larger base pages might cap stack allocations in
the PAGE_SIZE units) which should cover larger alloca() and VLA stack
allocations. It is obviously not a full fix because the problem is
somehow inherent, but it should reduce attack space a lot.

One could argue that the gap size should be configurable from userspace,
but that can be done later when somebody finds that the new 1MB is wrong
for some special case applications.  For now, add a kernel command line
option (stack_guard_gap) to specify the stack gap size (in page units).

Implementation wise, first delete all the old code for stack guard page:
because although we could get away with accounting one extra page in a
stack vma, accounting a larger gap can break userspace - case in point,
a program run with "ulimit -S -v 20000" failed when the 1MB gap was
counted for RLIMIT_AS; similar problems could come with RLIMIT_MLOCK
and strict non-overcommit mode.

Instead of keeping gap inside the stack vma, maintain the stack guard
gap as a gap between vmas: using vm_start_gap() in place of vm_start
(or vm_end_gap() in place of vm_end if VM_GROWSUP) in just those few
places which need to respect the gap - mainly arch_get_unmapped_area(),
and and the vma tree's subtree_gap support for that.

Original-patch-by: Oleg Nesterov <oleg@redhat.com>
Original-patch-by: Michal Hocko <mhocko@suse.com>
Bug: 38413813
Signed-off-by: Hugh Dickins <hughd@google.com>
Acked-by: Michal Hocko <mhocko@suse.com>
Tested-by: Helge Deller <deller@gmx.de> # parisc
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[wt: backport to 4.11: adjust context]
[wt: backport to 4.9: adjust context ; kernel doc was not in admin-guide]
[wt: backport to 4.4: adjust context ; drop ppc hugetlb_radix changes]
Signed-off-by: Willy Tarreau <w@1wt.eu>
[gkh: minor build fixes for 4.4]
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Change-Id: I9b4bb1015ae7604736ce3d9526b34fe9536522c5
2017-07-19 23:03:01 -07:00
edison_shih
47b2252826 fs:pstore:ramoops: add new driver to append bootloader log into ramoops
Append bootloader log into ramoops for debug purpose.

Bug: 62881076
Change-Id: Ia818e5c56b5a33293bd1614746f4174a39af764d
Signed-off-by: edison_shih <edison_shih@htc.com>
2017-07-20 01:24:56 +00:00
Linus Torvalds
5c485945a3 BACKPORT: compiler, clang: properly override 'inline' for clang
Commit abb2ea7dfd82 ("compiler, clang: suppress warning for unused
static inline functions") just caused more warnings due to re-defining
the 'inline' macro.

So undef it before re-defining it, and also add the 'notrace'
attribute like the gcc version that this is overriding does.

Maybe this makes clang happier.

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 32455818
BUg: 33244601
Change-Id: I8346d290a8d766445c84261a4334db876bb2e014
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-17 16:34:11 +00:00
David Rientjes
e6170f1460 BACKPORT: compiler, clang: suppress warning for unused static inline functions
GCC explicitly does not warn for unused static inline functions for
-Wunused-function.  The manual states:

Warn whenever a static function is declared but not defined or a
non-inline static function is unused.

Clang does warn for static inline functions that are unused.

It turns out that suppressing the warnings avoids potentially
complex #ifdef directives, which also reduces LOC.

Suppress the warning for clang.

Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Bug: 32455818
BUg: 33244601
Change-Id: I31a7ff4b828538a66d439203be8965c3d53e6763
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-17 16:33:59 +00:00
David Rientjes
564322f958 BACKPORT: compiler, clang: always inline when CONFIG_OPTIMIZE_INLINING is disabled
The motivation for commit abb2ea7dfd82 ("compiler, clang: suppress
warning for unused static inline functions") was to suppress clang's
warnings about unused static inline functions.

For configs without CONFIG_OPTIMIZE_INLINING enabled, such as any
non-x86
architecture, `inline' in the kernel implies that
__attribute__((always_inline)) is used.

Some code depends on that behavior, see
  https://lkml.org/lkml/2017/6/13/918:

  net/built-in.o: In function `__xchg_mb':
  arch/arm64/include/asm/cmpxchg.h:99: undefined reference to
`__compiletime_assert_99'
  arch/arm64/include/asm/cmpxchg.h:99: undefined reference to
`__compiletime_assert_99

The full fix would be to identify these breakages and annotate the
functions with __always_inline instead of `inline'.  But since we are
late in the 4.12-rc cycle, simply carry forward the forced inlining
behavior and work toward moving arm64, and other architectures, toward
CONFIG_OPTIMIZE_INLINING behavior.

Link:
http://lkml.kernel.org/r/alpine.DEB.2.10.1706261552200.1075@chino.kir.corp.google.com
Signed-off-by: David Rientjes <rientjes@google.com>
Reported-by: Sodagudi Prasad <psodagud@codeaurora.org>
Tested-by: Sodagudi Prasad <psodagud@codeaurora.org>
Tested-by: Matthias Kaehlcke <mka@chromium.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>`

Bug: 32455818
Change-Id: I0a8c688970440a80c907b257ed8ac57aaffbff8e
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-17 16:33:43 +00:00
Nick Desaulniers
43a338de85 Revert "LLVMLINUX: Mark inline functions as __maybe_unused"
This reverts commit bc272e8189.

Bug: 32455818
Change-Id: Ie01694d8b7f364731bdb241ec9666ffaa4acb8f3
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-07-17 16:33:26 +00:00
jonghyun26.kim
4e3ab2cb2b input: touch: ftm4: fix power on sequence
fix power on sequence
touch_1.8v high -> >10ms delay -> reset_pin high

Bug: 63576441
Change-Id: Ifd8387a4b8a6c49a4e7fbaa376e7c3430391bffb
Signed-off-by: keunyoung1.park <keunyoung1.park@lge.com>
Signed-off-by: Steve Pfetsch <spfetsch@google.com>
2017-07-14 12:54:14 -07:00
Philip Cuadra
2794ede02f tty: add tty_port_set_policy function
This function allows the port's scheduling policy to be changed.  Some
tty ports (like Bluetooth ones), need a higher priority to reduce
jitter.

Bug: 36106419
Test:  Bluetooth audio
Change-Id: If11e21c55924314910d602573c735c6afae09709
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-06-30 23:36:54 -07:00
Philip Cuadra
b83aec1ef0 tty: move tty_port workqueue to be a kthread
This makes each tty_port have their own kthread, hopefully allowing them
a bit more freedom in scheduling when they reveive data.

Based on a patch from Philip Cuadra <philipcuadra@google.com>
Based on a patch from Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Bug: 36106419
Test: run Bluetooth audio, ensure separate tty thread is created.
Signed-off-by: Philip Cuadra <philipcuadra@google.com>
Change-Id: I9fd25235b26a66acb37a40304c356209b74ad46c
2017-06-30 23:36:00 -07:00
Trevor Bunker
541a277947 pci-msm: add an API for toggling pcie reset
Bug: 36761289
Change-Id: Ib42b570b1c0aad37c47f51c4e82af83685b558a0
Signed-off-by: Trevor Bunker <trevorbunker@google.com>
2017-06-30 23:17:49 -07:00
Jin Qian
c8a8e221e4 ANDROID: sched: add a counter to track fsync
Change-Id: I6c138de5b2332eea70f57e098134d1d141247b3f
Signed-off-by: Jin Qian <jinqian@google.com>
2017-06-30 23:02:26 -07:00
John Dias
8d8a044b58 Revert "ANDROID: cpufreq: Add transient max freq for hw thermals"
This reverts commit 1c6341dc9a.

Bug: 63162144
Bug: 63143113
Bug: 63132939
Signed-off-by: John Dias <joaodias@google.com>
Change-Id: I52bcbec9c449f38d7e72f608a2c258705300416a
2017-06-30 17:31:58 +00:00
Andres Oportus
1c6341dc9a ANDROID: cpufreq: Add transient max freq for hw thermals
Allows thermal max freq notification to the scheduler without
interfacing it with the thermal driver.  Adds a new "transient"
field in the cpufreq policy to be notified by thermals and consumed
by the scheduler.  Note that this could be expanded for other
notifiers and consumers, in this CL though the intent is
only to allow thermals including a HW engine to notify
a transient value to be used by the scheduler but not by
the governor.

Signed-off-by: Andres Oportus <andresoportus@google.com>
Bug: 37716228
Test: Check that under thermal throttling the scheduler reports
less capacity in use as in:
2017-06-13 17:23:05>as 'dmesg|grep CPU|tail -1'
[  449.193273] CPU7: update max cpu_capacity 984

Change-Id: I13ddd3d62db765dc3b47ccaddeacfd92f79c5a2a
2017-06-28 20:32:23 +00:00
Thierry Strudel
f240d42733 Merge AU233 kernel into android-msm-wahoo-4.4
Change-Id: I466890021cdd2783ba44af077e10d944a616cd71
2017-06-24 00:49:27 -07:00
Rob Herring
4d54f0fbed UPSTREAM: tty: serial_core: add tty NULL check to uart_tx_stopped
Commit 761ed4a94582 ("tty: serial_core: convert uart_close to use
tty_port_close") created a case where a port used for a console does not
get shutdown on tty closing. Then a call to uart_tx_stopped() segfaults
because the tty is NULL. This could be fixed to restore old behavior,
but we also want to allow tty_ports to work without a tty attached. So
this change to allow a NULL tty_struct is needed either way.

Bug: 62912956
Change-Id: Ia44bff00c1136bc7d7c7489638344860c819de99
Fixes: 761ed4a94582 ("tty: serial_core: convert uart_close to use tty_port_close")
Reported-by: kernel test robot <xiaolong.ye@intel.com>
Signed-off-by: Rob Herring <robh@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Siqi Lin <siqilin@google.com>
2017-06-22 21:56:59 +00:00
Bernhard Rosenkränzer
79de094039 Fix for compilation with clang
The clang compiler treats the memory address of a structure field as
tautologically true when compared to non-NULL. This breaks the macros
in llist.h when compiled using clang. Fix this by not comparing the
address of a structure field to NULL when determining the end of the
llist. Refer to -Wtautological-pointer-compare in clang for more
information.

Bug: 32455818
Change-Id: I1732c543bebcd5c012b9a3e84d6613a973c82ae0
Signed-off-by: Hans Petter Selasky <hps@selasky.org>
Signed-off-by: Bernhard Rosenkränzer <bero@linaro.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-06-22 21:23:27 +00:00
Trevor Bunker
c045915716 msm: pcie: fix issue with memory leak
This patch fixes an issue that the pci state was being allocated for
each runtime suspend and never freed. Added a new pm config option for
stating if the config should be freed after restore. This option is only
valid if the NO_CFG_RESTORE option is not set.

Kmemleak dump:
unreferenced object 0xfffffff1acb27500 (size 128):
  comm "set_state_work", pid 502, jiffies 4295041066 (age 958.860s)
  hex dump (first 32 bytes):
    cb 17 05 01 06 00 10 00 00 00 04 06 00 00 01 00  ................
    04 00 10 1b 00 00 00 00 00 01 01 00 f0 00 00 00  ................
  backtrace:
    [<0000000000000000>] create_object+0x190/0x374
    [<0000000000000000>] kmemleak_alloc+0x68/0xc8
    [<0000000000000000>] __kmalloc+0x16c/0x2a4
    [<0000000000000000>] pci_store_saved_state+0x58/0xb4
    [<0000000000000000>] msm_pcie_pm_suspend+0x100/0x4fc
    [<0000000000000000>] msm_pcie_pm_control+0xdb4/0xe58
    [<0000000000000000>] mnh_pwr_pcie_suspend+0x94/0xd4
    [<0000000000000000>] __mnh_pwr_down+0x18/0x248
    [<0000000000000000>] mnh_pwr_set_state+0x94/0x334
    [<0000000000000000>] mnh_sm_set_state_locked+0xa8/0x5b8
    [<0000000000000000>] mnh_sm_set_state+0x84/0xc8
    [<0000000000000000>] mnh_sm_set_state_work+0x1c/0x38
    [<0000000000000000>] kthread_worker_fn+0xe4/0x178
    [<0000000000000000>] kthread+0xdc/0xec
    [<0000000000000000>] ret_from_fork+0x10/0x30
    [<0000000000000000>] 0xffffffffffffffff

Bug: 62888018
Change-Id: I3b06a048c2c5b9518f57584971b50c0f60d3c302
Signed-off-by: Trevor Bunker <trevorbunker@google.com>
2017-06-22 11:43:00 -07:00
eunsoo.na
d79ca80df8 power: smb-lib: add sysfs node for charging enable/disable
CHARGING_ENABLED_CMD(PMI 0x1042[0]) bit to enable/disable charging

BUG: 62568960
Change-Id: Id420582e7a15c20276b5c1e1fd056b90760af261
Signed-off-by: eunsoo.na <eunsoo.na@lge.com>
2017-06-22 01:18:14 +00:00
Thierry Strudel
954904edd0 Merge branch 'android-msm-8998-4.4-common' into android-msm-wahoo-4.4
Conflicts:
	arch/arm64/configs/wahoo_defconfig
	drivers/media/platform/msm/camera_v2/isp/msm_isp_axi_util.c
	drivers/media/platform/msm/camera_v2/isp/msm_isp_util.c
	drivers/platform/msm/ipa/ipa_v3/ipa.c
	drivers/power/supply/qcom/battery.c
	drivers/power/supply/qcom/smb-lib.c
	drivers/power/supply/qcom/smb-lib.h
	kernel/cgroup.c
	sound/soc/msm/msm-dai-fe.c
	sound/soc/msm/msm8998.c
	sound/soc/msm/qdsp6v2/msm-pcm-routing-v2.c
	sound/soc/msm/qdsp6v2/q6adm.c

Change-Id: I924236274bf23ef7955ebf0bdabcaf007451a488
2017-06-20 19:01:34 -07:00
Thierry Strudel
1b9ba8de9d Merge branch 'android-msm-8998-4.4' into android-msm-8998-4.4-common
Conflicts:
	arch/arm64/kernel/topology.c
	drivers/cpufreq/Kconfig
	drivers/cpufreq/cpufreq_interactive.c
	include/linux/sched.h
	include/linux/sched/sysctl.h
	include/linux/sched_energy.h
	include/trace/events/power.h
	include/trace/events/sched.h
	kernel/cgroup.c
	kernel/exit.c
	kernel/sched/Makefile
	kernel/sched/core.c
	kernel/sched/cputime.c
	kernel/sched/energy.c
	kernel/sched/fair.c
	kernel/sched/rt.c
	kernel/sched/sched.h
	kernel/sched/stop_task.c
	kernel/sched/tune.c
	kernel/sysctl.c
	kernel/watchdog.c
	lib/Kconfig.debug
	mm/vmstat.c

Bug: 62817801
Change-Id: I7e2df7e09c1f70a412b60b12c3f35d80798bf4ca
2017-06-20 17:53:15 -07:00
Veerabhadrarao Badiganti
17e10d91c6 mmc: core: Ignore CRC errors with CMD13 while executing tuning
While executing tuning in case CMD19 fails, the driver sends CMD13
multiple times to ensure the card is ready to receive the next tuning
command. If this status command fails with CRC error, it will trigger
tuning. This will result in back to back tuning multiple times.

To avoid this situation, ignore CRCs error generated with CMD13 while
executing tuning.

Change-Id: Ife338768264ebebebc655fe11874e905abdf7482
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
2017-06-14 02:09:05 -07:00
Yueyao Zhu
acc65f87f9 usb: typec: Merge staging version of type-c to wahoo
This commit syncs the version of type-c stack including TCPM,
Type-C connector class to align with commit
4cec1d769e7be15b335484565d712b85a993c9b1 in marlin tree, which
further aligns with mainline staging tree commit
https://git.kernel.org/pub/scm/linux/kernel/git/groeck/linux-staging.git/
commit/?h=typec&id=8edc2421f1fa24dd4d8055b8df7ad651d3002c92,
plus commits in marlin tree that is pending upstreaming:

4cec1d769e7b usb: typec: allow tcpm logs to overflow
487d4d6b5d47 usb: typec: Check for port type for Try.SRC/Try.SNK
335c421a423e usb: typec: tcpm set port type callback
439432bfb5ee usb: typec: Add a sysfs node to manage port type
  (This commit has been upstreamed: https://git.kernel.org/pub/scm/
   linux/kernel/git/gregkh/usb.git/commit/?h=usb-next&id=
   bab3548078237706f53baafe43ae58257225549d)

Bug: 62272992
Change-Id: I9a209d95328f9439c5aed6c9509128d9f4f2610b
Signed-off-by: Yueyao Zhu <yueyao@google.com>
2017-06-13 18:48:22 -07:00
Veerabhadrarao Badiganti
a989c4ff5f mmc: sdhci-msm: Store clock scaling frequencies in a dedicated table
Use a separate table to store the platform specific clock-scaling
frequencies.

The generic table where these frequencies used to be stored, would
get updated (in some cases) during clock scaling initialization.
But when a new card is inserted (In the case of a removable card),
the frequencies supported by the card should be compared against the
platform specific frequencies.

By storing these values in a separate table, these values would
remain intact and this table can be used for initializing the
generic table during clock-scaling initialization.

Change-Id: I5729f18a975f849bc2965a946473a9cdbd81e94a
Signed-off-by: Veerabhadrarao Badiganti <vbadigan@codeaurora.org>
2017-06-08 22:15:06 -07:00
Wei Wang
e9fd5d282b Revert "UPSTREAM: lz4: fix wrong compress buffer size for 64-bits"
This reverts commit a9743679ad.

Change-Id: I48f78f7982da083fb5c68f30fc819e5d6d3bd347
2017-06-08 00:20:41 +00:00