From 81a54a220ee9bd6bae4360eef5f63d10071b1ec6 Mon Sep 17 00:00:00 2001 From: Aditya Bavanari Date: Fri, 20 Sep 2019 00:23:59 +0530 Subject: [PATCH] dsp: Reset core hw vote client handle in SSR Reset core hw vote client handle in SSR use cases and do not unvote when the client handle is 0. This is to clean up the client ids in SSR in order to avoid unusual client deregistrations. Change-Id: Id0cee50f7ca27e29db6134b7a70ae75334e0d765 Signed-off-by: Aditya Bavanari --- dsp/q6afe.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 8120536b91..c30415a6b2 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -596,6 +596,11 @@ static int32_t afe_callback(struct apr_client_data *data, void *priv) rtac_set_afe_handle(this_afe.apr); } + /* Reset the core client handle in SSR/PDR use cases */ + mutex_lock(&this_afe.afe_cmd_lock); + this_afe.lpass_hw_core_client_hdl = 0; + mutex_unlock(&this_afe.afe_cmd_lock); + /* * Pass reset events to proxy driver, if cb is registered */ @@ -9058,6 +9063,7 @@ int __init afe_init(void) this_afe.mmap_handle = 0; this_afe.vi_tx_port = -1; this_afe.vi_rx_port = -1; + this_afe.lpass_hw_core_client_hdl = 0; this_afe.prot_cfg.mode = MSM_SPKR_PROT_DISABLED; this_afe.th_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED; this_afe.ex_ftm_cfg.mode = MSM_SPKR_PROT_DISABLED; @@ -9262,6 +9268,11 @@ int afe_unvote_lpass_core_hw(uint32_t hw_block_id, uint32_t client_handle) mutex_lock(&this_afe.afe_cmd_lock); + if (!this_afe.lpass_hw_core_client_hdl) { + pr_debug("%s: SSR in progress, return\n", __func__); + goto done; + } + memset(cmd_ptr, 0, sizeof(hw_vote_cfg)); cmd_ptr->hdr.hdr_field = APR_HDR_FIELD(APR_MSG_TYPE_SEQ_CMD, @@ -9278,6 +9289,12 @@ int afe_unvote_lpass_core_hw(uint32_t hw_block_id, uint32_t client_handle) pr_debug("%s: lpass core hw unvote opcode[0x%x] hw id[0x%x]\n", __func__, cmd_ptr->hdr.opcode, cmd_ptr->hw_block_id); + if (cmd_ptr->client_handle <= 0) { + pr_err("%s: invalid client handle\n", __func__); + ret = -EINVAL; + goto done; + } + atomic_set(&this_afe.status, 0); atomic_set(&this_afe.state, 1); ret = apr_send_pkt(this_afe.apr, (uint32_t *) cmd_ptr);