mmc: core: disable the cache before suspend only after stopping BKOPS

mmc_cache_ctrl was called in runtime suspend before MMC interrupted
BKOPS in case it is still running on the card. This caused the cache
disable to timeout.
Therefore, mmc_cache_ctrl has to move to mmc_suspend where we are sure
that the card can go into suspend and there is no pending activity.

CRs-Fixed: 436805
Change-Id: I76281a766f48ccacc24685a64067df4e60cfe1d8
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 67a51386fd99be62e5e68f4bc76ee00c19099cd6)

Conflicts:
	drivers/mmc/core/mmc.c
mmc: increase BKOPS polling duration before suspend

The timeout for the BKOPS polling is increased in order to allow the
card to complete the BKOPS before going to suspend.
In case we exit due to timeout we need to stop the BKOPS activity
performed by the card.

Change-Id: I39686de0c06a57242f11c8b1c9ae50b33417c088
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit ea1385e6d7542d4e3ad510de94ead00bece7823e)
mmc: Do not perform blocking BKOPS

BKOPS operations can take long time and cause bad user experience and
failure of time critical operations as EFS sync.
In order to prevent the above failures all the levels will be handled only
in idle time BKOPS handling and will allow interrupting the BKOPS when
needed.
In case the card raised an exception with a need for BKOPS, a flag will
be set to indicate MMC to start the BKOPS activity when it becomes idle.

Fixed-CRs: 432027
Change-Id: I5f7b43569c0242f0fea83355f76f286b1ad037bc
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 5f8ac3b955e44def61c2238192000ffe5f126714)

Conflicts:
	include/linux/mmc/card.h
mmc: use percentage changed sectors as indication to check BKOPS need

In order to keep card endurance, it is best not to check the need for
BKOPS every time the MMC is idle.
However, the decision when to check the card need for BKOPS according
to number of changed sectors doesn't fit all cards sizes. Therefore,
the check for BKOPS need is based on percentages of changed sectors
of the card size.
In order to assure that BKOPS will be triggered again in case it was
interrupted, the accumulated number of changed sectors is cleared only
in case BKOPS was completed without interruption.

Change-Id: I598f64b652a524a431b87d103fd5890b808f11b1
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit e1eae988976536834759a45cf7f62e1cb2b82838)
mmc: core: Cancel BKOPS checking in case MMC is suspended

If there is a race condition between the delayed BKOPS work and
the runtime suspend, and the suspend occurs before the delayed work,
the delayed work should be canceled.
Since mmc_claim_host can fail in case the host is suspended, we should
check if the delayed work is canceled before trying to claim the host.

CRs-Fixed: 443236
Change-Id: I9df506de4da6f9277a89ed608724f5b6e8585bfd
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 5a3d216c005725baad96b6858dbcd370056e470c)
mmc: core: Fix a deadlock due to race between suspend and delayed BKOPS

mmc_stop_bkops calls cancel_delayed_work_sync while the host is taken.
This can cause a deadlock since the delayed work is blocked on claiming
the host. In order to prevent that, mmc_start_bkops will not
be blocked waiting on mmc_claim_host and if the host is already taken
BKOPS will not be performed.

CRs-Fixed: 446090
Change-Id: I5cda5489e254764b3231b8a12da9e3c241c969c3
Signed-off-by: Maya Erez <merez@codeaurora.org>
(cherry picked from commit 8571386b83bea1cbadd81c75bf0614da30b6b7c0)
msm: audio: qdsp6v2:  Check return code from audio_aio_open()

When audio_aio_open() is triggered in blocking fashion, it  frees audio
resouces and returns error code. In the current implementation,  callers
did not check the error code which can lead to dereference to freed
resources and cause system crash.  Update the callers to check return
code and then return error back to application to avoid the issue. In
the meanwhile, update the audio_aio_open not to free memory for caller
and leave the caller to free the memory in error condition.

CRs-fixed: 436653
Change-Id: If4dda158cb988c5837517817b1afa0572c30696e
Signed-off-by: Kuirong Wang <kuirongw@codeaurora.org>
Bluetooth: Introduce new security level

Define new security level BT_SECURITY_VERY_HIGH
for BT-SAP secuirty requirements

Change-Id: Iee1f60def34d64174c71934ecf55319cee087c13
Signed-off-by: Bhakthavatsala Raghavendra <braghave@codeaurora.org>
Revert "Bluetooth: Avoid re-authentication for secure high connections"

This reverts commit 45c9e8141e54a691180c55ed9e242302a74224a8.

Change-Id: Iee644f37c2108013654e99d82f63101db3da009e
Signed-off-by: Bhakthavatsala Raghavendra <braghave@codeaurora.org>
usb: gadget: u_ether: Fix NULL pointer derefernce crash

port->port_usb can be NULL if USB cable is disconnected when
net device is trying to transfer data which is causing device
to crash. Hence add changes to eliminate need of accessing
port->port_usb to see multi_xfer_pkt value.

CRs-Fixed: 452642
Change-Id: I60bd2302371238707e951c77912b155d75dc8570
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Merge "mmc: core: Reduce the time to check for BKOPS need on idle"
Conflicts:
	drivers/mmc/core/mmc.c
Merge "mmc: Do not perform blocking BKOPS"
Conflicts:
	drivers/mmc/core/core.c
	include/linux/mmc/card.h
Merge "mmc: use percentage changed sectors as indication to check BKOPS need"
Merge "mmc: core: Cancel BKOPS checking in case MMC is suspended"
Conflicts:
	drivers/mmc/core/core.c
Merge "mmc: core: Fix a deadlock due to race between suspend and delayed BKOPS"
msm: vidc: Fix iommu pagefault in concurrent scenario

IOMMU pagefault is seen while running decoder and
encoder concurrently for specific codec combination.
Map double the buffer size to ion_map_iommu() API for
encoder reconstruction buffers to avoid the pagefault.

Change-Id: Ib5546a42a75c4c628767310f1a291e7ed443056c
CRs-fixed: 450621
Signed-off-by: Maheshwar Ajja <majja@codeaurora.org>
msm_fb: display: wait4vsync before set suspend flag

Since wait4vsync checks suspend flag, wait4vsync needs to
be executed before suspend flag set to enforce wait happen.
Also, when timing generator is turned off, wait4vsync can
not be used anymore since the last vsync may have passed
before wait4vsync called. This patch fixed commit_comp
timeout cause fence timeout happen on hdmi plug and unplug
cases.

CRs-fixed: 449027
Change-Id: I0f5520538bb290643a648c937296b6bc097fe051
Signed-off-by: Kuogee Hsieh <khsieh@codeaurora.org>

Conflicts:
	drivers/video/msm/mdp4_overlay_dsi_video.c
	drivers/video/msm/mdp4_overlay_dtv.c
defconfig: Enable CPU frequency switch profiling support on Krait targets

CPU frequency switch profiling is by default disabled but, by setting
this Kconfig, it can be enabled at runtime through debugfs to collect
useful statistics.

Conflicts:

	arch/arm/configs/msm8974_defconfig

(cherry picked from commit b29c5b57d7e576f5b3cb01de636e8316fcb641e4)

Change-Id: I222e90ebf56814e08298c6edb9fa025a89e3fcbb
Signed-off-by: Matt Wagantall <mattw@codeaurora.org>
USB: f_rndis: Check if cdev is NULL before accessing

RNDIS control path completion handlers are getting called after setting
cdev to NULL during disconnect as part of composition switch and this
is leading to a crash. Avoid this crash, by checking, if cdev is NULL
before accessing. Also don't queue request's to DCD, if composition switch
is in progress.

CRs-Fixed: 433534
Change-Id: Ic0790415ec3eaf866af2895370249e45adcbba5d
Signed-off-by: Chiranjeevi Velempati <cvelempa@codeaurora.org>
(cherry picked from commit 46874732be9d6997ff3bceaf97f07911f9f22440)

Conflicts:
	drivers/usb/gadget/f_rndis.c
ASoC: wcd9304: Turn off mclk during clock transition

The clock is not usable when either the clock source changes between
external MCLK and internal RCO or the bandgap mode changes to fast mode.
In such cases, turn off master clock and turn on again later to avoid
codec from going into bad state

CRs-fixed: 442464
Change-Id: Id8d07bbbd4bf6c7be16016800d19ab332b960d1a
Signed-off-by: Joonwoo Park <joonwoop@codeaurora.org>