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: 10149315 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 3980E601BE for ; Mon, 8 Jan 2018 12:23:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B32828469 for ; Mon, 8 Jan 2018 12:23:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1FE5328633; Mon, 8 Jan 2018 12:23:41 +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=-4.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 851F828469 for ; Mon, 8 Jan 2018 12:23:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=/9ZheLoK1fWHFUF40rr7qJW49oBBBGc05wJCPF2LYJc=; b=hUR mD0hjg8Mw0o5N4Bls2gOzTBgmJz/G14R4TaKm/csjAZj9I7mnfyio9EWx18/h/INvYXMsmIN+5uQs MAf+1fLUVglG/qYGxoHLiyQkf157H2UHIcG7HpqjJyUbtQTSr8+dfkcLLr6WZpw/uwh4ZlVgHCHvN Vn721qo40CKjyyP9QijM+O6L/FhWiXreeJZka7LmZ60SwW6q6ec9mdgtMQrGAiYfyxEpT++Dibzjg VzAnZ2iZU8cd7T4/Gx/5TFJP3vtrLB5YG2i0sSadlT1j7edlK7gKdygDOO7BHti/H1z/W2pqMlNLZ o0kEZp7Z9BMF03C8sLRQlf+SZiesblQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eYWSn-0002p9-AH; Mon, 08 Jan 2018 12:23:37 +0000 Received: from dougal.metanate.com ([90.155.101.14] helo=metanate.com) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYWSj-0002nb-0P for linux-rockchip@lists.infradead.org; Mon, 08 Jan 2018 12:23:35 +0000 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 Subject: [PATCH] ASoC: rockchip: i2s: fix playback after runtime resume 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_042333_249745_6B26DBEA X-CRM114-Status: GOOD ( 11.92 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sugar Zhang , linux-rockchip@lists.infradead.org, Mark Brown , John Keeping , Liam Girdwood MIME-Version: 1.0 Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+patchwork-linux-rockchip=patchwork.kernel.org@lists.infradead.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; }