Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: fccc9d9233f9 ("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>

authored by

j.turek and committed by
Greg Kroah-Hartman
267ee93c c3ca8a0a

+7 -7
+7 -7
drivers/tty/serial/xilinx_uartps.c
··· 428 428 struct tty_port *tport = &port->state->port; 429 429 unsigned int numbytes; 430 430 unsigned char ch; 431 + ktime_t rts_delay; 431 432 432 433 if (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port)) { 433 434 /* Disable the TX Empty interrupt */ 434 435 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 + } 435 442 return; 436 443 } 437 444 ··· 455 448 456 449 /* Enable the TX Empty interrupt */ 457 450 writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER); 458 - 459 - if (cdns_uart->port->rs485.flags & SER_RS485_ENABLED && 460 - (kfifo_is_empty(&tport->xmit_fifo) || uart_tx_stopped(port))) { 461 - hrtimer_update_function(&cdns_uart->tx_timer, cdns_rs485_rx_callback); 462 - hrtimer_start(&cdns_uart->tx_timer, 463 - ns_to_ktime(cdns_calc_after_tx_delay(cdns_uart)), HRTIMER_MODE_REL); 464 - } 465 451 } 466 452 467 453 /**