summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_core.c
diff options
context:
space:
mode:
authorian <ian@FreeBSD.org>2013-03-31 23:24:04 +0000
committerian <ian@FreeBSD.org>2013-03-31 23:24:04 +0000
commit2b56a5ce50807c0c4197f17f42b23f069dab02ba (patch)
tree56ef5677ed1bdc04549dfebddf3f2021382947fe /sys/dev/uart/uart_core.c
parentf370876f88224b709659a34169f56abc39f89efb (diff)
downloadFreeBSD-src-2b56a5ce50807c0c4197f17f42b23f069dab02ba.zip
FreeBSD-src-2b56a5ce50807c0c4197f17f42b23f069dab02ba.tar.gz
Accommodate uart devices with large FIFOs (or DMA buffers which amount
to the same thing) by allocating the uart(4) rx buffer based on the device's rxfifosz rather than using a hard-coded size of 384 bytes. The historical 384 byte size is 3 times the largest hard-coded fifo size in the tree, so use that ratio as a guide and allocate the buffer as three times rxfifosz, but never smaller than the historical size.
Diffstat (limited to 'sys/dev/uart/uart_core.c')
-rw-r--r--sys/dev/uart/uart_core.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/sys/dev/uart/uart_core.c b/sys/dev/uart/uart_core.c
index f5a9a1c..b264e5b 100644
--- a/sys/dev/uart/uart_core.c
+++ b/sys/dev/uart/uart_core.c
@@ -457,7 +457,13 @@ uart_bus_attach(device_t dev)
callout_init(&sc->sc_timer, 1);
}
- sc->sc_rxbufsz = 384;
+ /*
+ * Ensure there is room for at least three full FIFOs of data in the
+ * receive buffer (handles the case of low-level drivers with huge
+ * FIFOs), and also ensure that there is no less than the historical
+ * size of 384 bytes (handles the typical small-FIFO case).
+ */
+ sc->sc_rxbufsz = MAX(384, sc->sc_rxfifosz * 3);
sc->sc_rxbuf = malloc(sc->sc_rxbufsz * sizeof(*sc->sc_rxbuf),
M_UART, M_WAITOK);
sc->sc_txbuf = malloc(sc->sc_txfifosz * sizeof(*sc->sc_txbuf),
OpenPOWER on IntegriCloud