From 8f0c7ae73c205b9a1cfc685cbee9cb4ba437a554 Mon Sep 17 00:00:00 2001 From: Ramprasad Katkam Date: Wed, 17 May 2017 13:21:57 +0530 Subject: [PATCH] ASoC: APR: Fix missing APR deregister from asm APR deregister is to be called for two ports from both q6asm_callback(during RESET) and q6asm_audio_client_free. In race condition between the two, APR deregister is called only for one port. The mismatch in apr register-deregister count causes apr not to reset service after ssr, causing APR communication failure. Change-Id: Ibd0528215bf2fb986eda03ae0d683b2af31358fe Signed-off-by: Ramprasad Katkam --- drivers/soc/qcom/qdsp6v2/apr.c | 3 ++- sound/soc/msm/qdsp6v2/q6asm.c | 14 ++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/soc/qcom/qdsp6v2/apr.c b/drivers/soc/qcom/qdsp6v2/apr.c index a275537d4e08..2da8731c5753 100644 --- a/drivers/soc/qcom/qdsp6v2/apr.c +++ b/drivers/soc/qcom/qdsp6v2/apr.c @@ -745,13 +745,14 @@ int apr_deregister(void *handle) if (!handle) return -EINVAL; + mutex_lock(&svc->m_lock); if (!svc->svc_cnt) { pr_err("%s: svc already deregistered. svc = %pK\n", __func__, svc); + mutex_unlock(&svc->m_lock); return -EINVAL; } - mutex_lock(&svc->m_lock); dest_id = svc->dest_id; client_id = svc->client_id; clnt = &client[dest_id][client_id]; diff --git a/sound/soc/msm/qdsp6v2/q6asm.c b/sound/soc/msm/qdsp6v2/q6asm.c index 0cf386a3c2fc..b11b7fe91ec2 100644 --- a/sound/soc/msm/qdsp6v2/q6asm.c +++ b/sound/soc/msm/qdsp6v2/q6asm.c @@ -1031,14 +1031,12 @@ void q6asm_audio_client_free(struct audio_client *ac) } rtac_set_asm_handle(ac->session, NULL); - if (!atomic_read(&ac->reset)) { - apr_deregister(ac->apr2); - apr_deregister(ac->apr); - q6asm_mmap_apr_dereg(); - ac->apr2 = NULL; - ac->apr = NULL; - ac->mmap_apr = NULL; - } + apr_deregister(ac->apr2); + apr_deregister(ac->apr); + q6asm_mmap_apr_dereg(); + ac->apr2 = NULL; + ac->apr = NULL; + ac->mmap_apr = NULL; q6asm_session_free(ac); pr_debug("%s: APR De-Register\n", __func__);