All of lore.kernel.org
 help / color / mirror / Atom feed
From: Grant Edwards <grant.b.edwards@gmail.com>
To: linux-serial@vger.kernel.org
Subject: Re: API to flush rx fifo?
Date: Wed, 26 Feb 2014 17:51:13 +0000 (UTC)	[thread overview]
Message-ID: <lel9ih$p6i$1@ger.gmane.org> (raw)
In-Reply-To: 530E20EF.7070609@hurleysoftware.com

On 2014-02-26, Peter Hurley <peter@hurleysoftware.com> wrote:
> Hi Grant,
>
> I know this is old but I had marked this for re-review in my mail,
> and after re-looking at this problem, I realized I gave you some bad info.
>
> Since you were referring to uart_ops, I'll assume this is for your
> serial-core mini-driver(s).

Yup.

Upon review of this thread, I see that you had warned me that
tty->receive_room was going away, and I completely forgot about that
warning and didn't do anything about it about that until my drivers
actually broke 8 months later.

Shame on me.

>>>>> How does the rx fifo get flushed when the user calls tcflush(TCIFLUSH)?
>>>>
>>>> It doesn't.
>
> The ioctl(TCIFLUSH) does in fact flush the tty buffers.
>
> If you want to flush your hardware rx fifo, you can define the
> .ioctl() method in your struct uart_ops and handle TCIFLUSH there.
>
> Note: be sure to return -ENOIOCTLCMD so that TCIFLUSH processing
> still gets seen by the ldisc!
>
> Like this (apologies in advance for formatting; my mailer is
> dain-bramaged),
>
> /* called with port->mutex held */
> static int xxxxxx_ioctl(struct uart_port *port, unsigned int cmd,
> 			unsigned long arg)
> {
> 	if (cmd == TCFLSH) {
> 		switch (arg) {
> 		case TCIFLUSH:
> 		case TCIOFLUSH:
> 			spin_lock_irq(&port->lock);
> 			xxxxxx_empty_rx_fifo(port);
> 			spin_unlock_irq(&port->lock);
> 			/* fall-through */
> 		}
> 	}
> 	return -ENOIOCTLCMD;
> }
>
> Sorry, hope this isn't too late :(

Great!  That's certalinly simple enough.

It turns out the customer's problem had nothing to do with the UART's
rx fifos not getting flushed when TCIFLUSH was done, so I put that
issue on the list of things to be worried about later (and that's
where it still is).

I'll add the above handling to my drivers just to be complete, but I
don't think it's actually ever caused any problems.

-- 
Grant Edwards               grant.b.edwards        Yow! I was making donuts
                                  at               and now I'm on a bus!
                              gmail.com            


      reply	other threads:[~2014-02-26 17:51 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-12 20:03 API to flush rx fifo? Grant Edwards
2013-06-14 14:43 ` Peter Hurley
2013-06-14 15:17   ` Grant Edwards
2013-06-14 15:46     ` Peter Hurley
2013-06-14 16:29       ` Grant Edwards
2013-06-14 17:09         ` Peter Hurley
2013-06-14 17:39           ` Grant Edwards
2013-06-14 18:04             ` Peter Hurley
2013-06-14 19:12               ` Grant Edwards
2013-06-14 20:53                 ` Peter Hurley
2013-06-14 18:41             ` Grant Edwards
2013-06-14 20:19               ` Peter Hurley
2014-02-26 17:14       ` Peter Hurley
2014-02-26 17:51         ` Grant Edwards [this message]

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='lel9ih$p6i$1@ger.gmane.org' \
    --to=grant.b.edwards@gmail.com \
    --cc=linux-serial@vger.kernel.org \
    /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.