Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0fcf2af3 authored by Vignesh Kulothungan's avatar Vignesh Kulothungan Committed by Meng Wang
Browse files

asoc: dsp: ipc: Reduce wait timeout to 1 second



Reduce the amount of time driver waits to get a response from ADSP.
Current wait time in some cases is 5 secconds, which might cause
user space crashes in Android P. So reducing the timeout to
1 second.

CRs-Fixed: 2318751
Change-Id: I6b6789aa5b408659dd57f8f6b017df52d14b28aa
Signed-off-by: default avatarVignesh Kulothungan <vigneshk@codeaurora.org>
parent 63f48155
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */


@@ -40,6 +40,7 @@

#define DRV_NAME "msm-compress-q6-v2"

#define TIMEOUT_MS			1000
#define DSP_PP_BUFFERING_IN_MSEC	25
#define PARTIAL_DRAIN_ACK_EARLY_BY_MSEC	150
#define MP3_OUTPUT_FRAME_SZ		1152
@@ -1829,7 +1830,8 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
	}
	if (atomic_read(&prtd->eos)) {
		ret = wait_event_timeout(prtd->eos_wait,
					 prtd->eos_ack, 5 * HZ);
					prtd->eos_ack,
					msecs_to_jiffies(TIMEOUT_MS));
		if (!ret)
			pr_err("%s: CMD_EOS failed\n", __func__);
	}
@@ -1837,7 +1839,8 @@ static int msm_compr_playback_free(struct snd_compr_stream *cstream)
		prtd->cmd_ack = 0;
		atomic_set(&prtd->wait_on_close, 1);
		ret = wait_event_timeout(prtd->close_wait,
					prtd->cmd_ack, 5 * HZ);
					prtd->cmd_ack,
					msecs_to_jiffies(TIMEOUT_MS));
		if (!ret)
			pr_err("%s: CMD_CLOSE failed\n", __func__);
	}
+4 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */


@@ -26,6 +26,7 @@

#define DRV_NAME "msm-pcm-afe-v2"

#define TIMEOUT_MS	1000
#define MIN_PLAYBACK_PERIOD_SIZE (128 * 2)
#define MAX_PLAYBACK_PERIOD_SIZE (128 * 2 * 2 * 6)
#define MIN_PLAYBACK_NUM_PERIODS (4)
@@ -571,7 +572,8 @@ static int msm_afe_capture_copy(struct snd_pcm_substream *substream,

		prtd->dsp_cnt++;
		ret = wait_event_timeout(prtd->read_wait,
				atomic_read(&prtd->rec_bytes_avail), 5 * HZ);
				atomic_read(&prtd->rec_bytes_avail),
				msecs_to_jiffies(TIMEOUT_MS));
		if (ret < 0) {
			pr_err("%s: wait_event_timeout failed\n", __func__);

+6 −3
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */


@@ -35,6 +35,7 @@
#include "msm-qti-pp-config.h"

#define DRV_NAME "msm-pcm-q6-v2"
#define TIMEOUT_MS	1000

enum stream_state {
	IDLE = 0,
@@ -805,7 +806,8 @@ static int msm_pcm_playback_copy(struct snd_pcm_substream *substream, int a,
		}

		ret = wait_event_timeout(the_locks.write_wait,
				(atomic_read(&prtd->out_count)), 5 * HZ);
				(atomic_read(&prtd->out_count)),
				msecs_to_jiffies(TIMEOUT_MS));
		if (!ret) {
			pr_err("%s: wait_event_timeout failed\n", __func__);
			ret = -ETIMEDOUT;
@@ -966,7 +968,8 @@ static int msm_pcm_capture_copy(struct snd_pcm_substream *substream,
		return -ENETRESET;
	}
	ret = wait_event_timeout(the_locks.read_wait,
			(atomic_read(&prtd->in_count)), 5 * HZ);
			(atomic_read(&prtd->in_count)),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!ret) {
		pr_debug("%s: wait_event_timeout failed\n", __func__);
		goto fail;
+3 −4
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */
#include <linux/module.h>
#include <linux/slab.h>
@@ -9,7 +9,6 @@
#include <linux/jiffies.h>
#include <linux/uaccess.h>
#include <linux/atomic.h>
#include <linux/wait.h>
#include <sound/asound.h>
#include <dsp/msm-dts-srs-tm-config.h>
#include <dsp/apr_audio-v2.h>
@@ -1852,7 +1851,7 @@ static int adm_memory_map_regions(phys_addr_t *buf_add, uint32_t mempool_id,

	ret = wait_event_timeout(this_adm.adm_wait,
				 atomic_read(&this_adm.adm_stat) >= 0,
				 5 * HZ);
				 msecs_to_jiffies(TIMEOUT_MS));
	if (!ret) {
		pr_err("%s: timeout. waited for memory_map\n", __func__);
		ret = -EINVAL;
@@ -1902,7 +1901,7 @@ static int adm_memory_unmap_regions(void)

	ret = wait_event_timeout(this_adm.adm_wait,
				 atomic_read(&this_adm.adm_stat) >= 0,
				 5 * HZ);
				 msecs_to_jiffies(TIMEOUT_MS));
	if (!ret) {
		pr_err("%s: timeout. waited for memory_unmap\n",
		       __func__);
+130 −66
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 */
#include <linux/fs.h>
#include <linux/mutex.h>
@@ -12,7 +12,6 @@
#include <linux/miscdevice.h>
#include <linux/delay.h>
#include <linux/slab.h>

#include <linux/debugfs.h>
#include <linux/time.h>
#include <linux/atomic.h>
@@ -33,6 +32,7 @@
#include <dsp/q6core.h>
#include "adsp_err.h"

#define TIMEOUT_MS  1000
#define TRUE        0x01
#define FALSE       0x00
#define SESSION_MAX 8
@@ -813,7 +813,8 @@ int send_asm_custom_topology(struct audio_client *ac)
	}

	result = wait_event_timeout(ac->mem_wait,
			(atomic_read(&ac->mem_state) >= 0), 5*HZ);
			(atomic_read(&ac->mem_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!result) {
		pr_err("%s: Set topologies failed timeout\n", __func__);
		pr_debug("%s: Set topologies failed after timedout payload = 0x%pK\n",
@@ -1251,7 +1252,8 @@ int q6asm_send_stream_cmd(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state_pp) >= 0), 1 * HZ);
				(atomic_read(&ac->cmd_state_pp) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout for stream event cmd resp\n", __func__);
		rc = -ETIMEDOUT;
@@ -2782,7 +2784,8 @@ int q6asm_set_pp_params(struct audio_client *ac,
	}

	ret = wait_event_timeout(ac->cmd_wait,
				 atomic_read(&ac->cmd_state_pp) >= 0, 5 * HZ);
				 atomic_read(&ac->cmd_state_pp) >= 0,
				 msecs_to_jiffies(TIMEOUT_MS));
	if (!ret) {
		pr_err("%s: timeout sending apr pkt\n", __func__);
		ret = -ETIMEDOUT;
@@ -2932,7 +2935,8 @@ int q6asm_open_read_compressed(struct audio_client *ac, uint32_t format,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 1*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for OPEN_READ_COMPR rc[%d]\n",
			__func__, rc);
@@ -3055,7 +3059,8 @@ static int __q6asm_open_read(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for open read\n",
				__func__);
@@ -3248,7 +3253,8 @@ int q6asm_open_write_compressed(struct audio_client *ac, uint32_t format,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
		(atomic_read(&ac->cmd_state) >= 0), 1*HZ);
		(atomic_read(&ac->cmd_state) >= 0),
		msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for OPEN_WRITE_COMPR rc[%d]\n",
			__func__, rc);
@@ -3407,7 +3413,8 @@ static int __q6asm_open_write(struct audio_client *ac, uint32_t format,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for open write\n", __func__);
		rc = -ETIMEDOUT;
@@ -3710,7 +3717,8 @@ static int __q6asm_open_read_write(struct audio_client *ac, uint32_t rd_format,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for open read-write\n",
				__func__);
@@ -3864,7 +3872,8 @@ int q6asm_open_loopback_v2(struct audio_client *ac, uint16_t bits_per_sample)
		}
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for open_loopback\n",
				__func__);
@@ -3974,7 +3983,8 @@ int q6asm_open_transcode_loopback(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for open_transcode_loopback\n",
			__func__);
@@ -4265,7 +4275,8 @@ int q6asm_open_shared_io(struct audio_client *ac,

	pr_debug("%s: sent open apr pkt\n", __func__);
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) <= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) <= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: Timeout. Waited for open write apr pkt rc[%d]\n",
		       __func__, rc);
@@ -4435,7 +4446,8 @@ int q6asm_run(struct audio_client *ac, uint32_t flags,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for run success",
				__func__);
@@ -4580,7 +4592,8 @@ int q6asm_enc_cfg_blk_custom(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n",
			__func__);
@@ -4651,7 +4664,8 @@ int q6asm_enc_cfg_blk_aac(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n",
			__func__);
@@ -4713,7 +4727,8 @@ int q6asm_enc_cfg_blk_g711(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n",
			__func__);
@@ -4776,7 +4791,8 @@ int q6asm_set_encdec_chan_map(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				 (atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n", __func__,
			   chan_map.hdr.opcode);
@@ -4980,7 +4996,8 @@ int q6asm_enc_cfg_blk_pcm_v4(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n",
		       __func__, enc_cfg.hdr.opcode);
@@ -5077,7 +5094,8 @@ int q6asm_enc_cfg_blk_pcm_v3(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n",
		       __func__, enc_cfg.hdr.opcode);
@@ -5171,7 +5189,8 @@ int q6asm_enc_cfg_blk_pcm_v2(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n",
			__func__, enc_cfg.hdr.opcode);
@@ -5379,7 +5398,8 @@ int q6asm_enc_cfg_blk_pcm_native(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n",
			__func__, enc_cfg.hdr.opcode);
@@ -5551,7 +5571,8 @@ int q6asm_enable_sbrps(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x] ", __func__, sbrps.hdr.opcode);
		rc = -ETIMEDOUT;
@@ -5610,7 +5631,8 @@ int q6asm_cfg_dual_mono_aac(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n", __func__,
						dual_mono.hdr.opcode);
@@ -5656,7 +5678,8 @@ int q6asm_cfg_aac_sel_mix_coef(struct audio_client *ac, uint32_t mix_coeff)
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
		(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
		(atomic_read(&ac->cmd_state) >= 0),
		msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n",
			__func__, aac_mix_coeff.hdr.opcode);
@@ -5725,7 +5748,8 @@ int q6asm_enc_cfg_blk_qcelp(struct audio_client *ac, uint32_t frames_per_buf,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for setencdec v13k resp\n",
			__func__);
@@ -5792,7 +5816,8 @@ int q6asm_enc_cfg_blk_evrc(struct audio_client *ac, uint32_t frames_per_buf,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for encdec evrc\n", __func__);
		rc = -ETIMEDOUT;
@@ -5853,7 +5878,8 @@ int q6asm_enc_cfg_blk_amrnb(struct audio_client *ac, uint32_t frames_per_buf,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for set encdec amrnb\n", __func__);
		rc = -ETIMEDOUT;
@@ -5914,7 +5940,8 @@ int q6asm_enc_cfg_blk_amrwb(struct audio_client *ac, uint32_t frames_per_buf,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -5995,7 +6022,8 @@ static int __q6asm_media_format_block_pcm(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6076,7 +6104,8 @@ static int __q6asm_media_format_block_pcm_v3(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6161,7 +6190,8 @@ static int __q6asm_media_format_block_pcm_v4(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6483,7 +6513,8 @@ static int __q6asm_media_format_block_multi_ch_pcm(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6552,7 +6583,8 @@ static int __q6asm_media_format_block_multi_ch_pcm_v3(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6625,7 +6657,8 @@ static int __q6asm_media_format_block_multi_ch_pcm_v4(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6887,7 +6920,8 @@ int q6asm_media_format_block_gen_compr(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -6943,7 +6977,8 @@ int q6asm_media_format_block_iec(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for format update\n", __func__);
		rc = -ETIMEDOUT;
@@ -7012,7 +7047,8 @@ static int __q6asm_media_format_block_multi_aac(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7126,7 +7162,8 @@ int q6asm_media_format_block_wma(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7197,7 +7234,8 @@ int q6asm_media_format_block_wmapro(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7256,7 +7294,8 @@ int q6asm_media_format_block_amrwbplus(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7319,7 +7358,8 @@ int q6asm_stream_media_format_block_flac(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7386,7 +7426,8 @@ int q6asm_media_format_block_alac(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7455,7 +7496,8 @@ int q6asm_media_format_block_g711(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7511,7 +7553,8 @@ int q6asm_stream_media_format_block_vorbis(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7576,7 +7619,8 @@ int q6asm_media_format_block_ape(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7636,7 +7680,8 @@ int q6asm_media_format_block_dsd(struct audio_client *ac,
		goto done;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for DSD FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7698,7 +7743,8 @@ int q6asm_stream_media_format_block_aptx_dec(struct audio_client *ac,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s :timeout. waited for FORMAT_UPDATE\n", __func__);
		rc = -ETIMEDOUT;
@@ -7756,7 +7802,8 @@ static int __q6asm_ds1_set_endp_params(struct audio_client *ac, int param_id,
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
		(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
		(atomic_read(&ac->cmd_state) >= 0),
		msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout opcode[0x%x]\n", __func__,
			ddp_cfg.hdr.opcode);
@@ -7892,7 +7939,8 @@ int q6asm_memory_map(struct audio_client *ac, phys_addr_t buf_add, int dir,

	rc = wait_event_timeout(ac->mem_wait,
			(atomic_read(&ac->mem_state) >= 0 &&
			 ac->port[dir].tmp_hdl), 5*HZ);
			 ac->port[dir].tmp_hdl),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for memory_map\n", __func__);
		rc = -ETIMEDOUT;
@@ -7980,7 +8028,8 @@ int q6asm_memory_unmap(struct audio_client *ac, phys_addr_t buf_add, int dir)
	}

	rc = wait_event_timeout(ac->mem_wait,
			(atomic_read(&ac->mem_state) >= 0), 5 * HZ);
			(atomic_read(&ac->mem_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for memory_unmap of handle 0x%x\n",
			__func__, mem_unmap.mem_map_handle);
@@ -8132,7 +8181,8 @@ static int q6asm_memory_map_regions(struct audio_client *ac, int dir,

	rc = wait_event_timeout(ac->mem_wait,
			(atomic_read(&ac->mem_state) >= 0 &&
			 ac->port[dir].tmp_hdl), 5*HZ);
			 ac->port[dir].tmp_hdl),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for memory_map\n", __func__);
		rc = -ETIMEDOUT;
@@ -8231,7 +8281,8 @@ static int q6asm_memory_unmap_regions(struct audio_client *ac, int dir)
	}

	rc = wait_event_timeout(ac->mem_wait,
			(atomic_read(&ac->mem_state) >= 0), 5*HZ);
			(atomic_read(&ac->mem_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for memory_unmap of handle 0x%x\n",
			__func__, mem_unmap.mem_map_handle);
@@ -8495,7 +8546,8 @@ int q6asm_set_aptx_dec_bt_addr(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout, set-params paramid[0x%x]\n", __func__,
			paylod.encdec.param_id);
@@ -8590,7 +8642,8 @@ int q6asm_send_ion_fd(struct audio_client *ac, int fd)
	}

	ret = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 1*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!ret) {
		pr_err("%s: timeout, shm.encdec paramid[0x%x]\n", __func__,
		       shm.encdec.param_id);
@@ -8662,7 +8715,8 @@ int q6asm_send_rtic_event_ack(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 1 * HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout for rtic event ack cmd\n", __func__);
		rc = -ETIMEDOUT;
@@ -9468,7 +9522,8 @@ int q6asm_get_session_time(struct audio_client *ac, uint64_t *tstamp)
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->time_wait,
			(atomic_read(&ac->time_flag) == 0), 5*HZ);
			(atomic_read(&ac->time_flag) == 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout in getting session time from DSP\n",
				__func__);
@@ -9524,7 +9579,8 @@ int q6asm_get_session_time_legacy(struct audio_client *ac, uint64_t *tstamp)
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->time_wait,
			(atomic_read(&ac->time_flag) == 0), 5*HZ);
			(atomic_read(&ac->time_flag) == 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout in getting session time from DSP\n",
				__func__);
@@ -9602,7 +9658,8 @@ int q6asm_send_mtmx_strtr_window(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout, Render window start paramid[0x%x]\n",
			__func__, matrix.data.param_id);
@@ -9697,7 +9754,8 @@ int q6asm_send_mtmx_strtr_render_mode(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout, Render mode send paramid [0x%x]\n",
			__func__, matrix.data.param_id);
@@ -9792,7 +9850,8 @@ int q6asm_send_mtmx_strtr_clk_rec_mode(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout, clk rec mode send paramid [0x%x]\n",
			__func__, matrix.data.param_id);
@@ -9875,7 +9934,8 @@ int q6asm_send_mtmx_strtr_enable_adjust_session_clock(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: enable adjust session failed failed paramid [0x%x]\n",
			__func__, matrix.data.param_id);
@@ -9976,7 +10036,8 @@ static int __q6asm_cmd(struct audio_client *ac, int cmd, uint32_t stream_id)
		rc = -EINVAL;
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait, (atomic_read(state) >= 0), 5*HZ);
	rc = wait_event_timeout(ac->cmd_wait, (atomic_read(state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for response opcode[0x%x]\n",
				__func__, hdr.opcode);
@@ -10302,7 +10363,8 @@ int q6asm_reg_tx_overflow(struct audio_client *ac, uint16_t enable)
		goto fail_cmd;
	}
	rc = wait_event_timeout(ac->cmd_wait,
				(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
				(atomic_read(&ac->cmd_state) >= 0),
				msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for tx overflow\n", __func__);
		rc = -ETIMEDOUT;
@@ -10407,7 +10469,8 @@ int q6asm_adjust_session_clock(struct audio_client *ac,
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5*HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout, adjust_clock paramid[0x%x]\n",
			__func__, adjust_clock.hdr.opcode);
@@ -10459,7 +10522,8 @@ int q6asm_get_path_delay(struct audio_client *ac)
	}

	rc = wait_event_timeout(ac->cmd_wait,
			(atomic_read(&ac->cmd_state) >= 0), 5 * HZ);
			(atomic_read(&ac->cmd_state) >= 0),
			msecs_to_jiffies(TIMEOUT_MS));
	if (!rc) {
		pr_err("%s: timeout. waited for response opcode[0x%x]\n",
				__func__, hdr.opcode);
Loading