diag: dci: Safeguard to prevent Integer Underflow and Memory Leak

At certain point in diag driver there can be integer underflow
thus can lead to memory leak. Added a safeguard for that.

Change-Id: I2a0304f5b9888fe12ca9ef5fbaa9a68ee4ab9c15
Crs-fixed: 556860
Signed-off-by: Katish Paran <kparan@codeaurora.org>
misc: isa1200: Change mutex for isa1200 vibrator

Change i2c client device mutex to local driver mutex
for isa1200 vibrator which is used while enabling and
disabling the clock.

CRs-Fixed: 545512
Change-Id: I4f61c629c503c658410b5c14da2e1612b82ec201
Signed-off-by: Shantanu Jain <shjain@codeaurora.org>
msm: ipa: Send state changed event from IPA RM

In case that producer is granted synchronously, notify all
registered clients. This change is required as there was an IPA RM
client which didn't get the notification when required.

Change-Id: If400c5d4c48ae856a39277cfd1bdc4c27bf67372
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Change the value of HOLB timer

Change the value of HOLB timer from 0xff to 0x1ff.
This change is needed for TCP good bi-directional throughput.

Change-Id: Ib8e147fdda901e0bfc21c57c3853340ae3f68c20
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Adding debugfs stats to IPA RM

Adding statistical information regarding IPA RM

Change-Id: I03c3e95f5cf7e7568fbe7778965ea1b2b80a96fe
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: Bug fix in RM add_dependency

Fixing a minor bug in the RM at add_dependency

Change-Id: Icb6a53cd6b4bdbd590adea52725f7df688e0a2f0
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: ipa: a2_service: race condition fix

This issue is a rare race condition which appears after ~3 hours of
testing and causes a kernel crash.

Fixes the issue reported in droidbug-60712.

Change-Id: Id6d313088f7873ef3f47edeb25c54528691ece5b
Signed-off-by: Gidon Studinski <gidons@codeaurora.org>
msm: ipa: Move ipv4 RT rules to use system memory

Moving ipv4 routing rules in IPA-HW to use DDR memory.
By default ipv4 routing rules will reside in DDR memory.

Change-Id: I69c559ca90b638e38af872a3858f3fcb6e61d0b0
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
msm: ipa: wwan: release producer only when no outstanding packets

release WWAN_PROD only after getting WRITE_DONE
event for the last packet to make sure that there
is no outstanding packets when releasing WWAN_PROD.
This is fix for potential bug that A2 may go to
power collapse while there are packets pending in BAM

Change-Id: I6ae08fb149f4309866b693f37744e090581f5816
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
msm: ipa: use smem_alloc2 to allocate SMEM pipe mem

smem_alloc used previously assumes modem will alloc the
item before IPA driver is initialized. smem_alloc2 will
alloc the item if not already allocated.

Change-Id: I4bd1e8d85a325180e58507b300984db882d8e18d
Signed-off-by: Ravi Gummadidala <rgummadi@codeaurora.org>
msm: ipa: change release producer RM API to always return success

A bug fix in RM, which caused the producer to remain in
"release in progress" state when releasing producer.
The fix is to move to release state directly without
moving to "release in progress" state.

Change-Id: I588780898b7b234bbc3233f661f7bb90e34ce598
Signed-off-by: Vladislav Mordohovich <vmordoho@codeaurora.org>
msm: sps: free the interrupt for satellite mode

When BAM is registered in satellite mode on apps side, we do not
need to disable BAM HW when apps side does not use that BAM any
more. But we still should free the interrupt. This is addressed
in this change.

Change-Id: I955ea1a341036efa82f0ecc0f45cad5ec41651ae
Signed-off-by: Yan He <yanhe@codeaurora.org>
msm: sps: Fix error case handling in probe function

Fix possible NULL pointer dereference in the probe
function by adding proper error case handling for
clk errors.

CRs-fixed: 583991
Change-Id: Ief54cc28487e5559a893fa2f4c57148e76bd1acb
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
msm: sps: enable SPS for APQ8084

Add the support for new BAM HW features and LPAE.

1. Replace data types of physical addresses of descriptor
   and data with phys_addr_t.
2. Replace sps_transfer_one() function u32 addr argument
   to phys_addr_t addr.
3. Add new MSB registers address support for LPAE.
4. Add support for two new PIPE level ERROR IRQs which
   can be enable or disable by client.
5. Add support to read the BAM PIPEs attributed to
   specific EE.
6. Add the option for BAM Clients to specify whether
   enable or disable some HW features of their BAMs.

Change-Id: If41e3d5e7e8333d7076d924dbae06caa126a1694
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
msm: sps: add OCIMEM for pipe memory

BAM uses pipe memory for BAM-to-BAM connnections. OCIMEM is one of
memory types for pipe memory. Add the support for OCIMEM in this
change.

Change-Id: Ifc6fe537060d2c4120a03222cb419f463c7b4ab0
Signed-off-by: Yan He <yanhe@codeaurora.org>
msm: sps: Add probe deferral support in sps driver

Add probe deferral support in sps driver.

Change-Id: If65d2ebbcdece256fdfa000097ac25874c9a5000
Signed-off-by: Dipen Parmar <dipenp@codeaurora.org>
spmi: Add del_controller functionality

The del_controller function is required to release any client device
resources as well as the debugfs entries.  This patch adds that
functionality.

Change-Id: I91c6b840acfe002f096570cbe1867b302c475e60
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi and gpio: qpnp: add pointer check in qpnp drivers

This patch is to fix KW errors in drivers. It's
neccessary to check NULL pointer before dereferencing it.
There're 4 issues related to it in qpnp-int.c and
qpnp-pin.c. Fix them by checking before.

CRs-Fixed: 505322
Change-Id: I2f82d1b24c219ef7e6b0977091fc353dac579cbc
Signed-off-by: Zhenhua Huang <zhenhuah@codeaurora.org>

Conflicts:
	drivers/spmi/qpnp-int.c
spmi: Add check for NULL and invalid controller pointer

Replace the BUG_ON() check with a NULL pointer check and verify that
the controller type is set appropriately.  This prevents a system crash
due to invalid input.

Change-Id: I858980ad54ba0d764219049a20b4ca3e9b77f72e
Signed-off-by: Kenneth Heitke <kheitke@codeaurora.org>
spmi: qpnp-int: call arbiter ops only when all peripheral irqs are disabled

The current driver calls arbiter ops when an interrupt is being
masked or unmasked. However, the arbiter ops were meant to be
called if all interrupts for a peripheral were disabled or
the first enable happens.  The driver ends up masking the peripheral
(i.e.  all the interrupts in that peripheral) if any one interrupt in
that peripheral is masked. There could be other interrupts enabled
which will not trigger after this.

Fix this by changing the driver to call the arbiter ops only
when all the interrupts in the peripheral are disabled or when
the first enable of an interrupt in that peripheral happens.

Also take this opportunity to clean up the arbiter ops calls to
specifically write to the INT_ACC_ENABLE bit instead of entire
register as specified in the data sheets.

Change-Id: If5835ac125f59d2964242758aa9f9ef145000af7
Signed-off-by: Abhijeet Dharmapurikar <adharmap@codeaurora.org>