mirror of
https://github.com/team-infusion-developers/android_kernel_samsung_msm8976.git
synced 2024-11-01 02:21:16 +00:00
ASoC: wcd_cpe_core: Add mutex lock for CPE session
Add mutex lock to ensure atomic access to core handle in CPE alloc and dealloc sessions. CRs-Fixed: 2169403 Bug: 62536960 Signed-off-by: Vaishnavi Kommaraju <vkommara@codeaurora.org> Change-Id: Ic0bb7e1646cbeafe507680c39bb8de56086df47a
This commit is contained in:
parent
fb3ab18a56
commit
4d261ae9ac
3 changed files with 19 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -1943,6 +1943,7 @@ struct wcd_cpe_core *wcd_cpe_init(const char *img_fname,
|
|||
init_completion(&core->online_compl);
|
||||
init_waitqueue_head(&core->ssr_entry.offline_poll_wait);
|
||||
mutex_init(&core->ssr_lock);
|
||||
mutex_init(&core->session_lock);
|
||||
core->cpe_users = 0;
|
||||
core->cpe_clk_ref = 0;
|
||||
|
||||
|
@ -3432,6 +3433,7 @@ static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session(
|
|||
* If this is the first session to be allocated,
|
||||
* only then register the afe service.
|
||||
*/
|
||||
WCD_CPE_GRAB_LOCK(&core->session_lock, "session_lock");
|
||||
if (!wcd_cpe_lsm_session_active())
|
||||
afe_register_service = true;
|
||||
|
||||
|
@ -3443,6 +3445,7 @@ static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session(
|
|||
dev_err(core->dev,
|
||||
"%s: max allowed sessions already allocated\n",
|
||||
__func__);
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -3451,6 +3454,7 @@ static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session(
|
|||
dev_err(core->dev,
|
||||
"%s: Failed to enable cpe, err = %d\n",
|
||||
__func__, ret);
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -3497,6 +3501,8 @@ static struct cpe_lsm_session *wcd_cpe_alloc_lsm_session(
|
|||
init_completion(&session->cmd_comp);
|
||||
|
||||
lsm_sessions[session_id] = session;
|
||||
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return session;
|
||||
|
||||
err_afe_mode_cmd:
|
||||
|
@ -3511,6 +3517,7 @@ err_ret:
|
|||
|
||||
err_session_alloc:
|
||||
wcd_cpe_vote(core, false);
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -3660,9 +3667,11 @@ static int wcd_cpe_dealloc_lsm_session(void *core_handle,
|
|||
struct wcd_cpe_core *core = core_handle;
|
||||
int ret = 0;
|
||||
|
||||
WCD_CPE_GRAB_LOCK(&core->session_lock, "session_lock");
|
||||
if (!session) {
|
||||
dev_err(core->dev,
|
||||
"%s: Invalid lsm session\n", __func__);
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3673,6 +3682,7 @@ static int wcd_cpe_dealloc_lsm_session(void *core_handle,
|
|||
"%s: Wrong session id %d max allowed = %d\n",
|
||||
__func__, session->id,
|
||||
WCD_CPE_LSM_MAX_SESSIONS);
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
|
@ -3693,6 +3703,7 @@ static int wcd_cpe_dealloc_lsm_session(void *core_handle,
|
|||
"%s: Failed to un-vote cpe, err = %d\n",
|
||||
__func__, ret);
|
||||
|
||||
WCD_CPE_REL_LOCK(&core->session_lock, "session_lock");
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2013-2015, 2018, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -169,6 +169,9 @@ struct wcd_cpe_core {
|
|||
/* mutex to protect cpe ssr status variables */
|
||||
struct mutex ssr_lock;
|
||||
|
||||
/* mutex to protect cpe session status variables */
|
||||
struct mutex session_lock;
|
||||
|
||||
/* Store the calibration data needed for cpe */
|
||||
struct cal_type_data *cal_data[WCD_CPE_LSM_CAL_MAX];
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
|
||||
/* Copyright (c) 2014-2016, 2018, The Linux Foundation. All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 and
|
||||
|
@ -608,8 +608,10 @@ static enum cpe_svc_result cpe_deregister_generic(struct cpe_info *t_info,
|
|||
return CPE_SVC_INVALID_HANDLE;
|
||||
}
|
||||
|
||||
CPE_SVC_GRAB_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
|
||||
list_del(&(n->list));
|
||||
kfree(reg_handle);
|
||||
CPE_SVC_REL_LOCK(&cpe_d.cpe_svc_lock, "cpe_svc");
|
||||
|
||||
return CPE_SVC_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue