All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Paul Fertser <fercerpav@gmail.com>
Cc: alsa-devel@alsa-project.org, devicetree@vger.kernel.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 03/17] ASoC: tegra30: i2s: Restore hardware state on runtime PM resume
Date: Sun, 14 Mar 2021 18:44:45 +0300	[thread overview]
Message-ID: <20210314154459.15375-4-digetx@gmail.com> (raw)
In-Reply-To: <20210314154459.15375-1-digetx@gmail.com>

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 <digetx@gmail.com>
---
 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 = {
-- 
2.30.2


WARNING: multiple messages have this Message-ID (diff)
From: Dmitry Osipenko <digetx@gmail.com>
To: Thierry Reding <thierry.reding@gmail.com>,
	Jonathan Hunter <jonathanh@nvidia.com>,
	Mark Brown <broonie@kernel.org>, Takashi Iwai <tiwai@suse.com>,
	Jaroslav Kysela <perex@perex.cz>,
	Philipp Zabel <p.zabel@pengutronix.de>,
	Paul Fertser <fercerpav@gmail.com>
Cc: linux-tegra@vger.kernel.org, devicetree@vger.kernel.org,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH v5 03/17] ASoC: tegra30: i2s: Restore hardware state on runtime PM resume
Date: Sun, 14 Mar 2021 18:44:45 +0300	[thread overview]
Message-ID: <20210314154459.15375-4-digetx@gmail.com> (raw)
In-Reply-To: <20210314154459.15375-1-digetx@gmail.com>

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 <digetx@gmail.com>
---
 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 = {
-- 
2.30.2


  parent reply	other threads:[~2021-03-14 15:46 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-14 15:44 [PATCH v5 00/17] Fix reset controls and RPM of NVIDIA Tegra ASoC drivers Dmitry Osipenko
2021-03-14 15:44 ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 01/17] ASoC: tegra20: ac97: Add reset control Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 02/17] ASoC: tegra20: i2s: " Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` Dmitry Osipenko [this message]
2021-03-14 15:44   ` [PATCH v5 03/17] ASoC: tegra30: i2s: Restore hardware state on runtime PM resume Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 04/17] reset: Add reset_control_bulk API Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 05/17] ASoC: tegra30: ahub: Switch to use reset-bulk API Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 06/17] ASoC: tegra20: spdif: Correct driver removal order Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 07/17] ASoC: tegra20: spdif: Remove handing of disabled runtime PM Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 08/17] ASoC: tegra20: i2s: Add system level suspend-resume callbacks Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 09/17] ASoC: tegra20: i2s: Correct driver removal order Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 10/17] ASoC: tegra20: i2s: Use devm_clk_get() Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 11/17] ASoC: tegra20: i2s: Remove handing of disabled runtime PM Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 12/17] ASoC: tegra30: i2s: Correct driver removal order Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 13/17] ASoC: tegra30: i2s: Use devm_clk_get() Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 14/17] ASoC: tegra30: i2s: Remove handing of disabled runtime PM Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 15/17] ASoC: tegra30: ahub: Reset global variable Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 16/17] ASoC: tegra30: ahub: Correct suspend-resume callbacks Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-14 15:44 ` [PATCH v5 17/17] ASoC: tegra30: ahub: Remove handing of disabled runtime PM Dmitry Osipenko
2021-03-14 15:44   ` Dmitry Osipenko
2021-03-17 17:20 ` [PATCH v5 00/17] Fix reset controls and RPM of NVIDIA Tegra ASoC drivers Dmitry Osipenko
2021-03-17 17:20   ` Dmitry Osipenko
2021-03-17 17:54   ` Mark Brown
2021-03-17 17:54     ` Mark Brown
2021-03-17 18:12     ` Dmitry Osipenko
2021-03-17 18:12       ` Dmitry Osipenko
2021-03-18 18:33 ` Mark Brown
2021-03-18 18:36   ` Mark Brown
2021-03-18 18:36   ` Mark Brown
2021-03-18 18:33   ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210314154459.15375-4-digetx@gmail.com \
    --to=digetx@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=fercerpav@gmail.com \
    --cc=jonathanh@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=perex@perex.cz \
    --cc=thierry.reding@gmail.com \
    --cc=tiwai@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.