diff --git a/asoc/sdm845.c b/asoc/sdm845.c index 1bc31fb3ef8e..44bf0bf334fc 100644 --- a/asoc/sdm845.c +++ b/asoc/sdm845.c @@ -3641,31 +3641,44 @@ static void msm_afe_clear_config(void) afe_clear_config(AFE_SLIMBUS_SLAVE_CONFIG); } -static int msm_adsp_power_up_config(struct snd_soc_codec *codec) +static int msm_adsp_power_up_config(struct snd_soc_codec *codec, + struct snd_card *card) { int ret = 0; unsigned long timeout; int adsp_ready = 0; + bool snd_card_online = 0; timeout = jiffies + msecs_to_jiffies(ADSP_STATE_READY_TIMEOUT_MS); do { - if (q6core_is_adsp_ready()) { - pr_debug("%s: ADSP Audio is ready\n", __func__); - adsp_ready = 1; - break; + if (!snd_card_online) { + snd_card_online = snd_card_is_online_state(card); + pr_debug("%s: Sound card is %s\n", __func__, + snd_card_online ? "Online" : "Offline"); } + if (!adsp_ready) { + adsp_ready = q6core_is_adsp_ready(); + pr_debug("%s: ADSP Audio is %s\n", __func__, + adsp_ready ? "ready" : "not ready"); + } + if (snd_card_online && adsp_ready) + break; + /* - * ADSP will be coming up after subsystem restart and + * Sound card/ADSP will be coming up after subsystem restart and * it might not be fully up when the control reaches * here. So, wait for 50msec before checking ADSP state */ msleep(50); } while (time_after(timeout, jiffies)); - if (!adsp_ready) { - pr_err("%s: timed out waiting for ADSP Audio\n", __func__); + if (!snd_card_online || !adsp_ready) { + pr_err("%s: Timeout. Sound card is %s, ADSP Audio is %s\n", + __func__, + snd_card_online ? "Online" : "Offline", + adsp_ready ? "ready" : "not ready"); ret = -ETIMEDOUT; goto err; } @@ -3723,7 +3736,7 @@ static int sdm845_notifier_service_cb(struct notifier_block *this, } codec = rtd->codec; - ret = msm_adsp_power_up_config(codec); + ret = msm_adsp_power_up_config(codec, card->snd_card); if (ret < 0) { dev_err(card->dev, "%s: msm_adsp_power_up_config failed ret = %d!\n", @@ -3821,7 +3834,7 @@ static int msm_audrx_init(struct snd_soc_pcm_runtime *rtd) msm_codec_fn.get_afe_config_fn = tavil_get_afe_config; - ret = msm_adsp_power_up_config(codec); + ret = msm_adsp_power_up_config(codec, rtd->card->snd_card); if (ret) { pr_err("%s: Failed to set AFE config %d\n", __func__, ret); goto err; @@ -7069,6 +7082,7 @@ static int msm_asoc_machine_remove(struct platform_device *pdev) struct msm_asoc_mach_data *pdata = snd_soc_card_get_drvdata(card); + audio_notifier_deregister("sdm845"); if (pdata->us_euro_gpio > 0) { gpio_free(pdata->us_euro_gpio); pdata->us_euro_gpio = 0; @@ -7077,7 +7091,6 @@ static int msm_asoc_machine_remove(struct platform_device *pdev) msm_release_pinctrl(pdev); snd_soc_unregister_card(card); - audio_notifier_deregister("sdm845"); return 0; }