Bug 56171

Summary: Audio stop working after unplugging AC power
Product: Drivers Reporter: Nikita Tsukanov (keks9n)
Component: Sound(ALSA)Assignee: Jaroslav Kysela (perex)
Status: RESOLVED CODE_FIX    
Severity: normal CC: tiwai
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 3.9-rc5 Subsystem:
Regression: Yes Bisected commit-id:
Attachments: lsa-info with 42c364ace52ae6b4699105b39f2559c256b6cd4c, good
alsa-info with e152f18027552eb34006b35347e72bc805783027, bad
More output

Description Nikita Tsukanov 2013-04-03 09:34:47 UTC
Lenovo Thinkpad T520, Ubuntu 12.10
lshw -C sound
  *-multimedia            
       description: Audio device
       product: 6 Series/C200 Series Chipset Family High Definition Audio Controller
       vendor: Intel Corporation
       physical id: 1b
       bus info: pci@0000:00:1b.0
       version: 04
       width: 64 bits
       clock: 33MHz
       capabilities: pm msi pciexpress bus_master cap_list
       configuration: driver=snd_hda_intel latency=0
       resources: irq:45 memory:f2620000-f2623fff


After unplugging AC Power it repeats the last sound fragment until I plug power back, then I can hear nothing. After restarting alsa with "alsa force-reload" it seems to work as usual until the next time I unplug AC adapter.

It doesn't seem to be related to be related with powersaving since /sys/module/snd_hda_intel/parameters/power_save remains 0.
Comment 1 Takashi Iwai 2013-04-03 09:37:31 UTC
I have no other idea than the power-saving stuff if it's about HD-audio driver.

Is it a regression?  If so, could you bisect?
Comment 2 Nikita Tsukanov 2013-04-03 09:38:47 UTC
Sound works fine with kernels prior to 3.9. I'll try to find the exact commit caused the issue.
Comment 3 Nikita Tsukanov 2013-04-03 18:56:22 UTC
# git bisect log
git bisect start
# bad: [da241efcd9c3da2af6ba20055c7e158ec725005c] Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
git bisect bad da241efcd9c3da2af6ba20055c7e158ec725005c
# good: [19f949f52599ba7c3f67a5897ac6be14bfcb1200] Linux 3.8
git bisect good 19f949f52599ba7c3f67a5897ac6be14bfcb1200
# bad: [7c2db36e730ee4facd341679ecb21ee73ba92831] Merge branch 'akpm' (incoming from Andrew)
git bisect bad 7c2db36e730ee4facd341679ecb21ee73ba92831
# good: [c4bc705e45d91f900f7ec2e23a458280b084ae91] Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mszeredi/fuse
git bisect good c4bc705e45d91f900f7ec2e23a458280b084ae91
# bad: [b5c78e04dd061b776978dad61dd85357081147b0] Merge tag 'staging-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging
git bisect bad b5c78e04dd061b776978dad61dd85357081147b0
# bad: [06991c28f37ad68e5c03777f5c3b679b56e3dac1] Merge tag 'driver-core-3.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core
git bisect bad 06991c28f37ad68e5c03777f5c3b679b56e3dac1
# bad: [83048ea7b1d11f5e560dea53873fb51d860202eb] Merge tag 'asoc-3.9' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-next
git bisect bad 83048ea7b1d11f5e560dea53873fb51d860202eb
# bad: [4e637c6e09fde6c1984a820621b5a77fad1acd34] ALSA: hda - add support for IDT 92HD95 HDA codec
git bisect bad 4e637c6e09fde6c1984a820621b5a77fad1acd34
# good: [0b4df931ce3502311928bf66088cd76a2b5e604f] ALSA: hda - Avoid auto-mute or auto-mic of retasked jacks
git bisect good 0b4df931ce3502311928bf66088cd76a2b5e604f
# good: [0712eea349d8e2b6d0e44b94a752d999319027fb] ALSA: hda - Add a fixup for Packard-Bell desktop with ALC880
git bisect good 0712eea349d8e2b6d0e44b94a752d999319027fb
# good: [6f7c83afc6cc3f66d13e4ad0a0f5693d9175e1ab] ALSA: hda - Look for boost controls more deeply
git bisect good 6f7c83afc6cc3f66d13e4ad0a0f5693d9175e1ab
# good: [657e1b931d42882cb0a59b599247bef696c22406] ALSA: hda - Select auto-parser as default for AD codecs
git bisect good 657e1b931d42882cb0a59b599247bef696c22406
# bad: [5397145f4faeabbb7937ac784f734b06b20ed921] ALSA: hda - Add auto-mute support to PB desktop
git bisect bad 5397145f4faeabbb7937ac784f734b06b20ed921
# good: [49ba4f94bddb7f5272c4596d505f94355cc3fbd2] ALSA: hdsp - Remove obsolete settings functions
git bisect good 49ba4f94bddb7f5272c4596d505f94355cc3fbd2
# bad: [e4a395e7819b1e666b2e9da22234059f403dbc11] ALSA: hda - Fix missing path between aamix and outputs in AD codecs
git bisect bad e4a395e7819b1e666b2e9da22234059f403dbc11
# bad: [2cf215bfaa01384374291a118c8152ab18a55a63] Merge branch 'topic/hda-gen-parser' into for-next
git bisect bad 2cf215bfaa01384374291a118c8152ab18a55a63                                                                                                                                         
# bad: [e152f18027552eb34006b35347e72bc805783027] Merge branch 'for-linus' into for-next                                                                                                        
git bisect bad e152f18027552eb34006b35347e72bc805783027
Comment 4 Takashi Iwai 2013-04-04 10:48:01 UTC
Make sure that the last commit e152f18027 is really still a bad commit.  The previous one, 2cf215bfaa0, is the commit merging the whole bunch of new stuff, but the last one contains really little changes regarding HD-audio.

Also, please give alsa-info.sh outputs (run with --no-upload option) on both working and non-working kernels to this bugzilla.
Comment 5 Nikita Tsukanov 2013-04-04 11:14:56 UTC
Created attachment 97311 [details]
lsa-info with 42c364ace52ae6b4699105b39f2559c256b6cd4c, good
Comment 6 Nikita Tsukanov 2013-04-04 11:15:25 UTC
Created attachment 97321 [details]
alsa-info with e152f18027552eb34006b35347e72bc805783027, bad
Comment 7 Nikita Tsukanov 2013-04-04 11:15:45 UTC
git log

commit e152f18027552eb34006b35347e72bc805783027
Merge: 49ba4f9 42c364a
Author: Takashi Iwai <tiwai@suse.de>
Date:   Wed Jan 23 08:31:34 2013 +0100

    Merge branch 'for-linus' into for-next
    
    This is a preliminary merge before the upcoming merge of generic parser
    branch.

commit 42c364ace52ae6b4699105b39f2559c256b6cd4c
Author: Takashi Iwai <tiwai@suse.de>
Date:   Mon Jan 21 16:53:37 2013 +0100

    ALSA: hda - Add Conexant CX20755/20756/20757 codec IDs
    
    These are just compatible with other CX2075x codecs.
    
    Cc: <stable@vger.kernel.org>
    Signed-off-by: Takashi Iwai <tiwai@suse.de>


e152f18027552eb34006b35347e72bc805783027 - problem is present
42c364ace52ae6b4699105b39f2559c256b6cd4c - problem isn't present


Note: Both attached outputs were taken after testing (i. e. running mplayer, unpluggin AC power and running alsa force-reload in case of bad one. If you need alsa-info from "clean" system I can take one.
Comment 8 Nikita Tsukanov 2013-04-04 11:36:03 UTC
Created attachment 97331 [details]
More output

before_mplayer - before doing anything (pulseaudio probably has already started)
before_unplug - mplayer is playing music
after_unplug - WRWRWRWRWRWR instead of music, mplayer's UI shows that music plays extremely slow (1 second per 4-5 real seconds)
Comment 9 Takashi Iwai 2013-04-04 12:38:54 UTC
Hmm, if your bisection is really correct, there only three commits relevant with HD-audio:

  42c364ace52ae6b4699105b39f2559c256b6cd4c
    ALSA: hda - Add Conexant CX20755/20756/20757 codec IDs

  6ab317419c62850a71e2adfd1573e5ee87d8774f
    ALSA: hda - Allow power_save_controller option override DCAPS

  f4f0a8c4783a0258f2d0020a67fd619ce41a02a3
    ALSA: hda - print power state for AFG node in proc file

Most doubtful one is the second commit, but I see no problem there.

Could you continue bisection until spotting out the culprit commit?
Comment 10 Nikita Tsukanov 2013-04-04 12:54:24 UTC
git checkout 42c364ace52ae6b4699105b39f2559c256b6cd4c # Last good one 
git cherry-pick 6ab317419c62850a71e2adfd1573e5ee87d8774f #Suspicious one

Compile && Install && Reboot && mplayer + unplug power = awful noise
Comment 11 Nikita Tsukanov 2013-04-04 13:08:55 UTC
When booting without AC adapter plugged in I get this on dmesg:
[   14.204371] hda-intel 0000:00:1b.0: azx_get_response timeout, switching to polling mode: last cmd=0x010f0600
[   15.212210] hda-intel 0000:00:1b.0: No response from codec, disabling MSI: last cmd=0x010f0600
[   16.220015] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220020] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220021] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220022] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220023] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220024] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220025] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220026] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220027] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220028] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220029] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220030] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220031] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220031] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220032] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220033] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220034] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220035] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220036] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220037] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220038] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220039] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220040] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220041] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
[   16.220042] hda-intel 0000:00:1b.0: spurious response 0x0:0x0, last cmd=0x10f0600
Comment 12 Takashi Iwai 2013-04-04 13:13:37 UTC
Looking at alsa-info.sh output, I think this must be related with power-saving.
The power_save option value has been changed to 1.  Also, power_save_controller is set to 1 as well.

It means, someone screws up power_save_controller option unnecessarily.

The commit 6ab31741 changed the power_save_controller option so that it can override the behavior even if the driver capability disables the feature.
This assumed that no one actively changes this option, but my assumption was too naive -- it seems that some power-management stuff tries to screw up things stupidly without knowing what's doing.

So, could you try to revert 6ab31741 and check whether this fixes the issue?
If so, I'll revert for the next rc.
Comment 13 Nikita Tsukanov 2013-04-04 13:33:15 UTC
Reverting this commit solves the problem
Comment 14 Takashi Iwai 2013-04-04 13:48:38 UTC
OK.  I reverted the affecting commit now.  It'll be included in the next pull request sent to Linus.

Thanks for your quick tests!
Comment 15 Nikita Tsukanov 2013-11-13 17:26:14 UTC
BTW, I have simular issue with 3.11 and Dell M4800: when power_save_controller=Y and power_save=1 it occasionly stops any audio output.  Unfortunately, I don't know the exact sequence of actions to reproduce it, but turning off power saving "solves" the problem.
Comment 16 Takashi Iwai 2013-11-13 17:29:57 UTC
If it's a Haswell chip, this might be rather the runtime PM.  In that case, setting power_save_controller=n should suffice.
Comment 17 Nikita Tsukanov 2013-11-13 17:32:42 UTC
Yes, it's i7-4800MQ with Realtek ALC292.
Comment 18 Takashi Iwai 2013-11-13 17:39:56 UTC
OK, then please open another bug report.  I can add a patch to disable the runtime PM for the corresponding chipset.  (I guess it's either LynxPoint or LynxPoint-LP?)
Comment 19 Nikita Tsukanov 2013-11-13 17:42:52 UTC
Once I get it another time to gather alsa-info, I'll fill a new bug report. Or you need just alsa-info from normal state?
Comment 20 Takashi Iwai 2013-11-13 18:12:58 UTC
Yes, I just need the PCI ID.  But, of course, it'd be better if you can confirm power_save_controller=0 fixes the issue.