All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Jörn Nettingsmeier" <nettings@stackingdwarves.net>
To: alsa-devel@alsa-project.org, Takashi Iwai <tiwai@suse.de>,
	Adrian Knoth <adi@drcomp.erfurt.thur.de>
Subject: [PATCH] RME HDSPM MADI lock fix
Date: Sun, 05 Jun 2011 11:57:57 +0200	[thread overview]
Message-ID: <4DEB5325.9070903@stackingdwarves.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1941 bytes --]

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);
         if (n_pending > 0) {
                 if (hmidi->input) {
                         if (n_pending > (int)sizeof (buf))
                                 n_pending = sizeof (buf);
                         for (i = 0; i < n_pending; ++i)
                                 buf[i] = snd_hdspm_midi_read_byte 
(hmidi->hdspm,
 
hmidi->id);
                         if (n_pending)
                                 snd_rawmidi_receive (hmidi->input, buf,
                                                      n_pending);
                 } else {
                         /* flush the MIDI input FIFO */
                         while (n_pending--)
                                 snd_hdspm_midi_read_byte (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.


best,


jörn



-- 
Jörn Nettingsmeier
Lortzingstr. 11, 45128 Essen, Tel. +49 177 7937487

Meister für Veranstaltungstechnik (Bühne/Studio)
Tonmeister (VDT)

http://stackingdwarves.net

[-- Attachment #2: hdspm-lockfix.diff --]
[-- Type: text/x-patch, Size: 663 bytes --]

--- sound/pci/rme9652/hdspm.c~	2011-06-01 21:30:24.000000000 +0200
+++ sound/pci/rme9652/hdspm.c	2011-06-01 22:04:08.184946711 +0200
@@ -1619,7 +1619,7 @@
 	int n_pending;
 	int i;
 
-	spin_lock_irqsave (&hmidi->lock, flags);
+	spin_lock_irqsave (&hmidi->hdspm->lock, flags);
 	n_pending = snd_hdspm_midi_input_available (hmidi->hdspm, hmidi->id);
 	if (n_pending > 0) {
 		if (hmidi->input) {
@@ -1644,7 +1644,7 @@
 	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);
 }
 

[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



             reply	other threads:[~2011-06-05  9:51 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-05  9:57 Jörn Nettingsmeier [this message]
2011-06-06  9:05 ` [PATCH] RME HDSPM MADI lock fix Takashi Iwai
2011-06-07  8:33   ` Jörn Nettingsmeier
2011-06-07  8:38     ` Adrian Knoth
2011-06-07  9:28     ` Takashi Iwai
2011-06-07  9:30       ` Adrian Knoth
2011-06-07  9:37         ` Takashi Iwai
2011-06-07  9:41           ` Adrian Knoth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DEB5325.9070903@stackingdwarves.net \
    --to=nettings@stackingdwarves.net \
    --cc=adi@drcomp.erfurt.thur.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.