Re: [linux-usb-devel] Re: new locking in change_termios breaks USBserial drivers

From: Al Borchers
Date: Fri Oct 01 2004 - 13:25:36 EST


Alan Cox wrote:
In a waiting case the driver will get

->chars_in_buffer
until it returns zero
->wait_until_sent
->change_termios

which serializes with respect to the one writer. If you have a writer
during a termios change by another well tough luck, you lose and I've
no intention of changing that behaviour unless someone cites a standard
requiring it.

Right, of course.

My comments about TCSETAW just muddled the issue. Scratch those.

The problem is that a non-sleeping USB serial set_termios has to
return before it can be sure the termios settings have taken effect.
With USB we can send an urb to the device telling it to change termios
settings, but without waiting for the urb callback we don't know
that the device has received the command and actually changed the
settings.

So data written immediately following the set_termios, in the same
process, might possibly be sent out the serial port before the
termios changes have taken effect.

There are several solutions:

* The tty layer could use a semaphore so the USB serial set_termios could
sleep until the new termios settings have taken effect before returning.

* The USB serial driver could hold off sending data to the device after a
non-sleeping set_termios until it knew the settings had taken effect in
the device.

* Maybe in practice this is not a problem--we can just say "set_termios
for USB serial devices will change the termios settings as soon as
possible, but there is a slight chance data written immediately after
set termios might go out under the previous termios settings".

* Or ... other suggestions?

-- Al

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/