Skip to content

Commit 267ee93

Browse files
j.turekgregkh
authored andcommitted
serial: xilinx_uartps: fix rs485 delay_rts_after_send
RTS line control with delay should be triggered when there is no more bytes in kfifo and hardware buffer is empty. Without this patch RTS control is scheduled right after feeding hardware buffer and this is too early. RTS line may change state before hardware buffer is empty. With this patch delayed RTS state change is triggered when function cdns_uart_handle_tx is called from cdns_uart_isr on CDNS_UART_IXR_TXEMPTY exactly when hardware completed transmission Fixes: fccc9d9 ("tty: serial: uartps: Add rs485 support to uartps driver") Cc: stable <stable@kernel.org> Link: https://patch.msgid.link/20251221103221.1971125-1-jakub.turek@elsta.tech Signed-off-by: Jakub Turek <jakub.turek@elsta.tech> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent c3ca8a0 commit 267ee93

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

drivers/tty/serial/xilinx_uartps.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -428,10 +428,17 @@ static void cdns_uart_handle_tx(void *dev_id)
428428
struct tty_port *tport = &port->state->port;
429429
unsigned int numbytes;
430430
unsigned char ch;
431+
ktime_t rts_delay;
431432

432433
if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) {
433434
/* Disable the TX Empty interrupt */
434435
writel(CDNS_UART_IXR_TXEMPTY, port->membase + CDNS_UART_IDR);
436+
/* Set RTS line after delay */
437+
if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED) {
438+
cdns_uart->tx_timer.function = &cdns_rs485_rx_callback;
439+
rts_delay = ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart));
440+
hrtimer_start(&cdns_uart->tx_timer, rts_delay, HRTIMER_MODE_REL);
441+
}
435442
return;
436443
}
437444

@@ -448,13 +455,6 @@ static void cdns_uart_handle_tx(void *dev_id)
448455

449456
/* Enable the TX Empty interrupt */
450457
writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER);
451-
452-
if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED &&
453-
(kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port))) {
454-
hrtimer_update_function(&cdns_uart->tx_timer, cdns_rs485_rx_callback);
455-
hrtimer_start(&cdns_uart->tx_timer,
456-
ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart)), HRTIMER_MODE_REL);
457-
}
458458
}
459459

460460
/**

0 commit comments

Comments
 (0)