Re: [PATCH] USB: serial: Fix read regression in 2.6.31

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

 



On Mon, Sep 21, 2009 at 05:43:27PM -0700, Elina Pasheva wrote:
> On Mon, 2009-09-21 at 17:07 -0700, Johan Hovold wrote:

> > Use ASYNCB_INITIALIZED to determine when to stop reading.

> > Port count can no longer be used to determine when to stop reading from
> > the device as it can be zero when the first read callbacks are made (see
> > tty_port_block_til_read where port count is temporarily decremented
> > during serial_open).

> There seems to be a problem with this patch for sierra.c driver as
> Matthew Safar pointed out.
> The patch changes the use of port.count in sierra_indat_callback for a
> test_bit(ASYNCB_INITIALIZED). The problem is that the bit is set by
> usb_serial only _after_ the sierra_open is called.

> Often when modem has something to say its data  sits in a queue in the modem
> and once an RX urb is available the data is sent to the host. Often that
> happens while we are still in open - submitting more RX urbs.

Of course, you're right. My patch only shifted the problem around
somewhat.. Just as port count can no longer be used as it can be zero
after open (e.g. during dtr_rts), ASYNCB_INITIALIZED cannot alone be
used as read callbacks can be made before open returns. 

> Could it be the rest of the drivers have similar problem? (we have  not
> check that).

The ftdi driver sets up the read urb just before returning from open
but inserting a delay before returning triggers the problem you pointed
out.

> In sierra driver case we have "opened flag" - could it be used to achieve the same?

I guess so, but such a flag would be needed in every driver and should
therefore probably be handled in usb-serial?

Another way would be to test both port count and ASYNCB_INITALIZED:
	
/* Stop reading if port has been closed. */
if (port->port.count <= 0 && !test_bit(ASYNCB_INITIALIZED, &port->port.flags))
	return;

as port count is non-zero during open and ASYNCB_INITALIZED is set when
open returns (but before port count is decremented). I admit it's not
pretty. ;)

Any other suggestions?

Regards,
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