All of lore.kernel.org
 help / color / mirror / Atom feed
* snd_serial_u16550 lockup
@ 2005-01-17 13:22 Bill Adair
  0 siblings, 0 replies; only message in thread
From: Bill Adair @ 2005-01-17 13:22 UTC (permalink / raw)
  To: alsa-devel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2005-01-17 13:22 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-01-17 13:22 snd_serial_u16550 lockup Bill Adair

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.