All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: derosier@pianodisc.com
Cc: alsa-devel@lists.sourceforge.net
Subject: Re: [PATCH] serial-u16550 driver.  Fixes buffer blocking bug
Date: Thu, 30 Oct 2003 13:58:16 +0100	[thread overview]
Message-ID: <s5hn0biyj9z.wl@alsa2.suse.de> (raw)
In-Reply-To: <3FA03585.1000901@pianodisc.com>

Hi,

thanks for the patch!

At Wed, 29 Oct 2003 13:47:49 -0800,
Steve deRosier wrote:
> 
> I am submitting a patch to the serial-u16550 driver fix a bug 
> that we have encountered.  Basically, when using the 
> SNDRV_SERIAL_GENERIC adaptor in the serial-u16550 MIDI driver,
> if the device becomes unplugged or some other condition where
> the device stops signaling CTS, the send buffer backs up.
> This is fine and expected opperation, except on a prolonged
> problem (with our music, about 30-40 minutes typically) the
> buffer itself gets full.  It is supposed to then just throw 
> away data, but it seems that it doesn't operate quite right
> and it ends up backing up data in rawmidi.  When this 
> happens, the driver basically locks up (though "send direct"
> data still gets out), and only on a close and reopen of the
> device will recover.  
> 
> This patch fixes the problem, by modifiying how it checks
> for and handles its internal buffer:
> 
> 1. Move all checks of buffer overflow and such to the 
> actual buffer write and read routines.  This makes
> the buffer routines more robust and encaspulates buffer
> opperations better.

the check in the caller may be still needed for the multi-bytes write
(e.g. for switching the port).  otherwise, the port-switch command
can be mixed and messed up when the device is accessed concurrently.


> 2. Always try to send data to the buffers.  Don't interupt
> normal opperation of the algoritim because buffers are full.
> This was what was actually causing the data to be left in 
> rawmidi and thus causing it to lock up.  This is helped
> by moving the buffer size checks into the routines.

this is the questionary behavior.
the fact that the local buffer is full means that the transfer doesn't
work.  so, it is quite correct behavior that rawmidi blocks the
further write (in blocking mode), i think.  and, it should return
-EAGAIN in non-blocking mode.
or, at least, we can make the behavior selectable: abandon or block.

the problem is that there is no way to reset the device except for
reopening the device.  although there is a drop ioctl for rawmidi, it
doesn't reset the device as expected but only flushes the rawmidi
buffer.


> 3. When able to write, drain output as necessary instead of
> only writing one byte at a time.  This was causing us to 
> backup eventually anyway since we usually write more than 
> one byte of data.

looking at the code, only MS124W_SA and GENERIC types don't do loop.
so, it might be intentional, although i don't see any reason against
the looping.


btw, please use the unified diff (-u) as the patch at the next time.
it's much more readable.


ciao,

Takashi


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?   SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/

  reply	other threads:[~2003-10-30 12:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-10-29 21:47 [PATCH] serial-u16550 driver. Fixes buffer blocking bug Steve deRosier
2003-10-30 12:58 ` Takashi Iwai [this message]
2003-10-30 21:33   ` Steve deRosier
2003-10-31 17:49     ` Takashi Iwai
2003-11-04  1:44       ` Steve deRosier
2003-11-07 17:28         ` Takashi Iwai
2003-12-03  1:41       ` [PATCH] serial-u16550 driver. Fixes buffer blocking bug (2nd try) Steve deRosier
2003-12-03 13:25         ` Takashi Iwai

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=s5hn0biyj9z.wl@alsa2.suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@lists.sourceforge.net \
    --cc=derosier@pianodisc.com \
    /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.