* Re: rfcomm-tty driver->put_char
[not found] ` <1053379016.1475.66.camel@pegasus>
@ 2003-05-19 21:54 ` David Woodhouse
2003-05-20 8:56 ` Russell King
0 siblings, 1 reply; 2+ messages in thread
From: David Woodhouse @ 2003-05-19 21:54 UTC (permalink / raw)
To: Marcel Holtmann; +Cc: BlueZ Mailing List, viro, linux-kernel
On Mon, 2003-05-19 at 22:16, Marcel Holtmann wrote:
> > Once possible solution is to implement our own put_char() routine which
> > _does_ always allow the character to be queued, rather than allowing
> > tty_default_put_char() to call rfcomm_tty_write() which will fail.
>
> After some more tests, I plan to push this change.
Note that I recommend this for 2.4 _only_. For 2.5 the correct fix is to
fix the tty_driver API, so you can perhaps let this 'bug' remain there
for a while. I seem to be the only person using an rfcomm modem for
dialin anyway, and 2.5 doesn't even get as far as a login prompt on that
box, let alone support V.110 dialin over ISDN which is also required, so
I really won't miss it :)
The write_room() function is documented to return the number of
characters which can _currently_ be pushed to the tty driver. The n_tty
code has no business thinking that the value returned from write_room()
will be valid at _any_ point in the future, and the fact that put_char()
is not permitted to return any success/failure indication like write()
can is just bizarre.
--
dwmw2
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: rfcomm-tty driver->put_char
2003-05-19 21:54 ` rfcomm-tty driver->put_char David Woodhouse
@ 2003-05-20 8:56 ` Russell King
0 siblings, 0 replies; 2+ messages in thread
From: Russell King @ 2003-05-20 8:56 UTC (permalink / raw)
To: David Woodhouse; +Cc: Marcel Holtmann, BlueZ Mailing List, viro, linux-kernel
On Mon, May 19, 2003 at 10:54:10PM +0100, David Woodhouse wrote:
> Note that I recommend this for 2.4 _only_. For 2.5 the correct fix is to
> fix the tty_driver API, so you can perhaps let this 'bug' remain there
> for a while. I seem to be the only person using an rfcomm modem for
> dialin anyway, and 2.5 doesn't even get as far as a login prompt on that
> box, let alone support V.110 dialin over ISDN which is also required, so
> I really won't miss it :)
>
> The write_room() function is documented to return the number of
> characters which can _currently_ be pushed to the tty driver. The n_tty
> code has no business thinking that the value returned from write_room()
> will be valid at _any_ point in the future, and the fact that put_char()
> is not permitted to return any success/failure indication like write()
> can is just bizarre.
It is up to the line discipline to ensure that there is only a single
thread running between write_room() and the write() or put_char() call
(which is currently done thanks to lock_kernel(). If it isn't, the
tty locking broke and we have bigger problems.)
Without this guarantee, how do you propose to handle the following case:
- we have a "\n" character from user space.
- we have O_ONLCR set.
- we have only one character available in the output buffer in the driver.
This means we need to write two characters "\r\n" to the driver. If we
try to write "\r\n" using your proposed solution, we'd write "\r". How
do we remember that we need to write a "\n" (or some other string of
characters for that matter) ?
Now consider if we could remember we've only written half the string.
What happens if we've written "\r", then some tty echo occurs, then
we write "\n" ?
If these cases don't work with a new API, the new API is even more buggy
than the existing one.
(For user output, n_tty currently guarantees that we will not drop any
characters written from user space, as long as we remain single-threaded
between write_room() and put_char() or write() methods.)
Looking at rfcomm, this is probably part of your problem:
return dlc->mtu * (dlc->tx_credits ? : 10);
Also, rfcomm should be fixed to use the put_char / flush_buffer methods.
These are there to batch up single chars to make things more efficient,
and I wouldn't be surprised if a stream of single chars were eating up
all your tx credits.
I'm surprised that rfcomm, being a packet based communication system,
doesn't implement put_char.
--
Russell King (rmk@arm.linux.org.uk) The developer of ARM Linux
http://www.arm.linux.org.uk/personal/aboutme.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-05-20 8:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1053199887.9218.50.camel@imladris.demon.co.uk>
[not found] ` <1053379016.1475.66.camel@pegasus>
2003-05-19 21:54 ` rfcomm-tty driver->put_char David Woodhouse
2003-05-20 8:56 ` Russell King
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox