Revert "Francisco is right, onlining all cores is a nice workaround for the real problem."

This reverts commit 8418f8ec096274a1d67b704e33dc29edc4fa1ad6.
msm: kgsl: Don't do intensive memory recovery when allocating big pages

We don't want to incur too much overhead when allocating big pages
so don't attempt to retry, perform reclaim, or run memory compaction
on high-order allocations.

Change-Id: Ic0dedbadb354c6faea34abec36aee268ac0f2c34
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Insert kgsl idle for iommu-v1 when pagetables are changed.

An idle is needed for iommu-v1 before programming both tlb registers
and the pagetable register. Without this idle faults are observed on
2D core because a process uses another processes pagetable.

Change-Id: Ief14cd79b8e7ffaed413da49dc4b9e8416233186
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Don't access context memory after it's freed

Context memory was potentially accessed after being freed. Fix this
by incrementing the context's refcount at strategic places.

Change-Id: I31049bdd3eb9ac52160ca593619fcc8a32d4ddee
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
gpu: ion: enable the kmalloc heap

There are some Ion clients who would like to use the kmalloc
heap. Enable it.

Change-Id: Ie818be9e1211d52d489ad2cb63d94e2fddfc0f01
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
msm: kgsl: Add NULL check for next_event hook

KGSL driver needs to check that the function pointer
is not NULL before calling the hook. next_event
is an optional function not implemented by the 2d
core. This fix ensures that optional and unimplemented
function will not invoked by the driver.

Change-Id: I687b028260e3ec304d973c6a5bded0a8fdbfb73b
Signed-off-by: Hareesh Gundu <hareeshg@codeaurora.org>
msm: kgsl: Don't consider active count if not in active state

Don't consider active_cnt variable if not already in ACTIVE state.
The active count variable does not necessarily exactly indicate the
number of open handles to GPU for switching power state. Hence,
only wait for active count to reach zero before switching to SUSPEND
state if, the current state is ACTIVE.

CRs-fixed: 483154
Change-Id: Ie025a1873cfb9237bdfba89204f4c2116549eba4
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
gpu: msm: Allow retries for 0 order allocation

When allocating order 0 pages we allow the allocator to retry
the allocation to ensure we can take advantage of pages that
are being reclaimed. This will help avoid unnecessary out
of memory errors from kgsl clients.

Change-Id: Iec2a0a1fe10302c320a58cef90ae1ee7e35d71ee
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
msm: kgsl: Protect the mem_entry list during deletion

Use the spinlock to prevent corruption of the mem_entry list during
deletion. Otherwise the mem_entry list may be modified by another
thread at the same time resulting in memory corruption.

Change-Id: I5728a8b925753d5fda82413615e5ebaf0366dfd8
CRs-fixed: 489224
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
msm: kgsl: Submit a draw command on resume

For A305, submit an extra draw command while resuming the GPU from
SLUMBER state. This fixes corruption seen when the screen is
turned on.

Change-Id: Iafed90b617b0a700ac3f2afcb6d9ecadca590914
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
gpu: ion: Do fallback when allocating large sizes

The preferred allocation of memory for kernel data structures in
ION is to use kmalloc. This is mainly for performance reasons. However,
we are not guaranteed to be able to allocate large sizes. So to keep
the code performing well and at the same time allow for larger allocations,
implement a fallback mechanism for allocation of memory for ION kernel data
structures.

CRs-Fixed: 488521
Change-Id: I8c6a13ad74cce69f590920d28c01a58f7a540fd2
Signed-off-by: Olav Haugan <ohaugan@codeaurora.org>
[Resolved merge conflict]
Signed-off-by: Chintan Pandya <cpandya@codeaurora.org>
msm: kgsl: Always resume the GPU regardless of its state

Make sure we resume the GPU regardless of its current
state. If the device is not in suspend state restart the
device and  print an error message.

Change-Id: I9e71cbe27d360dc06513c54f3a734aaea5b10d2b
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
msm_fb: display: disable mdp blt mode

The switch of blt mode may cause mdp hang on some targets. To avoid
blt switch, we won't allocate the pipe that requires blt
mode. Basically this implies two things: downscaling is done by
rotator and gpu composition is used in case of blt mode is needed.

This implementation is to calculate mdp clk requirement based on the
req data passed from userspace before setting the actural pipe
data. If overlay_set asks for mdp clk that is greater than
mdp_max_clk, meaning blt is needed, overlay_set returns before pipe
allocation or pipe data change, so this way can avoid mdp to work on
wrong pipe data.

Change-Id: I22e73d08bed920b366c18ee21b132339cf2a0347
Signed-off-by: Huaibin Yang <huaibiny@codeaurora.org>
msm_fb: Fail fb2 open if called during suspend

At present, if msm_fb_open() for fb2 is called during suspend,
we increment the ref_count for fb2 and return success without
turning on the writeback pipeline. This causes the WFD client
think that fb2 is successfully opened whereas fb2_open should
not successful during suspend. Hence, return error if msm_fb_open()
is called for fb2 during suspend.

CRs-fixed: 475310
Change-Id: I73167a120a64ac18c5789ccc9cf7faad14b50b94
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
mms_fb: display: init pipe default configure as solidfill

Initialize mdp pipes default config as solid fill so that
there will have no memory fetch if pipe are staged into
mixer while flush bits are left behind and set at next vsync.
This is will prevent mdp iommu page fault from happening
at address 0x00000000 during resume.

Change-Id: Ide944ec1d069629f1ae2ecd0daf49c69ce2af2eb
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm_fb: Remove the extra MDP clock enable in writeback_commit

There is an extra MDP clock enable call in writeback commit
which causes the MDP clock to be enabled always once a WFD
session is setup. Remove this additional clock vote to make
sure the clock enable/disable calls are balanced.

Change-Id: I8b101f3eb76fe00ecf6d3967d0bf113146447db3
Signed-off-by: Padmanabhan Komanduru <pkomandu@codeaurora.org>
msm: display: Adjust video timing generator parameters for 8930 EVT device.

This change adjusts the video timing generator parameters to properly configure
porch values for the panel.

Change-Id: I920646f1edbf4fe0043336dd0e2914f0302be2d8
Signed-off-by: Sangani Suryanarayana Raju <csuryan@codeaurora.org>
msm_fb: display: Do a pre-fill to writeback buffers.

When switching mdp operating mode to blt, writeback buffers need
pre-fill. Move the pre-fill code from isr routine to do_blt, where
actual switch to blt mode happens.

CRs-fixed: 471098
Change-Id: I0f845397894c749ac518a1fa605f84cd5fc2ad15
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: display: Limit dynamic fps feature only to MIPI video panels.

As dynamic fps feature is supported only for MIPI video panels,
return -EINVAL if sysfs node is written for panels other than
MIPI video. This change also removes world writable permissions
for sysfs node.

Change-Id: I72260e6032cb8a758b0457c36a808263a981260f
Signed-off-by: Vishnuvardhan Prodduturi <vproddut@codeaurora.org>
msm_fb: display: add mdp master port1 bandwidth request

mdp bus traffic go through both mdp port0 and port1, but now mdp
bandwidth request is only for port0.

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