Linux Sound subsystem development
 help / color / mirror / Atom feed
From: David Cemin <dcemin@nvidia.com>
To: Takashi Iwai <tiwai@suse.com>
Cc: Jaroslav Kysela <perex@perex.cz>,
	linux-sound@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller
Date: Sat, 12 Sep 2026 11:21:20 -0700	[thread overview]
Message-ID: <20260912182120.1156356-1-dcemin@nvidia.com> (raw)

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


             reply	other threads:[~2026-09-12 18:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-12 18:21 David Cemin [this message]
2026-09-13  7:09 ` [PATCH] ALSA: hda/acpi: add runtime PM suspend/resume to the ACPI controller Takashi Iwai

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=20260912182120.1156356-1-dcemin@nvidia.com \
    --to=dcemin@nvidia.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=perex@perex.cz \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox