mmc: msm_sdcc: Fix scatterlist processing in PIO mode

sg_miter_next() does not place byte alignment restrictions on
sgl lengths. However, SDCC FIFO must be accessed in multiples
of 4 bytes, requiring rounding which can cause data corruption.

For example, an sgl of length 481 is decribed below:
	struct scatterlist sgl;
	sgl.page_link = 0xXXXX_XXXX;
	sgl.length    = 481;
	sgl.offset    = 3821;

First call to sg_miter_next():
	Sgl length returned = (PAGE_SIZE - 3821) = 275 bytes
	Driver rounds this length to multiple of 4 = 276 bytes

Next call to sg_miter_next():
	Sgl length returned = (481 - 275) = 206 bytes
	Driver rounds this length to 208 bytes

On a write, the extra byte written to the FIFO during the first
276 byte chunk is assumed valid. The next call writes 208 bytes,
but the last 3 bytes (276 + 208 - 481) including 1 valid byte,
are ignored, as the controller uses the MCI_DATA_LENGTH register
to figure out that it only needs to write a total of 481 bytes.

To fix the data corruption in cases as above, a 4 byte bounce
buffer is used realign buffer access to the FIFO, such that 4 byte
multiples are written until the last buffer chunk.

Note that in a simple case where all 481 bytes lie within a page,
the driver rounds the length to 484, but the MCI_DATA_LENGTH
register enusres only 481 bytes are actually written.

CRs-Fixed: 338102
Change-Id: Ia3438652c24c4f67981154bae250533a4c7986d3
Signed-off-by: Oluwafemi Adeyemi <aadeyemi@codeaurora.org>
Bluetooth: Set security level based on remote device features.

Connection security level is modified based on remote device's
extended feature. Deciding SSP capability of remote device
by EIR response is incorrect, because few BT2.1 devices do not
send EIR and few BT2.1 devices which send EIR do not support
SSP. SSP capability of remote device has to be decided based on
remote_extended_features event. This patch makes sure that
MEDIUM_SECURITY is set for non ssp devices' pairing process.

CRs-fixed: 339166
Signed-off-by: Prabhakaran Mc <prabhakaranmc@codeaurora.org>
(cherry picked from commit 453651c5db2cba83b07331199ce5e35a0f6f057b)

Change-Id: I3c6c90f5e0a8ea2eb5737456ecc07b24a2c44e38
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: kgsl: Poke regularly in adreno_idle

Poking once during adreno_idle is not enough; a GPU hang may still happen.
Seen on 7x27A. Write a few times during the wait timeout, to ensure that
the WPTR is updated properly.

CRs-fixed: 340123
Signed-off-by: Lynus Vaz <lvaz@codeaurora.org>
(cherry picked from commit 284d10404f81d05a59655dd03b72c80fae112b9d)

Change-Id: I7281fc1f02f38380a3f3e8ad16a7298f5bf4c1de
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm_serial_hs_lite: Fix hardware bug by using dummy read of UARTDM register

UARTDM hardware doesn't work if data is transferred immediately after
programming NO_CHARS_FOR_TX register. Hence read out UART Status
Register which introduces one AHB clock cycle delay after programming
NO_CHARS_FOR_TX register.

CRs-Fixed: 340339
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
(cherry picked from commit ec41e9351875484e5c1e83005c20689c3b3ed2cc)

Change-Id: I292a83e760038451129daeeb5de8cb9ffbd77bac
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm_serial_hs_lite: Save UART registers if stuck

Preserve and attempt to print out relevant UARTDM core
registers, followed by panicing the system, if the
polling-mode serial console fails to print a character as a
result of the TX buffer remaining full for more than 100
character transmit times. This information is useful for
troubleshooting extremely rare cases where the serial
console unexpectedly stops producing output.

CRs-Fixed: 340339
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 1d4731ee979106d1f661418bf0f5544634d26b8e)

Change-Id: If45e8449f65eca2ebfb217d2ee680fa69b108ce7
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Bluetooth: Fix L2CAP connection establishment

In hci_conn_security ( which is used during L2CAP connection
establishment ) test for HCI_CONN_ENCRYPT_PEND state also
sets this state, which is bogus and leads to connection time-out
on L2CAP sockets in certain situations (especially when
using non-ssp devices )

Signed-off-by: Ilia Kolomisnky <iliak@ti.com>
Signed-off-by: Gustavo F. Padovan <padovan@profusion.mobi>
[mathewm@codeaurora.org: Resolved conflict]
CRs-fixed: 343392
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
(cherry picked from commit edc44dd5059f7f16a63af462cd1fc48532b8933e)

Change-Id: I9ef864c81eed5b0aaa37683c7dee7f20535ed9e4
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
Bluetooth: Fix l2cap conn failures for ssp devices

Commit 330605423c fixed l2cap conn establishment for non-ssp remote
devices by not setting HCI_CONN_ENCRYPT_PEND every time conn security
is tested (which was always returning failure on any subsequent
security checks).

However, this broke l2cap conn establishment for ssp remote devices
when an ACL link was already established at SDP-level security. This
fix ensures that encryption must be pending whenever authentication
is also pending.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Tested-by: Daniel Wagner <daniel.wagner@bmw-carit.de>
Acked-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
CRs-fixed: 343392
Signed-off-by: Mat Martineau <mathewm@codeaurora.org>
(cherry picked from commit a5e5b0823a45f66a21ef4ef8a5f4b1b8639d828d)

Change-Id: I2ca7894e8c692ea058b14a54a9e47bcefa7add51
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: camera: optimize csiphy setting

Remove csiphy configuration of phy data lane control
registers and phy clock lane control registers that sets
default value. Tune csiphy configuration of phy data lane
control 2 for reducing LP CLK positioning

The change is to set back to default values, which is
recommended. Also, MIPI clk and data setting is matched in
this patch. Although the discrepancy won't hurt the current
POR camera sensors and most of camera sensors, this patch is
recommended in order to avoid future issue.

Signed-off-by: Hody Hung <hhung@codeaurora.org>
(cherry picked from commit fe282e9d62d3190ba4d8b5ded4f386e451f1a0b9)

Change-Id: Ib080bd62a0e90d168f369cb6df3b89f900e98570
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
defconfig: msm8960: sync up perf defconfig

Sync up msm8960-perf_defconfig with msm8960_defconfig by adding changes
missed in the orignal commit 69d8273 and the 8064 machine type commit
82b7e3f.

Signed-off-by: Jin Hong <jinh@codeaurora.org>
(cherry picked from commit d0a18a682efe4cab6905386e34953856a56b14f8)

Change-Id: Ic3e7ea3a1ca97622824208f2b84601558f4e7cbd
Signed-off-by: Zhoulu Luo <zluo@codeaurora.org>
msm: rtb: Macroize more of the readl/writel code

Most of the readl/writel macros for logging to the RTB
very similar. Create a dedicated macro to use for all of them
to make the code more readable and easier to maintain.

Change-Id: I87cccc092a630abb1c52bcf24c9c55a75d38b1d1
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: mm: update CONTEXTIDR register to contain PID of current process

This patch introduces a new Kconfig option which, when enabled, causes
the kernel to write the PID of the current task into the PROCID field
of the CONTEXTIDR on context switch. This is useful when analysing
hardware trace, since writes to this register can be configured to emit
an event into the trace stream.

The thread notifier for writing the PID is deliberately kept separate
from the ASID code, so that we can easily support newer processors (A15
onwards) which store the ASID in TTBR0. As such, the switch_mm code is
updated to perform a read-modify-write sequence to ensure that we don't
clobber the PID on older CPUs.

Change-Id: I2f703f49c62b866c5f1edba63cbe5942de6c5881
Cc: Wolfgang Betz <wolfgang.betz@st.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
msm_fb: HDMI: Video Quantization Ranges changed

MHL 1.1 Compliance was seen to fail in Test 3.2.3.4.
We currently limit this change to only when MHL is enabled.
In future, when we support MHL we can enable quantization by default.
Currently, HDMI compliance and other test cases have passed without this
change. So we can keep this change specific to MHL.

CRs-Fixed: 334268
Signed-off-by: Manoj Rao <manojraj@codeaurora.org>
(cherry picked from commit f1bbd8638d1e0ed84fcc9836f5b8dffebac5fb68)

Change-Id: I29b2151666baa933adfddeaaba551d85d4db4237
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
Merge changes I2ca7894e,I9ef864c8 into ics_chocolate

* changes:
  Bluetooth: Fix l2cap conn failures for ssp devices
  Bluetooth: Fix L2CAP connection establishment
Merge changes I2f703f49,I87cccc09 into ics_chocolate

* changes:
  ARM: mm: update CONTEXTIDR register to contain PID of current process
  msm: rtb: Macroize more of the readl/writel code
Merge "msm: camera: optimize csiphy setting" into ics_chocolate
Merge "defconfig: msm8960: sync up perf defconfig" into ics_chocolate
Merge "msm_fb: HDMI: Video Quantization Ranges changed" into ics_chocolate
defconfig: msm8960: sync up perf defconfig

Sync up msm8960-perf_defconfig with msm8960_defconfig by adding changes
missed in the orignal commit 69d8273 and the 8064 machine type commit
82b7e3f.

Signed-off-by: Jin Hong <jinh@codeaurora.org>
(cherry picked from commit d0a18a682efe4cab6905386e34953856a56b14f8)

Conflicts:

	arch/arm/configs/msm8960-perf_defconfig

Change-Id: I1885b13e7de4d81d148fec874b9b5aa7d2179d8b
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: vreg: Fix the vreg list for dangling node

While doing vreg_put call, it is just freeing the
vreg name and vreg regulator structure, but the node
in the list is still present, which will casue memory
leak and may lead to kernel panic.

One scenario to reproduce the issue is continuously use
of vreg_put/vreg_get apis and as it will increase the
dangling node in the list and results in the problem.
Hence delete the node from the list while calling vreg_put.

CRs-Fixed: 340097
Signed-off-by: Pankaj Kumar <pakuma@codeaurora.org>
(cherry picked from commit 679671e44ff3c6d2e1506c4325d3142fcbb40589)

Change-Id: Ib9b74c2aa4fabb8d19b9d03f3991c3fd14151ae8
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Merge "Bluetooth: Set security level based on remote device features." into ics_chocolate