All of lore.kernel.org
 help / color / mirror / Atom feed
* artpec.c / serial_core.c hardware flow control problem
@ 2012-06-28 15:29 Mikael Johansson
  2012-06-28 16:24 ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Mikael Johansson @ 2012-06-28 15:29 UTC (permalink / raw)
  To: linux-serial; +Cc: Mikael Starvik, Jesper Nilsson, Johan Adolfsson

Greetings,

We have a problem with drivers/serial/artpec.c (Not yet in main tree) 
which uses hardware supported flow control (XON/XOFF). We do cfmakeraw() 
and tcsetattr() from userspace to set a termios struct where (c_iflag & 
IXON) is not set. The problem is that the call to tcsetattr() is not 
propagated down to serial_artpec_set_termios(), the reason being that 
uart_set_termios() doesn't think that IXON is a RELEVANT_IFLAG and 
returns prematurely instead of calling uart_change_speed --> 
ops->set_termios().

Could this be fixed by making IXON a RELEVANT_IFLAG?:

diff --git a/drivers/serial/serial_core.c b/drivers/serial/serial_core.c
index 7f28307..d45473d 100644
--- a/drivers/serial/serial_core.c
+++ b/drivers/serial/serial_core.c
@@ -1211,7 +1211,7 @@ static void uart_set_termios(struct tty_struct *tty,
       * bits in c_cflag; c_[io]speed will always be set
       * appropriately by set_termios() in tty_ioctl.c
       */
-#define RELEVANT_IFLAG(iflag)    ((iflag) & 
(IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
+#define RELEVANT_IFLAG(iflag)    ((iflag) & 
(IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK|IXON))
      if ((cflag ^ old_termios->c_cflag) == 0 &&
          tty->termios->c_ospeed == old_termios->c_ospeed &&
          tty->termios->c_ispeed == old_termios->c_ispeed &&


Or should it be fixed at some other level?

Note: This was tested on 2.6.35 but appears to have the same code in the 
newer kernels. Not many drivers seem to look at the IXON flag, only 
crisv10, omap_serial and jsm_neo.

Best regards,
Mikael Johansson


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: artpec.c / serial_core.c hardware flow control problem
  2012-06-28 15:29 artpec.c / serial_core.c hardware flow control problem Mikael Johansson
@ 2012-06-28 16:24 ` Alan Cox
  2012-06-29 15:16   ` Johan Adolfsson
  0 siblings, 1 reply; 4+ messages in thread
From: Alan Cox @ 2012-06-28 16:24 UTC (permalink / raw)
  To: Mikael Johansson
  Cc: linux-serial, Mikael Starvik, Jesper Nilsson, Johan Adolfsson

On Thu, 28 Jun 2012 17:29:27 +0200
Mikael Johansson <mikael.lars.johansson@axis.com> wrote:

> Greetings,
> 
> We have a problem with drivers/serial/artpec.c (Not yet in main tree) 
> which uses hardware supported flow control (XON/XOFF). We do cfmakeraw() 
> and tcsetattr() from userspace to set a termios struct where (c_iflag & 
> IXON) is not set. The problem is that the call to tcsetattr() is not 
> propagated down to serial_artpec_set_termios(), the reason being that 
> uart_set_termios() doesn't think that IXON is a RELEVANT_IFLAG and 
> returns prematurely instead of calling uart_change_speed --> 
> ops->set_termios().
> 
> Could this be fixed by making IXON a RELEVANT_IFLAG?:

That's actually insufficient for those cases - you can set the characters
used for things as well plus IXANY and IXOFF.

It's a stupid "optimisation" and the only reason I didn't get rid of it
before was in case it broke something else. Time for it to go.

So yeah - I'd just delete it.

If you are doing hardware XON/XOFF watch c_cc[VSTART] and c_cc[VSTOP].
Those control the symbol used for soft flow control.

Alan



^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: artpec.c / serial_core.c hardware flow control problem
  2012-06-28 16:24 ` Alan Cox
@ 2012-06-29 15:16   ` Johan Adolfsson
  2012-06-29 16:31     ` Alan Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Johan Adolfsson @ 2012-06-29 15:16 UTC (permalink / raw)
  To: Alan Cox, Mikael Lars Johansson
  Cc: linux-serial, Mikael Starvik, Jesper Nilsson, Johan Adolfsson



> -----Original Message-----
> From: linux-serial-owner@vger.kernel.org [mailto:linux-serial-
> owner@vger.kernel.org] On Behalf Of Alan Cox
> Sent: den 28 juni 2012 18:24
> 
> On Thu, 28 Jun 2012 17:29:27 +0200
> Mikael Johansson <mikael.lars.johansson@axis.com> wrote:
> 
> > Greetings,
> >
> > We have a problem with drivers/serial/artpec.c (Not yet in main tree)
> > which uses hardware supported flow control (XON/XOFF). We do
> cfmakeraw()
> > and tcsetattr() from userspace to set a termios struct where (c_iflag
> &
> > IXON) is not set. The problem is that the call to tcsetattr() is not
> > propagated down to serial_artpec_set_termios(), the reason being that
> > uart_set_termios() doesn't think that IXON is a RELEVANT_IFLAG and
> > returns prematurely instead of calling uart_change_speed -->
> > ops->set_termios().
> >
> > Could this be fixed by making IXON a RELEVANT_IFLAG?:
> 
> That's actually insufficient for those cases - you can set the
> characters
> used for things as well plus IXANY and IXOFF.
> 
> It's a stupid "optimisation" and the only reason I didn't get rid of it
> before was in case it broke something else. Time for it to go.
> 
> So yeah - I'd just delete it.

Do you mean the entire if () { return; } statement or just the RELEVANT_IFLAG part?

> If you are doing hardware XON/XOFF watch c_cc[VSTART] and c_cc[VSTOP].
> Those control the symbol used for soft flow control.

We use STOP_CHAR(tty), we only have hardware support for stopping transfer,
the tty layer kicks in and enables it again.

> Alan

/Johan


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: artpec.c / serial_core.c hardware flow control problem
  2012-06-29 15:16   ` Johan Adolfsson
@ 2012-06-29 16:31     ` Alan Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Cox @ 2012-06-29 16:31 UTC (permalink / raw)
  To: Johan Adolfsson
  Cc: Mikael Lars Johansson, linux-serial, Mikael Starvik,
	Jesper Nilsson, Johan Adolfsson

> Do you mean the entire if () { return; } statement or just the RELEVANT_IFLAG part?

It's not enough to check the iflag in this case - a termios changing
c_cc[VSTOP) - which is what STOP_CHAR(tty) is, also might need
the stop handling reprogramming.

Alan


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-06-29 16:27 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-28 15:29 artpec.c / serial_core.c hardware flow control problem Mikael Johansson
2012-06-28 16:24 ` Alan Cox
2012-06-29 15:16   ` Johan Adolfsson
2012-06-29 16:31     ` Alan Cox

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.