Bug 237576 - UART NS8250 parity and frame errors detection doesn't work
Summary: UART NS8250 parity and frame errors detection doesn't work
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-bugs mailing list
URL: https://reviews.freebsd.org/D20072
Keywords: patch
Depends on:
Blocks: 16765
  Show dependency treegraph
 
Reported: 2019-04-26 08:30 UTC by Marius
Modified: 2019-05-23 08:36 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marius 2019-04-26 08:30:58 UTC
On the UART NS8250 errors (parity/frame) are not detected when data is received because every time there is a read on LSR register the errors bit is removed. See [1]
Current UART core implementation relies on the LSR register to detect if data is received. If data is received LSR is read again in pair with DATA register to determine if the received byte generate any errors. At this time LSR error bit is clear so no errors are reported.

In code:
1. uart_core.c: `uart_intr()` calls `UART_IPEND` which will go into `ns8250_bus_ipend()`. Here LSR register is read and returns data received.
2. `uart_intr` calls `uart_intr_rxready` -> `UART_RECEIVE` -> `ns8250_bus_receive`. Here LSR is read again to check if the received byte generated error, but error bit from LSR is now 0. It was cleared by step 1.


[1] https://en.wikibooks.org/wiki/Serial_Programming/8250_UART_Programming#Line_Status_Register
Comment 1 Marius 2019-04-26 08:33:08 UTC
I have a patch in place that based on my tests is fixing the problem: https://reviews.freebsd.org/D20072