ion: invalidate buffers before zero'ing

Currently, we invalidate the cache for buffers being zero'd *after* we
zero them. However, this is racey since a dirty cache line from an
earlier mapping could be written out to memory between the zero'ing and
the invalidation. Fix this by invalidating the cache *before* zero'ing
the buffer.

Before this change, I was seeing corruption with:

    $ cat <<EOF | ./memory_prof -e -i -
    simple_alloc,1,ION_SYSTEM_HEAP_ID,ION_FLAG_CACHED,0x100000,1MB
    simple_basic_sanity,1
    simple_profile,1
    simple_free,1
    EOF

After this change, no corruption.

CRs-Fixed: 585524
Change-Id: I1f2603604efc9be4ebf9112b06728e0aeca60ea0
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
ion: remove ion_cp_heap

The CP heap has been replaced by CMA-based heaps. Remove it.

Change-Id: I6b5e81d701e730584a456c7d9c3ff71397a12c0f
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

msm: Remove references to SMI

SMI memory is no longer supported on current targets. Remove
all references to it.

Change-Id: Ifbdf6247cc4b13c1d0173f1c998e07c702c06408
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: get rid of adjacent heap code

The targets that require adjacent heaps are no longer present. Get
rid of the complicated crufty code.

Change-Id: Ic46cd16d36b812b19a7dc88202264cf137aebdd1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: Remove mach/ion.h

This file is now mostly useless. Move the remaining defintions elsewhere
and cleanup the cruft.

Change-Id: Icc19f9138a0d9d24a466511d69bc0eed45789fb9
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: Remove allocate_contiguous_ebi call for carveouts

The allocate_contiguous_ebi APIs are being deprecated in favor
of the standard dma_alloc_coherent APIs. The carveout heap
does not currently support the dma_alloc_coherent APIs so just
give a note that clients should switch over to a heap type that
does support dma_alloc_coherent for non-fixed addresses. Remove
some crufty stuff related to allocate_contiguous_ebi memory types
as well.

Change-Id: I96fd43eb59d4cde4cdfd5c8d414885467ff423db
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

x9007: Remove references to SMI memory

Change-Id: I1b22e2d09c830be47e8100f1fbe9cf084fd0be31

gpu: ion: change pr_err to pr_debug for secure buffer failure

New architecture requirements for secure buffers mean that a
secure buffer failure may happen during normal playback. There's
no need to print an error message every time during normal use
cases so change the pr_err to pr_debug.

Change-Id: Ic05d0e95e2542dec9661e990cbfefd50274abc9e
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: Pull secure buffers out of Ion

Securing individual buffers does not belong in the Ion framework.
Pull the code out of the framework and into a file which can be
managed separately. The file can be moved elsewhere at a later
date.

Change-Id: Ifaec740abcd78ee1bc3769a6c73014e4309c82be
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: Skip wrong usage check for secure buffers

With the change to secure buffers at allocation time, it is
no longer possible to correctly validate if the memory is
re-secured with a different usage hint. Considering the usage
hint is being deprecated anyway, drop the redundant check. If
a client tries to re-secure with the wrong usage hint, failures
will occur elsewhere to indicate the problem.

Change-Id: If8487c431eb4555927cd06c6cc5edcb1a66002f1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

gpu: ion: only secure buffers when supported

There are some targets where securing Ion buffers is not supported
through the TZ API used in the MSM secure buffer code. Currently, we
simply try the allocation and if it fails we let the clients secure it
themselves through some other means. However, due to a recent change to
the TZ error logging in the kernel, the current "ask for forgiveness"
approach results in logspam. Fix this by moving to an "ask for
permission" approach: if the TZ API to secure the buffers is not
available, don't attempt to use it.

Change-Id: Ie003d5139a0622ce9c18719ca2697525e23e7733
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>

ion: fix print statements

Use %zx, %zu for printing size_t and %p for printing
pointers (rather than casting them as integers and using %x).

Change-Id: I86bc2b10283b640f51a861adde6b8181bdbbcb29
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

msm: Remove lib/memory_alloc.c and related files

The memory pools are gone for good. Remove memory_alloc.c and the
associated header file from clients.

Change-Id: I8d303c72fa03cdca7eee34b39d57d5cbb5df920d
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: Remove memory reservation code

The memory reservation API used for allocate_contiguous_ebi is now
deprecated in favor of using standard kernel APIs such as
dma_alloc_coherent and CMA for reserving/allocating memory. Remove
lots of code.

Change-Id: I5a7c22cce6b4b772dc67d18029e40b4509d3ba40
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: Remove ugly header include fixme

Long ago, some targets needed ugly hacks to work around buggy
hardware. These targets have fortunately been deprecated.
Remove the ugly header include remnants.

Change-Id: Ia7eef2f8f625775e40c1a73f5c2095560618cada
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: Remove store_ttbr0

This was used for debugging a while back but isn't even called
anymore. Remove it.

Change-Id: Ia5e9c609508a80ae471b9ff448b92fe193e2d2b1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: clean up memory.c

This file contained support and workarounds for platforms that are
no longer supported on 3.10 -- remove this code.

Change-Id: I841a04c34c5fbe36a40b5ee49e3ac8608c963808
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

msm: clean up memory.h

Remove various defines and comments which were only
relevant to platforms or features not supported any more.

Change-Id: I3eade953577079878375c87e35c842090c35f55d
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

msm: remove allocate_contiguous_ebi APIs

The allocate_contiguous_ebi APIs are now deprecated. Remove them.

Change-Id: Icb83230e5b4b2eca135e8a27f6d5e73a0b9b3bb9
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: Remove DONT_MAP_HOLE_AFTER_MEMBANK0

The DONT_MAP_HOLE_AFTER_MEMBANK0 feature is now deprecated. Remove
the code associated with it.

Change-Id: I729b9574a7655e97c8e7abc68797b874e90dcac2
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

ASoC: msm: qdsp6v2: Migrate away from allocate_contiguous_ebi APIs

The allocate_contiguous_ebi APIs are being deprecated in favor of
the standard dma_alloc_coherent APIs. Migrate accordingly.

Change-Id: I01dece36f7aaae192afa689daf0b51de4c1ec592
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: kgsl: Remove reference to memory_alloc.h

Change-Id: I11a86f6f3254c8f150b7287d729540ef5db71ea1

msm: rtb: Convert away from allocate_contiguous_ebi APIs

The allocate_contiguous_ebi APIs are now deprecated. Move
to using dma_alloc_coherent for the RTB buffer. Because we
aren't using allocate_contiguous_ebi for allocation, change
the devicetree bindings as well to support using CMA or just
a regular size from the generic region.

Change-Id: I8ab0b7336924a78b40c68af3f215d7bfd2fba33c
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: pm-boot: Remove boot remapping support

All devices that used the boot remapping code are no longer supported.
Remove the code that sets this up.

Change-Id: I85eb4e9f01664c855b0f96c34daca4c2a16ce896
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: pm-boot: clean up non TZ support code

Modern ARM processors supporting TZ environment by
default. Currently, cores warmboot starts from TZ when
there is a TZ support. This patch removes the non TZ
supported code.

Change-Id: Ifa5df40bd649e4860a2660132f3fc30fa7937358
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>

msm: pm-boot: flush msm_pm_boot_vector to main memory

msm_pm_boot_vector array stores cores warmboot entry before
cores enter into LPM mode. These warm boot entries must be
visible to core when it comes out of LPM mode. To ensure
this variable to appear in main memory use flush APIs to
flush out of caches. Use a different API to do this on
latest ARM based targets.

Change-Id: I870b68e4f6f6b116e93deffe59edff9094db0fa8
Signed-off-by: Murali Nalajala <mnalajal@codeaurora.org>

msm: buspm: Remove allocate_contiguous_ebi calls

allocate_contiguous_ebi is being deprecated in favor of the standard
dma_alloc_coherent APIs. Move accordingly.

Change-Id: I3746e5ac047b1a6ee570aaf96ffbe305e3b6a49f
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

msm: kgsl: Add CMA memory feature to support NOMMU for GPU

Reserves CMA memory for kgsl driver early during bootup and then
uses dma_alloc_coherent() to allocate physically contiguous memory
instead of using the MMU

Change-Id: Ica9b244fe9b9d8a902d670293a0bec2edf81bd5d
Signed-off-by: Shrenuj Bansal <shrenujb@codeaurora.org>

media: Remove videobuf2-msm-mem.c

This file is no longer needed by any frameworks. Remove it.

Change-Id: I66f01ab9ba273ba15b1966ad040d1d3d172d33bf
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8974.c
	arch/arm/mach-msm/oppo/board-8974-x9007.c
	drivers/gpu/ion/ion_cp_heap.c
	drivers/gpu/msm/adreno_a2xx.c
	drivers/gpu/msm/kgsl_sharedmem.c