pmem: fix buddy free memory corruption bug

Enforce explicit upper limit for buddy index during memory free
operations. This index is generated during memory free operations of
the buddy bestfit allocator. The index points to each free buddy that
should be coalesced into a greater free memory area. The upper limit
now enforced is the number of entries in the current PMEM region.

Without this fix, pmem_buddy_bestfit_free would continue to corrupt
bytes in ever higher addresses, by power of 2, of memory until
stopped by the high bit being set in the currently examined byte.
Unless the high bit was set immediately at the first invalid byte,
this could have caused memory corruption past the current pmem region
metadata in kernel memory space.

One manifestation of this problem was a corner case where
non-existent buddies were incorrectly coalesced.

In a 12MB region, the buddy free for 8MB tried to coalesce the freed
buddy metadata with a non-existent 8MB buddy which actually belonged
to the following region. This caused the order number in the metadata
belonging to the following region to be incorrectly incremented past
the region boundary. Soon after, there was a subsequent invalid
allocation in that following region past the region boundary.

Signed-off-by: Stephen Biggs <sbiggs@quicinc.com>
pmem: source renamed to be consistent with upstream
vidc: Add metabuffer mode support for 720p encoder driver

Added 720p core video encoder driver changes, this change
depends-on 93816, which allows clients to register buffers
in data path in meta buffer mode.

Change-Id: I41f74ceabe348de37763d9728090238d71a786bd
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm: vidc: add missing encoding levels
msm:kgsl: set state as requested state when in NAP

Fix the state to requested state so that when both ISR and
timer fire at the same time, the state is set as SLEEP

CRs-Fixed: 340484
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 9b6110bb38c7acf61e065ec206b62b1e1f089908)

Change-Id: Ie625aba09feddf495647be2844dc0a4014605141
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
hack to rip out "+" trailing in local string
UPDATE: Multiple kernel patches [Code Aurora]
msm: kgsl: increase valid timestamp range

The existing timestamp_cmp function returns a different
result depending on the order of the input parameters due to
having an asymetric valid window. When no rollover is
detected the window is 2^31 but when a rollover is detected
the window is 25000. This change makes the rollover window
symmetric at 2^31.

CRs-fixed: 347631
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
(cherry picked from commit beb4a64b08ac49d4e01f4dd0c911c14ed6939f6d)

Conflicts:

	drivers/gpu/msm/kgsl.h

Change-Id: I22dcc773438df32f105dc8bd069051c48fde5018
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: flush outer cache for alloc_page() pages

The outer cache needs to be flushed for these pages
after they are allocated so that the GPU and CPU
have a consistent view of them.

CRs-Fixed: 346921
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 7018a21bf2b52f1296557d1f6ec9ed64e9169de7)

Change-Id: Id5c11ab8d856fc270330fd3258baa51b8efca192
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: Resolve conflicts in state changes

Only check requested state once, and fully transition to that
specific state.  This will resolve any conflicts arising from
changes to the requested_state as the state transition occurs.

Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
(cherry picked from commit e4a7c1a365ea32aebfe3995e13fc63ca8c2916c5)

Change-Id: I9d351d9d7e479389e473fc6e54d9d06d7ef200b9
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: vidc: Remove vcd restriction of duplicate input buffer queue

VCD previously had a limitation of not allowing two consecutive
encode_frame calls with the same buffer. This was primarily due to the
handling of buffer_entry elements in the buffer pool.  This commit
removes this restriction by maintaining an internal buffer_entry element
that VCD keep track of.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 794a9dd1b5c22492ef2ad76e49073c0bc0a2b8f9)

Change-Id: Iadbcae197f4627218440bdf300e43e04e888eaaf
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
Revert "msm: audio: qdsp5v2: Update PCM driver to use pmem memory (squashed commit)"

This reverts commit 0ee4e0fb5ef4dc06509952a6dc3fc45d4215192e.
msm_fb: new version backported from primou 3.o kernel

Change-Id: I1cefad019f03f61dc65c56f255cdec2a1f89874c
msm: vidc: missing ifdef
semaphore: fix compiling error
msm: kgsl: Allocate physical pages instead of using vmalloc

Replace vmalloc allocation with physical page allocation. For most
allocations we do not need a kernel virual address. vmalloc uses up
the kernel virtual address space. By replacing vmalloc with physical
page alloction and mapping that allocation to kernel space only
when it is required prevents the kgsl driver from using unnecessary
vmalloc virtual space.

CRs-Fixed: 346921

Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
(cherry picked from commit 8cb835b656ae2c3faa79af4f374563d344b46d4a)

Conflicts:

	drivers/gpu/msm/kgsl_sharedmem.c

Change-Id: I88e1eb282cc4822970811728d00b1096188f64e9
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
power-supply: Limit the duration of psy_changed wakelocks
netfilter: qtaguid: initialize a local var to keep compiler happy.

There was a case that might have seemed like new_tag_stat was not
initialized and actually used.
Added comment explaining why it was impossible, and a BUG()
in case the logic gets changed.

Change-Id: I1eddd1b6f754c08a3bf89f7e9427e5dce1dfb081
Signed-off-by: JP Abgrall <jpa@google.com>
netfilter: xt_qtaguid: fix ipv6 protocol lookup

When updating the stats for a given uid it would incorrectly assume
IPV4 and pick up the wrong protocol when IPV6.

Change-Id: Iea4a635012b4123bf7aa93809011b7b2040bb3d5
Signed-off-by: JP Abgrall <jpa@google.com>
msm: kgsl: Add ION as an external memory source (CodeAurora)

Allow ION buffers to be attached via IOCTL_KGSL_MAP_USER_MEM

Change-Id: Ic0dedbada34d12fb70b528f3a93dd21805a4c8a4