Browse files

ALSA: hrtimer: handle delayed timer interrupts

commit b1d4f7f upstream.

If a timer interrupt was delayed too much, hrtimer_forward_now() will
forward the timer expiry more than once.  When this happens, the
additional number of elapsed ALSA timer ticks must be passed to
snd_timer_interrupt() to prevent the ALSA timer from falling behind.

This mostly fixes MIDI slowdown problems on highly-loaded systems with
badly behaved interrupt handlers.

Signed-off-by: Clemens Ladisch <>
Reported-and-tested-by: Arthur Marsh <>
Signed-off-by: Takashi Iwai <>
Signed-off-by: Greg Kroah-Hartman <>
  • Loading branch information...
1 parent cd4d828 commit 8da1632d55e79d6d4d9bde2a193d4265a343bf9b @cladisch cladisch committed with motley-git Mar 21, 2012
Showing with 3 additions and 2 deletions.
  1. +3 −2 sound/core/hrtimer.c
5 sound/core/hrtimer.c 100755 → 100644
@@ -45,12 +45,13 @@ static enum hrtimer_restart snd_hrtimer_callback(struct hrtimer *hrt)
struct snd_hrtimer *stime = container_of(hrt, struct snd_hrtimer, hrt);
struct snd_timer *t = stime->timer;
+ unsigned long oruns;
if (!atomic_read(&stime->running))
- hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
- snd_timer_interrupt(stime->timer, t->sticks);
+ oruns = hrtimer_forward_now(hrt, ns_to_ktime(t->sticks * resolution));
+ snd_timer_interrupt(stime->timer, t->sticks * oruns);
if (!atomic_read(&stime->running))

0 comments on commit 8da1632

Please sign in to comment.