msm: kgsl: Add CP_WAIT_FOR_IDLE packet before updating timestamp

HW workaround to resolve MMU pagefault caused by memory
freeing early before GPU completes it.

This is race condition where timestamp is getting updated
and the event handler runs before the GPU actually got done
with the timestamp, hence freeing the buffer early while GPU
still not completed with it.

Signed-off-by: Anshuman Dani <adani@codeaurora.org>

Conflicts:

	drivers/gpu/msm/adreno_ringbuffer.c
Change-Id: I6d338d7dca680f57f2c39ed5a14381b261bf8bce

Signed-off-by: Vikram Orre <vorre@codeaurora.org>
msm: kgsl: Add cache flush for A20x

Adding extra cache flush command to make sure that CP block
gets event from RB all the time to avoid race conditions because of
clock switches. this is to improve stability on 8x25 target.

Signed-off-by: Rajesh Kemisetti <rajeshk@codeaurora.org>

Conflicts:

	drivers/gpu/msm/adreno_ringbuffer.c
Change-Id: Ie411be46fa166864073d35c50085a8f2506d0eb8

Signed-off-by: Vikram Orre <vorre@codeaurora.org>
msm: vidc: Avoid memset of list elements in the buffer entry.

- Due to race condition between free buffer and flush output buffers,
  invalid buffer is getting accessed sometimes.
- Reset all the members in buffer entry except list elements.

(cherry picked from commit 8105df366cf6b9f1ddbc15d561fb6a5f12540416)

Change-Id: Ia3eaebdae102e4dff513cfffe31850350176d25f
CRs-Fixed: 411197
Signed-off-by: Srinu Gorle <sgorle@codeaurora.org>
lib: genalloc: Change chunk allocation to vmalloc

Change the chunk allocation from kmalloc to vmalloc for
allocations greater than a page. This allows large
chunks to be allocated from physically non-contiguous
memory and increases the chance of the allocation
succeeding.

(cherry picked from commit 0614b96dc8e4c8a0dd0db41aec5a79daa3bdf091)

Conflicts:

	lib/genalloc.c

(cherry picked from commit 64cf7183f37df623bec8f46348b11c5781d3b0cc)

Change-Id: Ied97c888b967c4433519cb47e972f7a0f2281d71
CRs-fixed: 387655
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
msm:vidc: Fix buffer pool index

While searching for the available buffer entry
in the buffer pool the search should begin from
index 1 as zeroth entry is reserved.

CRs-fixed: 366361
Signed-off-by: Mohan Kumar Gubbihalli Lachma Naik <mgubbi@codeaurora.org>
(cherry picked from commit 8c7e367a5ccd1c78c728657a14f08d6956b72e50)

Change-Id: I754fac98ce14f28cede1cb590c62784ad303a645
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
USB: f_mass_storage: Disable write cache support
As part of mode sense CBW command, communicate to the
host that write cache support is enabled and due to this
during the write commnd, the host is asking for FUA and
because of this write performance is degrading. Hence during
mode sense command, intimate the host that write cache is not
supported.

(cherry picked from commit a2da2c4)

Change-Id: I6ec66ff11181eeb70d62d31b7ddfbbf87880a885
CRs-Fixed: 278310
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
sched: Fix signed unsigned comparison in check_preempt_tick()

Signed unsigned comparison may lead to superfluous resched if leftmost
    is right of the current task, wasting a few cycles, and inadvertently
    _lengthening_ the current task's slice.

    Reported-by: Venkatesh Pallipadi <venki@google.com>
    Signed-off-by: Mike Galbraith <efault@gmx.de>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <1294202477.9384.5.camel@marge.simson.net>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
ched, autogroup: Fix reference leak

The cgroup exit mess also uncovered a struct autogroup reference leak.
    copy_process() was simply freeing vs putting the signal_struct,
    stranding a reference.

    Signed-off-by: Mike Galbraith <efault@gmx.de>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    Cc: Oleg Nesterov <oleg@redhat.com>
    LKML-Reference: <1293784350.6839.2.camel@marge.simson.net>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
sched_fair: Remove cpu from nohz idle set if not active

Currently, when determining which cpu should do load balancing in nohz
    mode, we still consider cpus that have been hotremoved. This is a
    problem because, if we decide to try and move the load balancing to a
    hotremoved cpu, we will spin and stop doing load balancing at all. This
    will also make us cease doing any idle power collapse until the cpu has
    been brought back online.

    Fix this by removing a cpu from the nohz idle mask if we find that it
    isn't active when we consider it for load balancing.

    Change-Id: I93a86fdcab88964a452cb3f38e4815db13d0ee6c
    CRs-Fixed: 290042
    Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
    Signed-off-by: Raj Kushwaha <rajk@codeaurora.org>
sched: Fix struct autogroup memory leak

Seems I lost a change somewhere, leaking memory.

    sched: fix struct autogroup memory leak

    Add missing change to actually use autogroup_free().

    Signed-off-by: Mike Galbraith <efault@gmx.de>
    Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
    LKML-Reference: <1294222285.8369.2.camel@marge.simson.net>
    Signed-off-by: Ingo Molnar <mingo@elte.hu>
hung_task: fix false positive during vfork

commit f9fab10 upstream.

vfork parent uninterruptibly and unkillably waits for its child to
exec/exit. This wait is of unbounded length. Ignore such waits
in the hung_task detector.

Signed-off-by: Mandeep Singh Baines <msb@chromium.org>
Reported-by: Sasha Levin <levinsasha928@gmail.com>
LKML-Reference: <1325344394.28904.43.camel@lappy>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: John Kacur <jkacur@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
ima: free duplicate measurement memory

Info about new measurements are cached in the iint for performance.  When
the inode is flushed from cache, the associated iint is flushed as well.
Subsequent access to the inode will cause the inode to be re-measured and
will attempt to add a duplicate entry to the measurement list.

This patch frees the duplicate measurement memory, fixing a memory leak.

Signed-off-by: Roberto Sassu <roberto.sassu@polito.it>
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

Conflicts:

	.config-ta_on
Backport adsp_video_verify from .38 kernel

- The cached buffers need to be invalidated before accessing them
  and need to be flushed after modification

- Validate headers for RealMedia and VP8 formats
rtc alarm: fix bad index when canceling alarms[]

It was using ANDROID_ALARM_ELAPSED_REALTIME_WAKEUP_MASK as an
index.

Change-Id: I919860cc71254453e382616bce9fd5455802cb3d
Signed-off-by: JP Abgrall <jpa@google.com>
rtc: alarm: Update hrtimer if alarm at the head of the queue is reprogrammed

If an alarm was restarted with a value that moved it away from the head
of a queue, the hrtimer would not be updated. This would cause unnecessary
wakeups.

Change-Id: If379f8dd92b0bdb3173bd8d057adfe0dc1d15259
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Revert "sched: Fix struct autogroup memory leak"

This reverts commit f71b0a27257a7c53a314754af847cedee2ecd8f0.