Re: tty_flip_buffer_push in interrupt context

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Jul 01, 2012 at 07:43:17AM +0000, tilman wrote:
> Hello
> 
> many of the usb serial drivers are using the code fragement below to fill
> received data into the read queue of the attached tty.
> 
> read_callback:
> ...
> tty = tty_port_tty_get(&port->port);
>         if (tty != NULL && urb->actual_length > 0) {
>                 tty_insert_flip_string(tty, data, urb->actual_length);
>                 tty_flip_buffer_push(tty);
>         }
>         tty_kref_put(tty);
> ...
> 
> Typically, tty->low_latency is set to 1 in the open function. 

This is simply not a correct statement -- no usb serial driver should be
setting low_latency in open and only the fairly recently added metro_usb
driver currently does. This should be fixed.

> Now, I read in the man page of tty_flip_buffer_push that it is not to be called
> from an interrupt context if tty->low_latency=1. I understand however that the
> callback handler runs in an interrupt context.

Correct. That is why low_latency should generally not be set.

> In a test driver I wrote, tty_flip_buffer_push(tty) makes the kernal crash if
> tty->low_latency=1. If I remove this line, the kernal does not crash. And I have
> a second driver that does not crash if tty->low_latency=1. It uses
> tty_flip_buffer_push in the read_callback handler.
> 
> Can somebody please shed some light under what circumstance tty_flip_buffer_push
> can be used from a callback handler ?

With changes made to the tty layer a fair while back there should no
longer be any need to use the low_latency flag as the tty layer provides
plenty of buffering these days.

Simply leave it unset and call tty_flip_buffer_push in your completion
handler.

Johan
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux