Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ALSA: pcm: Fix false lockdep warnings

As PCM core handles the multiple linked streams in parallel, lockdep
gets confused (partly because of weak annotations) and spews the
false-positive warnings. This hasn't been a problem for long time but
the latest PCM lock path update seems to have woken up a sleeping
dog.

Here is an attempt to paper over this issue: pass the lock subclass
just calculated from the depth in snd_pcm_action_group(). Also, a
(possibly) wrong lock subclass set in snd_pcm_action_lock_mutex() is
dropped, too.

Reported-and-tested-by: Arthur Marsh <arthur.marsh@internode.on.net>
Signed-off-by: Takashi Iwai <tiwai@suse.de>

+5 -7
+5 -7
sound/core/pcm_native.c
··· 781 781 { 782 782 struct snd_pcm_substream *s = NULL; 783 783 struct snd_pcm_substream *s1; 784 - int res = 0; 784 + int res = 0, depth = 1; 785 785 786 786 snd_pcm_group_for_each_entry(s, substream) { 787 787 if (do_lock && s != substream) { 788 788 if (s->pcm->nonatomic) 789 - mutex_lock_nested(&s->self_group.mutex, 790 - SINGLE_DEPTH_NESTING); 789 + mutex_lock_nested(&s->self_group.mutex, depth); 791 790 else 792 - spin_lock_nested(&s->self_group.lock, 793 - SINGLE_DEPTH_NESTING); 791 + spin_lock_nested(&s->self_group.lock, depth); 792 + depth++; 794 793 } 795 794 res = ops->pre_action(s, state); 796 795 if (res < 0) ··· 905 906 down_read(&snd_pcm_link_rwsem); 906 907 if (snd_pcm_stream_linked(substream)) { 907 908 mutex_lock(&substream->group->mutex); 908 - mutex_lock_nested(&substream->self_group.mutex, 909 - SINGLE_DEPTH_NESTING); 909 + mutex_lock(&substream->self_group.mutex); 910 910 res = snd_pcm_action_group(ops, substream, state, 1); 911 911 mutex_unlock(&substream->self_group.mutex); 912 912 mutex_unlock(&substream->group->mutex);