Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bbdbc138 authored by Vamsi krishna Gattupalli's avatar Vamsi krishna Gattupalli Committed by vgattupa
Browse files

msm: ADSPRPC: Fix deadlock during SSR



Deadlock is happening because map_mutex and smd_mutex lock is
acquired before fastrpc_mmap_remove_ssr() call and inside again
in get_args() and fastrpc_invoke_send() respectively. Added
lock only to critical sections in need.

Change-Id: I900e44790ec0285b7b156542bf599092479dc864
Signed-off-by: default avatarVamsi krishna Gattupalli <vgattupa@codeaurora.org>
parent 9cdeb30a
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -3191,13 +3191,18 @@ static int fastrpc_mmap_remove_ssr(struct fastrpc_file *fl)
					kfree(ramdump_segments_rh);
				}
			}
			mutex_lock(&fl->map_mutex);
			fastrpc_mmap_free(match, 0);
			mutex_unlock(&fl->map_mutex);
		}
	} while (match);
	me->enable_ramdump = false;
bail:
	if (err && match)
	if (err && match) {
		mutex_lock(&fl->map_mutex);
		fastrpc_mmap_add(match);
		mutex_unlock(&fl->map_mutex);
	}
	return err;
}

@@ -4006,13 +4011,13 @@ static int fastrpc_channel_open(struct fastrpc_file *fl)

	if (cid == ADSP_DOMAIN_ID && me->channel[cid].ssrcount !=
			 me->channel[cid].prevssrcount) {
		mutex_lock(&fl->map_mutex);
		mutex_unlock(&me->channel[cid].smd_mutex);
		err = fastrpc_mmap_remove_ssr(fl);
		if (err)
			pr_warn("adsprpc: %s: %s: failed to unmap remote heap for %s (err %d)\n",
					__func__, current->comm,
					me->channel[cid].subsys, err);
		mutex_unlock(&fl->map_mutex);
		mutex_lock(&me->channel[cid].smd_mutex);
		me->channel[cid].prevssrcount =
					me->channel[cid].ssrcount;
	}