msm: iommu: re-enable system IOMMU for KGSL

Change-Id: Idb4db36594284692f90e2b30793d28b8ddba02d2
gpu: ion: remove HTC MM heap 1M alignment

Change-Id: Ie786bb5ba45b4d1e1fce9f49a3107819aeb8ad1b
msm: iommu: Do not register API on unsupported SoC versions

In addition to not registering IOMMU devices, do not
register the IOMMU API on SoC versions which do not support
it. This will allow iommu_found to work properly.

Change-Id: I103fc4ff910bee3eb4039e19de52f36cd1778861
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-iommu.c
msm: iommu: Discontinue use of clk_set_min_rate()

Support for the proprietary clk_set_min_rate() API is being removed from
the clock driver. Replace it with a clk_round_rate() and clk_set_rate().

Change-Id: Icd62a8768d99cf007cf899c705626f8eacbaa7c8
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
msm: iommu: use sg_dma_address() in iommu_map_range()

Ion carveout and content protect buffers do not have
a struct page and thus sg_phys() cannot be used on them.
Try sg_dma_address() first and if it returns 0 then
use sg_phys().

Change-Id: I95ccb8f5a3c86cd09ecf2a2737c260f4996059ac
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 74e57d4eb3b37fbf57145573c5cb3892c89d8bc0)
cherrypick
cherrypick
cherrypick
gpu: ion: Remove extra iova free call

IOMMU virtual address (iova) is allocated locally in IOMMU mapping
functions per heap type. When an error happens the iova's are
freed in the same function as it was allocated. However, there
is an extra free call in the ion wrapper function that calls
these IOMMU mapping functions.

Remove the extra iova free call which can cause kernel panic.

Change-Id: Ic8978cf05202b29a42da7374e2c8c1e590b2d2a8
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit b343e0593e5f574cd1483497807a6cf10b7aee8e)
msm: display: Attach MDP IOMMU during first update after boot

For continuous splash support to work properly, attach the MDP IOMMU
device at a later point during boot to allow display use the
splash image from bootloader

Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Change-Id: Ife9a2afae1e9b9140ee74af0cc7dcf7ad945d4de

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_dtv.c
	drivers/video/msm/mdp4_overlay_lcdc.c
msm: Enable all IOMMU's

Enable video, camera, display, and rotator IOMMU's so
that virtual contigious memory can be used by these
devices. Physical contigious carveout regions can
be reduced so that more memory is available to the
rest of the system when not in use by multimedia.

Change-Id: Ibfad7d6a55e04490be9e39a5539780657f6727e0
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/iommu_domains.c
gpu: ion: Map everything into IOMMU with 64K pages.

Due to performance issues with 4K pages and the IOMMU we should use
64K pages. However, minimum allocation from ION is 4K so instead of
mapping on demand we need to map the full heap into the IOMMU when
the first request for mapping comes. Only unmap everything from the
IOMMU when the last buffer is freed.

CRs-fixed: 348606
Change-Id: Ic1793f5caaff2f69bf1fb7e8c8b3bd03378131b8
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 5027688e1d4cf244f84b525c76a000b9408c62a5)

Conflicts:
	arch/arm/mach-msm/board-8960.c
	arch/arm/mach-msm/board-msm8x60.c
	arch/arm/mach-msm/include/mach/iommu_domains.h
	include/linux/fmem.h
	include/linux/ion.h
msm: HTC 8960: update board files for 64K mappings

Change-Id: I10d33e476700d573fed7ef8c9f2e79f7f892538e
gpu: ion: Fix incorrect argument to map call

An incorrect argument is passed to a local ion heap
function call. This is causing incorrect flags to be
passed to iommu map call. The side effect is that the
flags passed to the iommu map call is defaulted to
read-write and uncached.

Change-Id: Ia2a7e64818dc8f251dadfb545f9b218a5e3cfc42
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 3d79eec14b8fdb99832a907a0ae29042eaba7f07)
gpu: ion: Use standard cache routines

Instead of using custom routines for cache operations use the
standard operations for cache flush, cache clean, and cache
invalidate. In addition only call outer cache routines if
outer cache is available.

Change-Id: Idb51bf7348fd526ebdea1e6ff2e366b8a3b4de33
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
(cherry picked from commit 85c95406680ce1a959a9b8cdb5aff7afcd699038)

Conflicts:

	drivers/gpu/ion/ion_system_heap.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
gpu: ion: Move MFC heap to different address

Video hardware has the following requirements for
ION heaps:

1. MM heap must be at a higher address than FW heap.
2. MFC heap must at a higher address than FW
3. MM heap must be adjacent to FW heap.
   (There cannot be another heap between FW and MM heap)
4. MM and MFC heap cannot be more than 256MB away
   from the base address of the FW heap.

MM heap is configured as a reusable heap (FMEM heap) and FMEM
is carved out at a much higher address than the other heaps breaking
the above requirements. To support the above requirements the
MFC heap together with the FW heap must be carved out at the same
location as MM heap.

Change-Id: Ie0acb4b267d4307190ea3cd9ff23c710ffa1a538
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8960.c
	include/linux/fmem.h
	include/linux/ion.h
cherrypick
ion: support creation of mm heap in a fixed place

The multimedia firmware on 8960 will always be
loaded into a fixed address, and all callers into
this firmware must be no more than 256M above the
start of this firmware.

This implies that the the mm ION heap and its associated heaps
(mm_fw and mfc) must also be created in a fixed place.

This version of the patch keeps the mm fw heap size
to 2M for compatibility with the current tip. This
will eventually be reduced to 1M.

Change-Id: I35f89b8c60165fb0adbb9d04412e0e200117beb9
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8960.c
cherrypick
msm: HTC8960: map all into IOMMU at correct alignments

Change-Id: I6f89f4dfc4cbb5fd7f85bc80bd802912581fe444