msm_fb: display: Map framebuffer region in Display Write Domain

Framebuffer is currently mapped for Display read and rotator source
domains. For MDP writeback mode, Display write domain requires
framebuffer region and it is mapped at initialization time.

CRs-Fixed: 382550
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Change-Id: Iba6fd0201a48fe1864bf42e9576f063cd58646fd
video: msm: Don't make the framebuffer cached

The video framebuffer should not be cached when mapping into the
rotator or video domains. Change it.

Change-Id: I407c68ac21a030aff801ebfae01d360bb6bf338c
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: Select page protection for IOMMU

IOMMU mapping requires explicit attributes for mapping instead
of relying on defaults. Add explicit page protection attributes
when mapping contiguous buffers.

Change-Id: I01e19eebd5b1a1c2456ba99861641baafbabe97a
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: iommu-domains: Check IOMMU capability of device

Since, IOMMU will be enabled by default, check the IOMMU support
from hardware and decide the code path.

Change-Id: I1cea3ff145add2c8ed9e99edecebfb80b1c78760
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
msm: Check for iommu with map_contiguous APIs

The msm_{un}map_contiguous_buffers lack checks for iommu_present.
This causes incorrect behavior if the APIs are used when IOMMU is
not present. Add these checks to do the correct action when IOMMU
is not present.

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

Conflicts:

	arch/arm/mach-msm/iommu_domains.c
msm: iommu: Reorganize platform devices

 * Via CodeAurora Forum

Change-Id: Ib91d56ba32f34b1ff23eb3942318a2deb7eab8b1
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>
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>
drivers: iommu: move to a dedicated folder

Create a dedicated folder for iommu drivers, and move the base
iommu implementation over there.

Grouping the various iommu drivers in a single location will help
finding similar problems shared by different platforms, so they
could be solved once, in the iommu framework, instead of solved
differently (or duplicated) in each driver.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

Conflicts:

	arch/arm/mach-msm/Kconfig
iommu/core: Add fault reporting mechanism

Add iommu fault report mechanism to the IOMMU API, so implementations
could report about mmu faults (translation errors, hardware errors,
etc..).

Fault reports can be used in several ways:
- mere logging
- reset the device that accessed the faulting address (may be necessary
  in case the device is a remote processor for example)
- implement dynamic PTE/TLB loading

A dedicated iommu_set_fault_handler() API has been added to allow
users, who are interested to receive such reports, to provide
their handler.

Signed-off-by: Ohad Ben-Cohen <ohad@wizery.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>

Conflicts:

	drivers/iommu/iommu.c
	include/linux/iommu.h
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>
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/board-8064-gpu.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>
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>
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-8930-gpu.c
	drivers/gpu/msm/kgsl_iommu.c