aries | p1: drivers: usb: gadget: update power configuration

 bmAttributes

	Specify power parameters for the configuration.
	If a device is self powered, it sets D6. Bit D7 was used
	in USB 1.0 to indicate a bus powered device, but this is
	now done by bMaxPower. If a device uses any power from the
	bus, whether it be as a bus powered device or as a self
	powered device, it must report its power consumption in bMaxPower.
	Devices can also support remote wakeup which allows the device
	to wake up the host when the host is in suspend.

 bMaxPower

	Defines the maximum power the device will drain from the bus.
	This is in 2mA units, thus a maximum of approximately 500mA
	can be specified. The specification allows a high powered bus
	powered device to drain no more than 500mA from Vbus. If a
	device loses external power, then it must not drain more than
	indicated in bMaxPower. It should fail any operation it cannot
	perform without external power

 reference

	these values is present at latest official samsung kernel (OSRC)
	released for arm arch exynos devices
	http://opensource.samsung.com

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: Id3db4b2fcab3ed0e933b864107ad8ea9cbcad83b
aries | p1: drivers: usb: gadget: add kernel debug messages

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I7bc75dd32308169ae6881805fdb5693df3258255
aries | p1: drivers: usb: gadget: add device selfpowered feature

this affects the device status reported by the hardware driver
to reflect that it now has a local power supply.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I0a8838109cf908cffa472968449b8a89a4ac550b
aries | p1: drivers: usb: gadget: fix logic

add one more test for usb status
if sysfs var (&enable) content is false
then android_usb is disabled too

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I3ec4f3489e68235cc338bdf04b317f9c578fd934
aries | p1: decompressor: add lz4 decompressor module

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

Benchmark Results(PATCH v3)
Compiler: Linaro ARM gcc 4.6.2

1. ARMv7, 1.5GHz based board
   Kernel: linux 3.4
   Uncompressed Kernel Size: 14MB
        Compressed Size  Decompression Speed
   LZO  6.7MB            20.1MB/s, 25.2MB/s(UA)
   LZ4  7.3MB            29.1MB/s, 45.6MB/s(UA)

2. ARMv7, 1.7GHz based board
   Kernel: linux 3.7
   Uncompressed Kernel Size: 14MB
        Compressed Size  Decompression Speed
   LZO  6.0MB            34.1MB/s, 52.2MB/s(UA)
   LZ4  6.5MB            86.7MB/s
- UA: Unaligned memory Access support
- Latest patch set for LZO applied

This patch set is for adding support for LZ4-compressed Kernel.  LZ4 is a
very fast lossless compression algorithm and it also features an extremely
fast decoder [1].

But we have five of decompressors already and one question which does
arise, however, is that of where do we stop adding new ones?  This issue
had been discussed and came to the conclusion [2].

Russell King said that we should have:

 - one decompressor which is the fastest
 - one decompressor for the highest compression ratio
 - one popular decompressor (eg conventional gzip)

If we have a replacement one for one of these, then it should do exactly
that: replace it.

The benchmark shows that an 8% increase in image size vs a 66% increase
in decompression speed compared to LZO(which has been known as the
fastest decompressor in the Kernel).  Therefore the "fast but may not be
small" compression title has clearly been taken by LZ4 [3].

[1] http://code.google.com/p/lz4/
[2] http://thread.gmane.org/gmane.linux.kbuild.devel/9157
[3] http://thread.gmane.org/gmane.linux.kbuild.devel/9347

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>
Signed-off-by: Yann Collet <yann.collet.73@gmail.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I064cd98424f7663b0fc37a047e1e6e21ae976316
aries | p1: lib: add support for lz4-compressed kernel

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

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Yann Collet <yann.collet.73@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Change-Id: I53474166464d3ac47fb4e276c4d84c9ded6a38e8
aries | p1: arm: add support for lz4-compressed kernel

Integrates the LZ4 decompression code to the arm pre-boot code.

Signed-off-by: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Russell King <rmk@arm.linux.org.uk>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Florian Fainelli <florian@openwrt.org>
Cc: Yann Collet <yann.collet.73@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I9a9c217af7ad048f75198b34133feece3a77f2e8
aries | p1: lib: add lz4 compressor module

This patchset is for supporting LZ4 compression and the crypto API using
it.

As shown below, the size of data is a little bit bigger but compressing
speed is faster under the enabled unaligned memory access.  We can use
lz4 de/compression through crypto API as well.  Also, It will be useful
for another potential user of lz4 compression.

lz4 Compression Benchmark:
Compiler: ARM gcc 4.6.4
ARMv7, 1 GHz based board
   Kernel: linux 3.4
   Uncompressed data Size: 101 MB
         Compressed Size  compression Speed
   LZO   72.1MB		  32.1MB/s, 33.0MB/s(UA)
   LZ4   75.1MB		  30.4MB/s, 35.9MB/s(UA)
   LZ4HC 59.8MB		   2.4MB/s,  2.5MB/s(UA)
- UA: Unaligned memory Access support
- Latest patch set for LZO applied

This patch:

Add support for LZ4 compression in the Linux Kernel.  LZ4 Compression APIs
for kernel are based on LZ4 implementation by Yann Collet and were changed
for 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.

[akpm@linux-foundation.org: make lz4_compresshcctx() static]
Signed-off-by: Chanho Min <chanho.min@lge.com>
Cc: "Darrick J. Wong" <djwong@us.ibm.com>
Cc: Bob Pearson <rpearson@systemfabricworks.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Herbert Xu <herbert@gondor.hengli.com.au>
Cc: Yann Collet <yann.collet.73@gmail.com>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I5a7c0930df11dc302b4eaf9f67b4225983cc3e15
aries | p1: crypto: add lz4 cryptographic api

Add support for lz4 and lz4hc compression algorithm using the lib/lz4/*
codebase.

[akpm@linux-foundation.org: fix warnings]
Signed-off-by: Chanho Min <chanho.min@lge.com>
Cc: "Darrick J. Wong" <djwong@us.ibm.com>
Cc: Bob Pearson <rpearson@systemfabricworks.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Herbert Xu <herbert@gondor.hengli.com.au>
Cc: Yann Collet <yann.collet.73@gmail.com>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>

Change-Id: I5637bd0bd06414119d2546f0cc78f2c60302414a
aries | p1: lib/lz4: correct the lz4 license

The LZ4 code is listed as using the "BSD 2-Clause License".

Signed-off-by: Richard Laager <rlaager@wiktel.com>
Acked-by: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: Chanho Min <chanho.min@lge.com>
Cc: Richard Yao <ryao@gentoo.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ The 2-clause BSD can be just converted into GPL, but that's rude and
  pointless, so don't do it   - Linus ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>

Change-Id: I1a80862c8bc319fb7c327c6c11d982d8d5487caf
aries | p1: lz4: fix compression/decompression signedness mismatch

LZ4 compression and decompression functions require different in
signedness input/output parameters: unsigned char for compression and
signed char for decompression.

Change decompression API to require "(const) unsigned char *".

Signed-off-by: Sergey Senozhatsky <sergey.senozhatsky@gmail.com>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: Yann Collet <yann.collet.73@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>

Change-Id: I2962c3e16e6435c705a8f41f8b584b1a4ee4143a
aries | p1: lib/decompress_unlz4.c: always set an error return code on failures

"ret", being set to -1 early on, gets cleared by the first invocation of
lz4_decompress()/lz4_decompress_unknownoutputsize(), and hence subsequent
failures wouldn't be noticed by the caller without setting it back to -1
right after those calls.

Reported-by: Matthew Daley <mattjd@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Cc: Kyungsik Lee <kyungsik.lee@lge.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: franciscofranco <franciscofranco.1990@gmail.com>
Signed-off-by: Humberto Borba <humberos@gmail.com>

Change-Id: I8feac97a7d1ecaf57bedf2a3438bca135608b405
aries | p1: drivers: staging: zram: add lz4 support

This patch Introduce LZ4 compression backend and make it available for
selection. LZ4 support is optional and requires user to set ZRAM_LZ4
config option. The default compression backend is LZO.

Test               LZO             LZ4
----------------------------------------------
Initial write   1642744.62      1317005.09
Rewrite         2498980.88      1800645.16
Read            3957026.38      5877043.75
Re-read         3950997.38      5861847.00
Reverse Read    2937114.56      5047384.00
Stride read     2948163.19      4929587.38
Random read     3292692.69      4880793.62
Mixed workload  1545602.62      3502940.38
Random write    2448039.75      1758786.25
Pwrite          1670051.03      1338329.69
Pread           2530682.00      5097177.62
Fwrite          3232085.62      3275942.56
Fread           6306880.25      6645271.12

LZ4 is a very fast lossless compression algorithm,
providing compression speed at 400 MB/s per core,
scalable with multi-cores CPU. It also features an
extremely fast decoder, with speed in multiple GB/s
per core, typically reaching RAM speed limits on
multi-core systems.

Quick comparison:

single thread, Core i5-3340M @2.7GHz,
using the Open-Source Benchmark by m^2 (v0.14.2)
compiled with GCC v4.6.1 on Linux Ubuntu 64-bits v11.10,
using the Silesia Corpus.

Name            Ratio  C.speed D.speed
                        MB/s    MB/s
LZ4 (r101)      2.084    422    1820
LZO 2.06        2.106    414     600
QuickLZ 1.5.1b6 2.237    373     420
Snappy 1.1.0    2.091    323    1070
LZF             2.077    270     570
zlib 1.2.8 -1   2.730     65     280
LZ4 HC (r101)   2.720     25    2080
zlib 1.2.8 -6   3.099     21     300

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I9f3e5d30967019023375413879d55102eff4303a
Revert "p1 | aries: config: add snappy compression support"

This reverts commit f1058d270e2a47d10ad28baab894e104671a8c81.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: Ib02eb53f0c444886089ae3bed5d8ac60db98355f
aries | p1: enable lz4 [de]compress for zram

Introduce LZ4 compression backend and make it available for selection.
LZ4 support is optional and requires user to set ZRAM_LZ4 config option.
The default compression backend is ZRAM_LZO.

Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I1f394e0e6ba274a79924c2f272ae661a7a3d53ae
aries | p1: staging: zram: remove useless offset calculation in handle_uncompressed_page()

The offset of uncompressed page is always zero: handle_uncompressed_page()
doesn't have to care about it.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I79cfe7ede6843b9420b22b307401e12b65e9e4d4
aries | p1: staging: zram: Refactor zram_read/write() functions

This patch refactor the code of zram_read/write() functions. It does
not removes a lot of duplicate code alone, but is mostly a helper for
the third patch of this series (Staging: zram: allow partial page
operations).

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I3a03e7235649cecee737cb37752bea5f9891fc4b
aries | p1: staging: zram: allow partial page operations

Commit 7b19b8d45b216ff3186f066b31937bdbde066f08 (zram: Prevent overflow
in logical block size) introduced ZRAM_LOGICAL_BLOCK_SIZE constant to
prevent overflow of logical block size on 64k page kernel.
However, the current implementation of zram only allow operation on block
of the same size as a page. That makes theorically legit 4k requests fail
on 64k page kernel.

This patch makes zram allow operation on partial pages. Basically, it
means we still do operations on full pages internally, but only copy the
relevent segments from/to the user memory.

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I38f5bc73823ba7d9117089769224f097fce3b1d8
aries | p1: staging: zram: replace mutex lock by a r/w semaphore

Currently, nothing protects zram table from concurrent access.
For instance, ZRAM_UNCOMPRESSED bit can be cleared by zram_free_page()
called from a concurrent write between the time ZRAM_UNCOMPRESSED has
been set and the time it is tested to unmap KM_USER0 in
zram_bvec_write(). This ultimately leads to kernel panic.

Also, a read request can occurs when the page has been freed by a
running write request and before it has been updated, leading to
zero filled block being incorrectly read and "Read before write"
error message.

This patch replace the current mutex by a rw_semaphore. It extends
the protection to zram table (currently, only compression buffers are
protected) and read requests (currently, only write requests are
protected).

Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I8fca7ec2b34769884a32bb89fbae316c98be34ea
aries | p1: staging: zram: fix kunmapping order

This patch fixes the unmapping order of KM_USER0/1 in
handle_uncompressed_page() and zram_read() so that kmap()/kunmap() calls
are correctly nested.

Reported-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Jerome Marchand <jmarchan@redhat.com>
Reviewed-by: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Humberto Borba <humberos@gmail.com>
Change-Id: I7ad461816f0ab9e6feff91d2a7ae85619bea943f