dsp: Add cmd locks to fix synchronization issues

Add mutex locks in q6core_send_get_avcs_fwk_ver_cmd()
and q6core_map_mdf_shared_memory() functions to fix
command-response synchronization issues in race conditions.

Change-Id: Ibdf6788b51965bd37245c611683102c600ca8eb4
Signed-off-by: Harshal Ahire <hahire@codeaurora.org>
This commit is contained in:
Harshal Ahire
2019-11-20 21:17:26 +05:30
committed by Faiz Nabi Kuchay
parent 1e4e99502b
commit 6b5e14d72d

View File

@@ -502,6 +502,7 @@ static int q6core_send_get_avcs_fwk_ver_cmd(void)
struct apr_hdr avcs_ver_cmd;
int ret;
mutex_lock(&q6core_lcl.cmd_lock);
avcs_ver_cmd.hdr_field =
APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, APR_HDR_LEN(APR_HDR_SIZE),
APR_PKT_VER);
@@ -548,6 +549,7 @@ static int q6core_send_get_avcs_fwk_ver_cmd(void)
ret = 0;
done:
mutex_unlock(&q6core_lcl.cmd_lock);
return ret;
}
@@ -1428,14 +1430,16 @@ int q6core_map_mdf_shared_memory(uint32_t map_handle, uint64_t *buf_add,
int i = 0;
int cmd_size = 0;
mutex_lock(&q6core_lcl.cmd_lock);
cmd_size = sizeof(struct avs_cmd_map_mdf_shared_memory)
+ sizeof(struct avs_shared_map_region_payload)
* bufcnt;
mmap_region_cmd = kzalloc(cmd_size, GFP_KERNEL);
if (mmap_region_cmd == NULL)
if (mmap_region_cmd == NULL) {
mutex_unlock(&q6core_lcl.cmd_lock);
return -ENOMEM;
}
mmap_regions = (struct avs_cmd_map_mdf_shared_memory *)mmap_region_cmd;
mmap_regions->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD,
APR_HDR_LEN(APR_HDR_SIZE),
@@ -1502,6 +1506,7 @@ int q6core_map_mdf_shared_memory(uint32_t map_handle, uint64_t *buf_add,
done:
kfree(mmap_region_cmd);
mutex_unlock(&q6core_lcl.cmd_lock);
return ret;
}