From a60909ecb4f11c44a5233d89bd8170d475393c9d Mon Sep 17 00:00:00 2001 From: Ravulapati Vishnu Vardhan Rao Date: Tue, 23 Jan 2024 16:35:55 +0530 Subject: [PATCH] audio_ssr: Mutex dead lock notifier_mutex is global mutex and there might be a thread which will acquire notifier_mutex which causes other thread to be in wait causing deadlock. Using static initialized mutex rectifies issue. Change-Id: Id8ba30f22419e1a8a7a7356f984db2559197a075 Signed-off-by: Ravulapati Vishnu Vardhan Rao --- dsp/audio_notifier.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/dsp/audio_notifier.c b/dsp/audio_notifier.c index a2299a61da..b2433e8544 100644 --- a/dsp/audio_notifier.c +++ b/dsp/audio_notifier.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2017, 2020-2021 The Linux Foundation. All rights reserved. - * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved. + * Copyright (c) 2022-2024 Qualcomm Innovation Center, Inc. All rights reserved. */ #include @@ -246,8 +246,10 @@ static int audio_notifier_dereg_service(int service, int domain) __func__, service_data[service][domain].name, service_data[service][domain].handle); + mutex_lock(¬ifier_mutex); service_data[service][domain].state = AUDIO_NOTIFIER_SERVICE_DOWN; service_data[service][domain].handle = NULL; + mutex_unlock(¬ifier_mutex); done: return ret; } @@ -459,16 +461,16 @@ static int audio_notifier_service_cb(unsigned long opcode, __func__, service_data[service][domain].name, notifier_opcode); mutex_lock(¬ifier_mutex); - service_data[service][domain].state = notifier_opcode; + ret = srcu_notifier_call_chain(&service_data[service][domain]. client_nb_list, notifier_opcode, &data); + mutex_unlock(¬ifier_mutex); if (ret < 0) pr_err_ratelimited("%s: srcu_notifier_call_chain returned %d, service %s, \ opcode 0x%lx\n", __func__, ret, service_data[service][domain].name, notifier_opcode); - mutex_unlock(¬ifier_mutex); return NOTIFY_OK; } @@ -506,7 +508,6 @@ int audio_notifier_deregister(char *client_name) ret = -EINVAL; goto done; } - mutex_lock(¬ifier_mutex); list_for_each_safe(ptr, next, &client_list) { client_data = list_entry(ptr, struct client_data, list); if (!strcmp(client_name, client_data->client_name)) { @@ -523,7 +524,6 @@ int audio_notifier_deregister(char *client_name) kfree(client_data); } } - mutex_unlock(¬ifier_mutex); done: return ret; }