From patchwork Mon Jan 8 16:01:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Keeping X-Patchwork-Id: 10149945 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 2B2E9601BE for ; Mon, 8 Jan 2018 16:13:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02B021FF87 for ; Mon, 8 Jan 2018 16:13:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB8CA204FE; Mon, 8 Jan 2018 16:13:37 +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 89C771FF87 for ; Mon, 8 Jan 2018 16:13:37 +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:References: In-Reply-To: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:List-Owner; bh=J6WuRwagOgLGNXJQB/XXgiSw9WmfTGaXhqyUN5XnOTc=; b=ikBrxW9FL+i4QD06kkhbNlFAbO s8dXgAjC3Ftws0oC5vnTsk46j0j5NZvzNgBDEFJWV1ZVyFIwyHhPyzxLzW4mO+yqkEfYLzN4AM51E XfCgj5HiDfp8Ro6Y7hfYUL4OctFNzHZRAgoQSSP9ywyPjR5NlIfHbrbokLqZerM45oCE1645SLrEM h4XCaD1HkD2Zq4phz1Rv+y7x6DEBzWDJ/uftp7e9JtMMlSAh7sQZKLR1XcwRXAGjT56nXo+Npljzd 1rXPTJP1AG6EQ2g1jPNSBjHLPU387Dxp3R55bS9WJVCi2p/Y5gCF0efWVZu4wRiRyzs5yoZ7CZQMu 5yMf0U3Q==; 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 1eYa3J-0000T5-R8; Mon, 08 Jan 2018 16:13:33 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYa3B-00008b-7K for linux-rockchip@bombadil.infradead.org; Mon, 08 Jan 2018 16:13:25 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To: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:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=1sg2mifTIaMikIsM04TKf8NEqSWTx347/COq2KUkdPU=; b=PFHyLXe3ehWGfAZ6i+zojrarc c4U/V6Di9mBb4XvOiDzg9huZb+dKtp5BlbWw2b1keLW4RxW+qu6s/IwOIEZyKZCzWced+GjG8+bB5 XrbjN2sANxjc9BdaaRfsS1gxiaB9N8AFh7nCKVgd8V22NJu9eCZo7F4HWTiuQ5cKI3W5FeWw2xjip A8LCwHNPCnhARB8KSBT+CxpOuebkxrSPhsNZRe9O4Ej6Yl7JrqEnAxMrPkxi303wg62nQToHxvUjo imygW/qP8SRFsWnDc7tJvLDOjfsc46N1bnTkWe4c3S39QopCx9bT/tM7C2rDmlSkFUVOW/iGN9KSG HXEMauM/w==; Received: from dougal.metanate.com ([90.155.101.14] helo=metanate.com) by casper.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eYZrl-0001NP-4G for linux-rockchip@lists.infradead.org; Mon, 08 Jan 2018 16:01:41 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=simple/simple; d=metanate.com; s=stronger; h=References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=QmWkAVrN2O572heiU+GyKQuygdiuczLC4M7o2Rkv34k=; b=AJWYTEqE++rzdIrXtMLwd4aPta YWtfok9h1FVYD52p7nwPBl8BxnjAB+Ufie6pq8EYvoxAwXYAhHopxfh2weWyOE1j+D2UN/RuhgdPN gRYzJ3RQPAqK0Xe8jrt6UjC7ur0uXKPNNVAsfLg/ftmEU1rTdk733yTS2BrUKjmjttQrYb/VgIrMB gbaO/M+eoxyBRw7Au1sOqL34hAKNsk6cnB1j2YvK/+Obl76cbife3KzAZWZkaRijW2MpseVAR48zF V1HLjjFiYozjqzKU2EwQQqvjisUl5Ng8tr8QjSgGC51nHnl2GrFf/j5STy+Sv7zJZnFmnWbeavZuo azzcNZ+Q==; 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 1eYZrI-0003pW-OG; Mon, 08 Jan 2018 16:01:08 +0000 From: John Keeping To: alsa-devel@alsa-project.org Subject: [PATCH v2] ASoC: rockchip: i2s: fix playback after runtime resume Date: Mon, 8 Jan 2018 16:01:04 +0000 Message-Id: <20180108160104.6307-1-john@metanate.com> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180108122301.18255-1-john@metanate.com> References: <20180108122301.18255-1-john@metanate.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180108_160139_204825_1730FDEC X-CRM114-Status: GOOD ( 13.34 ) 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 --- v2 changes: - Fix rockchip_i2s_precious_reg to return true for I2S_RXDR sound/soc/rockchip/rockchip_i2s.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/rockchip/rockchip_i2s.c b/sound/soc/rockchip/rockchip_i2s.c index 908211e1d6fc..eb27f6c24bf7 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,8 @@ 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: + return true; default: return false; }