# HG changeset patch # User Mychaela Falconia # Date 1581488602 0 # Node ID 9d9c241f2c84860c553ca857ca80dc6f5994b3b6 # Parent d5abcbbf7432f751deecdd4055b1325b9d6a4c15 libserial-newlnx experimental change to set ASYNC_LOW_LATENCY diff -r d5abcbbf7432 -r 9d9c241f2c84 libserial-newlnx/openport.c --- a/libserial-newlnx/openport.c Tue Feb 11 21:27:40 2020 +0000 +++ b/libserial-newlnx/openport.c Wed Feb 12 06:23:22 2020 +0000 @@ -5,6 +5,7 @@ #include #include #include +#include #include #include #include @@ -14,11 +15,25 @@ open_serial_port(ttyport) char *ttyport; { + struct serial_struct kernel_serial_settings; + target_fd = open(ttyport, O_RDWR|O_NONBLOCK); if (target_fd < 0) { perror(ttyport); exit(1); } ioctl(target_fd, TIOCEXCL); + /* + * It appears that some miscreants have modified recent Linux kernel + * versions (newer than linux-4.4.14 of Slackware 14.2) to insert + * a delay of 10 ms before select system call returns when serial + * input is ready; this Linux kernel misbehaviour majorly slows down + * many of our operations. It appears that we need to set the + * ASYNC_LOW_LATENCY flag in TIOCSSERIAL in order to get the old + * sane behaviour back. + */ + ioctl(target_fd, TIOCGSERIAL, &kernel_serial_settings); + kernel_serial_settings.flags |= ASYNC_LOW_LATENCY; + ioctl(target_fd, TIOCSSERIAL, &kernel_serial_settings); return 0; }