From patchwork Tue May 22 09:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KaiChieh Chuang X-Patchwork-Id: 10417667 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A0A916016C for ; Tue, 22 May 2018 09:13:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 906A228B64 for ; Tue, 22 May 2018 09:13:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 84BF928B7E; Tue, 22 May 2018 09:13:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E486228B64 for ; Tue, 22 May 2018 09:13:49 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 4211126765C; Tue, 22 May 2018 11:13:47 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 7F16A267660; Tue, 22 May 2018 11:13:45 +0200 (CEST) Received: from mailgw01.mediatek.com (unknown [210.61.82.183]) by alsa0.perex.cz (Postfix) with ESMTP id 7DF8D267651 for ; Tue, 22 May 2018 11:13:36 +0200 (CEST) X-UUID: b0a55ab5ba82427a89353d3ea6587b0e-20180522 Received: from mtkexhb02.mediatek.inc [(172.21.101.103)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 1817618366; Tue, 22 May 2018 17:13:32 +0800 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Tue, 22 May 2018 17:13:30 +0800 Received: from mtksdaap41.mediatek.inc (172.21.77.4) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Tue, 22 May 2018 17:13:30 +0800 From: KaiChieh Chuang To: Date: Tue, 22 May 2018 17:13:27 +0800 Message-ID: <1526980408-1935-2-git-send-email-kaichieh.chuang@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1526980408-1935-1-git-send-email-kaichieh.chuang@mediatek.com> References: <1526980408-1935-1-git-send-email-kaichieh.chuang@mediatek.com> MIME-Version: 1.0 X-MTK: N Cc: alsa-devel@alsa-project.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com, kaichieh.chuang@mediatek.com Subject: [alsa-devel] [PATCH 1/2] ASoC: dpcm: fix BE dai not hw_free and shutdown X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP In case, one BE is used by two FE1/FE2 FE1--->BE--> FE2---> When FE1/FE2 call dpcm_be_dai_hw_free() together the BE users will be 2 (> 1), hence cannot be hw_free. The be state will leave at, ex. SND_SOC_DPCM_STATE_STOP Later FE1/FE2 call dpcm_be_dai_shutdown(), will be skip due to wrong state. Leaving the BE not being hw_free and shutdown. This patch add a flag in snd_soc_dpcm to denote the hw_free cannot be excute for this fe->be dpcm. The BE dai will be hw_free later when calling dpcm_be_dai_shutdown() if still in invalid state. Signed-off-by: KaiChieh Chuang --- include/sound/soc-dpcm.h | 2 ++ sound/soc/soc-pcm.c | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/include/sound/soc-dpcm.h b/include/sound/soc-dpcm.h index 8060590..52d9b5d 100644 --- a/include/sound/soc-dpcm.h +++ b/include/sound/soc-dpcm.h @@ -86,6 +86,8 @@ struct snd_soc_dpcm { #ifdef CONFIG_DEBUG_FS struct dentry *debugfs_state; #endif + + bool be_hw_free_deferred; }; /* diff --git a/sound/soc/soc-pcm.c b/sound/soc/soc-pcm.c index 87c9af2..481604a 100644 --- a/sound/soc/soc-pcm.c +++ b/sound/soc/soc-pcm.c @@ -1866,8 +1866,16 @@ int dpcm_be_dai_shutdown(struct snd_soc_pcm_runtime *fe, int stream) continue; if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_FREE) && - (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN)) - continue; + (be->dpcm[stream].state != SND_SOC_DPCM_STATE_OPEN)) { + if (dpcm->be_hw_free_deferred) { + soc_pcm_hw_free(be_substream); + be->dpcm[stream].state = + SND_SOC_DPCM_STATE_HW_FREE; + dpcm->be_hw_free_deferred = false; + } else { + continue; + } + } dev_dbg(be->dev, "ASoC: close BE %s\n", be->dai_link->name); @@ -1924,8 +1932,10 @@ int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) continue; /* do not free hw if this BE is used by other FE */ - if (be->dpcm[stream].users > 1) + if (be->dpcm[stream].users > 1) { + dpcm->be_hw_free_deferred = true; continue; + } if ((be->dpcm[stream].state != SND_SOC_DPCM_STATE_HW_PARAMS) && (be->dpcm[stream].state != SND_SOC_DPCM_STATE_PREPARE) && @@ -1941,6 +1951,7 @@ int dpcm_be_dai_hw_free(struct snd_soc_pcm_runtime *fe, int stream) soc_pcm_hw_free(be_substream); be->dpcm[stream].state = SND_SOC_DPCM_STATE_HW_FREE; + dpcm->be_hw_free_deferred = false; } return 0;