diff mbox series

[1/2] ALSA: hda - Don't trigger jackpoll_work in azx_resume

Message ID 20190319012844.6543-1-hui.wang@canonical.com (mailing list archive)
State New, archived
Headers show
Series [1/2] ALSA: hda - Don't trigger jackpoll_work in azx_resume | expand

Commit Message

Hui Wang March 19, 2019, 1:28 a.m. UTC
The commit 3baffc4a84d7 (ALSA: hda/intel: Refactoring PM code) changed
the behaviour of azx_resume(), it triggers the jackpoll_work after
applying this commit.

This change introduced a new issue, all codecs are runtime active
after S3, and will not call runtime_suspend() automatically.

The root cause is the jackpoll_work calls snd_hda_power_up/down_pm,
and it calls up_pm before snd_hdac_enter_pm is called, while calls
the down_pm in the middle of enter_pm and leave_pm is called. This
makes the dev->power.usage_count unbalanced after S3.

To fix it, let azx_resume() don't trigger jackpoll_work as before
it did.

Fixes:  3baffc4a84d7 (ALSA: hda/intel: Refactoring PM code)
Signed-off-by: Hui Wang <hui.wang@canonical.com>
---
 sound/pci/hda/hda_intel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Takashi Iwai March 19, 2019, 5:56 a.m. UTC | #1
On Tue, 19 Mar 2019 02:28:43 +0100,
Hui Wang wrote:
> 
> The commit 3baffc4a84d7 (ALSA: hda/intel: Refactoring PM code) changed
> the behaviour of azx_resume(), it triggers the jackpoll_work after
> applying this commit.
> 
> This change introduced a new issue, all codecs are runtime active
> after S3, and will not call runtime_suspend() automatically.
> 
> The root cause is the jackpoll_work calls snd_hda_power_up/down_pm,
> and it calls up_pm before snd_hdac_enter_pm is called, while calls
> the down_pm in the middle of enter_pm and leave_pm is called. This
> makes the dev->power.usage_count unbalanced after S3.
> 
> To fix it, let azx_resume() don't trigger jackpoll_work as before
> it did.
> 
> Fixes:  3baffc4a84d7 (ALSA: hda/intel: Refactoring PM code)
> Signed-off-by: Hui Wang <hui.wang@canonical.com>

Applied, thanks.


Takashi
diff mbox series

Patch

diff --git a/sound/pci/hda/hda_intel.c b/sound/pci/hda/hda_intel.c
index e5c49003e75f..59e6af2db847 100644
--- a/sound/pci/hda/hda_intel.c
+++ b/sound/pci/hda/hda_intel.c
@@ -947,7 +947,7 @@  static void __azx_runtime_suspend(struct azx *chip)
 	display_power(chip, false);
 }
 
-static void __azx_runtime_resume(struct azx *chip)
+static void __azx_runtime_resume(struct azx *chip, bool from_rt)
 {
 	struct hda_intel *hda = container_of(chip, struct hda_intel, chip);
 	struct hdac_bus *bus = azx_bus(chip);
@@ -964,7 +964,7 @@  static void __azx_runtime_resume(struct azx *chip)
 	azx_init_pci(chip);
 	hda_intel_init_chip(chip, true);
 
-	if (status) {
+	if (status && from_rt) {
 		list_for_each_codec(codec, &chip->bus)
 			if (status & (1 << codec->addr))
 				schedule_delayed_work(&codec->jackpoll_work,
@@ -1016,7 +1016,7 @@  static int azx_resume(struct device *dev)
 			chip->msi = 0;
 	if (azx_acquire_irq(chip, 1) < 0)
 		return -EIO;
-	__azx_runtime_resume(chip);
+	__azx_runtime_resume(chip, false);
 	snd_power_change_state(card, SNDRV_CTL_POWER_D0);
 
 	trace_azx_resume(chip);
@@ -1081,7 +1081,7 @@  static int azx_runtime_resume(struct device *dev)
 	chip = card->private_data;
 	if (!azx_has_pm_runtime(chip))
 		return 0;
-	__azx_runtime_resume(chip);
+	__azx_runtime_resume(chip, true);
 
 	/* disable controller Wake Up event*/
 	azx_writew(chip, WAKEEN, azx_readw(chip, WAKEEN) &