--- sound/pci/rme9652/hdspm.c.orig 2011-05-15 17:56:25.819000813 +0200 +++ sound/pci/rme9652/hdspm.c 2011-06-01 19:05:06.402951169 +0200 @@ -1621,6 +1621,8 @@ spin_lock_irqsave (&hmidi->lock, flags); n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id); + spin_unlock_irqrestore(&hmidi->lock, flags); + if (n_pending > 0) { if (hmidi->input) { if (n_pending > (int)sizeof (buf)) @@ -1639,12 +1641,12 @@ } } hmidi->pending = 0; - + + spin_lock_irqsave (&hmidi->hdspm->lock, flags); hmidi->hdspm->control_register |= hmidi->ie; hdspm_write(hmidi->hdspm, HDSPM_controlRegister, hmidi->hdspm->control_register); - - spin_unlock_irqrestore (&hmidi->lock, flags); + spin_unlock_irqrestore(&hmidi->hdspm->lock, flags); return snd_hdspm_midi_output_write (hmidi); } @@ -1773,11 +1775,25 @@ return 0; } +static void snd_hdspm_midi_output_drain(struct snd_rawmidi_substream *substream) +{ + struct hdspm *hdspm; + struct hdspm_midi *hmidi; + + hmidi = substream->rmidi->private_data; + hdspm = hmidi->hdspm; + + while (128 != snd_hdspm_midi_output_possible(hdspm, hmidi->id)) { + mdelay(2); + } +} + static struct snd_rawmidi_ops snd_hdspm_midi_output = { .open = snd_hdspm_midi_output_open, .close = snd_hdspm_midi_output_close, .trigger = snd_hdspm_midi_output_trigger, + .drain = snd_hdspm_midi_output_drain, }; static struct snd_rawmidi_ops snd_hdspm_midi_input =