qseecom: Check the return value of "ion_phys"

Check for return value of "ion_phys" and handle
the error cases appropriately.

Change-Id: Ib4f24af24de2b2553ed91479f46b2f79e0be0446
Signed-off-by: Hariprasad Dhalinarasimha <hnamgund@codeaurora.org>
Signed-off-by: Zhen Kong <zkong@codeaurora.org>
msm: pil-q6v5: Handle undefined CONFIG_REGULATOR correctly

regulator_get() will return NULL if CONFIG_REGULATOR is defined. Handle
this value properly.

Change-Id: Iaaa8c6ddd91653349ddb107507bfb12e7e9418c8
Signed-off-by: Patrick Daly <pdaly@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>
msm: SSR: Add functionality to load restart groups from device tree

Subsystems on certain devices might need other subsystems to
restart when they undergo a subsystem restart.

The support to restart multiple subsystems together exists
currently. Use this feature to facilitate the restart groups
being initialized during run-time by reading the dependancy list
from the corresponding device tree entry using phandles.

Add a property called "qti,restart-group" in the respective dt
file device entries. This property is to be filled with the
phandles corresponding to the subsystems that need to restart
together.

Also, make a note that if a restart group is included for one
subsystem, the corresponding group should be included in the
other affected subsystems as well. The order of the subsystems
in the group doesn't matter.

Eg. subsys_0 has a property:
qti,restart-group = <&subsys_0 &subsys_1>;
Then, subsys_1's ssr-restart-group property should be identical:
qti,restart-group = <&subsys_1 &subsys_0>;

Change-Id: I22e3c46ab2b943b94227647d11863c4524a63005
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>

Conflicts:
	Documentation/devicetree/bindings/arm/msm/mdm-modem.txt
	Documentation/devicetree/bindings/pil/pil-bcss.txt
	Documentation/devicetree/bindings/pil/pil-femto-modem.txt
	Documentation/devicetree/bindings/pil/pil-pronto.txt
	Documentation/devicetree/bindings/pil/pil-q6v5-lpass.txt
	Documentation/devicetree/bindings/pil/pil-vpu.txt
msm: pil: Add notifications to indicate execution of proxy voting/unvoting

Add notifications to indicate that the generic work required to be
done in the proxy voting and unvoting functions has compeleted.

Moving forward, this will give drivers that have registered for
these notifications about the subsystem, a chance to do more
specific things at their end. This is crucial in moving forward
with having a generic driver for PIL and SSR across all
subsystems.

Change-Id: I8f1449ab86719ced533aa477f062d686958f50b2
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
msm: ssr: Send notification during a cold boot failure

Currently, when powering on a subsystem during cold boot fails,
the drivers that have registered for notifications about the
subsystem are not intimated.
Send the 'powerup failure' notification to these drivers to give
them an opportunity to do the necessary cleanup/logging at their
end before the subsystem is shutdown.

Change-Id: I09c10d5ead7dc153ed3ce3caf8f1c3442a66eb96
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
msm: ssr: Add sysfs entry to show number of subsystem crashes

Add a sysfs entry in the subsys* directory for each subsystem
called 'crash_count'. This entry gives the number of times that
a subsystem has crashed in the time that the device has been on.

Change-Id: I234b9dfb0fd59bce4ca19180c5c3d6452098488b
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/subsystem_restart.c
msm: subsystem-restart: Add structure to be passed in with notifications

Add a 'notif_data' structure which is sent with the subsystem
restart notifications. The drivers that have registered with the
framework for its notifications can use this structure to decide
upon specific tasks at their end.

CRs-Fixed: 625452

Change-Id: I0bfc277e569a72b2884837829009e96a51399874
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>

Conflicts:
	include/soc/qcom/subsystem_restart.h
msm: ssr: Remove entry from subsys list on unregistering

Currently, on a subsystem being unregistered, its entry is not
removed from the subsys list. This causes a crash when this
list is accessed at a later time.
Remove the subsys entry from the list during unregister.

Change-Id: I61f3cb82bf1ac22c6ef1374e530e14ccaaa095bb
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>
msm: subsystem_restart: Send sysmon event notifications to all subsystems

Currently, sysmon notifications are send to only subsystems which
call sysmon_send_event explicity. This leads to multiplication of
code every time that a subsystem needs these notifications.

Instead, notifications are sent to all the registered subsystems.
What the subsystems do with the information is left upto them.

Change-Id: I6396b77a36a08993eed0ad6fc1bfc7cf8b4efc09
Signed-off-by: Deepak Katragadda <dkatraga@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/pil-q6v5-lpass.c
	arch/arm/mach-msm/pil-q6v5-mss.c
	arch/arm/mach-msm/subsystem_restart.c
	include/soc/qcom/sysmon.h
msm: pil: Fix segment physical address comparison

The PIL must load segments in order of lowest physical address
to highest physical address.  The comparison used to sort the
segment list prior to load is replaced with one that works
for physical addresses above 2GB (0x80000000).  The previous
comparison returned an incorrect result when comparing a
segment with a physical address located below 2GB with one located
above 2GB.

Change-Id: Id648959a1619ad0a7bb7f8f78e1f7164b3693fb6
Acked-by: Kaushik Sikdar <ksikdar@qti.qualcomm.com>
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
msm: pil: remove use of MSM_IMEM_BASE

Move to getting address for PIL region of IMEM from the device tree and
mapping via ioremap.  This removes a usage of MSM_IMEM_BASE which will
allow removal of the static IO mappings.

Change-Id: I1321c978e4c102bfafcfb1a1c04464e31ae59943
Signed-off-by: Kumar Gala <galak@codeaurora.org>

Conflicts:
	arch/arm/boot/dts/qti/apq8084.dtsi
	arch/arm/boot/dts/qti/fsm9900.dtsi
	arch/arm/boot/dts/qti/mpq8092.dtsi
	arch/arm/boot/dts/qti/msm8226.dtsi
	arch/arm/boot/dts/qti/msm8610.dtsi
	arch/arm/boot/dts/qti/msm8974-v1.dtsi
	arch/arm/boot/dts/qti/msm8974-v2.dtsi
	arch/arm/boot/dts/qti/msm8974pro.dtsi
	arch/arm/boot/dts/qti/msmkrypton.dtsi
	arch/arm/boot/dts/qti/msmsamarium.dtsi
	arch/arm/mach-msm/peripheral-loader.c
msm: peripheral-loader: Return error codes up the chain

To allow probe deferral to work correctly, return error
codes from device tree gpio functions up to the caller.

Change-Id: Ia9f8f681e0b3205e57799af0d081ac607e9c3240
Signed-off-by: Jeffrey Hugo <jhugo@codeaurora.org>
msm: peripheral-loader: Move proxy voting to before init_image

Some PIL devices may use init_image to bring their
processor/subsystem out of reset, e.g. devices that
do self authentication. Move proxy voting to before
init_image to support this.

Change-Id: Ic99abb357ab1fb20a1d421c491fa81fa9c71fa9e
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
qcom: ramdump: Fix some format specifiers and return types

Fix format specifiers and return types to allow compilation
on different architectures and with stricter compilers.

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

Conflicts:
	drivers/soc/qcom/ramdump.c
kthread: introduce to_live_kthread()

"k->vfork_done != NULL" with a barrier() after to_kthread(k) in
task_get_live_kthread(k) looks unclear, and sub-optimal because we load
->vfork_done twice.

All we need is to ensure that we do not return to_kthread(NULL).  Add a
new trivial helper which loads/checks ->vfork_done once, this also looks
more understandable.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kthread: kill task_get_live_kthread()

task_get_live_kthread() looks confusing and unneeded.  It does
get_task_struct() but only kthread_stop() needs this, it can be called
even if the calller doesn't have a reference when we know that this
kthread can't exit until we do kthread_stop().

kthread_park() and kthread_unpark() do not need get_task_struct(), the
callers already have the reference.  And it can not help if we can race
with the exiting kthread anyway, kthread_park() can hang forever in this
case.

Change kthread_park() and kthread_unpark() to use to_live_kthread(),
change kthread_stop() to do get_task_struct() by hand and remove
task_get_live_kthread().

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rusty Russell <rusty@rustcorp.com.au>
Cc: "Srivatsa S. Bhat" <srivatsa.bhat@linux.vnet.ibm.com>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
kthread: Fix the race condition when kthread is parked

While stressing the CPU hotplug path, sometimes we hit a problem
as shown below.

[57056.416774] ------------[ cut here ]------------
[57056.489232] ksoftirqd/1 (14): undefined instruction: pc=c01931e8
[57056.489245] Code: e594a000 eb085236 e15a0000 0a000000 (e7f001f2)
[57056.489259] ------------[ cut here ]------------
[57056.492840] kernel BUG at kernel/kernel/smpboot.c:134!
[57056.513236] Internal error: Oops - BUG: 0 [#1] PREEMPT SMP ARM
[57056.519055] Modules linked in: wlan(O) mhi(O)
[57056.523394] CPU: 0 PID: 14 Comm: ksoftirqd/1 Tainted: G        W  O 3.10.0-g3677c61-00008-g180c060 #1
[57056.532595] task: f0c8b000 ti: f0e78000 task.ti: f0e78000
[57056.537991] PC is at smpboot_thread_fn+0x124/0x218
[57056.542750] LR is at smpboot_thread_fn+0x11c/0x218
[57056.547528] pc : [<c01931e8>]    lr : [<c01931e0>]    psr: 200f0013
[57056.547528] sp : f0e79f30  ip : 00000000  fp : 00000000
[57056.558983] r10: 00000001  r9 : 00000000  r8 : f0e78000
[57056.564192] r7 : 00000001  r6 : c1195758  r5 : f0e78000  r4 : f0e5fd00
[57056.570701] r3 : 00000001  r2 : f0e79f20  r1 : 00000000  r0 : 00000000

This issue was always seen in the context of "ksoftirqd". It seems to
be happening because of a potential race condition in __kthread_parkme
where just after completing the parked completion, before the
ksoftirqd task has been scheduled again, it can go into running state.

Fix this by waiting for the task state to parked after waiting the
parked completion.

CRs-Fixed: 659674
Change-Id: If3f0e9b706eeb5d30d5a32f84378d35bb03fe794
Signed-off-by: Subbaraman Narayanamurthy <subbaram@codeaurora.org>
spi_qsd: Correction in DMA mode check

Due to a bug in the if() condition msm_spi_use_dma
function is always returning '0' when cs_change
is true. Due to this issue the DMA mode is not being used
when it has to be.

CRs-Fixed: 475841
Change-Id: I7da2ee091635f0cfd89058787c35b62adf1984b5
Signed-off-by: Kiran Gunda <kgunda@codeaurora.org>
spi_qsd: Config GPIOs by name rather then by index

Currently GPIOs are identified (MISO/MOSI/CLK or CS0..3)
by their index in the device-tree entry's array.
Further, chipselect GPIOs must be declared in order.
This allows to set a value for GPIO number three only
if the values for GPIOs one and two are also set.
This patch allows the driver to identify GPIOs by a
unique name, thus allows to specify any arbitrary
chipselect GPIO and reduces chances of simple
user configuration error.

Change-Id: I7cf1fb4329155bd5fc635257fc58d1dfa7312462
Signed-off-by: Gilad Avidov <gavidov@codeaurora.org>