tty: TCIOFF/TCION under TCOOFF lose the character on pty and vt
Hi Greg, Jiri,
I hit a small corner case in tty_send_xchar(). It only happens on a pty or the vt console after output was suspended with TCOOFF, so it may not be worth fixing.
Under TCOOFF, tcflow(TCIOFF) and tcflow(TCION) still send the STOP or START character on most ttys. serial_core UARTs do it through ->send_xchar(). Drivers without ->send_xchar() go through ->write(): __start_tty() does nothing while tco_stopped is set, but usb-serial, cdc-acm and u_serial do not check the stopped state in ->write(), so the character still goes out.
pty_write() and the vt console's write return 0 while the tty is stopped, though. tty_send_xchar() ignores that and returns 0, so on a pty or vt the call reports success but the character is never sent, not even after TCOON.
On v7.3, with TCOOFF in effect, TCIOFF and TCION returned 0 on all of these. 8250, ftdi_sio, cdc-acm and u_serial delivered the character before TCOON. pty and vt delivered nothing, before or after TCOON. The code is unchanged in next-20261113.
tty_send_xchar() could return an error such as -EIO when the write took no byte. Since usb-serial and u_serial also return 0 when their FIFO is full, that should probably be limited to the case where the tty is stopped. I can send a patch if you want one.
Thanks,
Cheng Yongkang