Re: [PATCH V5 3/3] tty: serial: uartps: Add rs485 support to uartps driver

From: Lino Sanfilippo
Date: Thu Dec 14 2023 - 04:00:27 EST



Hi,

On 13.12.23 14:00, Manikanta Guntupalli wrote:

>
> +/**
> + * cdns_rs485_rx_callback - Timer rx callback handler for rs485.
> + * @t: Handle to the timer list structure
> + */
> +static void cdns_rs485_rx_callback(struct timer_list *t)
> +{
> + struct cdns_uart *cdns_uart = from_timer(cdns_uart, t, timer);
> +
> + /*
> + * Default Rx should be setup, because Rx signaling path
> + * need to enable to receive data.
> + */
> + cdns_rs485_rx_setup(cdns_uart);
> +}
> +
> +/**
> + * cdns_rs485_tx_callback - Timer tx callback handler for rs485.
> + * @t: Handle to the timer list structure
> + */
> +static void cdns_rs485_tx_callback(struct timer_list *t)
> +{
> + struct cdns_uart *cdns_uart = from_timer(cdns_uart, t, timer);
> +
> + cdns_uart_handle_tx(cdns_uart->port);

This is called without holding the port lock now. Are you sure the lock is not
needed? AFAIK the port lock is needed at least for accessing the circular
buffer.

> +
> + /* Enable the TX Empty interrupt */
> + writel(CDNS_UART_IXR_TXEMPTY, cdns_uart->port->membase + CDNS_UART_IER);
> +
> + if (uart_circ_empty(&cdns_uart->port->state->xmit) ||
> + uart_tx_stopped(cdns_uart->port)) {
> + timer_setup(&cdns_uart->timer, cdns_rs485_rx_callback, 0);
> + mod_timer(&cdns_uart->timer, jiffies +
> + msecs_to_jiffies(cdns_uart->port->rs485.delay_rts_after_send));
> + }
> +}

Regards,
Lino