ion: Switch map/unmap dma api to sg_tables

Switch these api's from scatterlists to sg_tables

Change-Id: I8b99e39633df009d472ce24704fa26af7bb50fa2
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>
ion: Add reserve function to ion

Rather than requiring each platform call memblock_remove or reserve
from the board file, add this to ion

Change-Id: Ie418a692c13e9e0cfe93ecc83d253d3ce860fc83
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: Devaraj Rangasamy <dev@ti.com>
gpu: ion: export needed functions for PVR SGX

Make ion symbols visible to kernel modules. The SGX DDK
in modular form requires these symbols to be exported.

The reason for the code movement of ion structs is due to
EXPORT_SYMBOL’s requirement that the storage size of all
function parameters is known. This is so that the kernel can
sanity-check the size of data structures at module load time.

Change-Id: I2b9efe285557268da3baf258af09b56917add920
Signed-off-by: Rogelio Garcia <rgarcia@ti.com>
Signed-off-by: amperific <amperific@gmail.com>
omap-ion: Fix build issue when CONFIG_PVR_SGX is defined

This was caused by wrong path to pvr header.

Change-Id: Id32ee97ecb6ac4dc0b3662781a28b9eb38208370
Signed-off-by: Hemant Hariyani <hemanthariyani@ti.com>
omap_ion: Revert ion_share and ion_import for PVR fds

This patch removes uneeded ion_share and ion_import for
PVR file descriptors. These changes were introduced during
the migration to PVR kernel modules. The call to ion_import
was also adding an extra ref count to ion buffers which
prevented them from being freed from tiler when SGX was
finished with them.

Change-Id: If3bdab42e31db3d7ddbb619a37aa4c8afef1aa74
Signed-off-by: Tate Hornbeck <tate.hornbeck@ti.com>
gpu: ion: group heap allocations by id in the debugfs

Multiple ion heaps can have the same type.  These heaps will have
separate debugfs files, but any allocation for a heap with the same
type will be listed in them.

Change-Id: Iad2f660c539e151d62e76f8f99ecc9ad80b16dd5
Signed-off-by: Lajos Molnar <lajos@ti.com>
Singed-off-by: Dima Svetlov <svetlov@ti.com>
 gpu: ion: omap: Set correct heap for TILER allocations

OMAP has two TILER heaps, but all allocations are logged under
the first TILER heap, as ion_alloc only takes a heap type mask.
Correct the heap after ion_alloc, so the buffer is maintained
under the correct heap.

Change-Id: I7b4eb690a6cde6f07632f5254c91374c6088cb8a
Signed-off-by: Lajos Molnar <lajos@ti.com>
Signed-off-by: Dima Svetlov <svetlov@ti.com>
ION: Added support for getting ion phys without client

In order to dereference the ion_handles passed from user side
to kernel, there should be support for api without client identity.
This patch adds this support.

Change-Id: I95d0d460c9e0ad202d14e7620b82e1fa9d48f746
Signed-off-by: Sunita Nadampalli <sunitan@ti.com>
Signed-off-by: Lajos Molnar <lajos@ti.com>
Signed-off-by: Dima Svetlov <svetlov@ti.com>
ion: convert system heap to alloc_page()

vmalloc() allocates pages and maps them into kernel space.  If nobody
requires the area to be mapped in kernel space, this uses potentially
valuable VM address space.  Split into separate allocation and mapping
of pages.

Change-Id: I98411b93edea67c2068e20b5e48708fb38a4cd1f
Signed-off-by: David Schleef <ds@ti.com>

Conflicts:
	drivers/gpu/ion/ion_system_heap.c
 gpu: ion: check for input arguments in ion_free

ion_free is a public API and is directly dereferencing a
pointer without checking for NULL. A check has been
added for the same and throws a WARN in case of invalid
arguments.

Change-Id: Idcf72e4449f8cba2b8342d6fb0f64600c2c59c7e
Signed-off-by: Suman Anna <s-anna@ti.com>
ion: omap: change behaviour of getting buffers from pvr fd

previous implemention shares the pvr ion client and the ion
handles associated with that client for a particular pvr fd.
now, we just call ion_share on the handles and return the
shared buffers. caller is in charge of calling ion_import using
its own ion client to get the ion handles.

Change-Id: I2abdee1daed7b5c57c66b2e5fddc4eb0d0cc1305
Signed-off-by: Tyler Luu <tluu@ti.com>
Signed-off-by: amperific <amperific@gmail.com>
FORK HEADERS.

Signed-off-by: amperific <amperific@gmail.com>
reset random to linux 3.101

Conflicts:
	drivers/char/random.c
random: fix up sparse warnings

Add extern and static declarations to suppress sparse warnings

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
random: fix debug format strings

Fix the following warnings in formatting debug output:

drivers/char/random.c: In function ‘xfer_secondary_pool’:
drivers/char/random.c:827: warning: format ‘%d’ expects type ‘int’, but argument 7 has type ‘size_t’
drivers/char/random.c: In function ‘account’:
drivers/char/random.c:859: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c:881: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘size_t’
drivers/char/random.c: In function ‘random_read’:
drivers/char/random.c:1141: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 5 has type ‘ssize_t’
drivers/char/random.c:1145: warning: format ‘%d’ expects type ‘int’, but argument 6 has type ‘long unsigned int’

by using '%zd' instead of '%d' to properly denote ssize_t/size_t conversion.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>

Conflicts:
	drivers/char/random.c

Conflicts:
	drivers/char/random.c
random: prime last_data value per fips requirements

The value stored in last_data must be primed for FIPS 140-2 purposes. Upon
first use, either on system startup or after an RNDCLEARPOOL ioctl, we
need to take an initial random sample, store it internally in last_data,
then pass along the value after that to the requester, so that consistency
checks aren't being run against stale and possibly known data.

CC: Herbert Xu <herbert@gondor.apana.org.au>
CC: "David S. Miller" <davem@davemloft.net>
CC: Matt Mackall <mpm@selenic.com>
CC: linux-crypto@vger.kernel.org
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Signed-off-by: Jarod Wilson <jarod@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
 random: make it possible to enable debugging without rebuild

The module parameter that turns debugging mode (which basically means
printing a few extra lines during runtime) is in '#if 0' block. Forcing
everyone who would like to see how entropy is behaving on his system to
rebuild seems to be a little bit too harsh.

If we were concerned about speed, we could potentially turn 'debug' into a
static key, but I don't think it's necessary.

Drop the '#if 0' block to allow using the 'debug' parameter without rebuilding.

Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
random: allow architectures to optionally define random_get_entropy()

Allow architectures which have a disabled get_cycles() function to
provide a random_get_entropy() function which provides a fine-grained,
rapidly changing counter that can be used by the /dev/random driver.

For example, an architecture might have a rapidly changing register
used to control random TLB cache eviction, or DRAM refresh that
doesn't meet the requirements of get_cycles(), but which is good
enough for the needs of the random driver.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@vger.kernel.org
random: mix in architectural randomness earlier in extract_buf()

Previously if CPU chip had a built-in random number generator (i.e.,
RDRAND on newer x86 chips), we mixed it in at the very end of
extract_buf() using an XOR operation.

We now mix it in right after the calculate a hash across the entire
pool.  This has the advantage that any contribution of entropy from
the CPU's HWRNG will get mixed back into the pool.  In addition, it
means that if the HWRNG has any defects (either accidentally or
maliciously introduced), this will be mitigated via the non-linear
transform of the SHA-1 hash function before we hand out generated
output.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
random: statically compute poolbitshift, poolbytes, poolbits

Use a macro to statically compute poolbitshift (will be used in a
subsequent patch), poolbytes, and poolbits.  On virtually all
architectures the cost of a memory load with an offset is the same as
the one of a memory load.

It is still possible for this to generate worse code since the C
compiler doesn't know the fixed relationship between these fields, but
that is somewhat unlikely.

Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>