diff options
author | Eva Huang <evahuang@google.com> | 2021-06-03 20:07:24 +0800 |
---|---|---|
committer | Eva Huang <evahuang@google.com> | 2021-06-03 20:07:24 +0800 |
commit | 25a1593c0a95baa29d83b93a7aa05f550a1b7c59 (patch) | |
tree | 1c6f08131b7d9775356f59d404f355e114c11e50 | |
parent | ab11b12d131f189bbf0c737988149d8699eeb0bd (diff) | |
parent | 577ec72fa4759d8fe91df2e9cb80695fef87fae5 (diff) | |
download | msm-extra-25a1593c0a95baa29d83b93a7aa05f550a1b7c59.tar.gz |
Merge branch 'android-msm-floral-4.14-rvc-security' into android-msm-floral-4.14-rvc-qpr3android-11.0.0_r0.98android-11.0.0_r0.113android-11.0.0_r0.103android-msm-coral-4.14-android11-qpr3
Aug 2021.1
Bug: 189715283
Change-Id: I302154f874234711d754671c580c24d1f5e6f6bc
-rw-r--r-- | 4.0/dsp/audio_cal_utils.c | 28 | ||||
-rw-r--r-- | 4.0/dsp/audio_calibration.c | 3 | ||||
-rw-r--r-- | 4.0/include/dsp/audio_cal_utils.h | 4 | ||||
-rw-r--r-- | dsp/audio_cal_utils.c | 26 | ||||
-rw-r--r-- | dsp/audio_calibration.c | 1 | ||||
-rw-r--r-- | dsp/q6afe.c | 2 | ||||
-rw-r--r-- | include/dsp/audio_cal_utils.h | 4 |
7 files changed, 56 insertions, 12 deletions
diff --git a/4.0/dsp/audio_cal_utils.c b/4.0/dsp/audio_cal_utils.c index 7e243e88..18b927dd 100644 --- a/4.0/dsp/audio_cal_utils.c +++ b/4.0/dsp/audio_cal_utils.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved. */ #include <linux/slab.h> #include <linux/fs.h> @@ -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); @@ -938,7 +940,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: @@ -1053,6 +1057,12 @@ 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 * @@ -1062,9 +1072,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/4.0/dsp/audio_calibration.c b/4.0/dsp/audio_calibration.c index a5167be3..2f7ba6df 100644 --- a/4.0/dsp/audio_calibration.c +++ b/4.0/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/4.0/include/dsp/audio_cal_utils.h b/4.0/include/dsp/audio_cal_utils.h index 06078150..99f619f2 100644 --- a/4.0/include/dsp/audio_cal_utils.h +++ b/4.0/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 diff --git a/dsp/audio_cal_utils.c b/dsp/audio_cal_utils.c index d8c4ea16..4339d01f 100644 --- a/dsp/audio_cal_utils.c +++ b/dsp/audio_cal_utils.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2014-2019, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014-2020, 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 @@ -18,6 +18,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); @@ -946,7 +948,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: @@ -1061,6 +1065,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 * @@ -1070,9 +1079,18 @@ 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 c895fa78..785c00a0 100644 --- a/dsp/audio_calibration.c +++ b/dsp/audio_calibration.c @@ -599,6 +599,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 1cb6d8a3..fa3b56c2 100644 --- a/dsp/q6afe.c +++ b/dsp/q6afe.c @@ -2415,7 +2415,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 614ef236..eb5c338c 100644 --- a/include/dsp/audio_cal_utils.h +++ b/include/dsp/audio_cal_utils.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2014, 2018, The Linux Foundation. All rights reserved. +/* Copyright (c) 2014, 2018, 2020, 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 @@ -103,4 +103,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 |