msm: iommu: Reorganize platform devices

 * Via CodeAurora Forum

Change-Id: Ib91d56ba32f34b1ff23eb3942318a2deb7eab8b1

Conflicts:
	arch/arm/mach-msm/devices-iommu.c

Conflicts:
	arch/arm/mach-msm/devices-iommu.c
msm: iommu: Switch to the new clock APIs

Change-Id: I26521f28bc0217eaf394ff4c133bb3266b7582b5
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: iommu: Convert spinlocks to mutexes

Use a mutex to protect the IOMMU data structures to allow
use of the new clock APIs from within lock-protected
regions.

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

Conflicts:
	arch/arm/mach-msm/iommu.c

Conflicts:
	arch/arm/mach-msm/iommu.c
msm: iommu: Support IOMMU page fault reporting

Provide the ability to report IOMMU fault events through
the IOMMU API. The driver will fall back on the previous
behavior of printing the fault information registers if no
domain fault handler is registered, or if the handler
returns -ENOSYS.

Change-Id: I9144e9b4bba117b67c7d81609e986ea716b34882
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
iommu/core: let drivers know if an iommu fault handler isn't installed

Make report_iommu_fault() return -ENOSYS whenever an iommu fault
handler isn't installed, so IOMMU drivers can then do their own
platform-specific default behavior if they wanted.

Fault handlers can still return -ENOSYS in case they want to elicit the
default behavior of the IOMMU drivers.

Change-Id: I4cb7d6566f9d0f4329c37e890fee6c113edeb981
Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
iommu: Initialize domain->handler in iommu_domain_alloc()

Since it is not guaranteed that an iommu driver initializes in its
domain_init() function, it must be initialized with NULL to prevent
calling a function in an arbitrary location when iommu fault occurred.

Change-Id: I1001bc6382cfe1e6cf8f311a822380f4151f8391
Signed-off-by: KyongHo Cho <pullip.cho@samsung.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
[stepanm@codeaurora.org: rebased to before the file moved]
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>

Conflicts:
	drivers/base/iommu.c
msm: kgsl: Program both IOMMUs at our disposal on 8064

APQ8064 has two AXI ports attached to the GPU with an IOMMU on both.
The VBIF can be programmed to use a round-robin arbitration to access
the ports equally, so we need to program both IOMMUs with the same
pagetable to make sure that the GPU can get where it needs to go.
All this involves a board file infrastructure change that affects 8960
too, but no functional changes are happening for that platform.

Change-Id: Ic0dedbad5198ed9c453711e58a3f1220ef5d5b4e
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/devices-8960.c
msm: kgsl: fix 8960 2d1 iommu name

The correct name is gfx2d1_2d1.

Change-Id: I7e988c0ac88fb4006096b210f829e7ad80e73c12
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Fix oops in early panic() when __etb_disable is called before being probed.

Change-Id: I05fc04d1ffae201988ff7225aa236d4735c4fef1
msm: iommu: Disable access to global registers

Global IOMMU registers are not accessible to Linux kernel and
should not be read or written to.

Add Kconfig option to turn on configuration of the global IOMMU
address space but leave default turned off.

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

Conflicts:
	arch/arm/mach-msm/include/mach/iommu_hw-8xxx.h
gpu: ion: Fix fragmentation debug message cond.

If an ion allocation fails because of memory fragmentation a debug
message should be printed. However, the logic that decides whether
the debug message should be printed or not is incorrect causing
the debug message to not be printed when the amount of space
available in the heap is equal to the requested size.

Change-Id: Iaaf8cd6742aeffab7bcb4806e485326fb9690945
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
msm: kgsl: Change iommu structure to better represent the hardware

Change the iommu structures to properly represent the iommu hardware
which makes the code more readable.

Change-Id: I61cf988998da3fc4f62ca020e4240cf50ddd20f0
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/board-8064-gpu.c
	arch/arm/mach-msm/board-8930-gpu.c
	drivers/gpu/msm/kgsl_iommu.c
	drivers/gpu/msm/kgsl_iommu.h
board-8064 msm: Overlap secure and non secure video firmware heaps.

Moves fixed area start address down, so that non secure
video firmware heap and secure video firmware area overlap.
Both use the region in a mutually exclusive manner.
ALso introduce a hole, that can be used by MM heap
lock down for content protection.

Change-Id: Ic240377da25e00423742ccb73dbb60a1ff037e37
Signed-off-by: Deepak Kotur <dkotur@codeaurora.org>
(cherry picked from commit eadb7505134a23b8de3cd74c924fd31324978a7e)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/board-8064.c
fmem: interact properly with DMM

On a system with both FMEM and DMM, FMEM must veto
memory hotremove of section(s) FMEM occupies when
in C-state and allow it (after cleaning up metadata)
in T-state (and then change to O-state).

It must also change back to T-state when all sections
FMEM uses have been powered on.

Change-Id: I9766a07305d1e3e2c6ff48e1cbf6933765b751f8
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
fmem: hotplug notifier should do nothing if fmem is inactive

If fmem discovers it has no memory to manage, it will
stay in an uninitialized state. However, this is
not discovered until long after the hotplug notifier
is set up (which must be in the fmem_init function).

Since fmem has not been initialized, the hotplug notifier
runs and incorrectly causes memory hotremove to fail, as
it bases its decision on uninitialized data.

The fix is for the hotplug notifier to just return
immediately if fmem is in the uninitialized state.

Change-Id: Ia647470d64fe1926be404af419f5f516e6b59c05
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
fmem: add missing zcache_put after zcache_get

The code to flush all objects was missing a needed
zcache_put after a zcache_get.

Change-Id: I03ad33ee74b42567d8c0598bd5c2af7e455ca097
CRs-Fixed: 350617
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
FMEM: allocate non-fixed FMEM from memory pool

On platforms whose FMEM is not at a fixed place
and which don't have DMM (such as 7x27a), FMEM
and the EBI memory pool would incorrectly overlap,
and the same memory would be used both as FMEM
and as memory allocated by allocate_contiguous_memory()
at the same time leading to crashes and strange behavior.

There are some unsolved problems related to
allocating FMEM from unstable memory, so we have
decided not to do this any longer. This decision allows
us to simply allocate non-fixed FMEM from the
EBI memory pool (this will prevent FMEM's memory
from being used by another allocator at the same time).
In this case FMEM will appear to "overlap" with
the memory pool, but this now OK as FMEM is allocated
from it.

This also re-enables FMEM on 7x27a and 8625, which
had been disabled due to the above-mentioned bug.

CRs-Fixed: 354254
Change-Id: I8e0bba332c7ddcac1d280de9642078fdfe61bbcc
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/board-8960.c
	arch/arm/mach-msm/board-msm7x27a.c
fmem: Use alignment property from platform data

Change-Id: I5d3e5f2c022937cd721befdd67a9d2f8f927608e
msm: HTC 8960: Import FMEM changes to board files

Change-Id: Id5cf6de6d0ec61744903d2d06a9db3d5d9dc9faa

Conflicts:
	arch/arm/mach-msm/board-elite.c
	arch/arm/mach-msm/board-ville.c
msm: display: check get_unused_fd_flags return val

Not checking the error code, which might be negative, will cause us to wrongly
reference fdt[fd] by using the error code, causing kernel panic in fd_install.

Change-Id: I1f8e68e74bdbdd5b81bc3450f7d93b5cd96c9439
Signed-off-by: Iliyan Malchev <malchev@google.com>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c