Skip to content

Commit b12adc3

Browse files
committed
drivers: serial: Fix litex driver
This fixes several ways to hang the driver, such as: - typing too fast - going over the read buffer capacity - pasting anything - using arrow keys (sending 2 chars at once) etc Signed-off-by: Camille BAUD <[email protected]>
1 parent e0dbba5 commit b12adc3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/serial/uart_litex.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,13 @@ static int uart_litex_fifo_fill(const struct device *dev,
204204
const struct uart_litex_device_config *config = dev->config;
205205
int i;
206206

207+
litex_write8(UART_EV_RX, config->ev_pending_addr);
207208
for (i = 0; i < size && !litex_read8(config->txfull_addr); i++) {
208209
litex_write8(tx_data[i], config->rxtx_addr);
209210
}
211+
while (!litex_read8(config->txfull_addr)) {
212+
litex_write8(0, config->rxtx_addr);
213+
}
210214

211215
return i;
212216
}
@@ -288,7 +292,9 @@ static void uart_litex_irq_handler(const struct device *dev)
288292
}
289293

290294
/* Clear RX events, TX events still needed to enqueue the next transfer */
291-
litex_write8(UART_EV_RX, config->ev_pending_addr);
295+
if (litex_read8(config->rxempty_addr)) {
296+
litex_write8(UART_EV_RX, config->ev_pending_addr);
297+
}
292298

293299
irq_unlock(key);
294300
}

0 commit comments

Comments
 (0)