msm8960: squashed commits from CM (1/4)
jewel: add missing display_on DSI command

Missing display_on DSI command caused jewel devices with certain panels
to fail to power on.

Change-Id: I9058c7a5a4ce2bcd4b62661a125768ffb6bb9d16

Linux 3.0.59

Change-Id: I5ff61809fd6771efed8ecdb02aa17e34539f4e68

ion: add hack for HTC IOMMU camera

HTC liboemcamera requests memory from the CAMERA or IOMMU heaps, which
we cannot provide currently. Since we cannot change liboemcamera, remap
to CP_MM heap if CAMERA heap is requested.

Change-Id: I6b965bb56835583c687f0086efcb153c64cf1e25

msm: clock-8960: Change source of DSI escape clock to byte clock

Changing DSI escape clock source from PXO to byte clock to add
flexibilty for customers. They can modify the escape clock by
changing the pinfo divider.

Change-Id: I3ad072fc524fe5fae9695a55bba24ce23b97efc7
CRs-Fixed: 361022
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/clock-8960.c

Revert "power: fbearlysuspend: add sleep hack for CRT-off animation"

This reverts commit eb1844ccd25305284c277f54b97a0fd6502589c6.

Linux 3.0.60

Change-Id: I9d3e94a3830cb37a0b0f457a5d3c0eade9400a75
Signed-off-by: rohan <rohanmathur34@gmail.com>

Linux 3.0.61

Change-Id: I9b6527e26176e1e6f67929a7d60d5e8de021ee12

bdi: use deferable timer for sync_supers task

sync_supers task currently wakes up periodically for superblock
writeback. This hurts power on battery driven devices. This patch
turns this housekeeping timer into a deferable timer so that it
does not fire when system is really idle.

CRs-Fixed: 353700
Signed-off-by: Yong Wang <yong.y.wang@intel.com>
Signed-off-by: Xia Wu <xia.wu@intel.com>
Signed-off-by: Krishna Vanka <kvanka@codeaurora.org>
(cherry picked from commit f398f30d1f34632d3c96758b5b19e65b056af072)

Change-Id: I6ec6310d66c0d014adf0f41e75cd4c48c233f83d
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>

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>

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

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>

msm: krait-l2-accessor: Add missing barriers

The Krait processor requires a barrier to be executed
between writing to L2CPUCPSELR and accessing L2CPUCPDR, to
ensure that the write to L2CPUCPSELR is reflected in the
access to L2CPUCPDR.

CRs-fixed: 367753
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 4d055616056994de077122c1a8c0a4370363c2ed)

Change-Id: I52a330455cb7c5d002d1d01ae6700c1347f9dc21
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

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>

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

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>

Conflicts:
	arch/arm/mach-msm/board-8064.c
	arch/arm/mach-msm/board-8930.c
	arch/arm/mach-msm/board-8960.c
	arch/arm/mach-msm/devices-8064.c
	arch/arm/mach-msm/devices-8960.c
	arch/arm/mach-msm/devices.h

msm: HTC 8960: Make iommu domains platform devices

Change-Id: I6cc59f40649cd36b3686d4bab8293a6dc1f95919

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>

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

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-8064.c
	arch/arm/mach-msm/board-8930-display.c
	arch/arm/mach-msm/board-8960-display.c
	arch/arm/mach-msm/board-msm8x60.c
	arch/arm/mach-msm/devices-8064.c
	arch/arm/mach-msm/devices-msm8x60.c
	arch/arm/mach-msm/devices.h
	arch/arm/mach-msm/include/mach/board.h

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_dma.c

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

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

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>

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>

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>

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

msm: display: Increase timeout value for fence waiting

In some benchmark use case, graphic engine is extremely
busy, need increase the fence waiting timeout value.

Change-Id: I3c483f98fa86030b283edd8a79e7b70fa1c06335
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

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>

msm_fb: display: Consolidate commit ioctls

Overlay commit and display commit were two separate
ioctls doing similar things. This change consolidates
the two into one display commit ioctl. With this, we
can use the RGB0 pipe with an IOMMU framebuffer.

Change-Id: I2b51e16a6678e6cec1bd3e56a00a476addb1296f
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:
	drivers/video/msm/msm_fb.c

msm_fb: display: remove background invert alpha option for alpha drop pipe

When the blended background pipe has dropped alpha and it is going to
be blended with foreground pipe on the next stage,
MDP4_BLEND_BG_ALPHA_FG_CONST is taken. Foreground alpha constant is
0xFF, so we need to use this alpha value to show background, instead
of its inverted value.

Change-Id: I9412141b28a46ed3b58079a56969e79dea4ed57c
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c

msm_fb: display: add per stage alpha drop detection

Currently, alpha drop detection is done per frame which
means multiple blending stages share same alpha drop status
which does not reflect the alpha effect truly on each blending
stage. This patch enforces that the alpha drop detection
is done per blending stage so that alpha effect is applied
properly at each blending stage.

Change-Id: I2f456623c696192cf3388a635584a4a49d4720a0
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

msm_fb: display: mdp4 version assigned at board file

The mdp4 version reflects mdp's capability and is referred to at
many places. Currently, it is acquired by reading mdp version
register. Since the MDP version is defined in the board file,
this patch uses that version at probe time.

Change-Id: Iae2db1fb8609cb80f3705b5e47d3fefedc15fec5
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>

msm_fb: display: add stage commit before kickoff to WFD

Since stage commit had been splited out of stage up fucnction,
it needed to be called to stage pipes into mixer befroe
kickoff mixer. Add this function into overlay writeback for WFD.

Change-Id: I11e4486d92b89a15e58531033d474b3137b5935a
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c

msm_fsb: handle pipe-allocation errors

In mdp4_overlay_writeback_on, return -EIO is pipe allocation fails.

Change-Id: I66e73fd342d2c45c55ece5f15d1109d64a089015
Signed-off-by: Iliyan Malchev <malchev@google.com>

msm_fb: display: add options to switch blt mode for dsi video

Currently switching mdp blt mode is done in dmap done isr which could
cause mdp hang for some panels/targets. One option is added: turning
off timing generator when switching blt mode, to avoid hang issues.

Change-Id: I92cbee7c070a17d20527815ef841d2cfbb06b5cc
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

msm_fb: display: Fix flickering when BLT is enabled/disabled

The transition of BLT enable and disable start at the beginning
of vsync. This ensures that the transition is completed within the
same vsync period. We Wait for DMA-P done after turning off the
timing generator and do not prefill the frame.

Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

msm_fb: display: fix dsi controller hang up during blt enable/disable

Wait for 2 ms to make sure both dsi lanes are in stop state and
fifo are empty before reseting dsi controller.

Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

msm_fb: Add option to enable/disable mixer commit

Adds support to enable or disable mixer commit during pipe staging operations.
Depending on the current activity, this selection can be made.

Change-Id: Ia2f5dbab58f73ef4de90abf7f278332d8d73df46
Signed-off-by: Pradeep Jilagam <pjilagam@codeaurora.org>
Signed-off-by: Ajay Dudani <adudani@codeaurora.org>
Signed-off-by: Iliyan Malchev <malchev@google.com>

msm_fb: display: wfd with vsync driven frame push

To improve performance, hardware vsync event at mdp driver
is passed to framework so that both composition and frame
update are aligned at vsync event. This patch will upgrade
wfd to incorporate vsync driven frame push in consistence
with other interfaces.

Change-Id: If088826ec387446301f1f6acc311d909edb04163
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit d74db5fcf24a223570137087aa5632593b315fcc)

Conflicts:
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_writeback.c

msm_fb: display: empty pending queue during suspend

Overlay_play() adds a pipe into pending queue and pan_display()
will commit those pipes to hardware and empty queue. This patch
will make sure queue is empty at suspend so that no unexpected
pipes will be commited to hardware by pan_display() at resume.
Otherwise, iommu page fault may happen.

Change-Id: Iafdf469c6cdbf5d469c9dee114555a8d1adb9c66
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

msm_fb: Wifi display changes for commit ioctl

This change handles panel updates for WFD panel via
overlay_commit interface, along with conglomeration of
some common code across pan_update and overlay_commit ioctls

Change-Id: I8e7453dc16dc04805aff0416789a622b824a44bb
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay.c
	drivers/video/msm/mdp4_overlay_writeback.c

msm_fb: display: empty pending queue during suspend for wfd

Add the logic for wfd writeback interface. It already presents on
other display interfaces.

Change-Id: I389be77ec18041e260d0e71940586e86f1841ff8
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit 3df55288659cfa826e9ad89cb38a8b722b2ae20f)

msm_fb: display: add config of wb_mux_sel during update

To make sure for each writeback play the reg is configured and avoid
mdp hang.

Change-Id: I29bdc31f27accca84e7add126c1c1e3c8a78fa15
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit 36ca4e992dc5c75a2dd709969db850aa02e7c6e7)

msm_fb: display: add sysfs and clock control to smart panel

Both vsync enabled and disabled are controlled by framework
through ioctl. Driver reports vsync event to framework via
sysfs. Meanwhile, mdp related clocks are enabled by frame
work at vsync enabled request and disabled by driver if there
is no any display update within specifid vsync period.

Change-Id: Ice5be3a6db5930b95bdd2f718d9256bf73936e23
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit 3c406e4eec79b710b7f5b5b67c23db7af871be40)

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_cmd.c
	drivers/video/msm/mipi_dsi.c
	drivers/video/msm/mipi_dsi_host.c
	drivers/video/msm/mipi_novatek.c
	drivers/video/msm/mipi_samsung_oled.c

msm_fb: display: add video mode dcs cmdlist support

Add video mode dcs command list support. This patch
make sure dcs commands committed while dsi video engine
is busy so that dcs command will be transmitted at beginning
of next BLLP.

Change-Id: I11b0214ee10f3b1ef33b1da4c8e577800068cb06
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit 7b0e0a45216714d76bf717a928a0db77bfa2868a)

msm_fb: display: fix dsi_busy_wait race condition

After pipe_commit() released mutex and before kickoff happens,
There has possibility that dcs command may start transmitted.
This patch add dsi_mdp_busy flag to fix this race condition.

Change-Id: I0d9a81cd0719085c91c03386117261ad3bb6b182
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit c9427ced2ab4cf1094b61360a476305066044a54)

Conflicts:
	drivers/video/msm/mipi_dsi_host.c

msm_fb: display: force mdp clock off at suspend

At suspend, turn off mdp related clocks off if clocks
are not turned off by vsync disable request.

Change-Id: I0949b00b9ee0aee05b9b553ac7318b647052d94d
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
(cherry picked from commit 780557dc178fc5511f4c03b4840791d27499a5f6)

msm_fb: display: add wait4videodone for video mode

Add wait4videodone to commit dcs commands to dsi controller
while video engine is busy so that dcs commands will be
transmitted to panel at next beginning of BLLP.

Change-Id: I7ca40124813452f25a60f899437aeb9bce6feb14
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

msm_fb: display: Removing extra disable irq in cmds_rx API's

Disable IRQ for DSI_CMD_TERM was already called in the isr.
Removing the extra call present in the cmds_rx API's.

Change-Id: I0000dd3166beb2a3b0c788327e1d7520e0c11a13
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

video: msm: Fix mismerge

Change-Id: Iacbe6a461b12dbf1c605cb4cd7a1422bba58fb6b

Conflicts:
	drivers/video/msm/mdp4.h
	drivers/video/msm/mipi_dsi_host.c

iopoll: Introduce memory-mapped IO polling macros

It is sometimes necessary to poll a memory-mapped register until its
value satisfies some condition. Introduce a family of convenience macros
that do this. Tight-loop and sleeping versions are provided with and
without timeouts.

Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
Change-Id: Ia7db00cbe60ded8b0ed9bbff264aaea0841da92a

iopoll: Tweak min sleep time used with usleep_range()

Users of the iopoll macros may need to poll addresses that take
a long time to update. In such cases, the hardcoded value of 1 us
passed as the minimum delay to usleep_range() may result in
reads that occur more often than necessary.

Use (sleep_us/4) as the min delay instead of 1 us to resolve this
is a scalable way.

Change-Id: I8f679a7ecdb9ea2666c78aabca3c8ba806e0ead3
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>

iopoll: Introduce the readl_iopoll_timeout_noirq macro

It is sometimes necessary to poll a register - until a
certain value is read - in atomic context. Introduce
a macro that allows one to specify the maximum number
of reads attempts and the number of microseconds to
delay between each read attempt.

Change-Id: Ice27e78cf4e156da9de00d58783c220bdbc758d3
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
(cherry picked from commit 7a35f5abde0192e72d4e7982411e376d8b898944)

msm: event_timer: Support to add event timers.

Add support to allow drivers to specify future events
that need to be treated as hard deadlines. Upon event timer
expiry the driver will be notified by callback function
that the driver provides.
The pm code can query the earliest event and modify
the event timer accounting for the back off based on the
latency of the low power mode being entered.

(cherry picked from commit 388c308cebef8e9cdbd80608a032abc810d46e62)
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>

Change-Id: I461e2c31c285b93588aa56dd25905efab020e0c8
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

msm: HTC 8960: update mipi_dsi_mdp_busy_wait function calls

Change-Id: I05e76b1fdc98aba8c1c8b5ecde2de647b68d1867

msm_fb: display: delete dsi clock control from cmdlist_commit

cmdlist_commit perform dsi clock control which turns off
dsi clock unexpectly when dsi controller is configured as
command mode during booting up. This cause display panel
can not be lit up. This patch drop clock control mechanism
from cmdlist_commit and move dsi clock control mechanism to
caller.

Change-Id: I1882ea3ee1c90ac5d76958c986740582929a5e3b
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
Signed-off-by: Siddhartha Agrawal <agrawals@codeaurora.org>

msm: display: non-blocking for overlay update

Display commit will work as overlay commit when
MDP_DISPLAY_COMMIT_OVERLAY flag is set. It will be
non-blocking if wait_for_finish is false.

Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Naseer Ahmed <naseer@codeaurora.org>
Change-Id: Ibd143dbfcd2fdd7a8fab3038c5af4e2fbc9ea198

video: msm: Move histogram disable to before panel off

Histogram expects the display to be on while running, thus moving its
disable call to before disabling the panel timing generator ensures this
assertion.

Change-Id: I308b3e0c24f0111fb8549d0a0ae025910d649b75
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:

	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_lcdc.c

Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

video: msm: Dynamically toggle histogram interrupt

Make histogram enable/disable functions also enable/disable the histogram
"interrupt enabled" bit on the MDP enabled interrupts register.

CRs-Fixed: 398556
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Change-Id: I56f811e88cf3fd44ae0a2df8a6e5de32ba9a0c1c
(cherry picked from commit 1026832c51cbadeea9a717fa20fb42b6a7c5661f)

Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

video: msm: Defer histogram reset to workqueue

Currently, when an underrun occurs, a reset request is sent to the
histogram hardware. This has been observed to cause a hang in the histogram
collection cycle. The fix for this hang is to instead rely on the existing
checks for histogram validity in the histgram read worker. When the
underrun occurs, the histogram is invalidated, which in turn causes the
histogram read worker to reset the histogram collection when it attempts to
read its contents.

Change-Id: I66d33ddedef76fdcb6c4a3d8095c0e8ca695e33d
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 2dd5234c094157bf77781b8646ac9ad114f819b0)

Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

video: msm: Ensure idle state before enabling histogram

Disable interrupt, set state flags to false, cancel histogram collection,
and clear the workqueue before attempting to enable the histogram. This
guarantees that this is the only configuration of the histogram running.

Change-Id: I222932db40494724b3efdb2e5bea08a849095c1e
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
(cherry picked from commit 5e5f3b4ff8a4a0d980e02fa38c2b70fec7095e79)

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

video: msm: Enable mdp clock for histogram and histLUT

Enable the mdp clock for histogram and histogram LUT to ensure that the
clock remains enabled when they are being accessed.

Change-Id: Ic744f2ee96b64442f23ba19aa1c38552c0dad83a
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

msm_fb: Retain CSC values across suspend/resume sequence

CSC values pertaining to various H/W blocks are stored in a
global structure and will be re-applied during resume sequence.

CRs-Fixed: 376159
Change-Id: Ieb151185efd106041e28feedf4fa271ae4ba2666
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_util.c

msm_fb: configure LM1 and LM2 CSC coefficients with RGB2YUV for WFD

1) Initialise the LM1 and LM2 coefficients with RGB2YUV as WFD expects
these coefficients to be programmed.
2) LM2 is available from MDP ver 4.3, fix conditions accordingly
CRs-Fixed: 399462
Change-Id: Ifad2be0fb5c3c96fa1515e114097a87d250fd62a
Signed-off-by: Kalyan Thota <kalyant@codeaurora.org>
(cherry picked from commit f6044334ee63fe9553f5cce8aa65c172c88e1175)

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

Conflicts:
	drivers/video/msm/mdp.c

msm_fb: display: Add timeout for waiting on update

Content Adaptive BackLight userspace algo waits on UPDATE_NOTIFY to
get the screen updates. When turning off CABL, this blocking ioctl
causes the CABL threads to wait until next screen update, which may
take indefinite time.

Add timeout value to the wait_for_completion call, to make ioctl
call blocking for at most timeout value.

CRs-Fixed: 384026
Change-Id: I6715a36020c24ddd09823bd54d4321900429a6b9
Signed-off-by: Kinjal Bhavsar <kbhavsar@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

video: msm: Send ETIMEDOUT on update-notify timeout

Send the ETIMEDOUT errno when the update-notify wait_for_completion times
out. This is required to be able to properly handle the different failure
cases in the functions that use the update notify ioctl.

Change-Id: I0e46b0b0c89f6b2e5beb3fc0ed18ebbb75dfa434
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>
Signed-off-by: Pravin Tamkhane <pravint@codeaurora.org>

video: msm: Remove adjustment to MDP revision

Remove the modification of mdp_rev during mdp_probe. Not needed since
board files now have the correct MDP revision data.

CRs-Fixed: 417080
Change-Id: I553cb2a8e8de43b6c7b7976c3eca67d00a3cfe4f
Signed-off-by: Carl Vanderlip <carlv@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp.c