[alsa-devel] pcm_lock deadlock

Takashi Iwai tiwai at suse.de
Wed Oct 30 15:36:40 CET 2019


On Wed, 30 Oct 2019 14:50:09 +0100,
Ville Syrjälä wrote:
> 
> On Tue, Oct 29, 2019 at 09:52:57PM +0100, Takashi Iwai wrote:
> > On Tue, 29 Oct 2019 20:10:50 +0100,
> > From: Takashi Iwai <tiwai at suse.de>
> > Subject: [PATCH] ALSA: hda - Fix mutex deadlock in HDMI codec driver
> > 
> > The commit ade49db337a9 ("ALSA: hda/hdmi - Allow audio component for
> > AMD/ATI and Nvidia HDMI") introduced the spec->pcm_lock mutex lock to
> > the whole generic_hdmi_init() function for avoiding the race with the
> > audio component registration.  However, this caused a dead lock when
> > the unsolicited event is handled without the audio component, as the
> > codec gets runtime-resumed in hdmi_present_sense() which is already
> > inside the spec->pcm_lock in its caller.
> > 
> > For avoiding this deadlock, add a new mutex only for the audio
> > component binding that is used in both generic_hdmi_init() and the
> > audio notifier registration where the jack callbacks are handled /
> > re-registered.
> > 
> > Fixes: ade49db337a9 ("ALSA: hda/hdmi - Allow audio component for AMD/ATI and Nvidia HDMI")
> > Reported-by: Ville Syrjälä <ville.syrjala at linux.intel.com>
> > Signed-off-by: Takashi Iwai <tiwai at suse.de>
> > ---
> >  sound/pci/hda/patch_hdmi.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/sound/pci/hda/patch_hdmi.c b/sound/pci/hda/patch_hdmi.c
> > index 795cbda32cbb..d9b5ba361409 100644
> > --- a/sound/pci/hda/patch_hdmi.c
> > +++ b/sound/pci/hda/patch_hdmi.c
> > @@ -145,6 +145,7 @@ struct hdmi_spec {
> >  	struct snd_array pins; /* struct hdmi_spec_per_pin */
> >  	struct hdmi_pcm pcm_rec[16];
> >  	struct mutex pcm_lock;
> > +	struct mutex bind_lock; /* for audio component binding */
> 
> Missing mutex_init() for this guy.

Ouch, fixed now.

> Tested-by: Ville Syrjälä <ville.syrjala at linux.intel.com>

Thanks for quick testing.  Now pushed out the right version.
I'll include this to the next pull request to 5.4-rc.


Takashi


More information about the Alsa-devel mailing list