All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Bill Adair" <adair@gotadsl.co.uk>
To: alsa-devel@lists.sourceforge.net
Subject: snd_serial_u16550 lockup
Date: Mon, 17 Jan 2005 13:22:01 -0000	[thread overview]
Message-ID: <opskq0qzkmn0kn27@linux.site> (raw)

I'm writing a driver based on this code for an Opcode 64X serial MIDI  
interface.
It's working for output using rosegarden and for input using amidi.
However when I set record on my device in Rosegarden (and other sequencer  
packages
jazz and Muse) the whole (twin CPU) pc locks solid and I have to press  
reset.
This happens only if my synth is turned on i.e. a stream of 'FE' midi bytes
are being delivered to the interface and then my driver software.

I have altered the code so it doens't call snd_rawmidi_receive at which  
point my
driver software runs happily receiving and acknowledging bytes from the  
interface.

The locking sequence runs.

static irqreturn_t snd_uart16550_interrupt (int irq, void *dev_id, struct  
pt_regs *regs)
{
         snd_uart16550_t *uart;
         unsigned char c;

         uart = (snd_uart16550_t *) dev_id;
         spin_lock (&uart->open_lock);
         if (uart->filemode == SERIAL_MODE_NOT_OPENED) {
                 spin_unlock (&uart->open_lock);
                 return (IRQ_NONE);
         }
         c = inb (uart->base + UART_IIR);
         snd_uart16550_io_loop (uart);
         spin_unlock (&uart->open_lock);
         return (IRQ_HANDLED);
}

static void snd_uart16550_io_loop(snd_uart16550_t *uart)
{
         if (uart->F5_received) {
			// switch streams
                   uart->F5_received = FALSE;
         }
         else {
                   if (uart->filemode & SERIAL_MODE_INPUT_OPEN
                   &&  uart->midi_input[substream] != NULL) {
                         snd_rawmidi_receive (uart->midi_input[substream],  
&c, 1);
                   }
         }
}

int snd_rawmidi_receive(snd_rawmidi_substream_t * substream, const  
unsigned char *buffer, int count)
{
         unsigned long flags;
         int result = 0, count1;
         snd_rawmidi_runtime_t *runtime = substream->runtime;

         if (runtime->buffer == NULL) {
                 snd_printd("snd_rawmidi_receive: input is not  
active!!!\n");
                 return -EINVAL;
         }
         spin_lock_irqsave(&runtime->lock, flags);
         if (count == 1) {       /* special case, faster code */
                 substream->bytes++;
                 if (runtime->avail < runtime->buffer_size) {
                         runtime->buffer[runtime->hw_ptr++] = buffer[0];
                         runtime->hw_ptr %= runtime->buffer_size;
                         runtime->avail++;
                         result++;
                 } else {
                         runtime->xruns++;
                 }
	  }
         if (result > 0 && runtime->event == NULL) {
                 if (snd_rawmidi_ready(substream))
                         wake_up(&runtime->sleep);
         }
         spin_unlock_irqrestore(&runtime->lock, flags);
         if (result > 0 && runtime->event)
                 runtime->event(substream);
         return result;
}


I'm assuming there is no way that the runtine lock and the uart lock are  
the same but that
I'm spinning against the runtime lock. Anyone got any ideas? Is it  
possible that Rosegarden
holds a lock on the ALSA runtime object at all times if output is open and  
amidi only ever
works in one direction (i.e. input or output)?

TIA
Bill
-- 
Using Opera's revolutionary e-mail client: http://www.opera.com/m2/


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt

                 reply	other threads:[~2005-01-17 13:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=opskq0qzkmn0kn27@linux.site \
    --to=adair@gotadsl.co.uk \
    --cc=alsa-devel@lists.sourceforge.net \
    /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.