msm_fb : Disable power collapse before VSync to negate wake up latencies.

For a 16ms frame period  the CPU may go into deep power collapse.
Based on the power collapse exit latency for that low power mode,
the frame period gets extended by the latency to wake up the CPU at the
next VSYNC. This results in a user experience glitch. Adding an hrtimer
to wake up the CPU few ms before the Vsync and disabling power collapse
compensates for the extra time spent in waking up the CPU out of deep
sleep. On timer expiry, set wakelock to veto idle power collapse till
the next VSync. The wakelock is released on the next VSYNC occurrence.

Change-Id: I3e013cc54c36d3015d6fafa4b9ccd435cb5532ab
Signed-off-by: Anitha Anand <anithas@codeaurora.org>
msm_fb: display: switch mdp mode without turning off timing generator

MDP need to be in idle state before switching to different mode.
Dmap_done interrupt is delivered when the last line of frame is
clocked out. Therefore mdp is in idle state during dmap_done ISR.
This patch execute mdp mode switching inside dmap_done ISR.
Therefore timing generator is not necessary to be turned off
since mdp is in idle state already.

CRs-fixed: 350154
Change-Id: Ib10557bde90856ffd5284a0a76dddbe92f2abc0e
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: display: Add proper flags for secure/non-secure writeback buffers

For MDP writeback buffer allocations, use appropriate heap id flags
for secure and non-secure sessions

Change-Id: I05e897d5d90ab03b17ccddbda764f39b963192ef
Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
msm_fb: display: Allocate writeback buffers of panel resolution sizes

Allocate MDP writeback buffers based on panel resolution size
dynamically

Signed-off-by: Ravishangar Kalyanam <rkalya@codeaurora.org>
Change-Id: I4a456199a05850f35c204edfa7ae3679036138a9
msm_fb: display: remove mdp writeback2 overlay kickoff waiting

Before overlay2 kickoff, there is already a dma busy waiting, so once
overlay is kicked off, mdp driver can safely return to userspace. Then
if there is another request while ovlay2 is still busy, dma busy can
take care of it.

Change-Id: Ibb45a8b306a393c8e240fc64b5857e8700afcaba
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
video: msm: wfd: Delete from free_queue before freeing memory

VSG has a stale pointer to deallocated memory that is accessed, causing
a page fault.

Change-Id: I036293950795f601c0592c39b6da20d3c0cbb77f
CRs-Fixed: 348977
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit c73f497b1ce2d267c1b9b5b272f625b406ab36b2)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm_fb: hdmi: Disable 1.1_FEATURE

Some displays support Enhanced Link Verfications(1.1_FEATURE)
which makes HDMI Tx to verify Pj on every 16th frame. Three
consecutive Pj mismatch will result in HDCP authentication
failure. If 1.1_FEATURE is supported(this can be detected by
reading BCAPS), it needs to be enabled by writing into AInfo
of display. Default is disbaled.
This change sets HDMI Tx core to disable 1.1_FEATURE by
default so that we don't see Pj mismatch error unless the
feature is enabled.

CRs-fixed: 348752
Change-Id: I996f60b852a7e867e8e13e700beecbac8190a59e
Signed-off-by: Ajay Singh Parmar <aparmar@codeaurora.org>
(cherry picked from commit 97e2fcf862d913feff157f536ee14cfc5f3197f7)
(cherry picked from commit 88cb4da47697fe407b013554678ec68d7c8ab93c)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
video: msm: wfd: Reduce first frame latency in CFR mode

When we get the first frame, push it immediately to the encoder rather
than waiting for the timer to expire.

Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
(cherry picked from commit 47ef81ffe4ffd35db48a0a8795697a910378664a)

Change-Id: If7f85e747646a5022b416d1189d5d55d16b19343
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit bf844198db86317b2e73c98dab5b2f85f08f7555)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: Allocate physical pages instead of using vmalloc

Replace vmalloc allocation with physical page allocation. For most
allocations we do not need a kernel virual address. vmalloc uses up
the kernel virtual address space. By replacing vmalloc with physical
page alloction and mapping that allocation to kernel space only
when it is required prevents the kgsl driver from using unnecessary
vmalloc virtual space.

CRs-Fixed: 346921

Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
(cherry picked from commit 8cb835b656ae2c3faa79af4f374563d344b46d4a)

Conflicts:

	drivers/gpu/msm/kgsl_sharedmem.c

Change-Id: I88e1eb282cc4822970811728d00b1096188f64e9
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit d5fa912f599a71223496d2ff97ecd5040b95baaf)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm:kgsl: set state as requested state when in NAP

Fix the state to requested state so that when both ISR and
timer fire at the same time, the state is set as SLEEP

CRs-Fixed: 340484
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 9b6110bb38c7acf61e065ec206b62b1e1f089908)

Change-Id: Ie625aba09feddf495647be2844dc0a4014605141
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit 7704bbd086590ef68aa30530c0ea18dc7f379780)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: vidc: Adds API to request performance level.

Adds API to request for a particular performance
level from video core. This is needed for Wi-fi
display (WFD) to reduce end to end latency.

Change-Id: Ib4133b8cd62ccad286be1984f944911754b887c5
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 3c51cb669e9ca03773444f69aa9c7fb6131cb726)

Conflicts:

	drivers/media/video/msm/wfd/enc-subdev.c
	drivers/video/msm/vidc/common/vcd/vcd_client_sm.c
	include/media/msm/vcd_property.h

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: cache_erp: Do not panic on TLB multi-hits

TLB multi-hit events may be reported as a result of a
benign condition, so there is no need to panic the kernel
if such a condition is encountered. A TLBIALL operation
needs to be performed to avoid an interrupt storm if the
condition persists.

Change-Id: I91219c299e0915b3e9e0b9d7a672b401e1479d71

(cherry picked from commit bddae7c5467da0dac4adec2b2e32c399033e6e51)
(cherry picked from commit e3bfcf483b8e52f540fa81273ef9a67fa8889a49)
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm: kgsl: flush outer cache for alloc_page() pages

The outer cache needs to be flushed for these pages
after they are allocated so that the GPU and CPU
have a consistent view of them.

CRs-Fixed: 346921
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 7018a21bf2b52f1296557d1f6ec9ed64e9169de7)

Change-Id: Id5c11ab8d856fc270330fd3258baa51b8efca192
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit a240fca76b5562d3ca53677151213286306bbc96)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
Revert "msm: kgsl: Remove wakelock and pm_qos requirements"

This reverts commit ef44e7338f1c021909133f481348a641d84652ee.

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

CRs-Fixed: 333977
(cherry picked from commit 10297895f5cf1271309514ded1b34a2a412c0a92)

Change-Id: I74a31ea7f8ddfca6015872721ed2b7582841c74f
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
(cherry picked from commit efa1fd88817051006d042b5ff9af871f02abc75a)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: kgsl: make pm_qos vote to default when in slumber

Change the pm_qos vote to default when the diplay goes
off. This allows the cpu to do idle power collapse after
display goes off.

CRs-fixed: 333977
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
(cherry picked from commit 3005cddf5800135618354f35dd0822e18d1e9b44)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Change-Id: Ie40454287669845e57afc235f17daa8b87176eeb
Signed-off-by: Ramakrishna Prasad N <crpn@codeaurora.org>
(cherry picked from commit eef51c92910064add2877091ddbd93cdf79c0c26)

Conflicts:

	drivers/gpu/msm/kgsl_pwrctrl.c

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
qseecom: Add error checks and logs

Adding/improving error logs and incorrect fd checks

Change-Id: Ia311e911eb8e5da3e7a3f413bb34b479389f3890
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
(cherry picked from commit a5f1aab25ea1da8cb26976072e95c01187d0437a)
(cherry picked from commit befcf2d23f754fa07217e550151516f29d9bded7)
msm: vidc: Use pre-computed frame delta values in WFD use case

In WFD use case with frame skipping enabled, we wish to fool the core
into thinking that that the frames are coming at a consistent rate so
that we don't run into any issues with the core's rate control
mechanism.

The following change introduces a property that the client may set that
dictates what the timestamp delta between any two frames might be.

Change-Id: Iea3f97879227b7932543d3449d311758dc4a2f59
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
(cherry picked from commit 806e8d1cf43de34ad38181a227bbcebb64a5fd9e)
msm: kgsl: call sysfs_notify when a hang snapshot is made

/sys/class/kgsl/kgsl-3d0/snapshot/timestamp will have sysfs_notify()
called when a hang happens, so that a userspace process can
poll(2) on this file to detect a hang.

CRs-Fixed: 354385
Change-Id: I0a3c8fcbe3fb09256bcd12f6e63c107536734485
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
(cherry picked from commit 90812c8eac42b5ce7bb48e35897537021e01e6de)
(cherry picked from commit 15456a25c55409ee3032c4e083d232a3d3aedf6e)

Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
netfilter: xt_qtaguid: start tracking iface rx/tx at low level

qtaguid tracks the device stats by monitoring when it goes up and down,
then it gets the dev_stats().
But devs don't correctly report stats (either they don't count headers
symmetrically between rx/tx, or they count internal control messages).

Now qtaguid counts the rx/tx bytes/packets during raw:prerouting and
mangle:postrouting (nat is not available in ipv6).

The results are in
  /proc/net/xt_qtaguid/iface_stat_fmt
which outputs a format line (bash expansion):
  ifname  total_skb_{rx,tx}_{bytes,packets}

Added event counters for pre/post handling.
Added extra ctrl_*() pid/uid debugging.

Change-Id: Id84345d544ad1dd5f63e3842cab229e71d339297
Signed-off-by: JP Abgrall <jpa@google.com>
vidc: send flush done if flush is issued in EoS while encoding

There is a race condition in encoder, when an input buffer
is received with an EoS flag but doesn't have an output
buffer to process that and if simultaneously flush is issued.
This is fixed by sending flush done if flush is issued in EoS.

CRs-Fixed: 353081
Change-Id: I925f49779ed5cb91bfab805ba4b7102c1e3f728b
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>