From a6d9099cf57b8e45ffcf92ef7f2d2512d5c91ecc Mon Sep 17 00:00:00 2001 From: Akhil Karuturi Date: Thu, 5 Nov 2020 11:42:02 -0800 Subject: [PATCH] dsp: q6core: retry till adsp is up to send custom topologies add retry logic to ensure adsp is up before registering custom topologies Change-Id: Ib88c06ae8c64cd0784319f40e3746ccbbce0cdf7 Signed-off-by: Akhil Karuturi --- dsp/q6core.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/dsp/q6core.c b/dsp/q6core.c index c6b8f3a712f9..2fce87998485 100644 --- a/dsp/q6core.c +++ b/dsp/q6core.c @@ -1762,12 +1762,33 @@ static int q6core_send_custom_topologies(void) { int ret = 0; int ret2 = 0; + int32_t adsp_ready = 0; + unsigned long timeout; struct cal_block_data *cal_block = NULL; struct avcs_cmd_register_topologies reg_top; + /* If ADSP is down, retry till ADSP is up */ if (!q6core_is_adsp_ready()) { - pr_err("%s: ADSP is not ready!\n", __func__); - return -ENODEV; + pr_err("%s: ADSP is not ready.proceed with retry!\n", + __func__); + + timeout = jiffies + + msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS); + + do { + adsp_ready = q6core_is_adsp_ready(); + pr_debug("%s: ADSP Audio is %s\n", __func__, + adsp_ready ? "ready" : "not ready"); + if (adsp_ready) + break; + msleep(50); + } while (time_after(timeout, jiffies)); + + if (!adsp_ready) { + pr_err_ratelimited("%s: Timeout. ADSP Audio is not ready\n", + __func__); + return -ENODEV; + } } memset(®_top, 0, sizeof(reg_top));