ASoC: codecs: pcm3168a: Fix and updates for power management
Subsystems (3)
cover ASoC: codecs: pcm3168a: Fix and updates for power management
Set of changes composed of one fix and two improvements.
The fix leads the series and addresses "unbalanced disables" coming from the regulator core during S4 (hibernation) scenario.
The SLEEP_PM_OPS are unset for the driver. Hibernation (S4) causes no resume (skipped thanks to smart_suspend=true) yet still performs the suspend sequence unconditionally, see device_complete() in drivers/base/power/main.c. In essence, we end up with double suspend (double disable) and thus the warning. Exemplary stack:
unbalanced disables for regulator-dummy
WARNING: drivers/regulator/core.c:3244 at _regulator_disable+0x161/0x270, CPU#6: kworker/u64:2/120 (...) Workqueue: pm pm_runtime_work RIP: 0010:_regulator_disable+0x161/0x270 (...) Call Trace: <TASK> regulator_bulk_disable+0xe4/0x220 ? __pfx_regulator_bulk_disable+0x10/0x10 ? pick_next_task_fair+0x36f/0x11f0 ? __pfx_regmap_unlock_mutex+0x10/0x10 ? regmap_unlock_mutex+0xe/0x20 pcm3168a_rt_suspend+0x57/0x90 [snd_soc_pcm3168a] ? __pfx_pcm3168a_rt_suspend+0x10/0x10 [snd_soc_pcm3168a] __rpm_callback+0x69/0x200 ? __pfx_pcm3168a_rt_suspend+0x10/0x10 [snd_soc_pcm3168a] rpm_callback+0xbc/0xd0 rpm_suspend+0x225/0x960 ? __pfx_rpm_suspend+0x10/0x10 ? __kasan_check_write+0x14/0x20 ? _raw_spin_lock_irq+0x8d/0xe0 ? __pfx__raw_spin_lock_irq+0x10/0x10 ? pwq_dec_nr_in_flight+0x63/0x4f0 pm_runtime_work+0xd0/0xf0
In regard to the improvements, both aim to drop redundant operations. One targets pm_runtime_idle() - no need to fire it manually, device-driver core will do that for us - while the second replaces preprocessor directive with pm_runtime_status_suspended() check. No !CONFIG_PM dependency equals better code coverege with default kconfigs.
Cezary Rojewski (3):
ASoC: codecs: pcm3168a: Prevent regulator double-disable in S4
ASoC: codecs: pcm3168a: Drop redundant pm_runtime_idle()
ASoC: codecs: pcm3168a: Drop CONFIG_PM-conditional preproc directive
sound/soc/codecs/pcm3168a.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 ASoC: codecs: pcm3168a: Prevent regulator double-disable in S4
The SLEEP_PM_OPS are unset for the driver. Hibernation (S4) causes no resume (skipped thanks to smart_suspend=true) yet still performs the suspend sequence unconditionally, see device_complete() in drivers/base/power/main.c.
If S4 runs for already suspended pcm3168a device, we end up with "unbalanced disables" warning from the regulators. Assigning the operations fixes the problem.
--- sound/soc/codecs/pcm3168a.c | 1 + 1 file changed, 1 insertion(+)
sound/soc/codecs/pcm3168a.c +1 -0
@@ -907,6 +907,7 @@ static int pcm3168a_rt_suspend(struct device *dev)EXPORT_GPL_DEV_PM_OPS (pcm3168a_pm_ops) = { RUNTIME_PM_OPS(pcm3168a_rt_suspend, pcm3168a_rt_resume, NULL) +SYSTEM_SLEEP_PM_OPS (pm_runtime_force_suspend, pm_runtime_force_resume) };MODULE_DESCRIPTION ("PCM3168A codec driver" );
Signature · 1 line
2.34.1
PATCH 2/3 ASoC: codecs: pcm3168a: Drop redundant pm_runtime_idle()
In reply to Cezary RojewskiDevice-driver core runs pm_request_idle() right after the probing sequence already, see __driver_probe_device().
--- sound/soc/codecs/pcm3168a.c | 1 - 1 file changed, 1 deletion(-)
sound/soc/codecs/pcm3168a.c +0 -1
@@ -799,7 +799,6 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap)pm_runtime_set_active (dev);pm_runtime_enable (dev); -pm_runtime_idle (dev);memcpy (pcm3168a->dai_drv, pcm3168a_dais,sizeof (pcm3168a->dai_drv)); ret = devm_snd_soc_register_component(dev, &pcm3168a_driver,
Signature · 1 line
2.34.1
PATCH 3/3 ASoC: codecs: pcm3168a: Drop CONFIG_PM-conditional preproc directive
In reply to Cezary RojewskiRevert changes done in commit 489db5d94150 ("ASoC: pcm3168a:
Don't disable pcm3168a when CONFIG_PM defined") and add pm_runtime_status_suspended() check.
The suspended-check addresses regulator's "unbalanced disables" warning during driver removal even when CONFIG_PM is enabled.
--- sound/soc/codecs/pcm3168a.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-)
sound/soc/codecs/pcm3168a.c +7 -13
@@ -821,15 +821,6 @@ int pcm3168a_probe(struct device *dev, struct regmap *regmap) }EXPORT_SYMBOL_GPL (pcm3168a_probe); -static void pcm3168a_disable (struct device *dev) -{ -struct pcm3168a_priv *pcm3168a =dev_get_drvdata (dev); - -regulator_bulk_disable (ARRAY_SIZE (pcm3168a->supplies), - pcm3168a->supplies); -clk_disable_unprepare (pcm3168a->scki); -} -void pcm3168a_remove (struct device *dev) {struct pcm3168a_priv *pcm3168a =dev_get_drvdata (dev);
@@ -841,10 +832,12 @@ void pcm3168a_remove(struct device *dev)* The asserted level of GPIO_ACTIVE_LOW is LOW. */ gpiod_set_value_cansleep (pcm3168a->gpio_rst,1 ); +pm_runtime_disable (dev); -#ifndef CONFIG_PM -pcm3168a_disable (dev); -#endif +if (!pm_runtime_status_suspended (dev)) { +regulator_bulk_disable (ARRAY_SIZE (pcm3168a->supplies), pcm3168a->supplies); +clk_disable_unprepare (pcm3168a->scki); + } }EXPORT_SYMBOL_GPL (pcm3168a_remove);
@@ -899,7 +892,8 @@ static int pcm3168a_rt_suspend(struct device *dev)regcache_cache_only (pcm3168a->regmap, true); -pcm3168a_disable (dev); +regulator_bulk_disable (ARRAY_SIZE (pcm3168a->supplies), pcm3168a->supplies); +clk_disable_unprepare (pcm3168a->scki);return 0 ; }
Signature · 1 line
2.34.1
Mark Brown
maintainerQuoted 8 lines · Cezary Rojewski
ASoC: codecs: pcm3168a: Fix and updates for power management
Set of changes composed of one fix and two improvements.
The fix leads the series and addresses "unbalanced disables" coming from the regulator core during S4 (hibernation) scenario.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2
Thanks!
[1/3] ASoC: codecs: pcm3168a: Prevent regulator double-disable in S4
https://git.kernel.org/broonie/sound/c/bb3c847523f9 [2/3] ASoC: codecs: pcm3168a: Drop redundant pm_runtime_idle() https://git.kernel.org/broonie/sound/c/2c734439be9c [3/3] ASoC: codecs: pcm3168a: Drop CONFIG_PM-conditional preproc directive https://git.kernel.org/broonie/sound/c/eb7107264da8
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark