ALSA: aloop - Fix possible IRQ lock inversion
loopback_pos_update() can be called in the timer callback, thus the lock held should be irq-safe. Otherwise you'll get AB/BA deadlock together with substream->self_group.lock. Reported-and-tested-by: Knut Petersen <Knut_Petersen@t-online.de> Cc: <stable@kernel.org> Signed-off-by: Takashi Iwai <tiwai@suse.de>
This commit is contained in:
parent
5b7c757d1a
commit
98d21df431
@ -482,8 +482,9 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
|
|||||||
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
|
cable->streams[SNDRV_PCM_STREAM_CAPTURE];
|
||||||
unsigned long delta_play = 0, delta_capt = 0;
|
unsigned long delta_play = 0, delta_capt = 0;
|
||||||
unsigned int running;
|
unsigned int running;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock(&cable->lock);
|
spin_lock_irqsave(&cable->lock, flags);
|
||||||
running = cable->running ^ cable->pause;
|
running = cable->running ^ cable->pause;
|
||||||
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
|
if (running & (1 << SNDRV_PCM_STREAM_PLAYBACK)) {
|
||||||
delta_play = jiffies - dpcm_play->last_jiffies;
|
delta_play = jiffies - dpcm_play->last_jiffies;
|
||||||
@ -495,10 +496,8 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
|
|||||||
dpcm_capt->last_jiffies += delta_capt;
|
dpcm_capt->last_jiffies += delta_capt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta_play == 0 && delta_capt == 0) {
|
if (delta_play == 0 && delta_capt == 0)
|
||||||
spin_unlock(&cable->lock);
|
goto unlock;
|
||||||
return running;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (delta_play > delta_capt) {
|
if (delta_play > delta_capt) {
|
||||||
loopback_bytepos_update(dpcm_play, delta_play - delta_capt,
|
loopback_bytepos_update(dpcm_play, delta_play - delta_capt,
|
||||||
@ -510,14 +509,14 @@ static unsigned int loopback_pos_update(struct loopback_cable *cable)
|
|||||||
delta_capt = delta_play;
|
delta_capt = delta_play;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (delta_play == 0 && delta_capt == 0) {
|
if (delta_play == 0 && delta_capt == 0)
|
||||||
spin_unlock(&cable->lock);
|
goto unlock;
|
||||||
return running;
|
|
||||||
}
|
|
||||||
/* note delta_capt == delta_play at this moment */
|
/* note delta_capt == delta_play at this moment */
|
||||||
loopback_bytepos_update(dpcm_capt, delta_capt, BYTEPOS_UPDATE_COPY);
|
loopback_bytepos_update(dpcm_capt, delta_capt, BYTEPOS_UPDATE_COPY);
|
||||||
loopback_bytepos_update(dpcm_play, delta_play, BYTEPOS_UPDATE_POSONLY);
|
loopback_bytepos_update(dpcm_play, delta_play, BYTEPOS_UPDATE_POSONLY);
|
||||||
spin_unlock(&cable->lock);
|
unlock:
|
||||||
|
spin_unlock_irqrestore(&cable->lock, flags);
|
||||||
return running;
|
return running;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user