On Sun, 2013-01-13 at 20:09 +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? Sounds like the same issue; you want to look at the serial port attribute "closing_wait". If the driver correctly implements that attribute (which they all should if they don't already), then in userspace if you do not want this behavior, you can set closing_wait to 0. But gadget doesn't implement this; so you'll want to modify drivers/usb/gadget/u_serial.c to add an ioctl hook to the gs_tty_ops structure. It should probably just do whatever usb_wwan_ioctl() does. See: https://patchwork.kernel.org/patch/1880941/ http://kerneltrap.org/mailarchive/linux-usb/2010/11/19/6266802 http://cgit.freedesktop.org/ModemManager/ModemManager/tree/src/mm-serial-port.c#n901 If the gadget Dan > thank you and best regards > > Petr Masek > > //////////////////////////////////////////////////////////////////////////////// > #include <stdio.h> > #include <string.h> > #include <stdio.h> > #include <termios.h> > #include <fcntl.h> > #include <errno.h> > > int main(void) > { > int fd = open("/dev/ttyGS0", O_NOCTTY | O_RDWR | O_NONBLOCK); > > if (fd < 0) { > printf("Serial device open error!\n"); > return -1; > } > > struct termios newtio; > > bzero(&newtio,sizeof(struct termios)); > newtio.c_cflag = B9600 | CS8 | CRTSCTS | CLOCAL | CREAD | > NOFLSH; > newtio.c_iflag = IGNPAR; > newtio.c_oflag = 0; > newtio.c_lflag = 0; > newtio.c_cc[VMIN] = 0; > newtio.c_cc[VTIME] = 0; > > tcsetattr(fd,TCSANOW,&newtio); > > int ret = 0; > while (ret >= 0) { > const char buffer[32] = "Hello World!\n"; > > ret = write(fd, buffer, strlen(buffer)); > if ((ret < 0) && (errno == EWOULDBLOCK)) printf("FIFO Full!\n"); > } > > tcflush(fd, TCOFLUSH); > > close(fd); > -- > 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 -- 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