From patchwork Thu Mar 11 17:59:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 12132277 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.7 required=3.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8B6CCC433E0 for ; Thu, 11 Mar 2021 18:02:43 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id DB5E564F94 for ; Thu, 11 Mar 2021 18:02:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DB5E564F94 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 3F58617CF; Thu, 11 Mar 2021 19:01:51 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 3F58617CF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1615485761; bh=lM8GOOCpvUTwlOOR+j55s0PnLGsgvCRMd2ds1GLpIqo=; h=From:To:Subject:Date:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=LtqrplcxfVzS4OnBpk8VXJA7sLlUTRrwXUOwM3OA5PIYpijANKlHxhAtUOYnC7A36 7D4Lwl0e49EK9ZYXTV73XELNf3LquR7ZjTmmFniLsbITdd4L8ql3iIXNuH3OIKbTA5 fBWjKhHUxqwIGjAvgbLGbXrXbCBA3ZkZ4tjpjGJE= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 494A8F8032D; Thu, 11 Mar 2021 19:00:23 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 89348F8032B; Thu, 11 Mar 2021 19:00:20 +0100 (CET) Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 4303CF80276 for ; Thu, 11 Mar 2021 19:00:10 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 4303CF80276 Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AS3GW0XC" Received: by mail-lj1-x231.google.com with SMTP id u20so3298576lja.13 for ; Thu, 11 Mar 2021 10:00:10 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=2SMSIMvYxaxu4F53i5qtc3hVUmETiEH2Ssz4CshQdOI=; b=AS3GW0XCPCtBu2eNd6+wVB3YLc3XmMhfJUoDml49eAVW6sBtpXvXDtkjEUHweHOhUX oZ4Elum7vmVDAF4QbluHt3Eww8U4DM2l5FfRmMNK/OyAgOqvkc+CC9R5zJv7f2sDPd1H B+6A1Krb5IMzHYb9DhRaCmy77BC+LmayAURKbHGqE/E7sW+KL0LkpKplwlsQcJh2igKB 2nPU3G0blwBkP8v1VnAovDO2FmWmgE19xb3kSp2fYiWriX9L4aJ6csMigU3OTlNYs+o7 BwJOKn4GhWdHIvIDl29i0ZvA1mNT+OdFmDTwilTmxrw5lbjGOOxktoCy2Mei79/NcL6D iNPQ== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=2SMSIMvYxaxu4F53i5qtc3hVUmETiEH2Ssz4CshQdOI=; b=gIA8hbVJ3ydWh93FFK5F3AnUidrYpNQbH8l5elRFmCmqu//7s6UIKo/QcK817k+Pg5 /+rn2EasMZ0HwqIfZ9LDPIKEiosNNzw/uAB9V98aIK2S4F4fZWyRkEv2iHroGRd2DJSu y34koXhUYjPxtFfy2EO0GRS7vhxLyEeYQ2CBtWd5HkWTwMnhfLsH0FtLOYPMpjg+iBjg t9xujr8NuCdSgHOaJ3Pu6RWIBIfFck+prYv5Jqm12swzQngUc985zXtdPyaXJyNc0YnA joURBqrh7jtNz7m/75zdOpF9cxp0dKsepglgXwh/fukRO7jjBwzcycf2VbiHA4qleRWA Vv4Q== X-Gm-Message-State: AOAM5316R2Lcb4MOOvTetsdb2S/WH10/Id6VutQ5O7pyhtfYbdenlFwH fMTepbW/KfCbZbogXsIhq7Y= X-Google-Smtp-Source: ABdhPJzquMAtNXxPNSc9ZahQypjTB6Ex+kG4p6Qn+zA6QSEthDwgSRlmNRnHxA+dZck2UE7SeQJRDQ== X-Received: by 2002:a2e:2f05:: with SMTP id v5mr64770ljv.114.1615485610280; Thu, 11 Mar 2021 10:00:10 -0800 (PST) Received: from localhost.localdomain (109-252-193-52.dynamic.spd-mgts.ru. [109.252.193.52]) by smtp.gmail.com with ESMTPSA id k18sm1014075lfm.88.2021.03.11.10.00.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 10:00:09 -0800 (PST) From: Dmitry Osipenko To: Thierry Reding , Jonathan Hunter , Mark Brown , Takashi Iwai , Jaroslav Kysela , Philipp Zabel , Paul Fertser Subject: [PATCH v4 3/5] ASoC: tegra30: i2s: Restore hardware state on runtime PM resume Date: Thu, 11 Mar 2021 20:59:56 +0300 Message-Id: <20210311175958.7433-4-digetx@gmail.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210311175958.7433-1-digetx@gmail.com> References: <20210311175958.7433-1-digetx@gmail.com> MIME-Version: 1.0 Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 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" Tegra30 I2S driver syncs regmap cache only on resume from system suspend, but hardware is reset across the runtime suspend because RPM of the parent AHUB driver resets the I2S hardware, hence h/w state is lost after each RPM resume. The problem isn't visible because hardware happens to be fully reprogrammed after each RPM resume. Move hardware syncing to RPM resume in order to restore h/w state properly. Fixes: ed9ce1ed2239 ("ASoC: tegra: ahub: Reset hardware properly") Signed-off-by: Dmitry Osipenko --- sound/soc/tegra/tegra30_i2s.c | 40 +++++++++++------------------------ 1 file changed, 12 insertions(+), 28 deletions(-) diff --git a/sound/soc/tegra/tegra30_i2s.c b/sound/soc/tegra/tegra30_i2s.c index 6740df541508..3d22c1be6f3d 100644 --- a/sound/soc/tegra/tegra30_i2s.c +++ b/sound/soc/tegra/tegra30_i2s.c @@ -58,8 +58,18 @@ static int tegra30_i2s_runtime_resume(struct device *dev) } regcache_cache_only(i2s->regmap, false); + regcache_mark_dirty(i2s->regmap); + + ret = regcache_sync(i2s->regmap); + if (ret) + goto disable_clocks; return 0; + +disable_clocks: + clk_disable_unprepare(i2s->clk_i2s); + + return ret; } static int tegra30_i2s_set_fmt(struct snd_soc_dai *dai, @@ -551,37 +561,11 @@ static int tegra30_i2s_platform_remove(struct platform_device *pdev) return 0; } -#ifdef CONFIG_PM_SLEEP -static int tegra30_i2s_suspend(struct device *dev) -{ - struct tegra30_i2s *i2s = dev_get_drvdata(dev); - - regcache_mark_dirty(i2s->regmap); - - return 0; -} - -static int tegra30_i2s_resume(struct device *dev) -{ - struct tegra30_i2s *i2s = dev_get_drvdata(dev); - int ret; - - ret = pm_runtime_get_sync(dev); - if (ret < 0) { - pm_runtime_put(dev); - return ret; - } - ret = regcache_sync(i2s->regmap); - pm_runtime_put(dev); - - return ret; -} -#endif - static const struct dev_pm_ops tegra30_i2s_pm_ops = { SET_RUNTIME_PM_OPS(tegra30_i2s_runtime_suspend, tegra30_i2s_runtime_resume, NULL) - SET_SYSTEM_SLEEP_PM_OPS(tegra30_i2s_suspend, tegra30_i2s_resume) + SET_SYSTEM_SLEEP_PM_OPS(pm_runtime_force_suspend, + pm_runtime_force_resume) }; static struct platform_driver tegra30_i2s_driver = {