From patchwork Thu May 22 21:33:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 4226711 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3E21FBF90B for ; Thu, 22 May 2014 21:33:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5DD9A2037A for ; Thu, 22 May 2014 21:33:31 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 01EE2201EC for ; Thu, 22 May 2014 21:33:30 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 594092655FB; Thu, 22 May 2014 23:33:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NO_DNS_FOR_FROM, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 2447A2655A7; Thu, 22 May 2014 23:33:18 +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 F215A2655B2; Thu, 22 May 2014 23:33:14 +0200 (CEST) Received: from mail-ve0-f181.google.com (mail-ve0-f181.google.com [209.85.128.181]) by alsa0.perex.cz (Postfix) with ESMTP id A116C261A3D for ; Thu, 22 May 2014 23:33:06 +0200 (CEST) Received: by mail-ve0-f181.google.com with SMTP id pa12so5156998veb.40 for ; Thu, 22 May 2014 14:33:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=q/uN1ZO0AfhbMhllkITs4qDAmocLwiHTF0Yt9d+spXk=; b=BPTSlAEd+UwVUWw1rPD0+MB68/YYWqi/aRwbIqQA0TbuEDd8UzkswAvqHMscZKZSXw M56AovzhN+BCDZOKNBtdTCW4jBXXAvE7RJfeOhza7T93Mf1Y3YwMXf4fbvgPNHDZF583 jSZbAU8qNeRA0ZX3YVblY8XSz/MN6l2AX5g6s32uABy+kinv3TG33bEbH7PQCT9cTZ9S C8USuUBuRS8HLdjtLXD5ubwmyag3DsbpQpQqxMM9EHTq7G6ty0re/+hBTBMo1EoJ+FtM 5hZdFVZOpgWTqOQN88uA698mqFCeM57BPEIT2BSUSDQ26k3aTFvluqxDeJGTrpIFunOW pTlQ== MIME-Version: 1.0 X-Received: by 10.52.255.65 with SMTP id ao1mr180993vdd.43.1400794385093; Thu, 22 May 2014 14:33:05 -0700 (PDT) Received: by 10.58.19.102 with HTTP; Thu, 22 May 2014 14:33:05 -0700 (PDT) In-Reply-To: <20140522174818.GN12304@sirena.org.uk> References: <20140522145650.GD32184@dragon> <20140522174818.GN12304@sirena.org.uk> Date: Thu, 22 May 2014 18:33:05 -0300 Message-ID: From: Fabio Estevam To: Mark Brown Cc: Fabio Estevam , "alsa-devel@alsa-project.org" , "linux-arm-kernel@lists.infradead.org" , Shawn Guo Subject: Re: [alsa-devel] The resume of sgtl5000 causes kernel Oops 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 Hi Mark, On Thu, May 22, 2014 at 2:48 PM, Mark Brown wrote: > On Thu, May 22, 2014 at 10:56:51PM +0800, Shawn Guo wrote: >> The suspend/resume test on imx51-babbage board discovers a kernel Oops >> caused by sgtl5000_resume(). I believe it happens due to commit >> e5d80e82e32e (ASoC: sgtl5000: Convert to use regmap directly). After >> the commit, it seems that the codec->reg_cache in function >> sgtl5000_restore_regs() becomes invalid. It looks that the register >> restoring in the function requires some strict sequence, I'm not sure >> what the correct fix is. > > Yes, reg_cache isn't there if we're not using ASoC level caching. The > fix should just be to replace the direct cache references with > snd_soc_read()s which will end up in a cache lookup if the register is > cached. Do you mean like this? /* * restore these regs according to the power setting sequence in @@ -1110,19 +1109,19 @@ static int sgtl5000_restore_regs(struct snd_soc_codec *codec) * prefer to resotre it after SGTL5000_CHIP_ANA_POWER restored */ snd_soc_write(codec, SGTL5000_CHIP_LINREG_CTRL, - cache[SGTL5000_CHIP_LINREG_CTRL]); + snd_soc_read(codec, SGTL5000_CHIP_LINREG_CTRL)); snd_soc_write(codec, SGTL5000_CHIP_ANA_POWER, - cache[SGTL5000_CHIP_ANA_POWER]); + snd_soc_read(codec, SGTL5000_CHIP_ANA_POWER)); snd_soc_write(codec, SGTL5000_CHIP_CLK_CTRL, - cache[SGTL5000_CHIP_CLK_CTRL]); + snd_soc_read(codec, SGTL5000_CHIP_CLK_CTRL)); snd_soc_write(codec, SGTL5000_CHIP_REF_CTRL, - cache[SGTL5000_CHIP_REF_CTRL]); + snd_soc_read(codec, SGTL5000_CHIP_REF_CTRL)); snd_soc_write(codec, SGTL5000_CHIP_LINE_OUT_CTRL, - cache[SGTL5000_CHIP_LINE_OUT_CTRL]); + snd_soc_read(codec, SGTL5000_CHIP_LINE_OUT_CTRL)); return 0; } This avoids the crash in suspend, but I get different errors now: root@freescale /$ echo mem > /sys/power/state PM: Syncing filesystems ... done. Freezing user space processes ... (elapsed 0.001 seconds) done. Freezing remaining freezable tasks ... (elapsed 0.002 seconds) done. Suspending console(s) (use no_console_suspend to debug) random: nonblocking pool is initialized PM: suspend of devices complete after 15.210 msecs PM: suspend devices took 0.010 seconds PM: late suspend of devices complete after 4.435 msecs PM: noirq suspend of devices complete after 4.691 msecs Disabling non-boot CPUs ... PM: noirq resume of devices complete after 3.931 msecs PM: early resume of devices complete after 5.724 msecs sgtl5000 1-000a: Failed to restore cache: -5 sgtl5000 1-000a: Failed to restore cache: -5 sgtl5000 1-000a: ASoC: Failed to turn on bias: -5 sgtl5000 1-000a: Failed to restore cache: -5 sgtl5000 1-000a: ASoC: Failed to turn on bias: -5 sgtl5000 1-000a: Failed to restore cache: -5 sgtl5000 1-000a: ASoC: Failed to turn on bias: -5 PM: resume of devices complete after 62.349 msecs PM: resume devices took 0.060 seconds Restarting tasks ... done. diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index 9626ee0..437751a 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -1075,7 +1075,6 @@ static int sgtl5000_suspend(struct snd_soc_codec *codec) */ static int sgtl5000_restore_regs(struct snd_soc_codec *codec) { - u16 *cache = codec->reg_cache; u16 reg; /* restore regular registers */ @@ -1089,12 +1088,12 @@ static int sgtl5000_restore_regs(struct snd_soc_codec *codec) reg == SGTL5000_CHIP_REF_CTRL) continue; - snd_soc_write(codec, reg, cache[reg]); + snd_soc_write(codec, reg, snd_soc_read(codec, reg)); } /* restore dap registers */ for (reg = SGTL5000_DAP_REG_OFFSET; reg < SGTL5000_MAX_REG_OFFSET; reg += 2) - snd_soc_write(codec, reg, cache[reg]); + snd_soc_write(codec, reg, snd_soc_read(codec, reg));