Re: close blocks, if FIFO full on gagdet serial

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

 



Hi,

On Sun, Jan 13, 2013 at 08:09:14PM +0100, masekp@xxxxxxxxxxxx wrote:
> Hello guys,
> I've found a following problems on BeagleBoard and Kernel 3.0.8 with
> gadget serial driver.
> 
> Attached is a small program, which opens gadget serial tty at
> /dev/ttyGS0. USB is NOT connected to host. Then it fills it's output
> fifo up. Before closing, it flushes the output fifo. But despite
> that, call to close function on last line blocks for 15seconds!
> 
> To me it looks like fifo flushing doesn't work. If I do this on
> regular serial port on PC and if I remove output fifo flushing, close
> also blocks (as I have flow control set). But if the flushing is
> present, close returns immediately on PC.
> 
> On gadget serial, it always block for 15s.
> 
> So it looks to me like a bug in gadget serial driver. Or is there any
> other cleanup, which I should do? Or at least some option how to
> lower the timeout value?
> 
> thank you and best regards

I haven't even compile tested this, but something like below is probably
what you need:

diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
index 598dcc1..adba385 100644
--- a/drivers/usb/gadget/u_serial.c
+++ b/drivers/usb/gadget/u_serial.c
@@ -936,8 +936,10 @@ static void gs_flush_chars(struct tty_struct *tty)
 	pr_vdebug("gs_flush_chars: (%d,%p)\n", port->port_num, tty);
 
 	spin_lock_irqsave(&port->port_lock, flags);
-	if (port->port_usb)
+	if (port->port_usb) {
+		gs_buf_clear(&port->port_write_buf);
 		gs_start_tx(port);
+	}
 	spin_unlock_irqrestore(&port->port_lock, flags);
 }
 

needs proper testing however. If you look at gs_start_tx(), you'll see
that it waits up to 15 seconds for port_write_buf to be cleared. In fact
I think gs_start_tx() shouldn't even be called from gs_flush_chars(),
IIUC, gs_flush_chars() should call usb_ep_dequeue() on every single
pending request and then call gs_buf_clear(), but that'll be a much more
involved work which I'll try to do later this week.

Meanwhile, can you see if patch above breaks anything ?

cheers

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux