浏览代码

dsp: prm: move g_prm.state and g_prm.status into mutex_lock protection

When two clients call prm_gpr_send_pkr concurrently, g_prm.status will be
set to 0 for both clients. When client_A returns some error, g_prm.status
will be some error value and not cleared for Client_B. When audio_prm_callback
returns correct value for Client_B, g_prm.status is some error value which causes
prm_gpr_send_pkt fails for Client_B by mistake.
Move g_prm.status and g_prm.state into mutex_lock to resolve this issue.

Change-Id: Ie028533e6590bfd59b2fa08a496bbffc8793e5f6
Signed-off-by: Meng Wang <[email protected]>
Meng Wang 3 年之前
父节点
当前提交
ac06fe7d10
共有 1 个文件被更改,包括 3 次插入3 次删除
  1. 3 3
      dsp/audio_prm.c

+ 3 - 3
dsp/audio_prm.c

@@ -86,13 +86,13 @@ static int prm_gpr_send_pkt(struct gpr_pkt *pkt, wait_queue_head_t *wait)
 	int ret = 0;
 	int retry;
 
+	mutex_lock(&g_prm.lock);
+	pr_debug("%s: enter",__func__);
+
 	if (wait)
 		atomic_set(&g_prm.state, 1);
 	atomic_set(&g_prm.status, 0);
 
-	mutex_lock(&g_prm.lock);
-	pr_debug("%s: enter",__func__);
-
 	if (g_prm.adev == NULL) {
 		pr_err("%s: apr is unregistered\n", __func__);
 		mutex_unlock(&g_prm.lock);