diff options
author | achigoliu <achigoliu@google.com> | 2021-06-07 18:18:56 +0800 |
---|---|---|
committer | achigoliu <achigoliu@google.com> | 2021-06-07 18:18:56 +0800 |
commit | 6e841e5c34fcb24ddf60c5a133d93256c67fea97 (patch) | |
tree | e5be33c05e0f688bc87e488967d7e663cd7d20af | |
parent | a83073669dd609c6c2c8eb82f8c0e48bb6a18517 (diff) | |
parent | 5a0d5926442d5323d495b003432cb9553c64b54e (diff) | |
download | msm-extra-6e841e5c34fcb24ddf60c5a133d93256c67fea97.tar.gz |
Merge remote-tracking branch 'android-msm-barbet-4.19-rvc-security' into android-msm-barbet-4.19-rvcandroid-11.0.0_r0.116android-11.0.0_r0.106android-msm-barbet-4.19-android11-d2
Aug 2021.1
Bug: 189715888
Bug: 189715042
Change-Id: I3798f624b84783365dddcbeb89dc9cdafc267736
-rw-r--r-- | dsp/audio_cal_utils.c | 25 | ||||
-rw-r--r-- | dsp/audio_calibration.c | 3 | ||||
-rw-r--r-- | dsp/q6afe.c | 2 | ||||
-rw-r--r-- | include/dsp/audio_cal_utils.h | 4 |
4 files changed, 28 insertions, 6 deletions
diff --git a/dsp/audio_cal_utils.c b/dsp/audio_cal_utils.c index fab5186a..919a4b1b 100644 --- a/dsp/audio_cal_utils.c +++ b/dsp/audio_cal_utils.c @@ -10,6 +10,8 @@ #include <linux/mutex.h> #include <dsp/audio_cal_utils.h> +struct mutex cal_lock; + static int unmap_memory(struct cal_type_data *cal_type, struct cal_block_data *cal_block); @@ -940,7 +942,9 @@ int cal_utils_dealloc_cal(size_t data_size, void *data, if (ret < 0) goto err; + mutex_lock(&cal_lock); delete_cal_block(cal_block); + mutex_unlock(&cal_lock); err: mutex_unlock(&cal_type->lock); done: @@ -1055,6 +1059,11 @@ void cal_utils_mark_cal_used(struct cal_block_data *cal_block) } EXPORT_SYMBOL(cal_utils_mark_cal_used); +int __init cal_utils_init(void) +{ + mutex_init(&cal_lock); + return 0; +} /** * cal_utils_is_cal_stale * @@ -1064,9 +1073,19 @@ EXPORT_SYMBOL(cal_utils_mark_cal_used); */ bool cal_utils_is_cal_stale(struct cal_block_data *cal_block) { - if ((cal_block) && (cal_block->cal_stale)) - return true; + bool ret = false; - return false; + mutex_lock(&cal_lock); + if (!cal_block) { + pr_err("%s: cal_block is Null", __func__); + goto unlock; + } + + if (cal_block->cal_stale) + ret = true; + +unlock: + mutex_unlock(&cal_lock); + return ret; } EXPORT_SYMBOL(cal_utils_is_cal_stale); diff --git a/dsp/audio_calibration.c b/dsp/audio_calibration.c index a5167be3..854d8821 100644 --- a/dsp/audio_calibration.c +++ b/dsp/audio_calibration.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2014, 2016-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2016-2017, 2020, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> #include <linux/fs.h> @@ -591,6 +591,7 @@ int __init audio_cal_init(void) pr_debug("%s\n", __func__); + cal_utils_init(); memset(&audio_cal, 0, sizeof(audio_cal)); mutex_init(&audio_cal.common_lock); for (; i < MAX_CAL_TYPES; i++) { diff --git a/dsp/q6afe.c b/dsp/q6afe.c index 1665abb4..cb71482e 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -2776,7 +2776,7 @@ static int send_afe_cal_type(int cal_index, int port_id) this_afe.cal_data[cal_index]); if (cal_block == NULL || cal_utils_is_cal_stale(cal_block)) { - pr_err("%s cal_block not found!!\n", __func__); + pr_err_ratelimited("%s cal_block not found!!\n", __func__); ret = -EINVAL; goto unlock; } diff --git a/include/dsp/audio_cal_utils.h b/include/dsp/audio_cal_utils.h index 06078150..99f619f2 100644 --- a/include/dsp/audio_cal_utils.h +++ b/include/dsp/audio_cal_utils.h @@ -1,6 +1,6 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* - * Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved. + * Copyright (c) 2014, 2018, 2020, The Linux Foundation. All rights reserved. */ #ifndef _AUDIO_CAL_UTILS_H #define _AUDIO_CAL_UTILS_H @@ -95,4 +95,6 @@ int32_t cal_utils_get_cal_type_version(void *cal_type_data); void cal_utils_mark_cal_used(struct cal_block_data *cal_block); bool cal_utils_is_cal_stale(struct cal_block_data *cal_block); + +int cal_utils_init(void); #endif |