msm: smd: call smem_find() after releasing spinlocks

If a subsystem crashes with a remote spinlock locked, then the subsystem
restart code should release it before attempting to access SMEM.
Originally when this code was written, smem_find() did not lock a remote
spinlock in violation of the SMEM protocol.  Once smem_find() was
updated to lock the remote spinlock, this deadlock scnario was created.

Do not call smem_find() until the remote spinlocks have been released
for the failed subsystem.

CRs-Fixed: 397287

Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit 50ad86febb34255ed47b7dd9840aaa6f1b257b3c)

Change-Id: Ied732e4bccdf2016ef627be28f12daf20cdff7b9
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
diff --git a/arch/arm/mach-msm/smd.c b/arch/arm/mach-msm/smd.c
index ef0f62a..80d0a4e 100644
--- a/arch/arm/mach-msm/smd.c
+++ b/arch/arm/mach-msm/smd.c
@@ -961,16 +961,17 @@
 	unsigned long flags;
 
 	SMD_DBG("%s: starting reset\n", __func__);
+
+	/* release any held spinlocks */
+	remote_spin_release(&remote_spinlock, restart_pid);
+	remote_spin_release_all(restart_pid);
+
 	shared = smem_find(ID_CH_ALLOC_TBL, sizeof(*shared) * 64);
 	if (!shared) {
 		pr_err("%s: allocation table not initialized\n", __func__);
 		return;
 	}
 
-	/* release any held spinlocks */
-	remote_spin_release(&remote_spinlock, restart_pid);
-	remote_spin_release_all(restart_pid);
-
 	/* reset SMSM entry */
 	if (smsm_info.state) {
 		writel_relaxed(0, SMSM_STATE_ADDR(restart_pid));