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>