selinux: add cm-patches for selinux and android

This commit squashes some commits seen on the mako kernel
branch together. Binder still needs some fixes.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
selinux: fixes and more cm-updates

No Errors now with or without selinux enabled.
Still wont boot, but the base for further
updates should be now there.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cpufreq: interactive: handle errors from cpufreq_frequency_table_target

Add checks for error return from cpufreq_frequency_table_target, and be
less noisy on the existing call with an error check.  CPU hotplug and
system shutdown may cause this call to return -EINVAL.

Bug: 8613560
Change-Id: Id78d8829920462c0db1c7e14e717d91740d6cb44
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Blechd0se <alex.christ@hotmail.de>

Conflicts:
	drivers/cpufreq/cpufreq_interactive.c
media: video: fixed a possible memory leak

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
media: video: fixed memory leak for sure

So there was happening some memory leak inside the
camera device driver:
unreferenced object 0xde5a2180 (size 128):
  comm "swapper", pid 1, jiffies 4294929160
  hex dump (first 32 bytes):
    80 21 5a de 80 21 5a de 68 a1 25 c0 a4 a0 25 c0  .!Z..!Z.h.%...%.
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace:
    [<c00e6774>] kmem_cache_alloc+0xb4/0xc0
    [<c025ac78>] device_private_init+0x14/0x4c
    [<c025ced8>] dev_set_drvdata+0x20/0x34
    [<c0300504>] omap34xxcam_device_register+0x1e4/0x2a8
    [<c02f7d54>] v4l2_int_device_try_attach_all+0x100/0x148
    [<c02f7df4>] v4l2_int_device_register+0x58/0x70
    [<c00237c8>] omap34xxcam_init+0xbc/0x108
    [<c004b37c>] do_one_initcall+0x5c/0x1b8
    [<c00083f8>] kernel_init+0x98/0x110
    [<c004c99c>] kernel_thread_exit+0x0/0x8
    [<ffffffff>] 0xffffffff

As seen in this commit 34f4bafbf87d4db582c6a4ca1ed57dcc81758b39 my
first attention was to free up cam if it fails to init. Obviously
this was the wrong way and @Musiker made some suggestions to really
fix this (thanks!). omap34xxcam!=NULL would be never called since it has got
only one init.
As hinted in the memory leak report, its somehow dev_set_drvdata()'s fault.
Because it gets called before the v4l2 device is registered properly and
therefore the device structure got zeroed after this. So reference is lost
and memory leak is happening.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cpufreq: interactive: reduce chance of zero time delta on load eval

Reschedule load sampling timer after timestamp of sample start taken,
hold spinlock across entire sequence to avoid preemption.  Avoid the
WARN for zero time delta in the load sampling timer function.

Change-Id: Idc10a756f09141decb6df92669521a1ebf0dbc10
Signed-off-by: Todd Poynor <toddpoynor@google.com>
Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cpufreq: interactive: avoid underflow on active time calculation

Check for idle time delta less than elapsed time delta, avoid
underflow computing active time.

Change-Id: I3e4c6ef1ad794eec49ed379c0c50fa727fd6ad28
Signed-off-by: Minsung Kim <ms925.kim@samsung.com>
Signed-off-by: Blechd0se <alex.christ@hotmail.de>
ion: make debug msg easier to read

Nearly every function has now a printk().
I am guessing i can narrow down the problem with ion a
little bit. There must be some problem with omap3_carveout.
I am assuming (according to logs) that the ion device gets
init before the hole memory gets allocated. At this stage
everything is fine, but then it waits to long to allocate
the memory for the device and thus won't work in the end.

At least something like this...

I am also assuming that the mapping to userspace is somehow wrong,
don't know if i am using the wrong libs, though. We should
port this code to the 3.0-Branch at compare the both outputs.

This commit also includes some random patches and also some
compiler fixup.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
ion: throw a error if allocation fails

If allocation fails inside of ion fails, we can throw
this nice and shiny error message.

Furthermore simplyfied the code and get rid of goto end.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
ion: bring in strlcpy for client->name

We wont use strncpy, according to the 3.4-branch
there has to be some sort of allocation for
client->name.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
ion: fix memory leak and race condition

Previous commit introduced a memory leak.
kfree(client->name) takes care of that.

Otherwise fix a race condition if there are two
threads in one client and both try to link to the
same handle.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cpufreq: interactive: changing behavior of hispeed_freq

The current frequency will be (nearly) always lower than
hispeed_freq. So changing that to our 800 freq and pushing
cpu to max freq the first time. This should decrease frequency
jumps in theory.

Also updating suspend code a bit and change boost_duration
to 2secs. This needs confirmation, since in those 2 seconds
there shouldn't be any calculation to keep UI interactions
even smoother.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cpufreq: interactive: small timer adjustments

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
staging: sync: Add synchronization framework

Sync is a framework for synchronization between multiple
drivers. Sync implementations can take advantage of hardware
synchronization built into devices like GPUs.

Cc: Maarten Lankhorst <maarten.lankhorst@canonical.com>
Cc: Erik Gilling <konkers@android.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Rob Clark <robclark@gmail.com>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: dri-devel@lists.freedesktop.org
Cc: Android Kernel Team <kernel-team@android.com>
Signed-off-by: Erik Gilling <konkers@android.com>
[jstultz: Added commit message, moved to staging, squished minor fix in]
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Signed-off-by: Blechd0se <alex.christ@hotmail.de>

Conflicts:
	drivers/staging/android/Makefile
defconfig: make this thing clean!

Also enable the new synchronization framework driver
from previous commit.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
staging: android: update sync to upstream

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
ion: Switch ion to use dma-buf

Ion now uses dma-buf file descriptors to share
buffers with userspace.  Ion becomes a dma-buf
exporter and any driver that can import dma-bufs
can now import ion file descriptors.

Change-Id: Ia04d6d72fb301dc088eb8db6576822e9260ff332
Signed-off-by: Rebecca Schultz Zavin <rebecca@android.com>
Signed-off-by: Blechd0se <alex.christ@hotmail.de>

Conflicts:
	drivers/gpu/ion/ion.c
	include/linux/ion.h
defconfig: disable sync driver

Signed-off-by: Blechd0se <alex.christ@hotmail.de>
cgroups: timer_slack: backport to 2.6.32

http://lwn.net/Articles/431847/

This implements the timer slack controller with all needed
patches. To make this actually work with Android
the following is needed in the ramdisk;

	mount cgroup none /dev/cpuctl cpu,timer_slack

I also recommend to set timer_slack.min_slack_ns at boot;

	write /dev/cpuctl/apps/bg_non_interactive/timer_slack.min_slack_ns 100000000

Normally you would mount the controller to change the timer slack,
unfortunately this ist broken at the moment at least for me.

Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
Signed-off-by: Blechd0se <alex.christ@hotmail.de>

Conflicts:
	include/linux/cgroup_subsys.h
	include/linux/prctl.h
shrinker: fix those stupid warnings

We won't use the new shrinker api any time soon, so
go one step back and get rid of those warnings.

Also enable the new timer slack controller for CM10 too.

Signed-off-by: Blechd0se <alex.christ@hotmail.de>