From patchwork Fri Feb 16 13:58:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabio Estevam X-Patchwork-Id: 10224783 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 55514602CB for ; Fri, 16 Feb 2018 13:59:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4381B29360 for ; Fri, 16 Feb 2018 13:59:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3852B29474; Fri, 16 Feb 2018 13:59:01 +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 7D86D29360 for ; Fri, 16 Feb 2018 13:59:00 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 0961D267E4C; Fri, 16 Feb 2018 14:58:59 +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 E48B9267E4E; Fri, 16 Feb 2018 14:58:57 +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 503A3267E3C for ; Fri, 16 Feb 2018 14:58:55 +0100 (CET) Received: by mail-qk0-f195.google.com with SMTP id o7so3866451qkc.1 for ; Fri, 16 Feb 2018 05:58:55 -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=lsnJa0u+hitEN01wcuNiQdMUqyVP+sMHN/p7/oN30tM=; b=X2Z2h+nomGG60WnPaE/hzj58HnheBcdBGx4Y4jOjn9mWEzso1OOhVZpbEL+J5SuaGY iO9j4fg9ooVvXeu3lY6Ag3K9FvkA2wkz3prQZ0WGthPrrcfW0/tTYvpMyomtgEU64KGj 3FOBfeW9LY4KNnXyIccR1JNZD0XW+YEMCg25/9FFHNY26CQc2aQvSAp/ZkTHSABW539+ vUZik02Hm/KSqtyGLVaLjLaStrmM63A9xZNAcqBiVWWy9YGmdZWdxQWteIqSU4rTzhuw v9+mWkuK8mbT5etyZAVIfD24i35OiWZ99ou2Oq56455N8DtC2Th9J6Q6uD6pK3EXdq51 CsKw== 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=lsnJa0u+hitEN01wcuNiQdMUqyVP+sMHN/p7/oN30tM=; b=ZKEvG+/FJCuEo6ORvlVubk7bz0IWA2XcRT/0XRsQ3aSknjuiT40YurZbGQbXIFIc78 /rhZLCOejFX70RbzKWOq75SbWE5e75Hk6hfP/3yS42toczVRIbmsOolTpvZnIn6Eid4K C/IGyWRaiGhBH96eshHYWpCstPMM2GD2lH3QuJkDg8+yiE+fnIIbM2+noXjxqS351VJa LX0h9thSHvnC0rHn/qgtRb9EQwDZBaWOZRb3WHGdOVVb9flOP5Cs6lcns/9rN3rxNjby LZ3X6+9y8p4lkLrjELPIUra4TdbWZAuO38aJi2y9KsE7/6T5z8GsWqtixIChXPXiXutW b2qQ== X-Gm-Message-State: APf1xPDeMwz/hHiMzx1fUfiswJVvSCQGiLLtFpV4l1VXv5YjdHUADas4 hdhdeKf/RX+VY3KNdY0PPE8= X-Google-Smtp-Source: AH8x226Nfwex7M08aQZ/a9aa++FSBesoeb0yH9cnSBTTsfG6TS73C0bpspTB/xTf9NtvvEvv9KtuUA== X-Received: by 10.55.217.220 with SMTP id q89mr10039030qkl.64.1518789534047; Fri, 16 Feb 2018 05:58:54 -0800 (PST) Received: from localhost.localdomain ([2804:14c:482:b3e:db8:f639:de4d:67f6]) by smtp.gmail.com with ESMTPSA id k67sm5896038qkh.95.2018.02.16.05.58.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Feb 2018 05:58:53 -0800 (PST) From: Fabio Estevam To: broonie@kernel.org Date: Fri, 16 Feb 2018 11:58:54 -0200 Message-Id: <1518789534-11828-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, stable@vger.kernel.org, max.krummenacher@toradex.com Subject: [alsa-devel] [PATCH v3] 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. Cc: Suggested-by: Mark Brown Signed-off-by: Fabio Estevam --- Changes since v2: - Rebased against Linus' tree 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 e1ab553..7ff5cb7 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_codec *codec, enum snd_soc_bias_level level) { + struct sgtl5000_priv *sgtl = snd_soc_codec_get_drvdata(codec); + 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_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, SGTL5000_REFTOP_POWERUP); break; case SND_SOC_BIAS_OFF: + regcache_cache_only(sgtl->regmap, true); snd_soc_update_bits(codec, SGTL5000_CHIP_ANA_POWER, SGTL5000_REFTOP_POWERUP, 0); break;