ASoC: audio: Fix MEM_UNMAP called before CLOSE ack
-When the commands for ASM_STREAM_CMD_SET_PP_PARAMS
and ASM_STREAM_CMD_CLOSE are sent back to back, Ack
for first command is misinterpreted as CMD_CLOSE ack
and proceeds to send memory unmap command resulting
in LPASS fatal.
-Maintain separate variable to wait on for CMD_CLOSE
that will avoid dependency to other commands getting
Ack early.
CRs-Fixed: 434279
Change-Id: I7b6b7f1b8154437b21c5ea14be2e774e4b96e2d1
Signed-off-by: Laxminath Kasam <lkasam@codeaurora.org>
diff --git a/include/sound/q6asm.h b/include/sound/q6asm.h
index 31bfa24..5099500 100644
--- a/include/sound/q6asm.h
+++ b/include/sound/q6asm.h
@@ -150,6 +150,7 @@
struct mutex cmd_lock;
atomic_t cmd_state;
+ atomic_t cmd_close_state;
atomic_t time_flag;
atomic_t nowait_cmd_cnt;
wait_queue_head_t cmd_wait;
diff --git a/sound/soc/msm/qdsp6/q6asm.c b/sound/soc/msm/qdsp6/q6asm.c
index 7ca7f75..01f4852 100644
--- a/sound/soc/msm/qdsp6/q6asm.c
+++ b/sound/soc/msm/qdsp6/q6asm.c
@@ -893,7 +893,11 @@
case ASM_STREAM_CMD_SET_ENCDEC_PARAM:
case ASM_STREAM_CMD_OPEN_WRITE_COMPRESSED:
case ASM_STREAM_CMD_OPEN_READ_COMPRESSED:
- if (atomic_read(&ac->cmd_state) && wakeup_flag) {
+ if (payload[0] == ASM_STREAM_CMD_CLOSE) {
+ atomic_set(&ac->cmd_close_state, 0);
+ wake_up(&ac->cmd_wait);
+ } else if (atomic_read(&ac->cmd_state) &&
+ wakeup_flag) {
atomic_set(&ac->cmd_state, 0);
if (payload[1] == ADSP_EUNSUPPORTED) {
pr_debug("paload[1]:%d unsupported",
@@ -3756,7 +3760,8 @@
case CMD_CLOSE:
pr_debug("%s:CMD_CLOSE\n", __func__);
hdr.opcode = ASM_STREAM_CMD_CLOSE;
- state = &ac->cmd_state;
+ atomic_set(&ac->cmd_close_state, 1);
+ state = &ac->cmd_close_state;
break;
default:
pr_err("Invalid format[%d]\n", cmd);