lowmemorykiller: updates from 3.4 kernel

Signed-off-by: Dan Trifan <jimsth@gmail.com>
defconfig: enable ANDROID_LOW_MEMORY_KILLER_AUTODETECT_OOM_ADJ_VALUES

Signed-off-by: Dan Trifan <jimsth@gmail.com>
fs/proc/base.c (affects lowmemorykiller): oom_adj -17 triggers oom_score_adj of -1000

Prior to this patch, oom_score_adj was automatically calculated based
on the oom_adj value.
When setting an oom_adj value of the minium value (-17), automatically
set oom_score_adj to its minimum value (-1000) as well.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
mm/oom_kill.c (affects lowmemorykiller): make tasks with oom_score_adj = -1000 unkillable

Signed-off-by: Dan Trifan <jimsth@gmail.com>
mm/oom_kill.c (affects lowmemorykiller): prevent changing oom_score_adj if its value is -1000

This should prevent that the Android OS automatically changes
its value if oom_adj -17 or oom_score_adj -1000 were explicitly
set by the user. To gain control over the variable again,
oom_adj has to be set to anything higher than -17.

Also: compare p->signal->oom_score_adj with OOM_SCORE_ADJ_MIN instead
of static value.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
mm/oom_kill.c (affects lowmemorykiller): prevent changing oom_adj if its value is -17

This should prevent that the Android OS automatically changes
its value when a process has been explicitly set to be unkillable.

To gain control over either oom_adj or oom_score_adj again, set
oom_score_adj to 1000 (OOM_SCORE_MAX).

Signed-off-by: Dan Trifan <jimsth@gmail.com>
cpufreq: interactive: don't remove sysfs nodes

Signed-off-by: Dan Trifan <jimsth@gmail.com>
USB: f_mass_storage: 2048 block size for cdrom devices

Bios will recognize the cdrom device like most other cdrom
devices. This allows people to boot ISOs from their phone.

Original by Andreas Kemnade:
http://www.spinics.net/lists/linux-usb/msg25178.html

Change-Id: Id8fba96e1683f6daa6330b1e59f4a4ca4fe5c271
Signed-off-by: Dan Trifan <jimsth@gmail.com>
USB: f_mass_storage: Added cdrom option to UMS-lun-devices

This patch allows programs to change the cdrom option at runtime
through sysfs.

Change-Id: I30a0ffc7f6e9a7f12d95ca1ab07949868aba440c
Signed-off-by: Dan Trifan <jimsth@gmail.com>
Makefile: change build flags

Signed-off-by: Dan Trifan <jimsth@gmail.com>
lib: Sparc's strncpy_from_user is generic enough, move under lib/

To use this, an architecture simply needs to:

1) Provide a user_addr_max() implementation via asm/uaccess.h

2) Add "select GENERIC_STRNCPY_FROM_USER" to their arch Kcnfig

3) Remove the existing strncpy_from_user() implementation and symbol
   exports their architecture had.

Signed-off-by: David S. Miller <davem@davemloft.net>
Acked-by: David Howells <dhowells@redhat.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>

Conflicts:
	arch/sparc/Kconfig
	arch/sparc/lib/usercopy.c
	lib/Makefile

boype:
  - backport from 3.6 kernel
  - sparc implementation was left out
  - add #define REPEAT_BYTE(x)  ((~0ul / 0xff) * (x)) to
    include/linux/kernel.h

Signed-off-by: Dan Trifan <jimsth@gmail.com>
lib: add generic strnlen_user() function

This adds a new generic optimized strnlen_user() function that uses the
<asm/word-at-a-time.h> infrastructure to portably do efficient string
handling.

In many ways, strnlen is much simpler than strncpy, and in particular we
can always pre-align the words we load from memory.  That means that all
the worries about alignment etc are a non-issue, so this one can easily
be used on any architecture.  You obviously do have to do the
appropriate word-at-a-time.h macros.

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

boype:
  - line 2: change #include <linux/export.h> to #include <linux/module.h>

Signed-off-by: Dan Trifan <jimsth@gmail.com>
ARM: 7449/1: use generic strnlen_user and strncpy_from_user functions

This patch implements the word-at-a-time interface for ARM using the
same algorithm as x86. We use the fls macro from ARMv5 onwards, where
we have a clz instruction available which saves us a mov instruction
when targetting Thumb-2. For older CPUs, we use the magic 0x0ff0001
constant. Big-endian configurations make use of the implementation from
asm-generic.

With this implemented, we can replace our byte-at-a-time strnlen_user
and strncpy_from_user functions with the optimised generic versions.

Reviewed-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
Linux v3.0.92

This is the 3.0.92 stable release.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
Linux v3.0.93

This is the 3.0.93 stable release.

Signed-off-by: Dan Trifan <jimsth@gmail.com>
decompressor: Add LZ4 decompressor module

Date	Tue, 26 Feb 2013 15:24:27 +0900

This patch adds support for LZ4 decompression in the Linux Kernel.
LZ4 Decompression APIs for kernel are based on LZ4 implementation
by Yann Collet.

LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
LZ4 source repository : http://code.google.com/p/lz4/

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Clean up code
- Enable unaligned access for ARM v6 and above with
  CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS
- Add lz4_decompress() for faster decompression with
  uncompressed output size

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
lib: Add support for LZ4-compressed kernel

Date	Tue, 26 Feb 2013 15:24:28 +0900

This patch adds support for extracting LZ4-compressed kernel images,
as well as LZ4-compressed ramdisk images in the kernel boot process.

This depends on the patch below
decompressor: Add LZ4 decompressor module

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Clean up code
- Use lz4_decompress() for LZ4-compressed kernel during boot-process

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
arm: Add support for LZ4-compressed kernel

Date	Tue, 26 Feb 2013 15:24:29 +0900

This patch integrates the LZ4 decompression code to the arm pre-boot code.
And it depends on two patchs below

lib: Add support for LZ4-compressed kernel
decompressor: Add LZ4 decompressor module

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>

v2:
- Apply CFLAGS, -Os to decompress.o to improve decompress
  performance during boot-up process

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
lib: Add lz4 compressor module

From	Chanho Min <>

This patch adds support for LZ4 compression in the Linux Kernel.
LZ4 Compression APIs for kernel are based on LZ4 implementation
by Yann Collet and changed with kernel coding style.

LZ4 homepage : http://fastcompression.blogspot.com/p/lz4.html
LZ4 source repository : http://code.google.com/p/lz4/
svn revision : r90

Two APIs are added:
lz4_compress() support basic lz4 compression whereas lz4hc_compress() support
high compression or CPU performance get lower but compression ratio get higher.
Also, we require the pre-allocated working memory with the defined size and
destination buffer must be allocated with the size of lz4_compressbound.

Signed-off-by: Chanho Min <chanho.min@lge.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>
crypto: Add lz4 Cryptographic API

From	Chanho Min <>

This patch adds support for lz4 and lz4hc compression algorithm
using the lib/lz4/* codebase.
Signed-off-by: Chanho Min <chanho.min@lge.com>

Signed-off-by: Paul Reioux <reioux@gmail.com>
Signed-off-by: Dan Trifan <jimsth@gmail.com>