LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 11-15-2023, 09:32 AM   #1
Rarebeast
LQ Newbie
 
Registered: Nov 2023
Posts: 1

Rep: Reputation: 0
Question Problem with port driver - UART4.


UART4 serial port driver (w-apb-uart) - UART4 has only two lines - Rx and Tx.

Kernel 6.5.8 is used.

Allwinner A40i processor.

This is exactly RS485, the UART is connected to the RS485 transceiver chip. The RTS pin is used to organize half-duplex transmission.

DTS
In the DTS file it is redefined as UART:
&uart4 {
pinctrl-names = "default";
compatible = "snps,dw-apb-uart";
pinctrl-0 = <&uart4_ph_pins>;
rts-gpios = <&pio 7 13 GPIO_ACTIVE_HIGH>; //PH13
//rs485-rts-delay = <0 200>;
linux,rs485-enabled-at-boot-time;
status = "okay";
};

The GPIO PH13 port is used as an RTS pin (this is not hardware RTS).

In the device tree on the fourth port we enable the mode (linux,rs485-enabled-at-boot-time).

MY ACTIONS:
We open the port (using SCREEN) - reception occurs normally.
But as soon as we send the first line or character, the port hangs, immediately after the first send (it is successful, it arrives).
When sending, the port goes to the HIGH position, but after it does not return to the LOW position. The port stops working both for reception and transmission.

We used different speeds - 9600 to 115200, does not affect the behavior of the port.

When digging into the depths of the port driver (/linux-6.5.8/drivers/tty/serial/8250/8250_dw.c) and trying to debug, it turned out that if you paste the output into the console //dev_err() or dev_info() - everything starts work, but at the same time messages begin to arrive in the console from the ports.

The function static int dw8250_handle_irq(struct uart_port *p) calls:
int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
{
struct uart_8250_port *up = up_to_u8250p(port);
struct tty_port *tport = &port->state->port;
bool skip_rx = false;
unsigned long flags;
u16 status;

if (iir & UART_IIR_NO_INT)
return 0;

//dev_err(port->dev, "Handle irq before breakpoint \n");//qq

spin_lock_irqsave(&port->lock, flags);

status = serial_lsr_in(up);

/*
* If port is stopped and there are no error conditions in the
* FIFO, then don't drain the FIFO, as this may lead to TTY buffer
* overflow. Not servicing, RX FIFO would trigger auto HW flow
* control when FIFO occupancy reaches preset threshold, thus
* halting RX. This only works when auto HW flow control is
* available.
*/
if (!(status & (UART_LSR_FIFOE | UART_LSR_BRK_ERROR_BITS)) &&
(port->status & (UPSTAT_AUTOCTS | UPSTAT_AUTORTS)) &&
!(port->read_status_mask & UART_LSR_DR))
skip_rx = true;

if (status & (UART_LSR_DR | UART_LSR_BI) && !skip_rx) {
if (irqd_is_wakeup_set(irq_get_irq_data(port->irq)))
pm_wakeup_event(tport->tty->dev, 0);
if (!up->dma handle_rx_dma(up, iir))
status = serial8250_rx_chars(up, status);
}

serial8250_modem_status(up);
if ((status & UART_LSR_THRE) && (up->ier & UART_IER_THRI)) {
if (!up->dma up->dma->tx_err)
serial8250_tx_chars(up);
else if (!up->dma->tx_running)
__stop_tx(up);
}

uart_unlock_and_check_sysrq_irqrestore(port, flags);

return 1;
}

If the output of dev_err() is placed before spin_lock_irqsave(&port->lock, flags); then everything works. If after that it does not work, a spin_lock of the port occurs and in the future it is not released, a dead_lock occurs.

uart_unlock_and_check_sysrq_irqrestore(port, flags); - doesn’t work.

QUESTION:
How to solve the problem so that the port works adequately, without sending messages from the ports to the console? Is the driver at fault?

TxRx Diagram - https://postimg.cc/BjVnxhD0

Last edited by Rarebeast; 11-15-2023 at 10:57 PM. Reason: image added
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] enabling uart4 and uart7 on a Banana Pro justwantin Slackware - ARM 3 08-27-2017 03:39 AM
Tomcat6 stops listening on port 80 when i change from port 8080 to port 80 trongthect Linux - Server 1 07-27-2012 05:41 PM
Beagle Bone Rev A5 serial communication UART4 and UART5 mux settings mandar.nandale Linux - Embedded & Single-board computer 0 05-22-2012 06:11 AM
--destination-ports port[,port[,port...]] KevinGuy Linux - Networking 1 03-16-2004 06:06 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 06:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration