Bug 75395

Summary: Second sound hardware turned off makes pulseaudio hang
Product: PulseAudio Reporter: jan-ake.larsson
Component: coreAssignee: pulseaudio-bugs
Status: RESOLVED NOTOURBUG QA Contact: pulseaudio-bugs
Severity: blocker    
Priority: medium CC: lennart
Version: unspecified   
Hardware: x86-64 (AMD64)   
OS: Linux (All)   
Whiteboard:
i915 platform: i915 features:
Attachments: alsa-info.sh output
gdb-pulseaudio.log
xrandr--verbose.txt
gdb-pulseaudio-2.log

Description jan-ake.larsson 2014-02-23 09:40:01 UTC
Hi, I have a dual display card setup on a hp tm2 laptop, Ubuntu linux. There is both a discrete radeon graphics card and an integrated intel card. If I use vgaswitcheroo to turn the radeon card OFF (to save battery), then pulseaudio hangs on the next sound played. This happens every time. Solutions for me: a) have the card on, or b) remove pulseaudio from the system. 

Pulseaudio hangs the system HARD. Let me know what logs you need, if any. Or if I possibly can change the configuration to make it work.
Comment 1 Raymond 2014-02-26 01:31:47 UTC
post output of alsa-info.sh

does it help if you switch the default sink back to analog first before you switch off HDMI ?

i.e. pulseaudio cannot get card removal udev event
Comment 2 jan-ake.larsson 2014-02-26 06:05:44 UTC
Created attachment 94749 [details]
alsa-info.sh output
Comment 3 jan-ake.larsson 2014-02-26 06:17:55 UTC
No difference in behaviour. The card seems to be present, still. One comment: it seems that it is not the whole system that hangs, just the program that plays the sound. If this is the session manager, I can't do anything anymore. And pulseaudio itself hangs. Pulseaudio doesn't even react to being killed after that.
Comment 4 Tanu Kaskinen 2014-02-26 07:36:07 UTC
Can you check with gdb where pulseaudio is hanging?
Comment 5 Raymond 2014-02-26 14:18:11 UTC
[    9.743743] HDMI: ELD buf size is 0, force 128
[    9.743760] HDMI: invalid ELD data byte 0

it seem that graphic driver cannot pass valid ELD to audio driver 

post output of 

xrandr --verbose

did you find your HDMI TV model in system log when drm parse EDID of your HDMI tv/monitor ?
Comment 6 jan-ake.larsson 2014-02-27 07:05:58 UTC
Created attachment 94800 [details]
gdb-pulseaudio.log
Comment 7 jan-ake.larsson 2014-02-27 07:08:46 UTC
Created attachment 94801 [details]
xrandr--verbose.txt
Comment 8 jan-ake.larsson 2014-02-27 07:12:21 UTC
I noticed that the sound-playing program hangs for quite some time, but then recovers and does play the sound. 

However, pulseaudio is completely non-responsive after this has happened. No reaction whatsoever, even to kill commands. I even had to cut and paste gdb output, my typescript session never wrote the last buffer to disk.
Comment 9 jan-ake.larsson 2014-02-27 07:14:09 UTC
I seem to remember that the monitor model is correct in the screen config when I connect an external monitor. Does that answer your question?
Comment 10 Raymond 2014-02-27 12:35:02 UTC
HDMI-1-0 disconnected (normal left inverted right x axis y axis)

and graphic driver does not show  audio is supported 




hdmi is plugged but no valid ELD

state.Generic {
	control.1 {
		iface CARD
		name 'HDMI/DP,pcm=3 Jack'
		value true
		comment {
			access read
			type BOOLEAN
			count 1
		}
	}


	control.6 {
		iface PCM
		device 3
		name ELD
		value ''
		comment {
			access 'read volatile'
			type BYTES
			count 0
		}
	}
Comment 11 Raymond 2014-02-27 12:40:37 UTC
LVDS1 

EDID: 
		00ffffffffffff004ca3414d00000000
		00120103801a10780a87f594574f8c27
		27505400000001010101010101010101
		010101010101121b0049502036301030
		130005a3100000190000000f00000000
		00000000002387026400000000fe0053
		414d53554e470a2020202020000000fe
		00313231415430392d4830310a20001e

seem not your hdmi monitor as no audio supported

Manufacturer: SEC Model 4d41 Serial Number 0
Made week 0 of 2008
EDID version: 1.3
Digital display
Maximum image size: 26 cm x 16 cm
Gamma: 2.20
Supported color formats: RGB 4:4:4, YCrCb 4:2:2
First detailed timing is preferred timing
Established timings supported:
Standard timings supported:
Detailed mode: Clock 69.300 MHz, 261 mm x 163 mm
               1280 1296 1344 1353 hborder 0
                800  801  804  854 vborder 0
               -hsync -vsync 
Manufacturer-specified data, tag 15
ASCII string: SAMSUNG
ASCII string: 121AT09
Checksum: 0x1e (valid)
Comment 12 jan-ake.larsson 2014-02-27 12:48:22 UTC
Sorry if I seem slow. The card is OFF, no HDMI monitor attached. This is the interesting case, no?
Comment 13 jan-ake.larsson 2014-02-27 13:16:40 UTC
I guess that would be the built-in screen in the laptop, then? This has no audio. There are built-in speakers in the laptop.
Comment 14 Raymond 2014-02-27 15:51:43 UTC
http://git.alsa-project.org/?p=alsa-lib.git;a=blob;f=include/control.h;hb=HEAD

TLV_DB_GAIN_MUTE	-9999999

it is strange that the virtual master playback volume has min dB -99999.99 but dB of slaves (e.g. headphone and speaker only have -95.25dB)

pulseaudio min_dB=-100146 which is even less than  SND_CTL_TLV_DB_GAIN_MUTE        

D: [pulseaudio] alsa-mixer.c: Removing path 'analog-output' as it is a subset of 'analog-output-speaker'.
D: [pulseaudio] alsa-mixer.c: Available mixer paths (after tidying):
D: [pulseaudio] alsa-mixer.c: Path Set 0x80e19b8, direction=1
D: [pulseaudio] alsa-mixer.c: Path analog-output-speaker (Speakers), direction=1, priority=100, probed=yes, supported=yes, has_mute=yes, has_volume=yes, has_dB=yes, min_volume=0, max_volume=127, min_dB=-100146, max_dB=0


MID {
	control.1 {
		iface MIXER
		name 'Headphone Playback Volume'
		value.0 127
		value.1 127
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 127'
			dbmin -9525
			dbmax 0
			dbvalue.0 0
			dbvalue.1 0
		}
	}


	control.3 {
		iface MIXER
		name 'Speaker Playback Volume'
		value.0 0
		value.1 0
		comment {
			access 'read write'
			type INTEGER
			count 2
			range '0 - 127'
			dbmin -9525
			dbmax 0
			dbvalue.0 -9525
			dbvalue.1 -9525
		}
	}

	

		
	control.15 {
		iface MIXER
		name 'Master Playback Volume'
		value 0
		comment {
			access 'read write'
			type INTEGER
			count 1
			range '0 - 127'
			dbmin -9999999
			dbmax 0
			dbvalue.0 -9999999
		}
Comment 16 Raymond 2014-03-01 01:46:18 UTC
is this normal when you turn off one of the slaves of the combine-sine as you use combine-sink ?

is it impossible for module-switch-on-port-available to switch from combin-sink to the still available slave ?
Comment 17 jan-ake.larsson 2014-03-01 09:22:57 UTC
Sequence:

-Check status of hardware in pavucontrol:
--Cedar HDMI Audio [Radeon HD 5400/6300 Series]: Analog stereoduplex
--Built-in audio: Anaolg stereoduplex
-Exit pavucontrol
-Turn off hardware
-Start pavucontrol
-It waits for pulseaudio forever

Reboot

-Turn discrete card off in pavucontrol:
--Cedar HDMI Audio [Radeon HD 5400/6300 Series]: Off
--Built-in audio: Anaolg stereoduplex
-Exit pavucontrol
-Turn off hardware
-Start pavucontrol
-Seems to work

Note that even in the later case, sound-playing programs hang for quite some time before playing the sound, and pulseaudio itself becomes [defunct] if killed, and won't respawn.
Comment 18 Raymond 2014-03-01 13:49:10 UTC
[    9.678269] [drm] Connector 1:
[    9.678272] [drm]   HDMI-A-1
[    9.678275] [drm]   HPD1


did the system log show the graphic driver got your HDMI monitor 's EDID before snd-hda-Intel was loaded  ?
Comment 19 Raymond 2014-03-02 02:48:13 UTC
--Cedar HDMI Audio [Radeon HD 5400/6300 Series]: Analog stereoduplex

your HDMI support playback only , not duplex (no cpature)

did you not remove module-combine-sink from default.pa ?


APLAY

**** List of PLAYBACK Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: Generic [HD-Audio Generic], device 3: HDMI 0 [HDMI 0]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

ARECORD

**** List of CAPTURE Hardware Devices ****
card 0: MID [HDA Intel MID], device 0: 92HD81B1X5 Analog [92HD81B1X5 Analog]
  Subdevices: 1/1
  Subdevice #0: subdevice #0
Comment 20 jan-ake.larsson 2014-03-02 11:46:28 UTC
The two choices I have in pavucontrol is "Analog stereoduplex" and "Off"

No I did not remove module-combine-sink from default.pa, it is not present in any file in /etc/pulse.
Comment 21 Raymond 2014-03-02 12:47:28 UTC
D: [pulseaudio] module-gconf.c: Loading module 'module-combine' with args '' due to GConf configuration.
W: [pulseaudio] module.c: [1mmodule-combine is deprecated: Please use module-combine-sink instead of module-combine![0m
W: [pulseaudio] module-combine.c: [1mWe will now load module-combine-sink. Please make sure to remove module-combine from your configuration.[0m
D: [pulseaudio] core-subscribe.c: Dropped redundant event due to change event.
I: [pulseaudio] module-device-restore.c: Restoring mute state for sink combined.
I: [pulseaudio] sink.c: Created sink 2 "combined" with sample spec s16le 2 kan. 44100 Hz and channel map front-left,front-right
I: [pulseaudio] sink.c:     device.class = "filter"
I: [pulseaudio] sink.c:     device.description = "Simultaneous Output"
I: [pulseaudio] sink.c:     device.icon_name = "audio-card"



I: [pulseaudio] source.c: Created source 3 "combined.monitor" with sample spec s16le 2 kan. 44100 Hz and channel map front-left,front-right
I: [pulseaudio] source.c:     device.description = "Monitor of Simultaneous Output"
I: [pulseaudio] source.c:     device.class = "monitor"
I: [pulseaudio] source.c:     device.icon_name = "audio-input-microphone"


: [pulseaudio] module-suspend-on-idle.c: Sink combined becomes busy, resuming.
D: [pulseaudio] sink.c: Suspend cause of sink combined is 0x0000, resuming
D: [pulseaudio] module-stream-restore.c: Not restoring device for stream sink-input-by-media-role:filter, because already set to 'alsa_output.pci-0000_01_00.1.hdmi-stereo'.
D: [pulseaudio] module-intended-roles.c: Not setting device for stream Simultaneous output on Cedar HDMI Audio [Radeon HD 5400/6300 Series] Digital Stereo (HDMI), because already set.
Comment 22 Tanu Kaskinen 2014-03-03 08:41:44 UTC
The combine sink is being loaded by module-gconf, which is controlled by paprefs.
Comment 23 jan-ake.larsson 2014-03-03 08:46:07 UTC
Yes, I did understand that, eventually. I turned that off this morning and now I have "Stereo output" or whatever, and "Off" to choose from. While I doubt this has any effect on the bug, I'll redo the test tonight, or when I get the time.
Comment 24 jan-ake.larsson 2014-03-05 08:07:20 UTC
Created attachment 95143 [details]
gdb-pulseaudio-2.log
Comment 25 jan-ake.larsson 2014-03-05 08:29:15 UTC
Appears to fix the issue. No freeze, no crash. Thanks, guys.

Complicated, this: Dual cards. Turn one off. Play a sound. Pulseaudio freezes. Turns out it is a configuration error: The combined sink cannot handle removing hardware, if I understand this correctly.

I did already check for /etc, ~/.pulse and dconf mis-configuration. Repeatedly. For a long time, removing .pulse seemed to fix the issue for the next login. But at the time I had all sorts of problems even booting the machine (a race condition in the two graphics drivers, which is gone now). I didn't think to look for gconf mis-configuration. 

Besides, I wouldn't have known to remove combine-sink, it was not obvious to me this would have any effect, even when I got the advice from you.

Will you write this as user error, or will you try to fix the issue? I mean, it is still there, because I see this as a workaround.

Anyhow, I can use the system now, which is great.
Comment 26 Tanu Kaskinen 2014-03-07 11:50:09 UTC
(In reply to comment #25)
> Appears to fix the issue. No freeze, no crash. Thanks, guys.
> 
> Complicated, this: Dual cards. Turn one off. Play a sound. Pulseaudio
> freezes. Turns out it is a configuration error: The combined sink cannot
> handle removing hardware, if I understand this correctly.

That's not correct - module-combine-sink does handle removing hardware (I just verified this myself - works fine).

This sounds like a sound card driver bug that is somehow triggered by module-combine-sink. When I asked to check with gdb where pulseaudio is hanging, I meant getting a backtrace, which would then probably show that it's some alsa call that is hung.

(Sorry for not being more responsive, I don't have much time for engaging with bug reports.)
Comment 27 jan-ake.larsson 2014-03-07 15:11:42 UTC
Yes, I would have provided a backtrace, but it seems pulseaudio does not react to SIGINT. Nor to SIGKILL. I'll try again during the weekend, but don't hold your breath.
Comment 28 jan-ake.larsson 2014-03-07 15:12:38 UTC
Does not respond to SIGINT when it has hung, I mean.
Comment 29 Tanu Kaskinen 2014-03-07 15:15:12 UTC
I wonder if attaching to the hung process from outside (with gdb -p `pidof pulseaudio`) would work better?
Comment 30 jan-ake.larsson 2014-03-07 15:17:08 UTC
Good point, I'll try that. 

And for what it's worth, I'm completely happy with the responsiveness of the bug tracking here.
Comment 31 jan-ake.larsson 2014-03-09 21:34:33 UTC
Nope, no response. Loads symbols, and reports three LWP items. Then completely unresponsive, debugger hung too.
Comment 32 Tanu Kaskinen 2014-03-11 14:21:49 UTC
Do you mind if I close this bug with the assumption that this is a bug in the kernel driver of the sound card?
Comment 33 jan-ake.larsson 2014-03-12 08:49:36 UTC
Well, no, because my system is now usable (but the sound indicator is still missing, haven't found how to re-enable that).

On the other hand, perhaps I should file a bug report on the driver. Any advice on that?
Comment 34 Tanu Kaskinen 2014-03-12 09:05:37 UTC
You can send mail to the alsa-devel mailing list. Attach or link to the alsa-info.sh output in your bug report.

I'm closing this bug now.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.