msm: mdss: add iommu attach in bus bandwidth control request

Add mdss_iommu_attach in mdss_bus_bandwidth_ctrl to
attach iommu on bus bandwidth enable request.
mdss_iommu_attach/mdss_iommu_dettach can happen in
separate thread, which may lead to a race condition
where attach/detach may happen at same time. Add lock
to properly synchronize the iommu attach/detach to
fix race condition.

Change-Id: I45c8ef1fa1fa1c2da9c6c3702bd007856e469b9d
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss.h
	drivers/video/msm/mdss/mdss_mdp.c
	drivers/video/msm/mdss/mdss_mdp_overlay.c
msm: mdss: refactor performance calculations

Current logic could potentially lead to drop in performance (and
underflow) when multiple panels are there and both are updating mixer
configuration independently, as we may end up raising bus bandwidth for
another panel which may not be ready just yet. This is addressed by
updating performance configuration values until it's ready to switch
rather than updating values and performing these later (other panel
update could come in between).

Change-Id: I247ef0cd3e0616de3e5ddd9599233af570e422a5
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_ctl.c
msm: mdss: add mdp overlap and prefill bandwidth calculations

This patch implements a set of new equations proposed by h/w team to
calculate mdp bandwidth. MDP has bandwidth requests during both
blanking and active periods. During blanking area, mdp needs to fill
its internal buffers, such as latency buffer, outstanding buffer,
pingpong buffer, etc. This bandwidth is called prefill bandwidth and
it is determined by the total amount of bytes of buffers to be filled
and the total amount of blanking time available. The bandwidth for the
active peroid is called overlap bandwidth which is the max bandwidth
request of all overlapped regions. The final vote from mdp would be
the worst case of prefill bandwidth and overlap bandwidth.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_ctl.c
msm: mdss: support mdp prefill bandwith for multiple platforms

To calculate mdp prefill bandwidth, mdp driver needs to get h/w
dependent buffer constants from device tree. Also add h/w feature
dependent logic.

Conflicts:

	drivers/video/msm/mdss/mdss.h

Change-Id: I8d56ec502a6fd56eaae5b65a326ef966be46f14b
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss.h

Conflicts:
	drivers/video/msm/mdss/mdss.h
msm: mdss: reduce mdp prefill bandwidth vote for command mode panel

The current result of mdp prefill bandwidth calculation for command
mode is larger than what is actually needed for many use cases. This
is due to the fact that for command mode panels during prefill time,
there are less buffer prefill requirement or time constraint than that
of video panels. This patch makes adjustment accordingly based on the
updated equations by h/w team.

Change-Id: I06935a29d771202b3f8dc2c62cf948a8ecc81481
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: calculate prefill bandwidth using the worst case vbp

The blanking period of a panel is determined by vbp factor: vertical
back porch plus vsync pulse width. The larger vbp, the larger blanking
time, and the smaller prefill bandwidth request. When two or more
types of interfaces/panels are involved, although each panel has its
own vbp, there is an option to calculate the prefill bandwidth for
each panel with the worst case vbp of all panels. This way there is no
need to increase fudge factor to avoid underruns.

Change-Id: I60dda6ad41bbb353c58ef93cf97787c4da3929dc
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: add tile format condition for prefill bytes calculation

Latency buffer requires more lines to be prefilled for use cases that
supports tile format.

Change-Id: I552bade677822d47cdd5b43c01f795552e94b406
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: release mdp bandwidth voting for command mode when idle

There is no bandwidth usage for command mode panel if no new commit
comes, so mdp bandwidth request can be zero as soon as data transfer
to panel is done. This could bring power savings for use cases of
short transfer time relatively to long idle time (duty cycle) such as
partial update, and slow fps. When video mode panel is present, this
bandwidth cannot be released since the timing of this release is
unpredictable.

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

Conflicts:
	drivers/video/msm/mdss/mdss_mdp_intf_cmd.c
msm: mdss: update latency buffer bytes calculation for prefill bandwidth

This is a s/w change to reflect the new h/w update of latency buffer
byte calculation for prefill bandwidth. Previously this number of
latency buffer bytes is the amount of allocated smp bytes, however,
for some use cases this doesn't not match the bandwidth equation
result. So for the purpose of matching mdp prefill bandwidth
equations, a standalone calculation is needed.

Change-Id: Ic74599d2c2bfe9610ebc22dee137a0df7171dcb5
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm: mdss: add iommu attach in bus bandwidth control request

Add mdss_iommu_attach in mdss_bus_bandwidth_ctrl to
attach iommu on bus bandwidth enable request.
mdss_iommu_attach/mdss_iommu_dettach can happen in
separate thread, which may lead to a race condition
where attach/detach may happen at same time. Add lock
to properly synchronize the iommu attach/detach to
fix race condition.

Change-Id: I45c8ef1fa1fa1c2da9c6c3702bd007856e469b9d
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdss.h
	drivers/video/msm/mdss/mdss_mdp.c
	drivers/video/msm/mdss/mdss_mdp_overlay.c
msm: mdss: Update wr mem fields with correct names

wr mem start and continue were incorrectly named in
the documentation and dtsi files. Changing the names
to wr-mem-start and wr-mem-continue to more accurately
reflect the fields.

Change-Id: If2cdd410fd50a4690dcb6c87cb0b9f4818848848
CRs-Fixed: 578028
Signed-off-by: Casey Piper <cpiper@codeaurora.org>
msm: mdss: Dynamically change writeback path OT

Writeback path when used for WFD is processed at 1px/clk
whereas when used for rotator, it is processed at 4px/clk.
To ensure that writeback during WFD doesn't slow down,
reduce the WB block rotator OT to different number depending
on different target.

Change-Id: I6f37557756d0c8c5037bbd251637ed872d872f74
Signed-off-by: Jayant Shekhar <jshekhar@codeaurora.org>
msm: mdss: fix the panel color distortion issue for RGB565 format

For the color format RGB565, the pack pattern was set to BGR instead
of RGB, causing the red and blue color swapping on the panel.

Change-Id: Ib9233a93676e7d5d40f134f9a1657781c631ebdd
Signed-off-by: Xiaoming Zhou <zhoux@codeaurora.org>

Conflicts:
	drivers/video/msm/mdss/mdp3_ctrl.c
Fix a few incorrectly checked [io_]remap_pfn_range() calls

Nico Golde reports a few straggling uses of [io_]remap_pfn_range() that
really should use the vm_iomap_memory() helper.  This trivially converts
two of them to the helper, and comments about why the third one really
needs to continue to use remap_pfn_range(), and adds the missing size
check.

CRs-Fixed: 570735
Change-Id: I927a67ea80fea5ed706749ead9defb1e72633952
Reported-by: Nico Golde <nico@ngolde.de>
Cc: stable@kernel.org
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org.
Git-commit: 7314e613d5ff9f0934f7a0f74ed7973b903315d1
Git-repo: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git
[pratibha@codeaurora.org:resolve trivial merge conflicts]
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>

Conflicts:
	drivers/uio/uio.c
Revert "msm: mdss: delay freeing buffers for additional vsync"

This reverts commit 6c3274f8170e1411583f6145f7bc615021ac8b25.

Conflicts:
	drivers/video/msm/mdss/mdss_mdp.h
	drivers/video/msm/mdss/mdss_mdp_overlay.c

Change-Id: Ib6cd73c59d772b8d39428b9975ed542468387a5e
Revert "Revert "msm: mdss: delay freeing buffers for additional vsync""

This reverts commit fc2eebd251bfa2110c587b90228aa7f55c10ca09.
Revert "Revert "msm: mdss: Display splash screen during boot up""

This reverts commit a700297f160964ba19a8688878fc6f7629371f87.

Change-Id: I79f2b0b1be7fdf489a6d013020d15d19cc441d95
video: mdss: Kill "pervious" logspam

Change-Id: Id81659ec6a23c3c27a60ba639793b506da4c89a5
msm: mdss: optimize MDP pipes cleanup

There are cases where pipe cleanup can happen without display commit.
This means that the pipe was never programmed to hardware, in these
cases the pipe can be cleaned up without the need of display commit
cycle to happen. Also there is no need to access hardware to release
resources such as SMPs since they have not been programmed yet.

Change-Id: I57a46471dc1fba4e45e55c3543940ba4fba0540a
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Ujwal Patel <ujwalp@codeaurora.org>
msm: mdss: implement overlay prepare ioctl

Overlay prepare will allow a full frame with multiple overlays to be
configured at once and perform frame level checks before being pushed to
display. This function guarantees that if the call is successful, the
frame can be displayed successfully on the screen when display commit is
called.

Change-Id: I276b6fe3e0a872a2e93170f3cea1002d3ce0dac9
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
Signed-off-by: Anusha Koduru <kanusha@codeaurora.org>