Bug 50251

Summary: modprobe -r snd_hda_intel hangs after invocation of aumix
Product: Drivers Reporter: Martin Ziegler (ziegler)
Component: Sound(ALSA)Assignee: Takashi Iwai (tiwai)
Status: RESOLVED CODE_FIX    
Severity: normal CC: florian, tiwai
Priority: P1    
Hardware: x86-64   
OS: Linux   
Kernel Version: 3.7.0-rc4-00020-g0e4a43e Subsystem:
Regression: Yes Bisected commit-id:
Attachments: kernel-config
Fix card refcount unbalance

Description Martin Ziegler 2012-11-08 00:21:33 UTC
Created attachment 85881 [details]
kernel-config

After 

  /usr/bin/aumix -v 0 -w 0 -W 0 -p 0

the command 

  modprobe -r snd_hda_intel 

hangs and cannot be killed.

Bisection resulted in 

  commit a0830dbd4e42b38aefdf3fb61ba5019a1a99ea85
  Author: Takashi Iwai <tiwai@suse.de>
  Date:   Tue Oct 16 13:05:59 2012 +0200

  ALSA: Add a reference counter to card instance

as the first bad commit. Reverting this commit in 
3.7.0-rc4-00020-g0e4a43e fixes the problem.

The machine is a thinkpad T510. 
CPU:
   Intel(R) Core(TM) i5 CPU       M 560  @ 2.67GHz
AUDIO:
   Intel Corporation 5 Series/3400 Series Chipset High Definition Audio
Comment 1 Takashi Iwai 2012-11-08 07:49:17 UTC
Is aumix accessing via ALSA API or OSS API?  I tried to reproduce with amixer, but it works fine.
Comment 2 Martin Ziegler 2012-11-08 12:31:19 UTC
I do not know since I dont understand the sound system. But the
following informations may help.

aumix needs the module snd_pcm_oss to run. 

The snd* modules loaded are:

  snd_hda_codec_conexant    40366  1
  snd_hda_intel          20675  0
  snd_hda_codec          71325  2 snd_hda_codec_conexant,snd_hda_intel
  snd_pcm_oss            29043  0
  snd_mixer_oss          12526  1 snd_pcm_oss
  snd_pcm                57725  3 snd_pcm_oss,snd_hda_codec,snd_hda_intel
  snd_page_alloc          6082  2 snd_pcm,snd_hda_intel
  snd_timer              15125  1 snd_pcm


The content of /proc/asound/oss/sndstat is:
 
  Config options: 0

  Installed drivers:
  Type 10: ALSA emulation

  Card config:
  HDA Intel MID at 0xf2620000 irq 44
  ThinkPad Console Audio Control at EC reg 0x30, fw 6MHT43WW-1.18

  Audio devices:
  0: CONEXANT Analog (DUPLEX)

  Synth devices: NOT ENABLED IN CONFIG

  Midi devices: NOT ENABLED IN CONFIG

  Timers:
  7: system timer

  Mixers:
  0: Intel ID 2804
  5: ThinkPad EC 6MHT43WW-1.18

This is a quote from /usr/share/doc/aumix/README.Debian:

   The old aumix-alsa package has been removed as there is no support for
   it anymore upstream.  The aumix package works fine (although with
   limited channels) with the OSS compatibility layer for ALSA.  To enable
   the compatibility layer, modprobe the snd_mixer_oss module (and/or put
   it in /etc/modules).

   Hopefully aumix will have full ALSA support in the future (it is on
   upstream's TODO list).  If you're knowledgeable with ALSA stuff, feel
   free to contact aumix@packages.debian.org to help out.  The Debian
   maintainer works closely with the aumix upstream maintainer.

The aumix version is 2.9.1

amixer does not trigger the problem. I tried it with
   
    amixer set Master mute 0%
Comment 3 Martin Ziegler 2012-11-08 13:07:48 UTC
From the aumix homepage http://www.jpj.net/~trevor/aumix.html

  what aumix is

  This program adjusts an audio mixer from X11, the console, a terminal, 
  the command line or a script. It uses the Open Sound System API and works on
  OpenBSD, NetBSD, FreeBSD, and Linux.
Comment 4 Takashi Iwai 2012-11-08 13:45:39 UTC
Created attachment 85931 [details]
Fix card refcount unbalance

Could you try this patch?  This should fix the refcount unbalance in case where OSS emulation is used.
Comment 5 Martin Ziegler 2012-11-08 14:23:16 UTC
I applied the patch. The problem does not
longer occur.

Thanks
Martin
Comment 6 Takashi Iwai 2012-11-08 14:29:57 UTC
Thanks for a quick test.

The patch is merged now to sound git tree.  I'm going to send a pull request tomorrow.
Comment 7 Florian Mickler 2012-11-11 18:46:44 UTC
A patch referencing this bug report has been merged in Linux v3.7-rc5:

commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f
Author: Takashi Iwai <tiwai@suse.de>
Date:   Thu Nov 8 14:36:18 2012 +0100

    ALSA: Fix card refcount unbalance