msm: pil-riva: Flush instead of cancel delayed work on removal

If the pil riva driver is removed or fails to probe we want to
ensure that the proxy votes made during boot are removed even if
they're pending removal. cancel_delayed_work_sync() will ensure
that the proxy vote removal callback no longer runs, but it
doesn't force the callback to run. This means that the proxy
votes stay in place even though the driver has been detached.
Therefore, replace cancel_delayed_work_sync() with
flush_delayed_work_sync() to forcibly remove the proxy votes
before detaching the driver.

Change-Id: I1661d8ef612223e9f2471c9b2bf2fadaeb07af50
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: pil-riva: Fix error paths when proxy voting fails

If the proxy voting for CXO or the PLL regulator fails, we should
unwind the work to the state before the failure. Do this so that
users of the driver can recover from errors more easily.

Change-Id: I04e388abe31273007ad59e6df8563bbd21b12e87
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: pil-riva: Hold wakelock while proxy voting

If the system goes to suspend immediately after RIVA is brought
out of reset the proxy vote for CXO and the PLLs will stay
asserted until the kernel wakes up again. Since there is no
guarantee for the kernel to wakeup again from suspend for a very
long time we may block XO shutdown as well as keep regulators
enabled when they shouldn't be enabled.

To avoid such a situation register for a wakelock so that this
driver can block suspend until the allotted timeout has expired.
Doing this will ensure that the proxy vote is removed with a
minor hit to power while we wait for the timeout to expire.

Change-Id: Iaa3e074734db4acacafa7c812be0463c72e0df59
CRs-Fixed: 337631
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: spm: Update secondary cores bootup rail voltage.

The commit updates the secondary cores bootup rail voltage from 1.3V to
1.15V. 1.3V is beyond the max voltage limit for the core and can result
in thermal issues.

CRs-fixed: 342007
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
(cherry picked from commit cd91c8fa10bef58c634bebe23ffdffb6ef710f22)

Change-Id: I05f1cf136ad61b16f054bab0706d88609043cc90
Signed-off-by: Yen-Pin Hsiao <yphsiao@codeaurora.org>
msm: camera: Fix the stretch issue in Camera Preview

In non zsl camera preview mode, two vfe outputs are configured as
preview and video outputs. Greater of the two is output from main
scaler and the lower one from the secondary scaler. In Camera preview mode,
application matches preview dimensions aspect ratio to snapshot
dimensions and in camcordermode it is matched to video.

In Current design, We have below scenarios for Non ZSL Camera Preview

Case1: Main Scaler is preview and secondary scalar is video
  In this scenario no error is observed
Case2: Main scalar is video and secondary scalar is preview
  In this scenario since preview output in derived from video but the
aspect ratio may not match in camera mode, so we see stretch in camera
preview.

  This issue is fixed by configuring only single VFE output as per
display dimensions in Camera Preview  since the second video output
is never used

CRs-Fixed: 343884
Change-Id: I25a82b417a3ed1b28ea243c6ce988c23d5fed4a7
Signed-off-by: Nishant Pandit <npandit@codeaurora.org>
wcnss: remove LVS1 vote from APPS

LVS1 is now turned ON by bootloader; and APPS don't need to vote for this.
RPM was turning ON this rail irrespective of any votes, it doesn't need
to do that anymore.

CRs-fixed: 341984
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>
(cherry picked from commit e187c3d85bebcfa9177cd0bd0a345ffd97fa75f6)

Conflicts:

	drivers/net/wireless/wcnss/wcnss_riva.c

Change-Id: Id40bfb2c9bcbbd6c7b9a82360a55903153681df0
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
mmc: sd: fix the issue with paranoid SD card init retry

mmc_resume_host() is called during resume (runtime or system) which calls
	1. mmc_power_up
	2. mmc_select_voltage
	3. host->bus_ops->resume() (mmc_sd_resume())

mmc_sd_resume() ultimately calls mmc_sd_init_card() to initialize the
SD card. But let's say if mmc_sd_init_card() fails during the
execute_tuning(). At this point, host controller timing is changed
to SDR104/SDR50 mode and host clock will also be > 100 MHz.

If there is an error returned by mmc_sd_init_card() and
if CONFIG_MMC_PARANOID_SD_INIT defined, it retries by calling
mmc_sd_init_card() without making sure that host controller timing
and clock be initialized again. This may cause the further
mmc_sd_init_card() also to fail.

To fix this, mmc_sd_resume() should call mmc_power_up()
and mmc_select_voltage() before retrying.

CRs-fixed: 344643
Change-Id: I8de39ea547fa0d5eca478719a4cf9255b6652503
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
mmc: bus: print bus speed mode of UHS-I card

When UHS-I card is detected also print the bus speed mode
in which UHS-I card will be running.

Change-Id: Ifd58b91b605d132cd80b18ad4cfe02f59e8a80eb
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
msm: pil: Synchronize request_firmware() with suspend

Calling request_firmware() during suspend/resume operations is
buggy and error prone. Therefore a check exists in
request_firmware() to see if a suspend/resume operation is in
progress. In testing we've seen that a wakeup interrupt can come
in during suspend and trigger subsystem restart to call
pil_force_boot() before userspace has fully thawed. Since this is
not allowed the request_firmware() call from pil_force_boot()
fails with -EBUSY and the processor is never rebooted.

Register for PM notifiers to avoid calling request_firmware()
when suspend/resume is in progress. Within the notifier
synchronize any request firmware calls with suspend using a
rwsem. In the case where pil is called before suspend, the
suspend notifier should block on the down_write() during
PM_SUSPEND_PREPARE. When suspend is initiated before pil any pil
operations should block on the down_read() until suspend
finishes. Doing this should fix races between suspend/resume and
request_firmware() within PIL.

Change-Id: Id12d128a3729680b36845de7228bf3919c32a672
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
clk: added tsif clocks

Added tsif_pclk and tsif_ref_clk to the clock list.  These are required
by both the TSIF driver and the TSPP driver on 8960.

Change-Id: I5438a3679e18c8a8ef0a19ee3aea2e9dc2819be9
Signed-off-by: Joel Nider <jnider@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/clock-8960.c

Signed-off-by: Praveena Pachipulusu <pveena@codeaurora.org>
msm: board-8960: Handle unstable section overflow

If the calculation for 'high' overflows, it is set to
0xFFFFFFFF. This will cause the unstable region to be
aligned in the wrong way.

This change avoids the overflow by subtracting the
MIN_MEMORY_BLOCK_SIZE before adding the membank size.

Change-Id: Ie2b5f2ce0a6ddc6cdffa7554957bd458cf744e5d
Signed-off-by: Jack Cheung <jackc@codeaurora.org>
(cherry picked from commit 60eaeabda563156525247dc6e19480a2caa244f5)
msm: board-8930: Calculate unstable zone for 8930

Port "msm: board-8960: Handle unstable section overflow"
to 8930 board file.

Change-Id: I234f665e7e6ff404428cc4d05bbea85f46684c62
Signed-off-by: Jack Cheung <jackc@codeaurora.org>
(cherry picked from commit 6ce8f6895815d23a523ae4e4293aba7183679105)
arm: Add support for CONFIG_ENABLE_DMM

Add a new config ENABLE_DMM that will turn on/off the DMM feature.
DMM stands for "dynamic memory management" (the ability to power
off some memory when the system is idle) and the reason this
is needed is that many customers do not want this functionality
and we want to provide a consistent and simple way of turning
this off, rather than the ad-hoc methods some have been using.

DMM currently is enabled by default on 8960.

The following configs are currently used only by DMM
and will be disabled if ENABLE_DMM is not true.

CONFIG_MEMORY_HOTPLUG
CONFIG_HOTREMOVE
CONFIG_ARCH_ENABLE_MEMORY_HOTPLUG
CONFIG_ARCH_ENABLE_MEMORY_HOTREMOVE
CONFIG_MIGRATION
CONFIG_ARCH_MEMORY_PROBE
CONFIG_ARCH_MEMORY_REMOVE

CRs-Fixed: 344176
Change-Id: I1f1fa8a8882136a38f0abd01b0f5cb59c9a25152
Signed-off-by: Jack Cheung <jackc@codeaurora.org>
Signed-off-by: Larry Bassel <lbassel@codeaurora.org>
(cherry picked from commit b8d6102e021946973b20f4c2646e24c256eaab32)
vidc: Increase size of h264 encoder's mv buffer

Corruption is seen in the output bitstream in hfr recording
mode.

The output corruption is avoided by increasing the size
of the mv buffer.

Change-Id: I6fed4329a9be772cb680e268cf0c618d8a350f14
CRs-Fixed: 340590
Signed-off-by: Luis GarciaCalderon <luisgc@codeaurora.org>
(cherry picked from commit 8cd67fa36db83b5757c61de4b3bed567bc800b14)
Bluetooth: Poll for RSSI updates from the remote device

This feature is required for implementing Low energy
proximity client immediate alert service. The proximtiy
client registers with the kernel for receiving RSSI updates
of the remote device. The kernel starts polling for RSSI
value using READ_RSSI HCI command and When it reaches
a particular threshold set by the proximity client,
updates are sent to the client.

CRs-fixed: 344936
Signed-off-by: Archana Ramachandran <archanar@codeaurora.org>
(cherry picked from commit 26a752b8a7af75b375ea6322d6819700afe3263f)

Change-Id: I3cddbb00790389ae8f8d8e5ffd7cfcd9ddb0fa4c
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit c66e9ca52fa8af8663a0be1caa90b887a542d576)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
(cherry picked from commit cc267c57bec232bf57c91fcd19e3175155e91924)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Merge "Bluetooth: Poll for RSSI updates from the remote device" into ics_chocolate
defconfig: msm8960: Enable PID saving in contextidr

Saving the PID in CONTEXTIDR will allow us to view it in ETB when the
context is traced.

Change-Id: Iabed55b756ea5b1aee85b587453e1bfe069f4521
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: rtb: Give explicit numbers to log ids

Explicitly number all log ids for the RTB. This makes it
easier to specify a bit mask through sysfs or on the kernel
command line.

Change-Id: I99c73c68eaae0eff5c4b465192138bf956aadbec
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm: rtb: Log the context id in the rtb

Store the context id in the register trace buffer.
The process id can be derived from the context id.
This gives a general idea about what process was last
running when the RTB stopped.

Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
Change-Id: I4fe82d9912b5d7df142399c4a9eafa89dfe8fa3d
msm: rtb: Remove size parameter

The size parameter was removed in "msm: rtb: Convert RTB
to platform device" (9b9f1d772e3ff5bfd1ee520c1ffd9219a167b8c2)
but was reintroduced due to a merge conflict. Remove it again.

Change-Id: I782b975fab5745271448b5ab37d6f4461c16934b
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>