msm: cpufreq: Move the enabling of the CPU/L2 clocks to CPU_STARTING

It is a requirement of PLLs in MSM SoCs that the PLL power
supplies be enabled while the PLL is running. If the PLL is
locked and outputs enabled, turning off the regulator(s)
supplying the PLL will cause the PLL to enter an unpredictable
state.

Now in the CPU_UP_PREPARE notifier, the CPU clocks are prepared
and enabled, causing the source HFPLLs to also turn on. Note
that the CPU isn't clocked yet. It is possible that execution is
pre-empted and the CPU running the notifier enters power
collapse. If all other CPUs also enter power collapse, then it
is possible for an RPM notification to go out, allowing the RPM
to transition the Apps processor to its sleep set. This can
result in the HFPLL supplies being turned off while the HFPLL is
running, violating the requirement mentioned above. Once the CPU
is unclamped, the CPU is effectively unclocked, due to the HFPLL
being in an unknown state.

There is a check that is enabled in the PM code's CPU_UP_PREPARE
notifier callback. This check ensures that the problematic RPM
notification cannot occur until the core that is being brought
online also enters power collapse. However, there is no ordering
guarantee between that PM's hotplug notifier callback's execution
and the cpufreq hotplug notifier callback's execution. This
ordering depends on program link order, which is unreliable.

It is necessary to ensure that once the HFPLL is enabled, the
RPM cannot transition apps to its sleep set. Move the enabling
of the CPU clocks to the CPU_STARTING notifier, which runs on
the CPU bring brought online. The CPU_STARTING notifier is
guaranteed to run after the CPU_UP_PREPARE notifier, which
implies that the aforementioned do-not-notify-rpm check is
executed *before* the HFPLL is enabled. Therefore even if all
cores enter power collapse after the HFPLL is enabled, the
HFPLL supplies are guaranteed to stay on, or the CPU clock
is switched to the safe source and the HFPLL is turned off.

CRs-Fixed: 622738
Change-Id: I136841405806c07e755919859e649ded0c719abb
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
ASoC: wcd9xxx: Correct wrong check conditions

1) For targets where micbias is shared, we do not
use vddio to identify special headset. We want
micbias to be enabled always with any headset
inserted for such targets. Currently, if headset is
inserted during recording, we check for this vddio
flag as well. Since, it is null for the above mentioned
targets, we never touch the code to enable micbias
always for any type of headset.

2) Again for the above mentioned targets, if micbias
is enabled by voice call, and we insert the headset.
Now if headset is removed, we try force diable of
micbias. This results in Tx mute. The count to disable
micbias needs to be corrected.

Change-Id: I022a54578c47485ebf7eef27c405e31ea6395ecf
Signed-off-by: Simmi Pateriya <simmip@codeaurora.org>
msm: ultrasound: add support for stream parameters

Add new IOCTLs to get and set ultrasound stream parameters in DSP
using shared memory.

Change-Id: I627e9e40e29c6233dab4295e2c355a718e30bd01
Acked-by: Hadar Sivan <hsivan@qti.qualcomm.com>
Signed-off-by: Lior Barenboim <liorb@codeaurora.org>
msm: vidc: Increase I-frame period to INT_MAX

There is no restriction on I-frame and IDR period
values, so set them to INT_MAX.

Change-Id: I364ead16c3b8b8463fc8180159e5ee1f9fa10f37
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
ARM: dts: msm8974pro: Update BW votes to reflect clock plan

Either 931MHz or 800MHz is the turbo BIMC frequency, but both
do not exist in the same build.  Just request 931MHz.

Change-Id: I4b587e08689f9baa6e1088388d2748a298e7c916
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
ARM: dts: msm: Add NFC to msm8974pro-ab device tree

enable nfc on 8974-ab devices with pm8941.

Change-Id: I4165f52da25839dacf00232edde3ceac0d0adef1
Signed-off-by: Houston Hoffman <hhoffman@codeaurora.org>
msm: camera2: cpp: Change bus scale vector call sequence

The cpp driver can set the bus scale vector when cpp module is
actually included. This will avoid unnecessary power consumption
due to setting the bus scale vector.

Change-Id: I898bb33f4433d8b70f63c07facd6e22d58196211
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
msm: camera: Free queue data during camera close

CPP hardware is singleton, only one hardware used for processing
frames of different camera if more than one camera is running at
the same time. When camera is closed ensure that processing frame
queue and event data queue is empty.

Change-Id: Ie8e41431dd9b7acd29bac0f59fe2d4afa243ec2c
Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
msm: camera2: cpp: Support queue and timer clean up.

The timer callback is triggered after the node shutdown under
some error conditions. The timer callback should be avoided
in such cases. If in some race condition the timer callback is
triggered then it needs to check the state before timeout
processing.

Change-Id: Ic5663c69f556f30592ff6eb20f99c7c4a5ac859d
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
ASoC: msm: qdsp6v2: adding volume per dev-id

Add volume mixer control per device id for pcm use case.

Change-Id: Ieab721541a5cdf494b7fad78abc06d4f667b4baf
Signed-off-by: Anish Kumar <kanish@codeaurora.org>
msm: kgsl: Add a flag to mark user mapped GPU buffers

Add a flag in /sys/kernel/debug/kgsl/kgsl-3do/proc/<pid>/mem
file to indicate for each GPU buffer if it is mapped to userspace
in <pid> or not.

CRs-fixed: 634962

Conflicts:

	drivers/gpu/msm/kgsl_debugfs.c

Change-Id: I8abda74ef5656aca6b1c0315af8deb77460fa5a9
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
Signed-off-by: Prabhat Awasthi <pawasthi@codeaurora.org>
arm: mach-msm: Remove the unused rmt_storage code

The rmt_storage module is no longer used.
Remove the unused module and cleanup the makefile and kconfig.

CRs-Fixed: 549951
Change-Id: Ie9ebaa2209ea9fa0df05dc892504fcb882f00f29
Signed-off-by: Nikhilesh Reddy <reddyn@codeaurora.org>
cma: Allow option to use strict memblock_reserved memory

Despite all the performance optimizations, some clients are
still unable to use CMA because of the allocation latency.
Rather than make those clients use a separate set of APIs,
extend the CMA code to allow clients to keep the memory out of
the buddy allocator. Since the pages never actually go to the
buddy allocator, allocation and freeing is only based on the bitmap
allocator to find the appropriate region.

Change-Id: Ia31bb1212fd7b19280361128453c8d25369ce592
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
msm: mdss: check for fb node refcount before calling null commit

Add a frame buffer reference count check before calling
null commit to release the free list pipes. This avoids
unnecessary flickering on screen if a process tries to open
and close the fb node without performing any operation.

Change-Id: I96b824edccf27f0ddb796c420ef1feb49f65ddea
Signed-off-by: Dhaval Patel <pdhaval@codeaurora.org>
msm: vidc: Query deblocker parameters from cluster

Various fields of h264_db_control were left uninitialised before being
sent to the firmware.  As a result, due to poor luck, the resulting
encoded bitstreams were invalid as the alpha and beta were not in the
acceptable range of [-6, 6].  This commit fills the uninitialised values
with values obtained by querying the cluster.

Change-Id: Ic217d007239bc059302bdcdf2aebad1c9ca88244
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Arun Menon <avmenon@codeaurora.org>
usb: msm_otg: Fix bug with hvdcp connect and disconnect processing

The HVDCP charger is detected as a DCP charger by the USB driver. When a
DCP is detected, ext_chg_active flag is set to true and low power mode is
deferred by 3 seconds. When the user space receives the DCP connect uevent,
it kicks the charger detection algorithm. The charger detection procedure
involves reading and writing to the USB hardware registers and it makes an
ioctl call to block the low power mode by incrementing the pmruntime usage
counter. The user space calls the ioctl to unblock low power mode once
hvdcp detection is done by decrementing the pmruntime usage counter .

Consider the scenario where DCP detection is done and userspace makes
ioctl call to block low power mode. Next usb cable is disconnected and then
userspace makes ioctl call to unblock the low power mode by decrementing
the pmruntime usage counter. Due to this runtime suspend gets called and
USB clocks are turned off which later leads to unclocked access in
disconnnect processing. As part of USB disconnect, phy reset is done which
also involves ulpi register access. As clocks are turned off, it leads to
crash.

Fix the issue by making sure otg_sm work for usb disconnect is processed
first followed by decrementing the pmruntime usage counter in the ioctl
call made by userspace for unblocking the low power mode.

CRs-Fixed: 668648
Change-Id: I91db5f2e1084ae8f65dd8ec51c4314acc764c9c5
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
msm: mdss: Add missing BL lock around BL-related info

The bl_updated variable requires the BL lock. Otherwise, it can be
corrupted and cause backlight issues.

Change-Id: I55eb4b8d525765ede4f27a404f5c3f1f0b446719
Signed-off-by: Benet Clark <benetc@codeaurora.org>
msm: kgsl: Return HI offset from kgsl_perfcounter_get

Previously, kgsl_perfcounter_get only returned the offset
of the LO perf counter register. This assumed that the HI
register would always be adjacent to the LO register. With
VBIF 2.0, this assumption has now been broken, so both the
HI and LO register offsets must be returned.

Conflicts:

        drivers/gpu/msm/a4xx_reg.h
        drivers/gpu/msm/adreno_a3xx.c
        drivers/gpu/msm/adreno_a4xx.c
        include/uapi/linux/msm_kgsl.h

CRs-fixed: 578771
Change-Id: Ie74da5d797e58a143b89a61aba7ebaf1ed42ed5e
Signed-off-by: Kevin Matlage <kmatlage@codeaurora.org>
msm: display: only release kickoff when no cleanup pipe

If there is some pipe to clean up, need wait for it be done to
make sure the pipe can be used for the second cycle and recover
mode can be executed.

Change-Id: Ifb3fdb152bc4bbf367b3d272aa0c88b1a0650c19
Signed-off-by: Ken Zhang <kenz@codeaurora.org>
Signed-off-by: Neti Ravi Kumar <ravineti@codeaurora.org>
msm: mdss: Prevent AD configuration on HDMI path

Currently there is no use case for enabling AD on HDMI path. This check
is already present in mdss_ad_init_checks(), but that does not prevent
mdss_mdp_ad_setup() from being called. So invoke mdss_mdp_ad_setup() only
if display panel is not of HDMI type.

CRs-fixed: 624298
Change-Id: I175fcdbb0cc4ccda31d3fc8074b1e0213e0af10a
Signed-off-by: Ping Li <quicpingli@codeaurora.org>