public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program
@ 2002-05-01  0:28 David Dyck
  2002-05-01 15:03 ` Stuart MacDonald
  0 siblings, 1 reply; 3+ messages in thread
From: David Dyck @ 2002-05-01  0:28 UTC (permalink / raw)
  To: Stuart MacDonald, Alan Modra, Kiyokazu SUTO, Andrew Morton,
	Arnaldo Carvalho de Melo, Kanoj Sarcar, Christer Weinigel,
	Robert Schwebel, Juergen Beisert, Theodore Ts'o, Sapan Bhatia
  Cc: linux-kernel


I have a program that opened "/dev/ttyS0" twice,
once as O_RDONLY, and once as O_WRONLY
 (I know now that I could have opened only one channel O_RDWR)

The program used tcsetattr( ,TCSANOW, ) to modify
c_iflag, c_oflag, and c_cflag for both channels.
first for the O_RDONLY channel, and then for the O_WRONLY.

Later the program used select() on the O_RDONLY channel to
detect characters, and read() to extract them from the driver.
This used to work in 2.2.x, (2.2.20) but select() now reports no characters
available on 2.4.x (today it is 2.4.19-pre7-ac3).

If I change the order of the tcsetattr() to modify the O_RDONLY
after the O_WRONLY channel, then it works on both 2.2.x and 2.4.x.
I have a workaround (by changing the order), but this order
dependency is not documented and I wonder if it is some new
feature, or a bug.
 (I think it is a bug)

I have a 158 line program that I use to demonstrate the
bug that I could email if requested.

I am wondering what changed between 2.2.x and 2.4.x that
could have caused this change in behaviour.

It turns out also that the O_WRONLY channel had CREAD turned off,
which I would expect was appropriate for an output channel, and
in 2.2 kernels, it didn't affect the O_RDONLY channel.  If I enable
the CREAD bit in termios c_cflag register for the O_WRONLY channel also
then the select on the O_RDONLY channel reports characters available.

I suspect that there is a different level of information sharing
between the 2 channels that are open, but which is the correct behaviour,
and why?

 David

I've addressed this email to those that have modified
the code since 2.2.20, maybe these symtoms will ring a bell.
Perhaps the change that causes this is outside of serial.c.


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

* Re: changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program
  2002-05-01  0:28 changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program David Dyck
@ 2002-05-01 15:03 ` Stuart MacDonald
  2002-05-01 16:45   ` David Dyck
  0 siblings, 1 reply; 3+ messages in thread
From: Stuart MacDonald @ 2002-05-01 15:03 UTC (permalink / raw)
  To: David Dyck, Alan Modra, Kiyokazu SUTO, Andrew Morton,
	Arnaldo Carvalho de Melo, Kanoj Sarcar, Christer Weinigel,
	Robert Schwebel, Juergen Beisert, Theodore Ts'o, Sapan Bhatia
  Cc: linux-kernel

From: "David Dyck" <dcd@tc.fluke.com>
> It turns out also that the O_WRONLY channel had CREAD turned off,
> which I would expect was appropriate for an output channel, and
> in 2.2 kernels, it didn't affect the O_RDONLY channel.  If I enable
> the CREAD bit in termios c_cflag register for the O_WRONLY channel also
> then the select on the O_RDONLY channel reports characters available.
>
> I suspect that there is a different level of information sharing
> between the 2 channels that are open, but which is the correct behaviour,
> and why?

CREAD handling was changed to be correct; recently, but I don't know
exactly when. The 2.4 vs 2.2 difference sounds about right though.
Previously CREAD had been incorrectly handled by the driver and hadn't
been changed because some apps would break. Now data is correctly
ignored on receive when CREAD is off.

When you talk about the "O_WRONLY channel" and the "O_RDONLY channel"
you're not actually referring to separate things. Each serial port is
represented in the kernel as one entity that may be opened different
ways, possibly multiple times.

When you turn off CREAD in your write side, you turn off CREAD for the
whole port, including the read only side. This is not a bug in the
driver.

..Stu



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

* Re: changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program
  2002-05-01 15:03 ` Stuart MacDonald
@ 2002-05-01 16:45   ` David Dyck
  0 siblings, 0 replies; 3+ messages in thread
From: David Dyck @ 2002-05-01 16:45 UTC (permalink / raw)
  To: Stuart MacDonald
  Cc: Alan Modra, Kiyokazu SUTO, Andrew Morton,
	Arnaldo Carvalho de Melo, Kanoj Sarcar, Christer Weinigel,
	Robert Schwebel, Juergen Beisert, Theodore Ts'o, Sapan Bhatia,
	linux-kernel

On Wed, 1 May 2002 at 11:03 -0400, Stuart MacDonald <stuartm@connecttech.co...:

> CREAD handling was changed to be correct; recently, but I don't know
> exactly when. The 2.4 vs 2.2 difference sounds about right though.
> Previously CREAD had been incorrectly handled by the driver and hadn't
> been changed because some apps would break. Now data is correctly
> ignored on receive when CREAD is off.
>
> When you talk about the "O_WRONLY channel" and the "O_RDONLY channel"
> you're not actually referring to separate things. Each serial port is
> represented in the kernel as one entity that may be opened different
> ways, possibly multiple times.
>
> When you turn off CREAD in your write side, you turn off CREAD for the
> whole port, including the read only side. This is not a bug in the
> driver.

Thanks for your response.  (thanks also the the other
folks that responded). It makes sense to me that 2 open calls
to the same "/dev/ttyS0" should map to the same driver and kernel
structure, so there is only one place that CREAD effects.

To bad that the 2.2 code was in error, but I can work around with that.

 David


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

end of thread, other threads:[~2002-05-01 16:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-05-01  0:28 changes between 2.2.20 and 2.4.x 'broke' select() from detecting input characters in my serial /dev/ttyS0 program David Dyck
2002-05-01 15:03 ` Stuart MacDonald
2002-05-01 16:45   ` David Dyck

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox