linux-stable/sound/pci/hda
Ville Syrjälä 30ff5957c3 ALSA: hda - Autosuspend controller after probe even if codecs are already suspended
azx_probe_continue() uses pm_runtime_put_noidle() to drop the rpm
usage_count, which means that if it's the last reference the
autosuspend of the controller won't actually happen. So if the codecs
autosuspend before the azx_probe_continue() drops the last
reference we'll fail to autosuspend the controller. This does happen
in practice, but not every time. As can be seen in [1] the controller
autosuspend attempt fails due to the usage_count when suspending the
codecs. A bit later we see the the contoller usage_count dropping to
zero without further attempts at autosuspend.

Fix the problem by using pm_runtime_put_autosuspend() instead, which
will kick off the autosuspend of the controller even if the codecs
are already asleep. As can be seen in [2] the controller autosuspend
still fails while suspending the codecs, but later on we see another
autosuspend attempt after dropping the usage_count to 0.

I was also a bit worried that there might still be a race between the
controller autosuspend and the rest of the code in azx_probe_continue().
So I also tried replacing the the put_noidle() with put_sync_suspend().
No explosions occurred, so I'm somewhat satisfied that there are no
serious problems in this area.

[1]
 kworker/1:2-122   [001] ....    63.661310: __pm_runtime_suspend: hdaudioC0D0 usage_count 0
 kworker/1:2-122   [001] d..2    63.661316: rpm_suspend: hdaudioC0D0 flags-d cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/1:2-122   [001] d..1    63.661317: rpm_check_suspend_allowed: hdaudioC0D0 retval 0
 kworker/1:2-122   [001] d..2    63.661332: rpm_return_int: rpm_suspend+0x406/0x5e8:hdaudioC0D0 ret=0
 kworker/1:1-72    [001] d..2    63.661543: rpm_suspend: hdaudioC0D0 flags-a cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/1:1-72    [001] d..1    63.661544: rpm_check_suspend_allowed: hdaudioC0D0 retval 0
 kworker/1:1-72    [001] ....    63.661545: hda_codec_runtime_suspend: hdaudioC0D0 suspend
 kworker/1:1-72    [001] d..2    63.661614: rpm_idle: 0000:00:03.0 flags-1 cnt-1  dep-0  auto-1 p-0 irq-0 child-0
 kworker/1:1-72    [001] d..1    63.661615: rpm_check_suspend_allowed: 0000:00:03.0 usage_count 1
 kworker/1:1-72    [001] d..1    63.661615: rpm_check_suspend_allowed: 0000:00:03.0 retval -11
 kworker/1:1-72    [001] d..2    63.661616: rpm_return_int: rpm_idle+0x249/0x487:0000:00:03.0 ret=-11
 kworker/1:1-72    [001] d..2    63.661616: rpm_return_int: rpm_suspend+0x406/0x5e8:hdaudioC0D0 ret=0
 kworker/1:2-122   [001] d..2    63.664834: rpm_idle: hdaudioC0D0 flags-8 cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/1:2-122   [001] d..1    63.664835: rpm_check_suspend_allowed: hdaudioC0D0 retval 1
 kworker/1:2-122   [001] d..2    63.664836: rpm_return_int: rpm_idle+0x249/0x487:hdaudioC0D0 ret=-11
 kworker/1:2-122   [001] d..2    63.664841: rpm_idle: hdaudioC0D0 flags-8 cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/1:2-122   [001] d..1    63.664841: rpm_check_suspend_allowed: hdaudioC0D0 retval 1
 kworker/1:2-122   [001] d..2    63.664841: rpm_return_int: rpm_idle+0x249/0x487:hdaudioC0D0 ret=-11
 kworker/1:2-122   [001] ....    63.664842: azx_probe_continue: 0000:00:03.0 usage_count=0

[2]
 kworker/0:0-4     [000] ....    50.354567: __pm_runtime_suspend: hdaudioC0D0 usage_count 0
 kworker/0:0-4     [000] d..2    50.354574: rpm_suspend: hdaudioC0D0 flags-d cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:0-4     [000] d..1    50.354575: rpm_check_suspend_allowed: hdaudioC0D0 retval 0
 kworker/0:0-4     [000] d..2    50.354589: rpm_return_int: rpm_suspend+0x406/0x5e8:hdaudioC0D0 ret=0
 kworker/0:2-135   [000] d..2    50.354809: rpm_suspend: hdaudioC0D0 flags-a cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:2-135   [000] d..1    50.354810: rpm_check_suspend_allowed: hdaudioC0D0 retval 0
 kworker/0:2-135   [000] ....    50.354816: hda_codec_runtime_suspend: hdaudioC0D0 suspend
 kworker/0:2-135   [000] d..2    50.354908: rpm_idle: 0000:00:03.0 flags-1 cnt-1  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:2-135   [000] d..1    50.354909: rpm_check_suspend_allowed: 0000:00:03.0 usage_count 1
 kworker/0:2-135   [000] d..1    50.354909: rpm_check_suspend_allowed: 0000:00:03.0 retval -11
 kworker/0:2-135   [000] d..2    50.354909: rpm_return_int: rpm_idle+0x249/0x487:0000:00:03.0 ret=-11
 kworker/0:2-135   [000] d..2    50.354910: rpm_return_int: rpm_suspend+0x406/0x5e8:hdaudioC0D0 ret=0
 kworker/0:0-4     [000] d..2    50.373791: rpm_idle: hdaudioC0D0 flags-8 cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:0-4     [000] d..1    50.373792: rpm_check_suspend_allowed: hdaudioC0D0 retval 1
 kworker/0:0-4     [000] d..2    50.373793: rpm_return_int: rpm_idle+0x249/0x487:hdaudioC0D0 ret=-11
 kworker/0:0-4     [000] d..2    50.373797: rpm_idle: hdaudioC0D0 flags-8 cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:0-4     [000] d..1    50.373798: rpm_check_suspend_allowed: hdaudioC0D0 retval 1
 kworker/0:0-4     [000] d..2    50.373798: rpm_return_int: rpm_idle+0x249/0x487:hdaudioC0D0 ret=-11
 kworker/0:0-4     [000] ....    50.373799: __pm_runtime_suspend: 0000:00:03.0 usage_count 0
 kworker/0:0-4     [000] d..2    50.373800: rpm_suspend: 0000:00:03.0 flags-d cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:0-4     [000] d..1    50.373800: rpm_check_suspend_allowed: 0000:00:03.0 retval 0
 kworker/0:0-4     [000] d..2    50.373803: rpm_return_int: rpm_suspend+0x406/0x5e8:0000:00:03.0 ret=0
 kworker/0:0-4     [000] d..2    50.385164: rpm_suspend: 0000:00:03.0 flags-a cnt-0  dep-0  auto-1 p-0 irq-0 child-0
 kworker/0:0-4     [000] d..1    50.385165: rpm_check_suspend_allowed: 0000:00:03.0 retval 0
 kworker/0:0-4     [000] ....    50.385174: azx_runtime_suspend: 0000:00:03.0 azx suspend releaseing power well
 kworker/0:0-4     [000] ....    50.385179: azx_runtime_suspend: 0000:00:03.0 azx suspend
 kworker/0:0-4     [000] d..2    50.386872: rpm_return_int: rpm_suspend+0x406/0x5e8:0000:00:03.0 ret=0

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2016-02-26 20:18:48 +01:00
..
ca0132_regs.h ALSA: hda: ca0132_regs.h: Fix typo in include guard 2014-08-22 11:24:11 +02:00
dell_wmi_helper.c
hda_auto_parser.c ALSA: hda - remove no physical connection pins from pin_quirk table 2015-08-03 10:16:20 +02:00
hda_auto_parser.h ALSA: hda - Sort input pins depending on amp caps 2014-09-23 15:57:32 +02:00
hda_beep.c ALSA: hda-beep: Update authors dead email address 2015-06-13 09:13:26 +02:00
hda_beep.h ALSA: hda-beep: Update authors dead email address 2015-06-20 09:24:40 +02:00
hda_bind.c ALSA: hda - Fix missing module loading with model=generic option 2016-01-20 15:56:42 +01:00
hda_codec.c ASoC: Updates for v4.4 2015-10-26 12:14:49 +01:00
hda_codec.h Merge branch 'topic/hda-modalias' into for-next 2015-10-20 10:19:40 +02:00
hda_controller.c ALSA: hda - Raise AZX_DCAPS_RIRB_DELAY handling into top drivers 2015-12-17 12:47:10 +01:00
hda_controller.h ALSA: hda - Drop unused AZX_DCAPS_REVERSE_ASSIGN 2015-12-17 12:47:18 +01:00
hda_controller_trace.h ALSA: hda - rename hda_intel_trace.h to hda_controller_trace.h 2015-05-18 10:06:32 +02:00
hda_eld.c ALSA: hda - Do zero-clear in snd_hdmi_parse_eld() itself 2015-12-04 15:06:45 +01:00
hda_generic.c ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
hda_generic.h ALSA: hda - Make snd_hda_parse_nid_path() local 2015-12-08 11:48:39 +01:00
hda_hwdep.c ALSA: hda - Add card field to hda_codec struct 2015-03-03 11:25:16 +01:00
hda_intel.c ALSA: hda - Autosuspend controller after probe even if codecs are already suspended 2016-02-26 20:18:48 +01:00
hda_intel.h ALSA: hda - Spell vga_switcheroo consistently 2015-10-19 11:00:45 +02:00
hda_intel_trace.h ALSA: hda - add hda_intel_trace.h 2015-05-18 10:06:44 +02:00
hda_jack.c ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
hda_jack.h ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
hda_local.h ALSA: hda: make use of core codec fns 2015-10-08 19:09:36 +02:00
hda_proc.c ALSA: hda/proc - Fix racy string access for power states 2015-08-17 15:12:04 +02:00
hda_sysfs.c ALSA: hda - consolidate chip rename functions 2015-10-15 14:05:28 +02:00
hda_tegra.c ALSA: hda - Raise AZX_DCAPS_RIRB_DELAY handling into top drivers 2015-12-17 12:47:10 +01:00
Kconfig ALSA: jack: Allow building the jack layer without input device 2016-02-23 09:03:07 +01:00
local.h ALSA: hda - Move a part of hda_codec stuff into hdac_device 2015-03-23 13:17:17 +01:00
Makefile ALSA: replace CONFIG_PROC_FS with CONFIG_SND_PROC_FS 2015-05-27 21:25:19 +02:00
patch_analog.c ALSA: hda - convert to hda_device_id 2015-10-20 10:15:20 +02:00
patch_ca0110.c ALSA: hda - convert to hda_device_id 2015-10-20 10:15:20 +02:00
patch_ca0132.c ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
patch_cirrus.c ALSA: hda - Add fixup for Mac Mini 7,1 model 2016-02-03 12:32:51 +01:00
patch_cmedia.c ALSA: hda - convert to hda_device_id 2015-10-20 10:15:20 +02:00
patch_conexant.c Merge branch 'for-linus' into for-next 2015-12-03 17:36:02 +01:00
patch_hdmi.c ALSA: hda - hdmi eld control created based on pcm 2016-02-23 10:33:44 +01:00
patch_realtek.c ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
patch_si3054.c ALSA: hda - convert to hda_device_id 2015-10-20 10:15:20 +02:00
patch_sigmatel.c ALSA: hda - Fix bad dereference of jack object 2016-02-09 12:16:31 +01:00
patch_via.c ALSA: hda - convert to hda_device_id 2015-10-20 10:15:20 +02:00
thinkpad_helper.c ALSA: hda - Use acpi_dev_present() 2016-02-21 09:16:00 +01:00