NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/61013: Serial port stalls under crtscts when CTS is dropped and raised again
>Number: 61013
>Category: kern
>Synopsis: Serial port stalls under crtscts when CTS is dropped and raised again
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sun Nov 15 23:30:00 +0000 2026
>Originator: John Goerzen
>Release: NetBSD 11.0
>Organization:
>Environment:
NetBSD [redacted] 11.1 NetBSD 11.1 (GENERIC) #0: Mon Nov 2 16:34:32 UTC 2026 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/alpha/compile/GENERIC alpha
>Description:
On a 16550A UART dial-in line connected to a US Robotics Courier modem, with the serial port set at a fixed speed of 115200bps, I have connections at about 28800bps. The line is flagged rtscts in /etc/ttys. When the NetBSD machine transmits enough data that the modem deasserts CTS, NetBSD correctly stops transmitting data.
However, it does not restart transmitting data when the modem re-asserts CTS. This leads to a permanent transmit stall until one of the conditions I describe below occurs.
An easy way to provoke this is to "pkgin install lrzsz" and then use lsz to transmit a compressed file. ZModem, by default, is a streaming protocol that does not send ACKs.
When the stall occurs, I observe:
1. The modem's CS light had briefly been off, but is back on. This light corresponds to the CTS line.
2. TIOCMGET on the port incorrectly indicates CTS is 0. It correctly indicates that DSR, DCD, RTS, and DRT are 1. Before the stall, TIOCMGET correctling indicated CTS was 1.
3. pstat -t shows a non-empty output queue that doesn't drain. State is "OC", with no TTSTOP.
4. If the processes on that tty are killed, even with -9, the line never closes. The login process remains a zombie and a new getty isn't spawned until a new call changes the modem signals. At that point, the queued data is sent, and the modem hangs up immediately after. Then a second call works.
I have found the following to break the stall, and allow NetBSD to continue transmitting:
1. Sending any character to the NetBSD system
2. From another terminal, turn crtscts off and back on again. I do this with "stty -f /dev/ttyC1 -crtscts; stty -f /dev/ttyC1 crtscts)
In either of these cases, it'll stall again a few KB later.
Example pstat -t output (in this example ttyC3 was the port being tested):
6 terminal devices
LINE RAW CAN OUT HWT LWT COL STATE SESS PGID DISC
4095,1048575 0 0 0 0 0 0 - 0 0 termios
4095,1048575 0 0 0 0 0 0 - 0 0 termios
ttyC2 0 0 0 8192 2048 658 O FFFFFC003FB9C940 1177 termios
ttyC3 0 0 8872 17280 5760 17430 OC FFFFFC003547A9C0 1064 termios
pts/0 0 0 0 8192 2048 0 OC FFFFFC003D10FB40 1060 termios
pts/1 0 0 0 8192 2048 0 - 0 0 termios
This Alpha has 4 16550A ports. Two are integrated on the motherboard, and show as ISA ports at PC standard IRQs and ports, ttyC2 and ttyC3. Two are on a PCI card with 16550A ports, showing up as ttyC0 and ttyC1. There are no errors related to these in dmesg, but here's how they show up:
[ 1.000000] puc0 at pci0 dev 5 function 0: NetMos NM9865 1 UART (com)
[ 1.000000] com0 at puc0 port 0 (16550-compatible): interrupting at eb164 irq 2
[ 1.000000] com0: ns16550a, 16-byte FIFO
[ 1.000000] puc1 at pci0 dev 5 function 1: NetMos NM9865 1 UART (com)
[ 1.000000] com1 at puc1 port 0 (16550-compatible): interrupting at eb164 irq 9
[ 1.000000] com1: ns16550a, 16-byte FIFO
...
[ 1.000000] com2 at isa0 port 0x3f8-0x3ff irq 4: ns16550a, 16-byte FIFO
[ 1.000000] com2: console
[ 1.000000] com3 at isa0 port 0x2f8-0x2ff irq 3: ns16550a, 16-byte FIFO
I tested this on both ttyC1 and ttyC3, and got the same behavior on both.
I used the exact same modem and cable connected to a Linux box with crtscts enabled (using a FTDI USB serial adapter), and there were no problems there. No data loss, and transmit perfectly stopped when CTS was dropped and perfectly resumed when CTS was raised.
As a workaround, I was able to drop the serial port speed to 19200 (which is below the speed of the modem, so CTS is never deasserted), and to use lsz -w 2048. The latter causes the receiving end of the ZModem transmission to issue ACKs after each 1K block, which I theorize effectively unstalls the UART since I know that sending at least one character will do so.
I theorize that any interrupt from the 16550 will cause the driver to re-sync its notion of the state of CTS.
I also ran pppd on this system without obvious issue. I suspect that, in that case, ACKs (or perhaps timeouts triggering a resend request) were frequent enough that the stall, if it happened, wasn't hugely noticed.
>How-To-Repeat:
Set a serial port to a speed significantly in excess of the line rate of a modem. Put the port and the modem in RTS/CTS flow control mode. Transmit a large amount of data, enough to cause CTS to be deasserted, such as with lsz in its default mode of operation. Observe the stall.
>Fix:
I don't know.
Home |
Main Index |
Thread Index |
Old Index