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: Fix mdss_dsi_cmd_mdp_busy timeout error

Make MDSS clock ON before sending DCS command  to fix
mdss_dsi_cmd_mdp_busy timeout error.

Change-Id: I78a5931715f7a8803af77cd43c6191c225bcecd8
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: Detach mdss iommu on static screen

Detach mdss iommu on static screen and re-attach
on next commit to allow full power collapse of MDSS.
IOMMU driver keeps its vote for bus bandwidth for as
long as the MDP driver is attached to the IOMMU.
When MDP detaches from the IOMMU, IOMMU driver will
remove its vote for bus bandwidth.

Change-Id: I1e5c5c50bc157c3ebfc63e198e4608dad820a288
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: mdss: Release smp's held for writeback mixers

Smp's reserved for writeback interface can be released safely
as long as the pipeline is idle. This allows pipe reprogramming
during concurrent line and block mode operations.

Change-Id: Ib0fdf4d45412daa4478ac0fb7aff2e3564b2a584
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: Check extra mmb allocated to a pipe

If set call to a pipe changes smp configuration such that
calculated no. of  mmb blocks are less than allocated mmb
blocks, fail this set call. This ensures pipe disconnection
and smp configuration is possible in next commit cycle.
Also, check that no extra mmb is left allocated to any plane
when pipe's format changes. If so, fail the set call to let
correct smp configuration happen in next commit cycle.

Change-Id: Iec2b8cb18088587655cf0c68dc81e3ac7b819cbc
Signed-off-by: Mayank Chopra <makchopra@codeaurora.org>
msm: mdss: Modify SMP requirement for BWC decompression

BWC SMP buffer allocations are different from BWC fetch strides.
The Detile write of BWC is segmented into 16 algined segments for
every line buffer. This has to be taken into account and based on the
format the buffers need to be channeled.

Change-Id: I168014709bd81bfb189ce8cb3d1224f911838ba7
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
mdp: mdss: Honor ROI only for interface mixers

When partial update is enabled and we have a valid ROI, crop
source and destination rectangles against ROI only those pipes configured
for interface mixers.

Change-Id: I75111998a43f796f9315b25709e78a568fb1ec0c
Signed-off-by: Jeykumar Sankaran <jsanka@codeaurora.org>
msm: mdss:  Set rotator output format as pseudo planar 420

Set rotator output format for planar 420 as pseudo planar 420.
Configure BWC output format as MDP_Y_CRCB_H2V2 when
input color format is MDP_Y_CBCR_H2V2.

CRs-Fixed: 549326 552372 552375
Change-Id: I9c39ab3d8a867909853ffd6ecc2120ab160914d1
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: synchronize wfd driver iommu mmap/munmap with mdss

Add clocks reference during wfd driver iommu mdp_mmap/mdp_munmap
to ensure iommu is in proper state while wfd driver map/un-map
any buffers.

Change-Id: Id1a24285b81d5047e5e9f002ade9694ea49be59d
Signed-off-by: Pawan Kumar <pavaku@codeaurora.org>
msm: mdss: call suspend and resume panel events during runtime triggers

Send a panel suspend/resume event to all the MDSS devices to ensure
proper handling of regulators and clocks during the suspend/resume
sequence.

Change-Id: I820f5e4113f599ba53d4fa4726e406f74872f95f
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@codeaurora.org>
msm: mdss: set vsync clock rate

Vsync clock rate is not set when vsync clock is enabled.
This cause command mode TE logic not works.

Change-Id: Ibf7dd07e53b2cd76ef30f13133368000c79ae149
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>
msm: mdss: Decimation and BWC cannot be enabled together

Hardware cannot support decimation and bwc together.
The use case should be failed.

Change-Id: Ic7547340eb08d542a296aa9cfdd150e7eb0bea4b
Signed-off-by: Sree Sesha Aravind Vadrevu <svadrevu@quicinc.com>
msm: mdss: fix frame done not signaling for command mode

When ping pong done schedule_work is used to schedule a workqueue to
signal the frame done signaling. Schedule work does not guarantee one to
one mapping to the signals done and if a second interrupt comes before
workqueue is done it may lead to some frame done signaling not
happening. Fix this by having additional count for the frames done.

Change-Id: Ie0a67ab45657ff6ef894f6958e9e4f1309ad9455
Signed-off-by: Adrian Salido-Moreno <adrianm@codeaurora.org>
msm: kgsl: Fix range checking for profile wrapping

There is a chance that the profile code will not wrap correctly.
This can cause the in stream profiling to cause buffer pre-run
or undershoot (accessing data before the buffer). Fix logic to
cause the correct wrapping.

Change-Id: I9aa68228ff5be1bd26ee1cf1a486859346a8027f
CRs-Fixed: 585754
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
msm: kgsl: Don't open kgsl device in erroneous case

If kgsl_get_process_private() returns NULL, it goes to
err_stop with result = -ENOMEM. If open_count is 0,
adreno_stop() overwrites the result variable with 0.
This leads to kgsl_open() to be successful while it
shouldn't.

Change-Id: Ic12d92a099280e4d958fa192fa5128211120d361
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
ARM: dts: msm: Allow L2 to be in GDHS during Standalone PC for msm8974

Add a new low power level that puts L2 in GDHS mode during standalone
PC. This low power mode will give additional savings by putting L2 into
GDHS mode while the core does power collapse.

This can only be done in single core cases, the pm driver code takes
care of ensuring that L2 can be put into GDHS only when one core is online.

Change-Id: I71d237283820974c4d509606a01b67f5791d2fb9
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
arm: dts: msm8974: Enable L2 power collapse during sleep

The L2 power collapse was removed to address DDR corruption associated
with voltage droop on the MX rail. Power collapsing the MX rail doesn't
cause the Voltage to droop on the MX rail

Change-Id: Ia4ce5d374ed1197b924ae9f8fb4a5a325f81dbba
CRs-fixed: 497712
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm_sdcc: Fix building without BROADCOM_WIFI_RESERVED_MEM

There's no DMA QoS support when a static buffer isn't in use

Change-Id: If34a11c1f4362d08e3198558f7e0830f47447b5d
msm: vidc: fix memory leak issue in dynamic buffer mode

While flushing output buffers held in v4l2 video
driver, i.e, with ref count equal to 2, the driver
was freeing the binfo structure. This would leak
the mapped output buffer memory. By avoiding
freeing of the binfo structure, the driver waits
for the release reference event from the firmware
to free and unmap the output buffer. Also move
initialization of dequeued flag for buffers to be
held in driver, till the time we queue this buffer
to firmware. By not doing so, the video driver can
enter a race condition, whereby, a output buffer could
be unmapped and freed before v4l2 client has called
dequeue on the buffer.

Change-Id: Ic95f13b9f4426574012539a76c0b87bedb8e805a
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
mdss: dsi: Resolving memory leak in parse dsi commands

Free buf variable before exiting function in error cases
in order to avoid possible memory leaks.

Change-Id: I8ebc3f0f3f40be85e312f9646374a074f1414bdb
Signed-off-by: Krishna Chaitanya Parimi <cparimi@codeaurora.org>