From b29145e957cd9b58facd7724110123a63747bd17 Mon Sep 17 00:00:00 2001 From: Prasad Kumpatla Date: Mon, 4 May 2020 13:07:09 +0530 Subject: [PATCH] dsp: codecs: Add spin_lock_irqsave instead of spin_lock spin_lock is acquired in process context and trying do the operation in process context,while the interrupt came and the same lock is trying to take in interrupt context which leads to deadlock.To avoid this we are using spin_lock_irqsave instead of spin_lock. Change-Id: I9c4a3ac65d92b0612d7c4845212647c51a72065b Signed-off-by: Prasad Kumpatla --- dsp/codecs/audio_utils.c | 5 +++-- dsp/codecs/audio_utils_aio.c | 5 +++-- dsp/codecs/q6audio_v2.c | 5 +++-- dsp/codecs/q6audio_v2_aio.c | 5 +++-- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/dsp/codecs/audio_utils.c b/dsp/codecs/audio_utils.c index ac934132ac..33495b2f7d 100644 --- a/dsp/codecs/audio_utils.c +++ b/dsp/codecs/audio_utils.c @@ -936,6 +936,7 @@ ssize_t audio_in_write(struct file *file, int audio_in_release(struct inode *inode, struct file *file) { + unsigned long flags = 0; struct q6audio_in *audio = file->private_data; pr_info("%s: session id %d\n", __func__, audio->ac->session); @@ -943,11 +944,11 @@ int audio_in_release(struct inode *inode, struct file *file) audio_in_disable(audio); q6asm_audio_client_free(audio->ac); mutex_unlock(&audio->lock); - spin_lock(&enc_dec_lock); + spin_lock_irqsave(&enc_dec_lock, flags); kfree(audio->enc_cfg); kfree(audio->codec_cfg); kfree(audio); file->private_data = NULL; - spin_unlock(&enc_dec_lock); + spin_unlock_irqrestore(&enc_dec_lock, flags); return 0; } diff --git a/dsp/codecs/audio_utils_aio.c b/dsp/codecs/audio_utils_aio.c index 93095e3007..94be57db32 100644 --- a/dsp/codecs/audio_utils_aio.c +++ b/dsp/codecs/audio_utils_aio.c @@ -588,6 +588,7 @@ int enable_volume_ramp(struct q6audio_aio *audio) int audio_aio_release(struct inode *inode, struct file *file) { + unsigned long flags = 0; struct q6audio_aio *audio = file->private_data; pr_debug("%s[%pK]\n", __func__, audio); @@ -631,11 +632,11 @@ int audio_aio_release(struct inode *inode, struct file *file) #ifdef CONFIG_DEBUG_FS debugfs_remove(audio->dentry); #endif - spin_lock(&enc_dec_lock); + spin_lock_irqsave(&enc_dec_lock, flags); kfree(audio->codec_cfg); kfree(audio); file->private_data = NULL; - spin_unlock(&enc_dec_lock); + spin_unlock_irqrestore(&enc_dec_lock, flags); mutex_unlock(&lock); return 0; } diff --git a/dsp/codecs/q6audio_v2.c b/dsp/codecs/q6audio_v2.c index e25a5e786a..83e3813047 100644 --- a/dsp/codecs/q6audio_v2.c +++ b/dsp/codecs/q6audio_v2.c @@ -20,8 +20,9 @@ void q6asm_in_cb(uint32_t opcode, uint32_t token, { struct q6audio_in *audio = (struct q6audio_in *)priv; unsigned long flags; + unsigned long en_de_flags; - spin_lock(&enc_dec_lock); + spin_lock_irqsave(&enc_dec_lock, en_de_flags); if (audio == NULL) { pr_err("%s: failed to get q6audio value\n", __func__); goto error; @@ -65,7 +66,7 @@ void q6asm_in_cb(uint32_t opcode, uint32_t token, } spin_unlock_irqrestore(&audio->dsp_lock, flags); error: - spin_unlock(&enc_dec_lock); + spin_unlock_irqrestore(&enc_dec_lock, en_de_flags); } void audio_in_get_dsp_frames(void *priv, diff --git a/dsp/codecs/q6audio_v2_aio.c b/dsp/codecs/q6audio_v2_aio.c index fac9f9747a..642987f5d6 100644 --- a/dsp/codecs/q6audio_v2_aio.c +++ b/dsp/codecs/q6audio_v2_aio.c @@ -43,8 +43,9 @@ void audio_aio_cb(uint32_t opcode, uint32_t token, { struct q6audio_aio *audio = (struct q6audio_aio *)priv; union msm_audio_event_payload e_payload; + unsigned long flags = 0; - spin_lock(&enc_dec_lock); + spin_lock_irqsave(&enc_dec_lock, flags); if (audio == NULL) { pr_err("%s: failed to get q6audio value\n", __func__); goto error; @@ -115,7 +116,7 @@ void audio_aio_cb(uint32_t opcode, uint32_t token, break; } error: - spin_unlock(&enc_dec_lock); + spin_unlock_irqrestore(&enc_dec_lock, flags); } int extract_meta_out_info(struct q6audio_aio *audio,