Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp373064ybl; Tue, 27 Aug 2019 22:23:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqwULQyfdkDExE+ePihj+S2S5QPzJdcJAh5WtZywtEKZuyQ+KXv6h5zUL5r/z/oPuhG2L2MO X-Received: by 2002:a17:902:b582:: with SMTP id a2mr2503759pls.199.1566969797161; Tue, 27 Aug 2019 22:23:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566969797; cv=none; d=google.com; s=arc-20160816; b=JSGkvrNivXn3p1f8Ac60UZRu1OfJza6S5NZlXstNb0oWM3+4MvlKpFNSlI1UQbMzmO Jty1o9KyaBx/D8jcudaMVFoMirw56CEjlH2t7Rui2YjId4TaFCQCDZqE3aq6UEeKY07I jUx/oRihOvEZu+Cz8Co1t17FupT2lgXb/TIc4bx7xYPa752gV+016UfC4XwVJD3YwyvG FlOwWIIvl29Rig/FGAqf+JSIAy76K1GEF8B5MQgv6J8uSOheeDVhD0BZnOZ9b1MQ+RED 9TCYaXTTC1JOiIoeC8jIV1x/Wr/PbtEi5NLZlPiW2EIi+U/IkiDVZMKdI2UD38e8+bgV 1QMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:to:from; bh=zopfmOiM+9viIX58S6HnPnldng1R4NzoFvmpTIkythU=; b=rsIYK5tiiKYE/bc+ICh53YHMa/uLEj8R64UhCO4ZXyNyWkqnwKUqRoHbkiHk1YHwDW t6391NedaQt2oE8GpNiUbHgJo5Rfgtvgn8a0aNJFzry9gWrNFtdovVPeO5dfXUg5lO04 XNRAWVmY7K7+xBxvlKJu1P1km1BwyamhMLWXqcqtDcq8wKcAeJcaB3tHnrNaPmsRcsV5 /NRfioJ668rBbakNOITuWTlEdRKcZqoB2P7NbeuoCMmvVnQ4M2lcJ5vtxxx8X+Ue94Kv 4fS5WsSlxp4WjFlR5YQI5VSEFkfdGNNUa1lZPtisOjM7/D1QHcAKAzyKikQ4k5I/hGhh WwMg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r23si1033497pls.370.2019.08.27.22.22.47; Tue, 27 Aug 2019 22:23:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726136AbfH1FVY (ORCPT + 99 others); Wed, 28 Aug 2019 01:21:24 -0400 Received: from inva021.nxp.com ([92.121.34.21]:41612 "EHLO inva021.nxp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726052AbfH1FVY (ORCPT ); Wed, 28 Aug 2019 01:21:24 -0400 Received: from inva021.nxp.com (localhost [127.0.0.1]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id D581C200274; Wed, 28 Aug 2019 07:21:21 +0200 (CEST) Received: from invc005.ap-rdc01.nxp.com (invc005.ap-rdc01.nxp.com [165.114.16.14]) by inva021.eu-rdc02.nxp.com (Postfix) with ESMTP id 595BD2001A9; Wed, 28 Aug 2019 07:21:16 +0200 (CEST) Received: from localhost.localdomain (shlinux2.ap.freescale.net [10.192.224.44]) by invc005.ap-rdc01.nxp.com (Postfix) with ESMTP id 65E74402C0; Wed, 28 Aug 2019 13:21:09 +0800 (SGT) From: Shengjiu Wang To: timur@kernel.org, nicoleotsuka@gmail.com, Xiubo.Lee@gmail.com, festevam@gmail.com, lgirdwood@gmail.com, broonie@kernel.org, perex@perex.cz, tiwai@suse.com, alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: fsl_ssi: Fix clock control issue in master mode Date: Wed, 28 Aug 2019 13:20:17 -0400 Message-Id: <1567012817-12625-1-git-send-email-shengjiu.wang@nxp.com> X-Mailer: git-send-email 2.7.4 X-Virus-Scanned: ClamAV using ClamSMTP Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The test case is arecord -Dhw:0 -d 10 -f S16_LE -r 48000 -c 2 temp.wav & aplay -Dhw:0 -d 30 -f S16_LE -r 48000 -c 2 test.wav There will be error after end of arecord: aplay: pcm_write:2051: write error: Input/output error Capture and Playback work in parallel in master mode, one substream stops, the other substream is impacted, the reason is that clock is disabled wrongly. The clock's reference count is not increased when second substream starts, the hw_param() function returns in the beginning because first substream is enabled, then in end of first substream, the hw_free() disables the clock. This patch is to move the clock enablement to the place before checking of the device enablement in hw_param(). Signed-off-by: Shengjiu Wang --- sound/soc/fsl/fsl_ssi.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c index b0a6fead1a6a..537dc69256f0 100644 --- a/sound/soc/fsl/fsl_ssi.c +++ b/sound/soc/fsl/fsl_ssi.c @@ -799,15 +799,6 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, u32 wl = SSI_SxCCR_WL(sample_size); int ret; - /* - * SSI is properly configured if it is enabled and running in - * the synchronous mode; Note that AC97 mode is an exception - * that should set separate configurations for STCCR and SRCCR - * despite running in the synchronous mode. - */ - if (ssi->streams && ssi->synchronous) - return 0; - if (fsl_ssi_is_i2s_master(ssi)) { ret = fsl_ssi_set_bclk(substream, dai, hw_params); if (ret) @@ -823,6 +814,15 @@ static int fsl_ssi_hw_params(struct snd_pcm_substream *substream, } } + /* + * SSI is properly configured if it is enabled and running in + * the synchronous mode; Note that AC97 mode is an exception + * that should set separate configurations for STCCR and SRCCR + * despite running in the synchronous mode. + */ + if (ssi->streams && ssi->synchronous) + return 0; + if (!fsl_ssi_is_ac97(ssi)) { /* * Keep the ssi->i2s_net intact while having a local variable -- 2.21.0