What is the motivation of this if-condition in void serial8250_tx_chars(struct uart_8250_port *up)?
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(port);
It has been there ever since Linux 1.1.13 (May 1994) and repeats in most UART drivers.
Background: customized Linux 3.4.91, embedded system on ARMv7, UART port 0 is configured for 38400 baud, 16 byte FIFO for i/o. None of this can be changed in our setup.
When printf-ing very heavily on the console via UART, the internal 4kB-buffer (UART_XMIT_SIZE) fills up and then stalls the user-space process until the buffer is emptied (which takes one second at 38400 baud!). Then this behavior repeats. This is because function n_tty_write() goes to sleep when the buffer is full, and is not woken up for a long time because of the questionable condition above.
I would find it more natural and efficient if this check was simply removed. Then the printfs would fill up the buffer as quickly as they can, and then continue at the speed at which the buffer is being emptied, rather than the burst-processing I am observing.
It works fine in my environment but surely I am missing or misunderstanding something. There must be a reason for the current implementation. Are there any side effects if I remove that condition?
As a side-question: are there configuration options to tune this behavior, e.g. to have printf always return immediately and discard the output if the buffer is full?