gpu: ion: Add ION Memory Manager

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Several fixes

Fix some cases where locks were not released on error paths
Change heap->prio to heap->id to make meaning clearer
Fix kernel doc to match sources
gpu: ion: Add omap support to ion

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Fix bug in ion_buffer_add

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Remove incorrect error message

The function name is wrong here, and this function may
sometimes be called to see if a value passed from userspace
is an ion handle.  Since it's not really an error when it
fails, remove the log message.

Change-Id: I7bee0e7ffb72b4c4768774a3586f97e306700c21
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Fix bug in ion_client_create

If a process already had a client, ion_client_create
would loop forever.

Change-Id: I723207b5872dfc11be04ca27d38a3cf39c4a1426
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Fix bug in ion client destroy

ion_client_destroy kernel api should only delete the client
if it's refcount has gone to zero.

Change-Id: Iaa662bd82d67279a9807e01f9a24aebe3d21c17d
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Remove redunant code from ion_open

ion_client_create now does a lookup, so this need not
also be done from ion_open

Change-Id: Icb101bbf514bf2e40b4b5d9b320130bf185349aa
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Fix possible memory leak

Change-Id: I66f5ad2c95513dfab9f4fc5ae2fcb1316f486d34
Signed-off-by: Choi, Jong-Hwan <jhbird.choi@samsung.com>
gpu: ion: Fix deferencing ERR_PTR

Change-Id: I986c380d75591571890f1a2cba1405e66789b25c
Signed-off-by: Choi, Jong-Hwan <jhbird.choi@samsung.com>
gpu: ion: omap: Add debug statements

Add debug statements to all the failing paths in omap_tiler_alloc

Change-Id: Ib6d6cb771976226776e4410551c928c78011af4d
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
gpu: ion: Validate handles passed via the kernel api

Before freeing or sharing handles, confirm that they
are valid in the provided client

Change-Id: I06ec599c0b277fcb5417325a12ecbf8b2d248a7b
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
ION : Fix memory leak issue for TILER 2D buffers

The ION was not freeing all allocated physical pages.

Change-Id: I079a8ef68afce42e425739fcc5873d4bdd9393b8
Signed-off-by: Lakshman Gowda <lakshman79@ti.com>
ion: minor clean up

-- init rb nodes in ion_handle_create
-- in ion_handle_destroy, check that a node belongs to a tree before removing
   it (safety check, does not happen right now)
-- mark as static functions used only inside ion.c
-- update comments to ion_share() with a relevant blurb from the implementation
-- other minor updates/typo fixes to comments

Signed-off-by: Iliyan Malchev <malchev@google.com>
OMAP: ION: Add support for nonsecure tiler carveout.

We may need to allocate some tiler buffers from a nonsecure
carveout while we secure the rest of the tiler buffers.

For now create omap_ion_nonsecure_tiler_alloc() method.  It would
be cleaner to specify a flag to have secure or nonsecure tiler
allocation, but it would require changing all current users of
TILER to specify secure flag.

Change-Id: I4bbb66d49b5ab45524447b7796a9dfa8e6b4a1d1
Signed-off-by: Lajos Molnar <molnar@ti.com>
omap: try not to allocate memory page by page

Instead, try to allocate memory for all physical pages together.  Idea from
Lakshman Gowda <lakshman79@ti.com>.  Speeds up allocations from the
tiler carveout by ~50ms.

This patch also combines three kzallocs into one.

Signed-off-by: Iliyan Malchev <malchev@google.com>
timers: Introduce timerlist infrastructure.

The timerlist infrastructure is a thin layer over the rbtree
code that implements a simple list of timers sorted by an
expires value, and a getnext function that provides a pointer
to the earliest timer.

This infrastructure allows drivers and other kernel infrastructure
to easily implement timers without duplicating code.

Signed-off-by: John Stultz <john.stultz@linaro.org>
LKML Reference: <1290136329-18291-2-git-send-email-john.stultz@linaro.org>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
CC: Alessandro Zummo <a.zummo@towertech.it>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Richard Cochran <richardcochran@gmail.com>
timers: Rename timerlist infrastructure to timerqueue

Thomas pointed out a namespace collision between the new timerlist
infrastructure I introduced and the existing timer_list.c

So to avoid confusion, I've renamed the timerlist infrastructure
to timerqueue.

Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
timers: Fixup allmodconfig build issue

Adds missed EXPORT_SYMBOL lines that cause the following build
failures with allmodconfig:
ERROR: "timerqueue_add" [drivers/rtc/rtc-core.ko] undefined!
ERROR: "timerqueue_getnext" [drivers/rtc/rtc-core.ko] undefined!
ERROR: "timerqueue_del" [drivers/rtc/rtc-core.ko] undefined!

Reported-by: Ingo Molnar <mingo@elte.hu>
Reported-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: John Stultz <john.stultz@linaro.org>
timerqueue: Make timerqueue_getnext() static inline

No point in calling a function just to dereference a pointer.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: John Stultz <john.stultz@linaro.org>