From patchwork Thu Feb 15 18:36:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10223153 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 12448601D7 for ; Thu, 15 Feb 2018 18:37:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 009932915E for ; Thu, 15 Feb 2018 18:37:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E955429172; Thu, 15 Feb 2018 18:37:05 +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_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, 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 09B292915E for ; Thu, 15 Feb 2018 18:37:04 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id B140C267D59; Thu, 15 Feb 2018 19:37:02 +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 6DCFB267D3E; Thu, 15 Feb 2018 19:37:02 +0100 (CET) Received: from mail-qk0-f195.google.com (mail-qk0-f195.google.com [209.85.220.195]) by alsa0.perex.cz (Postfix) with ESMTP id 0CC67267D3E for ; Thu, 15 Feb 2018 19:36:51 +0100 (CET) Received: by mail-qk0-f195.google.com with SMTP id g2so748487qkd.12 for ; Thu, 15 Feb 2018 10:36:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VYmVkVWGGyqMpevtZSvcu2pub2x/3xqBEbEvA5uqiU8=; b=mef7q74ouJM2qP1sl611WWWNg7jlvWfp7vTivDbtDZ00fT/OTs4TVNeaKf3YNRr380 YTI/Jkx+307XHOZ8eQDaEuVBf10F1ipKS1oG/dRCbOnRlsd6sQdu4m7a/r6lDQsVdzZU 0dDi/jBXuTaBpfBP+lkX7g/4eolFDU/EcVg6UTNI6JRYVlT6/w+B8veEjUaJvBjiMvRx zWp32SUHniDTpE1naylMeoEwq5PJt4IFPTf5YhALAg8coWEZnM0MMHNZMs9oPcLYkqEh PKpoUusG5Iwr4SE/sLPSZgnjbfPWmVQM4b6xeSeg7UEwou7BXh9rRh2FfHjFwiLZTGJa kk2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VYmVkVWGGyqMpevtZSvcu2pub2x/3xqBEbEvA5uqiU8=; b=ZMXuIm2zdFWStsKOtW0l4QkRYnDP7ZlE7qYbTRGjNJJ2IFdqkuP8tiQYNTi2lseYko OD6E1WS+b0Otd+Zdp0owuq9P7xs+P+WDgdigSbAtS/LjNJVkcgY4UIu5k0LoEoWh0vj9 h1zq7eQlIIxxJ+Bi9/4ORuh88GP0SuheOX0tzqYxl2mpAqybmKoTHlEkQDlP9G0Nc2tV Z5TstJPQXTytKRXDpUBg5bZWnLJtFFyZbZIR9xLwVouKp58a7MeUHdP+dJtgFqeFQ1Dk grnmsPVAP223IdQKKiIRBFNjn80MxYhaAlvrkNMaQptwozzz7kecd5Q5SXXhf8F+3Etm Md6w== X-Gm-Message-State: APf1xPAL0asSfktxrT0t8URVbUjj3Us1F0nExW7rwp83o2q9OgUQOZ+p ZVbOY1xRZsY6vSYvsOJB8CM= X-Google-Smtp-Source: AH8x224JAeY3WlBoBHv14HiGNq4owdd6XtM9k55UiZo0Eq3/EEvYL2uXhsm4Qx1xfsLIjl0opNmz8Q== X-Received: by 10.55.27.27 with SMTP id b27mr5340156qkb.19.1518719810396; Thu, 15 Feb 2018 10:36:50 -0800 (PST) Received: from localhost.localdomain ([2804:14c:482:b3e:b9e4:e2b1:ec95:462c]) by smtp.gmail.com with ESMTPSA id s4sm1008108qta.34.2018.02.15.10.36.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Feb 2018 10:36:49 -0800 (PST) From: Fabio Estevam To: broonie@kernel.org Date: Thu, 15 Feb 2018 16:36:49 -0200 Message-Id: <1518719809-14987-1-git-send-email-festevam@gmail.com> X-Mailer: git-send-email 2.7.4 Cc: Fabio Estevam , eric@nelint.com, alsa-devel@alsa-project.org, max.krummenacher@toradex.com Subject: [alsa-devel] [PATCH v2] ASoC: sgtl5000: Fix suspend/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 From: Fabio Estevam Commit 8419caa72702 ("ASoC: sgtl5000: Do not disable regulators in SND_SOC_BIAS_OFF") causes the sgtl5000 to fail after a suspend/resume sequence: # aplay /media/a2002011001-e02.wav Playing WAVE '/media/a2002011001-e02.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo aplay: pcm_write:2051: write error: Input/output error The problem is caused by the fact that the aforementioned commit dropped the cache handling, so re-introduce the register map resync to fix the problem. Suggested-by: Mark Brown Signed-off-by: Fabio Estevam --- Changes since v1: - Re-introduce cache handling (Mark). Mark, If this gets applied into next, then I can generate the fixes for the 4.9 and 4.14 stable versions later. Thanks sound/soc/codecs/sgtl5000.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/codecs/sgtl5000.c b/sound/soc/codecs/sgtl5000.c index c26ac22..7514c77 100644 --- a/sound/soc/codecs/sgtl5000.c +++ b/sound/soc/codecs/sgtl5000.c @@ -871,15 +871,26 @@ static int sgtl5000_pcm_hw_params(struct snd_pcm_substream *substream, static int sgtl5000_set_bias_level(struct snd_soc_component *component, enum snd_soc_bias_level level) { + struct sgtl5000_priv *sgtl = snd_soc_component_get_drvdata(component); + int ret; + switch (level) { case SND_SOC_BIAS_ON: case SND_SOC_BIAS_PREPARE: case SND_SOC_BIAS_STANDBY: + regcache_cache_only(sgtl->regmap, false); + ret = regcache_sync(sgtl->regmap); + if (ret) { + regcache_cache_only(sgtl->regmap, true); + return ret; + } + snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, SGTL5000_REFTOP_POWERUP); break; case SND_SOC_BIAS_OFF: + regcache_cache_only(sgtl->regmap, true); snd_soc_component_update_bits(component, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, 0); break;