From patchwork Mon Jan 8 12:23:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 10149313 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 1CB75601BE for ; Mon, 8 Jan 2018 12:23:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E9A22839C for ; Mon, 8 Jan 2018 12:23:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 037BF28632; Mon, 8 Jan 2018 12:23:27 +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=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=no 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 A79C52839C for ; Mon, 8 Jan 2018 12:23:25 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id E19B7266EC4; Mon, 8 Jan 2018 13:23:22 +0100 (CET) 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 4CE76267063; Mon, 8 Jan 2018 13:23:21 +0100 (CET) Received: from metanate.com (dougal.metanate.com [90.155.101.14]) by alsa0.perex.cz (Postfix) with ESMTP id 365D926698E for ; Mon, 8 Jan 2018 13:23:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: MIME-Version:Content-Type:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=Xw+nH4DERCgXD7Yia1iB+KFMRLwVa2dRPNb7ea/JosA=; b=Uep6w3hw4q7IONlm7BxzKlwqiv DMrjCKPlBJRrUv3QsIPbBrLbA+XMbkXSL6S1UWxylRZUQLJQblDkE7mxFNvteYNXeQK+YehQCsYy5 dnHOsvKiIdKOGc9sqmwR4JnYbmUUMCFj5F0oL31KZ6nO35hAPNbufQFWSSjfXUztZ+quj7ikj4L4r qzMfouiDjhge+AduJlTeVyqpFWsOPjh8TbSzqcXC2hyWGk9YUYG2KQGfvJgcpz+XjZDzys98/mMIw fh7e9t1hd99Im+1UHgazr5egltSA7ncyMTifpWv8lmSjRwqKu6rbZgWdY2Fs77MwkhyYqAdKm7Tmq F5SZg9Yg==; Received: from dougal.metanate.com ([192.168.88.1] helo=leela.metanate.com) by shrek.metanate.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) (envelope-from ) id 1eYWSN-0002d8-N8; Mon, 08 Jan 2018 12:23:11 +0000 From: John Keeping To: alsa-devel@alsa-project.org Date: Mon, 8 Jan 2018 12:23:01 +0000 Message-Id: <20180108122301.18255-1-john@metanate.com> X-Mailer: git-send-email 2.15.1 Cc: Sugar Zhang , linux-rockchip@lists.infradead.org, Mark Brown , John Keeping , Liam Girdwood Subject: [alsa-devel] [PATCH] ASoC: rockchip: i2s: fix playback after runtime resume 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: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP When restoring registers during runtime resume, we must not write to I2S_TXDR which is the transmit FIFO as this queues up a sample to be output and pushes all of the output channels down by one. This can be demonstrated with the speaker-test utility: for i in a b c; do speaker-test -c 2 -s 1; done which should play a test through the left speaker three times but if the I2S hardware starts runtime suspended the first sample will be played through the right speaker. Fix this by marking I2S_TXDR as volatile (which also requires marking it as readble, even though it technically isn't). This seems to be the most robust fix, the alternative of giving I2S_TXDR a default value is more fragile since it does not prevent regcache writing to the register in all circumstances. While here, also fix the configuration of I2S_RXDR and I2S_FIFOLR; these are not writable so they do not suffer from the same problem as I2S_TXDR but reading from I2S_RXDR does suffer from a similar problem. Fixes: f0447f6cbb20 ("ASoC: rockchip: i2s: restore register during runtime_suspend/resume cycle", 2016-09-07) Signed-off-by: John Keeping --- I'm not completely happy with marking I2S_TXDR as readable here, but I can't see a better way to do this. Neither "volatile" nor "precious" seem to match exactly a writable FIFO register but this does at least fix the bug and tegra30_ahub.c seems to take the same approach. sound/soc/rockchip/rockchip_i2s.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 908211e1d6fc..20855ed8e4b7 100644 --- a/sound/soc/rockchip/rockchip_i2s.c +++ b/sound/soc/rockchip/rockchip_i2s.c @@ -504,6 +504,7 @@ static bool rockchip_i2s_rd_reg(struct device *dev, unsigned int reg) case I2S_INTCR: case I2S_XFER: case I2S_CLR: + case I2S_TXDR: case I2S_RXDR: case I2S_FIFOLR: case I2S_INTSR: @@ -518,6 +519,9 @@ static bool rockchip_i2s_volatile_reg(struct device *dev, unsigned int reg) switch (reg) { case I2S_INTSR: case I2S_CLR: + case I2S_FIFOLR: + case I2S_TXDR: + case I2S_RXDR: return true; default: return false; @@ -527,6 +531,7 @@ static bool rockchip_i2s_volatile_reg(struct device *dev, unsigned int reg) static bool rockchip_i2s_precious_reg(struct device *dev, unsigned int reg) { switch (reg) { + case I2S_RXDR: default: return false; }