hsic_sysmon_test: Add check for userspace buffer size count

hsic_sysmon_test local buffer size limit is 4096 bytes. If user space
tries to write data with size greater than 4096 bytes, memory corruption
would happen. Hence, add check for userspace buffer size count before
writing data from userspace buffer to hsic_sysmon_test local buffer.

CRs-Fixed: 547489
Change-Id: I29b286451395bef68a879baa0366dcef56d489c4
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
msm: rpm-regulator-smd: correct use-after-free in rpm_vreg_device_remove

Modify the rpm_vreg_device_remove() function so that the reg
pointer is not dereferenced after being freed.

Change-Id: I0bc2c38a00c5d6b783f52c0ae0f1faa31d3a1e4d
CRs-Fixed: 564463
Signed-off-by: David Collins <collinsd@codeaurora.org>
msm: rpm-regulator-smd: limit current to RPM defined maximum

Modify the rpm_vreg_get_optimum_mode() function so that it
restricts the maximum current that can be sent for the 'ma' KVP
to the limit defined by the RPM.

Change-Id: I744e656c75a5e78a81df9c283a8f14a977c4c6ee
Signed-off-by: David Collins <collinsd@codeaurora.org>
msm: rpm-regulator-smd: remove incorrect rpm_regulator_get() unlock calls

The rpm_regulator_get() function calls rpm_vreg_unlock() in
failure paths after two kzalloc() calls.  However, there is no
corresponding rpm_vreg_lock() call before these calls.  Also, the
code being executed does not require mutual exclusion.  Thus,
remove the rpm_vreg_unlock() calls in order to avoid possible
locking problems if kzalloc() fails.

Change-Id: I0a0f2ffde5a6c54600a823e3ed12c3c47c3bac6a
Signed-off-by: David Collins <collinsd@codeaurora.org>
msm: rpm-smd: Wait for RPM channel notification before opening a channel

On some targets, where RPM doesn't bring the Apps core out of reset, the
RPM driver might fail on a channel open if RPM has not yet created a SMD
channel for it.

Wait for a smd channel created notification before attempting to open
the RPM-SMD channel.

Change-Id: Ia432ac2c033ab66a70a87b26637bdfc95cadec74
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
msm: rpm-smd: add missing kvp in sleep set

If there is a KVP that was not present in first sleepset
request and sent later, the same KVP is not updated to
the node in tree internally maintained

the kvp is added to the existing node

CRs-fixed: 546434
Change-Id: I43301f93fb48535e3d4a0833333568488a2c33d3
Signed-off-by: Venkat Devarasetty <vdevaras@codeaurora.org>
msm: pil-q6v5-mss: Set the force stop bit and wait for ack when necessary

The force stop bit can be used to indicate to the modem to dump its memory
and stop execution. The dumped memory can then be used for debugging
purposes.

This should be done under the following circumstances:

1. When the application processor panics, we need the modem image to stop
execution and dump its memory for future analysis. Setting the force stop
bit achieves this. But in this scenario use a timeout and do not wait for
the acknowledgement from the modem because all interrupts would be disabled
in the application processor.

2. When an SSR is being performed on the modem as part of a group of
subsystems where the SSR is not a direct result of the modem crashing but
because of any other subsystem in the group. In this case, dumping the
modem memory can help debug if there were any interdependencies between
the subsystems in the group which led to the SSR.

3. When an independent SSR is being performed where the modem doesn't
detect an error (and hence doesn't flush its buffer on its own) but a
client running on the application processor detects an error. The memory
dump then could lead to finding the cause of the error.

In cases 2 and 3, wait for the force stop acknowledgement from the modem
before proceeding further.

Change-Id: I816b53fb961adf93943893793e38254cb8bfcde1
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: pil: Proxy unvote after pil_shutdown() when using IRQs

Subsystems might use an IRQ for removal of proxy votes via the
power/clock ready interrupt. So, if a peripheral shutdown is triggered
before the power/clock ready interrupt is received, remove the proxy
votes and bypass the unvoting in the power/clock ready interrupt handler.
Conversely, if the power/clock interrupt is received before shutdown is
triggered, bypass the unvoting during pil shutdown.

Also, remove the hack to proxy unvote directly from the pil-q6v5-mss
driver.

Change-Id: I254ab5a1595ceb27a2cfcac99c4c1d2f2443b7c7
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: pil-q6v5-mss: Get smem reason buffer without taking remote spinlock

During a subsystem restart the modem might have crashed after taking the
remote spinlock. In such a case, when application processor tries to get
the smem entry for the SFR log, it would wait indefinitely for the remote
spinlock to be released. To solve this problem, use the smem API that
gets the entry buffer without taking the remote spinlock.

Change-Id: I00e77472bc88e276afb20835bdc24c5da09b9e86
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: pil-q6v5-mss: Do not generate redundant smem ramdump

When the device crashes, smem ramdump is already generated by the smem
driver. Therefore, the smem ramdump generated by pil-q6v5-mss is redundant
and the code responsible for it can be taken out.

CRs-fixed: 485208
Change-Id: I8b67ff9f54663b68268b7b87e9cb1f3930219afa
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pil-q6v5-mss.c
msm: pil-q6v5-mss: Initialize the stop ack completion variable

In case of targets that don't use the PIL framework to boot the modem,
the stop_ack completion variable might remain in uninitialized state as
the initialization is currently being done only within PIL callbacks.
So, fix this my initializing the completion variable outside of PIL
by callbacks.

Change-Id: I204b0fbf461b1e1f1d4576dc43e33c7442eaf0e0
Signed-off-by: Seemanta Dutta <seemanta@codeaurora.org>
msm: pil-q6v5-mss: Correct kzalloc return path checking

devm_kzalloc returns NULL on failure, not an error code.
Fix the check done on mba_data after the allocation.

Change-Id: Ie7a75d8864889f0426a7f3fb54908e4869a719a8
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pil-q6v5-mss.c