msm: iommu: Use threaded IRQ handler for page faults

A threaded interrupt handler for IOMMU page faults will
allow the use of the new clock APIs from the interrupt
handler.

Change-Id: I381df3974daa7fbc4bc4ec0558434959597b4f24
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: iommu: Enable use of TTBR1 register of IOMMU

Add a new platform data in iommu devices to indicate whether ttbr1
should be used which also dictates how the address space should be
split between ttbr0 and ttbr1.

Change-Id: Iab3aac74256bd4d49f47f89e6638f014e6e539e9
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: iommu: Support mapping attributes

Add support for the IOMMU_READ and IOMMU_WRITE attributes
for mappings. Read-only and read-write mappings are fully
supported. Write-only mappings are not supported in
hardware and will fall back to read-write. Specifying
neither attribute in iommu_map will result in a warning on
the first call, and the mapping will be treated as
read-write.

Change-Id: Ibe9bd340d0743f37c91580c7db4f199fb4afba8b
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: Move subsystem map specific code to the subsystem map file

Code to translate between the old style subsystem map ids and
newer domain/partition numbers is no longer dependent on anything
in iommu_domains.c. Move it to the subsystem_map file to better
separate the old code from the new code.

Change-Id: I899a3215f17b7b8c55969086389b89c4401bea3f
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: iommu: Use ttbr1 for graphics 2d devices

Split the virtual address between ttbr0 and ttbr1 for
2d devices of graphics

Change-Id: I6f5751c0586cfd16e01f2e324b544463efdd54d2
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
msm: Add simple APIs to map contiguous buffer

Typicall, most iommu mapping happens through Ion or another
API. There may be other cases when clients need a simple
API to map a contiguous physical address into an iommu.
Add apis to support mapping and unmapping a physical range
into the iommu. The client is responsible for any reference
counting that needs to occur.

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

Conflicts:

	arch/arm/mach-msm/include/mach/iommu_domains.h
msm: iommu: Clean newly-allocated page tables

If L2 redirection is disabled, clean page tables upon
allocation to prevent hardware table walks into unmapped
areas from accessing stale data.

Change-Id: If1e70bfa52f86d9ddc5a001a699050667b075631
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: iommu: Refactor cache cleaning functionality

Refactor clean_pte to accept a redirection attribute, which
allows for cleaner code at the caller.

Change-Id: Iff77abdced1fa6ea295a4bf6ec76f644b9922e63
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: iommu: Use iommu_map_range for 4K mappings

iommu_map_range is much more effective than
calling iommu_map for each page to be mapped.

Change-Id: I674af262f730cddbc49cdabe564e14f0874c0196
CRs-fixed: 369080
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/iommu_domains.c
fs: fat: rate limit the kernel messages

If FAT formatted SD card gets removed without unmounting,
FAT file system may throw many kernel error messages which
could too much traffic for console driver and can sometimes
even cause the system to trigger watchdog timeout.

This patch converts the printk to printk_ratelimited to rate
limit the error messages from FAT fs.

CRs-fixed: 368446
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit a872b71069d717ced1a2de642afa0693d1bb9448)

Change-Id: I3ace0ffc5a0119641dff8084adccf7ed780c7900
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
arm: free all .init memory when CONFIG_STRICT_MEMORY_RWX is set

When CONFIG_STRICT_MEMORY_RWX is set, the .init section is
padded to the next megabyte boundary. The part of the .init
section past __init_end (i.e. the pad) was not being freed
since the kernel uses the address of __init_end to determine
how much memory to free.

The fix is to set __init_end to the end of the pad.

CRs-fixed: 367748
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
(cherry picked from commit f759542791356b1678698551b198ba062bfa97bd)

Change-Id: I2adf714b6a89a21b336990fc2f9398b7344963fc
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
msm: Make iommu domains platform devices

Information about the layout of iommu domains is a device
specific option. Convert the iommu domain information
into a platform driver with a corresponding platform device.
This allows different devices to have different layouts as
needed.

Change-Id: I6bf4162476143daabe16a2f5de3b655ae4377902
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: Add api to register virtual domain space

Going forward, clients may want to have more control over the
virtual address space for iommu domains. Add API to support
clients registering virtual address space information. Current
clients are internally converted to use the new APIs.

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

Conflicts:

	arch/arm/mach-msm/include/mach/iommu_domains.h
	drivers/gpu/ion/ion_iommu_heap.c
msm: Correctly lookup iommu domains.

Correctly compare against the value in the domain
structure when looking up domains.

Change-Id: Ibeb4ffff4ee14b651797668606a8e81f102b3a19
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
(cherry picked from commit 723970deb6b98b4577689eb413378051dbf3fe72)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
gpu: ion: Check return code of msm_allocate_iova_address

In the IOMMU heap, the return value of msm_allocate_iova_address
needs to be checked instead of the value of the iova address.
Check the return value instead.

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

Conflicts:

	drivers/gpu/ion/ion_iommu_heap.c

Conflicts:

	drivers/gpu/ion/ion_iommu_heap.c
video: msm: Migrate away from subsystem map APIs

This reverts commit 526068c5f872b805bfb6c4a66365d2483f2f1237.
This used the split domain names for display and rotator
subsystems compared to earlier version.

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

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_writeback.c
msm: iommu: Split rotator/mdp iommu domains

Finer granularity is needed when mapping into the IOMMU's for
rotator and mdp for secure playback. During secure playback
HLOS will only have access to map into one context bank. The
other context bank is secured and programmed by TrustZone.

Divide DISPLAY_DOMAIN into DISPLAY_WRITE_DOMAIN and
DISPLAY_READ_DOMAIN. Divide ROTATOR_DOMAIN into ROTATOR_SRC_DOMAIN
and ROTATOR_DST_DOMAIN.

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

Conflicts:

	arch/arm/mach-msm/board-8960-display.c
	drivers/video/msm/mdp.c
Split rotator/mdp iommu domains on samsung boards
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
msm_fb: display: add spinlock to protect dma status.

During dma transfer to interface host the status of the dma
needs to be protected in the smp environment.

Change-Id: I02b4f046de7f693bb098343b7345c4aa6ca395bd
Signed-off-by: Jeevan Shriram <jshriram@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp.c
	drivers/video/msm/mdp_dma.c

Conflicts:

	drivers/video/msm/mdp.c
	drivers/video/msm/mdp_dma.c