msm_fb: display: Fix incorrect goto call

During the probe for writeback panel, for MDP hardware versions
earlier than 4.3 an incorrect goto call un registers the bus scale handle
that primary panel uses. This is causing the boot failures because the
primary panel turn on sequence triggers the bus scale update request on
already unregistered handle.

(cherry picked from commit 284fc85908c31b7424cc600083c2499d4188bdfd)

Change-Id: Id87d622c83fb5fe9d8776d7c0abaeaedd983013d
Signed-off-by: Rajesh Sastrula <vrajesh@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
base: genlock: Properly destroy handle resources

The resources allocated for a handle were not being freed on device
release.  This included releasing the lock.  Unfortunately, the
lock release had a fput() too many which was screwing up the
reference counting on the file descriptors.  When attaching a lock,
we only need the file pointer for a short time so fput() it back
immediately.  That way, only there will only be one reference to
the lock per process, and the process will be responsible for
closing the fd directly and the fput() in genlock_release_lock
is no longer needed.

CRs-fixed: 322645
Change-Id: Ic0dedbad55300a2f8463c800cf8361719583b0b8
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
base: genlock: Avoid a race condition when releasing locks

Avoid a race condition if a lock gets released by all owners
but a process fails to close a lock file descriptor and tries
to reuse it.  Clearing the pointers to the data will ensure
that attaching a dead lock will return an error.

Change-Id: Ic0dedbadd693c7a22b027052cdd247370b28a7c5
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
base: genlock: Add error messages for failure cases

Signed-off-by: Naomi Luis <nluis@codeaurora.org>
Change-Id: I833e480abfc11ce4aa00a5ae46144895429a0339
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Fix bug in ion_buffer_add

Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.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>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.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>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Fix possible memory leak

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

Change-Id: I986c380d75591571890f1a2cba1405e66789b25c
Signed-off-by: Choi, Jong-Hwan <jhbird.choi@samsung.com>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: check return value from gen_pool_add

Check the return value from gen_pool_add and handle
any error gracefully.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Fix cached and uncached mapping in carveout heap

When the cached flag is set, ioremap_cached should be called.
When the cache flag is not set, ioremap should be called.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Add O_DSYNC flag to generated file

Ion uses the O_DSYNC flag of a file to indicate an uncached mapping.
When generating a file for mmaping, the new file needs to have the
same O_DSYNC flag as the parent (the file of the ioctl open call)
to indicate if the mapping should be cached or uncached.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Move initialization earlier

Ion needs to be initialized before most other subsystems.
Move the call to be earlier to ensure drivers that need to
allocate memory at bootup can.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Add IS_CACHED macro

Add a proper IS_CACHED macro for detecting whether or not
flags indicated a cached mapping.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Actually return aligned memory

Currently, the ion allocation API takes an alignment
argument. This alignment argument is currently ignored
everywhere. The system heaps cannot support the alignment
argument, but carveout heaps can. Add support for carveout
heaps to give back aligned memory.

Change-Id: Ic4cff37a7de51e1c85e273c2589958f7f13c33c9
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Do the cache op when the buffer is cached

Only do the cache operation when the buffer is cached.
If the buffer is uncached, just return. Fixes a bug
where the cache was only being flushed when the buffer
was uncached instead of cached.

Change-Id: Ib1fa01168de79d5627b11d07c5313d19b3049145
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Add better debugfs information

In debugfs, clients now show individual allocations.
Carveout heaps now give the number of bytes currently
allocated out of total possible bytes. The system heaps
just show the number of bytes currently allocated.

Change-Id: I4acfcdc1089c73c28041e09cb6b5a03b956e936a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Add warning during client freeing

Add warning when freeing client with buffers that are currently
mappped.

Change-Id: Ib8e17786daa7c890245c3d3e37143137cae7d078
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Check for NULL pointer in client destroy

Silently check for a null pointer in ion_client_destroy

Change-Id: Ic0dedbada03496faf2eb024c40f9cfaf8d08c98f
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>
gpu: ion: Add information about failed fd imports

If an fd import fails because the fd is not an Ion fd,
print out the name of the file. This way, it can be possible
to deduce where the fd came from.

Change-Id: I8464517ac011d62ebbd7e472f3e5734b0faacb0d
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Ronny Schmatzler <schmatzler@googlemail.com>