android_kernel_samsung_univ.../sound
Takashi Iwai 097994b3d1 ALSA: hda - Fix deadlock of controller device lock at unbinding
commit ab949d519601880fd46e8bc1445d6a453bf2dc09 upstream.

Imre Deak reported a deadlock of HD-audio driver at unbinding while
it's still in probing.  Since we probe the codecs asynchronously in a
work, the codec driver probe may still be kicked off while the
controller itself is being unbound.  And, azx_remove() tries to
process all pending tasks via cancel_work_sync() for fixing the other
races (see commit [0b8c82190c12: ALSA: hda - Cancel probe work instead
of flush at remove]), now we may meet a bizarre deadlock:

Unbind snd_hda_intel via sysfs:
  device_release_driver() ->
    device_lock(snd_hda_intel) ->
      azx_remove() ->
        cancel_work_sync(azx_probe_work)

azx_probe_work():
  codec driver probe() ->
     __driver_attach() ->
       device_lock(snd_hda_intel)

This deadlock is caused by the fact that both device_release_driver()
and driver_probe_device() take both the device and its parent locks at
the same time.  The codec device sets the controller device as its
parent, and this lock is taken before the probe() callback is called,
while the controller remove() callback gets called also with the same
lock.

In this patch, as an ugly workaround, we unlock the controller device
temporarily during cancel_work_sync() call.  The race against another
bind call should be still suppressed by the parent's device lock.

Reported-by: Imre Deak <imre.deak@intel.com>
Fixes: 0b8c82190c12 ("ALSA: hda - Cancel probe work instead of flush at remove")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-05-14 13:32:58 +02:00
..
aoa
arm
atmel
core ALSA: seq: Don't break snd_use_lock_sync() loop by timeout 2017-05-02 21:19:55 -07:00
drivers
firewire ALSA: firewire-lib: fix inappropriate assignment between signed/unsigned type 2017-05-02 21:19:55 -07:00
hda
i2c
isa
mips
oss
parisc
pci ALSA: hda - Fix deadlock of controller device lock at unbinding 2017-05-14 13:32:58 +02:00
pcmcia
ppc ALSA: ppc/awacs: shut up maybe-uninitialized warning 2017-05-08 07:46:01 +02:00
sh
soc ASoC: intel: Fix PM and non-atomic crash in bytcr drivers 2017-05-08 07:46:01 +02:00
sparc
spi
synth
usb ALSA: usb-audio: Add a quirk for Plantronics BT600 2017-01-15 13:41:36 +01:00
ac97_bus.c
Kconfig
last.c
Makefile
sound_core.c
sound_firmware.c