Linux Tegra architecture development
 help / color / mirror / Atom feed
* [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller
@ 2026-09-12 18:21 David Cemin
  2026-09-13  7:09 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: David Cemin @ 2026-09-12 18:21 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Jaroslav Kysela, linux-sound, linux-tegra

The hda-acpi platform driver never enables runtime PM, so
pm_runtime_force_suspend() in hda_acpi_suspend() skips the runtime
callbacks. On resume the controller is therefore never re-initialised:
azx_init_chip() is called only at probe time, so after S3 the codec
verbs time out and audio is dead until the driver is rebound.

Add explicit runtime_suspend/runtime_resume callbacks and invoke them
from the system-sleep paths, mirroring the pattern used by snd-hda-intel.
Tested on an arm64 platform with the NVDA2014 controller: resume latency
drops from 81.5 s to 3.6 s and audio is live immediately after wake.

Signed-off-by: David Cemin <dcemin@nvidia.com>
---
 sound/hda/controllers/acpi.c | 41 ++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/sound/hda/controllers/acpi.c b/sound/hda/controllers/acpi.c
index 505cc97e0ee9..04b261dde22e 100644
--- a/sound/hda/controllers/acpi.c
+++ b/sound/hda/controllers/acpi.c
@@ -266,6 +266,38 @@ static void hda_acpi_shutdown(struct platform_device *pdev)
 		azx_stop_chip(chip);
 }
 
+static int hda_acpi_runtime_suspend(struct device *dev)
+{
+	struct snd_card *card = dev_get_drvdata(dev);
+	struct azx *chip = card->private_data;
+
+	if (chip && chip->running) {
+		/* enable controller wake up event */
+		azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) |
+			   STATESTS_INT_MASK);
+
+		azx_stop_chip(chip);
+		azx_enter_link_reset(chip);
+	}
+
+	return 0;
+}
+
+static int hda_acpi_runtime_resume(struct device *dev)
+{
+	struct snd_card *card = dev_get_drvdata(dev);
+	struct azx *chip = card->private_data;
+
+	if (chip && chip->running) {
+		azx_init_chip(chip, 1);
+		/* disable controller wake up event */
+		azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &
+			   ~STATESTS_INT_MASK);
+	}
+
+	return 0;
+}
+
 static int hda_acpi_suspend(struct device *dev)
 {
 	struct snd_card *card = dev_get_drvdata(dev);
@@ -274,6 +306,12 @@ static int hda_acpi_suspend(struct device *dev)
 	rc = pm_runtime_force_suspend(dev);
 	if (rc < 0)
 		return rc;
+	/*
+	 * Runtime PM is never enabled for this device, so the force_suspend
+	 * above does not reach the runtime callback; stop the controller
+	 * explicitly.
+	 */
+	hda_acpi_runtime_suspend(dev);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
 
 	return 0;
@@ -287,6 +325,8 @@ static int hda_acpi_resume(struct device *dev)
 	rc = pm_runtime_force_resume(dev);
 	if (rc < 0)
 		return rc;
+	/* See hda_acpi_suspend(): re-init the controller explicitly. */
+	hda_acpi_runtime_resume(dev);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 
 	return 0;
@@ -294,6 +334,7 @@ static int hda_acpi_resume(struct device *dev)
 
 static const struct dev_pm_ops hda_acpi_pm = {
 	SYSTEM_SLEEP_PM_OPS(hda_acpi_suspend, hda_acpi_resume)
+	RUNTIME_PM_OPS(hda_acpi_runtime_suspend, hda_acpi_runtime_resume, NULL)
 };
 
 static const struct hda_data nvidia_hda_data = {

base-commit: 841e384b841a3d89c50b4b2d6c5bb6abab1a7e39
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller
  2026-09-12 18:21 [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller David Cemin
@ 2026-09-13  7:09 ` Takashi Iwai
  0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-09-13  7:09 UTC (permalink / raw)
  To: David Cemin; +Cc: Takashi Iwai, Jaroslav Kysela, linux-sound, linux-tegra

On Sat, 12 Sep 2026 20:21:20 +0200,
David Cemin wrote:
> 
> The hda-acpi platform driver never enables runtime PM, so
> pm_runtime_force_suspend() in hda_acpi_suspend() skips the runtime
> callbacks. On resume the controller is therefore never re-initialised:
> azx_init_chip() is called only at probe time, so after S3 the codec
> verbs time out and audio is dead until the driver is rebound.
> 
> Add explicit runtime_suspend/runtime_resume callbacks and invoke them
> from the system-sleep paths, mirroring the pattern used by snd-hda-intel.
> Tested on an arm64 platform with the NVDA2014 controller: resume latency
> drops from 81.5 s to 3.6 s and audio is live immediately after wake.
> 
> Signed-off-by: David Cemin <dcemin@nvidia.com>

Applied to for-next branch.  Thanks.


Takashi

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-13  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-12 18:21 [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller David Cemin
2026-09-13  7:09 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox