[alsa-devel] [PATCH] RME HDSPM MADI lock fix
Takashi Iwai
tiwai at suse.de
Tue Jun 7 11:28:49 CEST 2011
At Tue, 07 Jun 2011 10:33:55 +0200,
Jörn Nettingsmeier wrote:
>
> On 06/06/2011 11:05 AM, Takashi Iwai wrote:
> > At Sun, 05 Jun 2011 11:57:57 +0200,
> > Jörn Nettingsmeier wrote:
> >>
> >> hi *!
> >>
> >> while we were trying to debug the midi-related xruns in the current
> >> driver, i came across what looks like an unrelated locking bug to me:
> >>
> >> static int snd_hdspm_midi_input_read (struct hdspm_midi *hmidi)
> >> ...
> >> spin_lock_irqsave (&hmidi->lock, flags);<---------------
> >> n_pending = snd_hdspm_midi_input_available (hmidi->hdspm,
> >> hmidi->id);
> >> ...
> >> hmidi->pending = 0;
> >>
> >> hmidi->hdspm->control_register |= hmidi->ie;<------- !!!
> >> hdspm_write(hmidi->hdspm, HDSPM_controlRegister,
> >> hmidi->hdspm->control_register);
> >>
> >> spin_unlock_irqrestore (&hmidi->lock, flags);<---------
> >> return snd_hdspm_midi_output_write (hmidi);
> >> }
> >>
> >>
> >> if i understand this whole business correctly, we should be holding the
> >> hdspm lock here, not the hmidi one.
> >>
> >> please review the attached patch and apply if you think it's ok.
> >
> > Well, it's a wrong lock for snd_hdspm_midi_input_available().
> > So you'll need to lock twice, either once unlock and lock another or
> > nested. Re-locking would be less messy in this case, I suppose.
>
> ok, here's a revised patch. has been running for 20 or so hours without
> problems, although the load was light most of the time.
>
> please consider for inclusion.
Looks good. But please give a proper changelog and your sign-off
for inclusion.
thanks,
Takashi
More information about the Alsa-devel
mailing list