Commit Graph

82455 Commits

Author SHA1 Message Date
Tim Murray
7006ddcef6 Revert "misc: mnh: Allocate partial carveout for kernel use"
This reverts commit 5a8d54cf41.

bug 63347709

Change-Id: I2aedc8ff6e147d3162de10377edcda3190c82425
2017-09-01 18:07:39 +00:00
Suren Baghdasaryan
3a2bcefbff Revert "events: add tracepoint for find_best_target"
This reverts commit 0022a24d6d.

bug: 64952298

Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: I1cd9ef75843d024cebf6311e58ffb4a8946e1ace
2017-08-30 22:54:06 +00:00
Cheng Gu
5a8d54cf41 misc: mnh: Allocate partial carveout for kernel use
Increase AP carveout to 96 MB.  Use 48 MB in kernel space and leave
the other 48 MB to userspace.

Bug: 63347709
Change-Id: I3e7b73a6932041cca26ca1a40f83bf1caa048077
Signed-off-by: Cheng Gu <gucheng@google.com>
2017-08-30 21:29:04 +00:00
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
Arnd Geis
2f07603879 misc: mnh: add firmware version
This CL implements Easel firmware version extraction and
an IOCTL and sysfs interface to query this version information.
The IOCTL interface is used in combination with the camera
HAL via easelcontrolclient to save firmware version information
in the exif section of captured frames.

Bug: b/36723642

Change-Id: I1afc7d29817c0cf3c5b11ad2f12603243258aecf
Signed-off-by: Arnd Geis <arndg@google.com>
2017-08-25 18:05:26 +00:00
Colin Cross
b37ba51aa9 Add BINDER_GET_NODE_DEBUG_INFO ioctl
The BINDER_GET_NODE_DEBUG_INFO ioctl will return debug info on
a node.  Each successive call reusing the previous return value
will return the next node.  The data will be used by
libmemunreachable to mark the pointers with kernel references
as reachable.

Bug: 28275695
Change-Id: Idbbafa648a33822dc023862cd92b51a595cf7c1c
Signed-off-by: Colin Cross <ccross@android.com>
Signed-off-by: Martijn Coenen <maco@android.com>
2017-08-25 08:47:57 +02: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
Patrick Tjin
44269c40a2 Merge branch 'android-msm-wahoo-4.4-oc-dr1' into android-msm-wahoo-4.4
* 95e321d7 misc: easelcomm: fix stop path
* bf92996e misc: mnh: fix handling of pcie suspend in failure cases
* 50b80d88 staging: bcm15602: power cycle pmic for stuck i2c errors
* 73930d4a Revert "arm64/dts: taimen: change display lp mode duty cycle"
* 33121106 misc: easelcomm: Double check command_arg_len
* 83b11743 misc: mnh: disable L1ss
* d6432127 qcacld-3.0: WLAN upgrade to 5.1.2.21Y.1
* 00d7fe35 qcacmn: Fix TSO segmentation and fragment creation logic
* 4d55cb1a qcacld-3.0: Add channels 5735-5835 to the world mode
* 8fe20259 Revert "arm64: dts: taimen: Prevent NFC_SPI_MISO pin floating"
* 1386e511 msm: gsi: check the channel state in case of stopped but the interrupt was not handled
* 2904dec0 ASoC: wcd934x: Increase port disconnect timeout to 1.6sec
* b5f4c09f msm: camera2_v2: Reject delayed RDI requests
* 3cd276bc fs/pstore/ramoops: Allocate decryption buffer with vmalloc
* 9941a0f2 arm64/dts: taimen: add delay to AVDD voltage enable during ALPM
* 7af6fbe7 ASoC: msm: q6dspv2: fix ramp down data loss on next clip
* fd4891d9 arm64/dts: taimen: update ALPM brightness buckets for DVT
* a0ceb49f arm64: dts: taimen: Prevent NFC_SPI_MISO pin floating
* ea144416 arm64/config: wahoo: disable mdss xlog debug
* a7fcec23 arm64/dts: taimen: change display lp mode duty cycle
* d68d8aa7 Revert "power: lge-battery: change max charging current 1.0C to 0.85C"
* 28dc1cf9 msm: mdss: Remove read err flags
* 74bb1e59 qcacld-3.0: Remove extra peer ref during attach
* 5b00c903 qcacld-3.0: WLAN upgrade to 5.1.2.21Y
* 2a114e17 cfg80211: Support backport of removing ieee80211
* 3b184f28 UPSTREAM: net/packet: fix overflow in check for priv area size
* 51b12e78 arm64: dts: taimen: remove big core emergency-frequency-mitigate
* 9912287a msm: cpp: Reduce cpp timeout on MC error
* bd9506f3 taimen: usb: to add usb2 host mode phy tune feature
* 8c473c55 misc: mnh: Allow longer hotplug timeout for debug
* 11cda422 arm64: dts: taimen: usb: apply USB phy tuning value
2017-08-17 21:27:44 +00:00
Patrick Bellasi
0022a24d6d events: add tracepoint for find_best_target
bug: 64610159

Change-Id: I4c245ffacb207d7ea826c5763a426efe5399e0a2
Signed-off-by: Patrick Bellasi <patrick.bellasi@arm.com>
2017-08-11 13:57:17 -07: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
Srinivas Girigowda
2a114e1752 cfg80211: Support backport of removing ieee80211
Bug: 62058353
Change-Id: Id8725947048bb4ba461dcb77b7b9023991a304be
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-08-09 01:29:07 +00:00
Johannes Berg
56f601d6bb BACKPORT: cfg80211: remove enum ieee80211_band
This enum is already perfectly aliased to enum nl80211_band, and
the only reason for it is that we get IEEE80211_NUM_BANDS out of
it. There's no really good reason to not declare the number of
bands in nl80211 though, so do that and remove the cfg80211 one.

Change-Id: Ifc56e6297146c9095432b757fabd0c463d7cc583
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Bug: 62057517
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
2017-08-02 18:13:32 -07: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
Nick Desaulniers
e204046385 BACKPORT: PCI: Make PCI_ROM_ADDRESS_MASK a 32-bit constant
A 64-bit value is not needed since a PCI ROM address consists in 32
bits.  This fixes a clang warning about "implicit conversion from
'unsigned long' to 'u32'".

Also remove now unnecessary casts to u32 from __pci_read_base() and
pci_std_update_resource().

Change-Id: I9fe11487a5cab742501444eccab7b405a9ba4885
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
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
Maggie White
b2d18321bf scsi: ufs: add debugfs node that dumps health desc
Test: cat /d/ufshcd0/dump_health_desc
Bug: 63147665

Change-Id: Iaf4aea6009f38972c9f79a331020148ffcf37bc6
Signed-off-by: Maggie White <maggiewhite@google.com>
2017-07-17 13:59:06 -07: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