msm: krait-regulator: handle efuse differences

Scaling factor version is valid for
- 8974 based devices when the version bits read 1
- 8974pro based devices when the version bits read 1 or 2
- 8084 based devices when the version bits read 0
- 8092 based devices when the version bits read 0

Moreover the three bit scaling factor data for
- 8974 based devices starts at bit 16
- 8974pro based devices starts at bit 16
- 8084 based devices starts at bit 14
- 8092 based devices starts at bit 14

Update the code to handle these differences.

[neo: Only required parts]

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: krait-regulator: fix unnecessary calls to switch to LDO

When asked to set a LDO voltage the driver rounds it up to
the nearest step value. However, when checking if the requested voltage
is already set it doesn't account for the rounding up.

Fix this by rounding up the requested value, which avoids
unnecessary calls to set the LDO voltage and switch to LDO.

Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
msm: lpm_levels: Adjust latency for Multi core cases

In multi core cases for several cores going in and out of power collapse
the warmboot is serialized at Trust Zone, which means the exit latency
will scale based on the number of cores exiting power collapse.

Adjust for this when chosing a low power mode based on the number of online
cpus.

Change-Id: I4fe137a1bf8596b7da7990845b18ceb8f3d529da
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
msm: clock-pll: Force PLLs off before reprogramming

PLLs can be enabled by the bootloaders without linux's knowledge. Ensure
the plls are off before changing their rates.

Change-Id: I77d1519117257570a1f3fa2e451d88b20776a013
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
msm: clock-pll: Add clk_round/set_rate() support for fixed rate PLLs

For any clock that dynamically decides the right parent to use during a
clk_set_rate() call, the parents need to support clk_round_rate() and
clk_set_rate() APIs to aid with the decision making. Since PLLs could be
parents to such clocks, add support for these clk_set_rate() and
clk_round_rate() to fixed rate PLLs.

clk_round_rate() always returns the fixed rate of the PLL and
clk_set_rate() fails for any rate that's not equal to the fixed rate of the
PLL.

Change-Id: I867e253040bd9d01f9a8a8437adf511553bfcbfe
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
msm: clock-rpm: Correct is_enabled implementation for RPM-SMD clocks

Clocks using the RPM-SMD driver have no way to query
clock state from the RPM. Therefore do not use the
get_rate function to figure out the enable-state of
the clock.

Change-Id: I4d142c716a4e41e54185e4ed4fe9feb33a1c2427
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
msm: clock-rpm: Remove the factor field from struct rpm_clk

The factor field was introduced for QDSS clocks to set a rate of
0, 1, 2. The rate for other RPM clocks is set in Hz. The factor
would determine the divisor applied to a rate before sending it
over to the RPM. In order to remove this extra complexity (factor
field), the QDSS driver is made to set rates of 0, 1000, 2000.

Change-Id: I722c32e7c66e16b62d4cf31eb865a80b4a7f3922
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
msm: iommu: Check for NULL genpools during domain teardown

During domain creation, some of the genpools will be set to NULL if
there is not enough memory for creation. Check for these NULL
genpools during domain destruction to avoid NULL dereferences.

Change-Id: I60238c138b809ef5c13383f5b1752ab6c799707d
CRs-Fixed: 573612
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: msm_dcvs_scm: Flush buffers before invoking scm_call

scm_call will no longer flush the entire cache. To ensure that
the secure world doesn't see stale data, flush buffers before
invoking scm_call.

Change-Id: Ib6d32c911f56a886a69fc2d70ac39858cc2f24f7
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
msm: tracing: disable tracing for the RTB log functions

The function graph tracer causes a kernel crash when enabled. The
counter_get_cntvct_mem and uncached_logk functions call each other
recursively causing a kernel stack overflow. Fix this by annotating
RTB log functions with notrace.

Change-Id: I196a2d554e8210f4a2fb2ee5d489be5b1eb2cab5
CRs-Fixed: 525920
Signed-off-by: Sarang Joshi <spjoshi@codeaurora.org>
msm: cachedump: Add cache maintenance for calls into TZ

The scm_call API is no longer providing implicit cache maintenance for
shared buffers. Add cache flushing for buffers heading towards TZ and
cache invalidation for buffers coming from TZ.

Change-Id: Iaafdc10ee49b43f462ba00dd751861a3b285a067
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
msm: use dma_alloc_coherent for L1/L2 cache dump buffers

Currently buffers for L1 and L2 cache dump are allocated using
allocate_contiguous_ebi_nomap() api. On devices with more than
2GB of memory, debug image crashes since these buffers end up
being allocated above 2GB address space which the debug image
currently does not support.Hence, use the dma api so as to
have these buffers be allocated below 2GB address space.

CRs-Fixed: 515701
Change-Id: Iaf862753e63fd9f42256c820b3e3ba08b6894bf3
Signed-off-by: Pushkar Joshi <pushkarj@codeaurora.org>
msm: audio: qdsp6v2: Change acdb_mmap size variable to unsigned

The acdb_mmap fuction does a size calculation but
stores the result in an int which makes negitive
numbers possible. Changing the variable to unsigned
ensures that the size used is never out of bounds.

Change-Id: Iffd9c1440d2f28b703a77993fdbb3ccd18f30694
CRs-fixed: 548145
Signed-off-by: Ben Romberger <bromberg@codeaurora.org>
base: genlock: Zero a structure before sending it to user space

In the handler for GENLOCK_IOC_EXPORT zero the entire genlock_lock
structure before passing it to the user.

CRs-fixed: 552303
Change-Id: Ic0dedbad257bf0a448d0bf67a14a3932b7925bfc
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
base: genlock: Correct the lock file reference count.

genlock_get_fd_handle API creates a new FD and attaches
it to lock file and shares this FD to second process.
Now, two file descriptor are pointing to same file.
If one FD is closed, lock file will be closed. This
changes add a extra reference to lock file as new FD
has been attached. Taking this reference will make sure
that file doesn't get close. This refrence will go when
client will call close on this FD.

Change-Id: I3524bed5ededd89d43ca6d8b85df11c85c03c1e3
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
gpio: msm-common: Add support to configure SDC1 RCLK pin

eMMC5.0 specification adds a new RCLK pin to the eMMC interface. Add a
tlmm entry to support configuring its pull state.

Change-Id: I29d2248e4660bf3b65143bac97a1c9a594a0eec0
Signed-off-by: Venkat Gopalakrishnan <venkatg@codeaurora.org>
crypto: msm: Process keydata for HW/PIPE key use case

When client sets HW_KEY flag, driver should ignore key data
and length when client issues set_key request.
When client sets PIPE_KEY flag, driver should ignore key data.

Change-Id: I550d1d2a217e6b9c9de50064bfafe72f9f32e6e1
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
crypto: msm: Designate memory chunk for ignore_buffer

Memory was not assigned to ignore_buffer pointer and uninitialized
pointer was being used.

Change-Id: Ie7c372aeafdfe17b9bb70d38666fa81c3df1e043
Signed-off-by: Mona Hossain <mhossain@codeaurora.org>
crypto: msm: check NULL pointer in _qcrypto_setkey_des()

add NULL pointer check before des_ekey()

Change-Id: I57c40b82fc5141c1666c3fd493b43e962f0d1ae9
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
crypto: msm: Fix null pointer exception in qcrypto_count_sg()

Fixes null pointer exception in count scatter gather function. Scatter
gather list pointer become NULL if the sg pointer reaches last but one
node, which results in NULL pointer exception.

Change-Id: I634baf30074e6e53ffa22635565da54e9ae43150
Signed-off-by: AnilKumar Chimata <anilc@codeaurora.org>