From 0d30652d51d7b78aca02696a0a88f17ac59953d2 Mon Sep 17 00:00:00 2001 From: Vatsal Bucha Date: Mon, 22 Mar 2021 16:11:08 +0530 Subject: [PATCH] dsp: codecs: Add flag to check if wait event initialized before access Add flag to check if wait event initialized before access. Change-Id: Ib4b4654dfe1b0a18506ae6fb8029296a5f780fe9 Signed-off-by: Vatsal Bucha --- dsp/codecs/audio_utils_aio.c | 4 +++- dsp/codecs/audio_utils_aio.h | 3 ++- dsp/codecs/q6audio_v2_aio.c | 5 +++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dsp/codecs/audio_utils_aio.c b/dsp/codecs/audio_utils_aio.c index 94be57db32bd..a1393e43a0da 100644 --- a/dsp/codecs/audio_utils_aio.c +++ b/dsp/codecs/audio_utils_aio.c @@ -1,7 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2009-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -1340,6 +1340,7 @@ int audio_aio_open(struct q6audio_aio *audio, struct file *file) audio->pcm_cfg.sample_rate = 48000; audio->pcm_cfg.channel_count = 2; + audio->wake_event_initialized = false; /* Only AIO interface */ if (file->f_flags & O_NONBLOCK) { pr_debug("%s[%pK]:set to aio interface\n", __func__, audio); @@ -1373,6 +1374,7 @@ int audio_aio_open(struct q6audio_aio *audio, struct file *file) audio->drv_ops.out_flush(audio); audio->opened = 1; audio->reset_event = false; + audio->wake_event_initialized = true; file->private_data = audio; audio->codec_ioctl = audio_aio_ioctl; audio->codec_compat_ioctl = audio_aio_compat_ioctl; diff --git a/dsp/codecs/audio_utils_aio.h b/dsp/codecs/audio_utils_aio.h index c7365a17169a..60785b61fe31 100644 --- a/dsp/codecs/audio_utils_aio.h +++ b/dsp/codecs/audio_utils_aio.h @@ -1,7 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2009-2018, 2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2009-2018, 2020-2021 The Linux Foundation. All rights reserved. */ #include @@ -188,6 +188,7 @@ struct q6audio_aio { int rflush; /* Read flush */ int wflush; /* Write flush */ bool reset_event; + bool wake_event_initialized; long (*codec_ioctl)(struct file *, unsigned int, unsigned long); long (*codec_compat_ioctl)(struct file *, unsigned int, unsigned long); }; diff --git a/dsp/codecs/q6audio_v2_aio.c b/dsp/codecs/q6audio_v2_aio.c index 642987f5d6ad..5876abb7ac90 100644 --- a/dsp/codecs/q6audio_v2_aio.c +++ b/dsp/codecs/q6audio_v2_aio.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved. */ #include @@ -110,7 +110,8 @@ void audio_aio_cb(uint32_t opcode, uint32_t token, pr_err("%s: Received opcode:0x%x\n", __func__, opcode); audio->stopped = 1; audio->reset_event = true; - wake_up(&audio->event_wait); + if (audio->wake_event_initialized) + wake_up(&audio->event_wait); break; default: break;