msm: kgsl: Pass correct datatype to kgsl_mmu_ptpool_destroy()

This fixes a crash due to NULL pointer access when allocation of DMA
Coherent memory fails.

Change-Id: I7ea7405713682aaa7cd660ef341a968342dc0880
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
msm: kgsl: Follow reverse sequence of init procedure during exit

Fixes kernel warnings about sysfs entries being unavailable when they
are removed during exit.

Change-Id: I6caaaff935b31d3f39a3610cdd2b048baf2f1a97
Signed-off-by: Ranjhith Kalisamy <ranjhith@codeaurora.org>
msm: kgsl: Modify kgsl_core_exit to release resources carefully.

kgsl_core_exit() should not call kgsl_sharedmem_uninit_sysfs() and
device_unregister() if those resources have not been allocated.
We check this by seeing if kgsl_driver.virtdev has been
populated or not.

CRs-fixed: 359477
Change-Id: Ic040667b29bd4e006e6f29a50809d94a2bb4b469
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: kgsl: use correct 2d ringbuffer offset in resume

The 2d timestamp is used as an index into the ringbuffer.
Now that z180_dev->current_timestamp is preserved across
resume, make sure that ADDR_VGV3_NEXTADDR is set to the
gpu address that corresponds to the current timestamp.

CRs-Fixed: 347025
Change-Id: Ib7dc4579943ab24e04279ede1555539ec21adabd
Signed-off-by: Jeremy Gebben <jgebben@codeaurora.org>
Bluetooth: Store the MTU if configuration of other params fail

Store the MTU to use the proper MTU requested by remote if the
configuration fails for other options. If the remote does not
send the MTU in the next configuration request,
we need to use that value.

CRs-fixed: 373233
Signed-off-by: Mallikarjuna GB <gbmalli@codeaurora.org>
(cherry picked from commit 647b004ede4061d336536f68aece062d5c20b984)

Change-Id: I9406a7f50d57646533dacda1687f9623faf4ad53
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>

Conflicts:
	net/bluetooth/l2cap_core.c
Bluetooth : hidp: Get the valid hci_conn while unlink

Since the context where unlink will be called is unaware of
validity of hci_conn pointer, fetch the valid hci_conn
before unlink.

CRs-fixed: 370274
Signed-off-by: Mallikarjuna GB <gbmalli@codeaurora.org>
(cherry picked from commit f411769619b631aa0d9f7d460bcfec4ff3e6f54a)

Change-Id: I0cb900e570b30604dcf3f08644866d8c72e2b8bd
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: gic: Remove manual GIC programming for PPI trigger type

There is no need to manually program GIC for edge trigger PPIs
through board or device file hooks after the introduction of
enable_percpu_irq(.., type) interface. 2nd parameter of this
API needs to be used for programming the right trigger
type for the PPI.

Change-Id: Ie200928eb70fcbab6646ddd63acfd89a1a87f5fe
Signed-off-by: Trilok Soni <tsoni@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
mmc: msm_sdcc: Fix race in disabling sdcc core irq

o Assume SDCC driver has SDIO clients attached and
  runtime clock gating has turned off the SDCC clocks.

o Now, if the SDIO client driver has initiated a request
  to SDCC and since the clocks are turned off, mmc framework
  tries to turn them on calling msmsdcc_set_ios().

o msmsdcc_set_ios() tries to disable the core irq first and
  reenable after the clocks are turned on. While in process
  of disabling the irq, if there is an asynchronous notification
  from SDIO client h/w, it will preempt ongoing disable and run
  msmsdcc_irq() which internally does disable_irq_nosync() since
  the clocks are still off.

o While the control returns to msmsdcc_set_ios() from preemption
  it will continue disabling the core irq (even though
  host->sdcc_irq_disabled = 1). In effect, calls disable_irq()
  twice increasing the irq desc->depth to 2.

o The enable_irq() API enables the irq in h/w if and only if
  desc->depth = 1, and hence become a noop if it is called with
  desc->depth = 2 causing sdcc failure because the interrupts
  are not enabled in h/w.

Fix the above race condition by making sure disable irq is done
atomically.

CRs-Fixed: 357406
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit b72586253db2ac7105f6dea45418ce5c50e2fcac)

Change-Id: I63a30978941746a48221cb7d4b7860956001329a
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
mmc: msm_sdcc: Fix deadlock while resuming sdcc from userspace

The runtime power management of sdcc can be controlled by
userspace with auto/on modes by writing into
/sys/devices/platform/msm_sdcc.1/power/control entry.
"auto" mode allows runtime pm suspend to happen.
"on" mode forbids runtime suspend of sdcc and also take care
of resuming the device if already suspended. During this resume
process there is a deadlock as described below:

o User writes "on" into control parameter.

o The sysfs write triggers a rpm_resume() (assume sdcc is
  already suspended, hence rpm_resume() tries to wake it up).

o rpm_resume() -> msmsdcc_runtime_resume() -> mmc_claim_host()
  -> msmsdcc_enable() -> pm_runtime_get_sync() -> rpm_resume()
  -> wait for previous rpm_resume() completion which cause deadlock.

CRs-Fixed: 372071
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit 112bd758e0992f1c7de4531e6530db5e49d6f21f)

Change-Id: I87538826bacd36971deeec4ff7f36aa5782b328e
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
Revert "Revert "mmc: sdio: optimized SDIO IRQ handling for single irq""

This reverts commit 6e611f2b8655684f578cb975fa0ebfd031b45d69.

CRs-fixed: 363705
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit c49bee55cf610a74b635c3480e97b6b9aaf885e6)

Change-Id: Ifc9d0c5d200bf2043054526f00a3c54af4e8eca1
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
mmc: sdio: avoid spurious calls to interrupt handlers

Commit 06e8935feb ("optimized SDIO IRQ handling for single irq")
introduced some spurious calls to SDIO function interrupt handlers,
such as when the SDIO IRQ thread is started, or the safety check
performed upon a system resume.  Let's add a flag to perform the
optimization only when a real interrupt is signaled by the host
driver and we know there is no point confirming it.

CRs-fixed: 363705
Reported-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Nicolas Pitre <nico@linaro.org>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
(cherry picked from commit fed14d9343eaf05e2412eedd09cbd9de9c272acd)

Change-Id: I8a80a30d14ab16d80994d13e0ed08644cc52047c
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: watchdog: set expired enable register

The apq8064 has an extra register that needs to be set to enable
a watchdog bite.

Change-Id: I7012a4d88b6fc9566cac7ff44b96db541cac8f84
Signed-off-by: Joel King <joelking@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: watchdog: Add support for VIC based devices

Current driver supports only GIC based devices. Revert
the old changes such that VIC based device can use the existing
driver.

Change-Id: I77bcdc57a001f77538641a62f57d13da4f278bac
Acked-by: Kaushik Sikdar <ksikdar@qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
arm: gic: Configure the GIC to run in secure mode

Configure the GIC to run in secure mode and handle
secure as well as non-secure interrupts. This patch
adds an API to configure an IRQ as a secure IRQ so that
it can be treated as an FIQ in the secure mode.

Change-Id: Ic3321e76c95a4c10d6287ba418e84623e7004cb1
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Sathish Ambley <sambley@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
arm: fiq: Provide empty stubs for fiq functions

A driver using fiq functions should be usable on targets
with or without CONFIG_FIQ enabled. Instead of making code
dependent on #ifdef CONFIG_FIQ, add empty stubs for the fiq
functions.

Change-Id: Ie8b1905ba53664d99bd707be3c83291c97eb1066
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: watchdog: Add support for in-kernel bark FIQ for MSM9615

MSM9615 runs in secure mode and has no TZ. Therefore, it can
handle the watchdog bark FIQ in the kernel.
The FIQ handler dumps the cpu registers from all processing modes
and finally calls panic to reboot.

Change-Id: I22b83b5d528b32fd0b43a9b4e4031ef27ef243f7
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>

Conflicts:

	arch/arm/mach-msm/Kconfig

Change-Id: Ibe110f9995fcc8f82e1ef3ff52a5a735762be32a
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: msm_watchdog: Don't pet the watchdog if it isn't enabled

If the kernel commandline has msm_watchdog.enable set to
zero and another driver calls pet_watchdog, the kernel will
panic since msm_tmr0_base is NULL (early return in probe).
Fix the pet_watchdog function to be a no-op if enable is
set to zero.

Change-Id: I4e1b72f9d98d5b4ca9ea312abde39dac7cb94b7d
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: watchdog: always manage interrupt on core 0

Previously the interrupt could end up being enabled or disabled on
either core. Since we switched to the percpu irq framework, it is a
problem if we enable the irq on one core and disable it on the other.
So, guarantee that the irq is always setup and removed on core 0.

CRs-fixed: 367280
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
(cherry picked from commit b1e211ed27c6e09963513cc702f8682fa5fbbe4d)

Change-Id: Ib69c5808bca89453f3a222bed8eb66e4db4111fb
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
RNDIS: Add Data aggregation (multi packet) support

Add data aggregation support using RNDIS Multi Packet feature
to achieve better UDP Downlink throughput. Max 3 RNDIS Packets
aggregated into one RNDIS Packet with this implementation.

With this change, seeing UDP Downlink throughput increase
from 90 Mbps to above 100 Mbps when using Iperf and sending
data more than 100 Mbps.

CRs-Fixed: 352010
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Signed-off-by: Rajkumar Raghupathy <raghup@codeaurora.org>
(cherry picked from commit 5b165cb7da498d1489a66affd4309215aae65554)

Change-Id: I4f4d3c43020b0a04ee86bf8a55423b9094673ac8
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
vidc: Adjust core timeout based on input frame size

Video core is dropping certain IDR frames due to timeout.
This is resulting in video corruption. Computing the core
timeout based on input frame size and programming it for
each input frame fixes the issue.

CRs-fixed: 370570
Signed-off-by: Rajeshwar Kurapaty <rkurapat@codeaurora.org>
(cherry picked from commit 6084636fbf190de0add7a0fb192a26f695fbe402)

Change-Id: I72f81d642860ed28b4b5caf2e3a119245f9abb65
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>