答复: 答复: [PATCH] serial: 8250: add lock for dma rx

From: wigin zeng
Date: Thu Dec 09 2021 - 04:08:58 EST


> What issue exactly?
The interval of UART input packages is very small(1ms~ 10ms), and some package size larger than configured DMA transfer size.

> But what data is being accessed at the same time to cause a crash?
> How is data being added into the buffer at the same time in two different places into the same queue? What userspace programs are causing this?
Both places will modify tty_port *port->buf.tail (kmalloc operation and write the data/flag into this address)

>So all tty buffer accesses need to be protected by your new lock?
New lock only protected the tty_buffer alloc and write operation in serial-tty case.

BRs
Wigin
-----邮件原件-----
发件人: Greg KH [mailto:gregkh@xxxxxxxxxxxxxxxxxxx]
发送时间: 2021年12月9日 16:42
收件人: wigin zeng <wigin.zeng@xxxxxxx>
抄送: jirislaby@xxxxxxxxxx; linux-serial@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx
主题: Re: 答复: [PATCH] serial: 8250: add lock for dma rx

【EXTERNAL EMAIL】 DO NOT CLICK any links or attachments unless you can make sure both the sender and the content are trustworthy.


【外部邮件提醒】以下邮件来源于公司外部,请勿点击链接或附件,除非您确认邮件发件人和内容可信。



A: http://en.wikipedia.org/wiki/Top_post
Q: Were do I find info about this thing called top-posting?
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

A: No.
Q: Should I include quotations after my reply?

http://daringfireball.net/2007/07/on_top

On Thu, Dec 09, 2021 at 08:15:00AM +0000, wigin zeng wrote:
> We encountered this issue when UART transfer very intensive.

What issue exactly?

> DMA irq-thread processed on CPU0 and serial irq-thread executing on
> CPU1, In DMA irq-thread will invoke "tty_insert_filp_string" function to add the rx_buf into tty_buffer.
> In serial irq-thread also has chance to access tty_insert_flip_char(in serial8250_rx_chars ) to access tty_buffer.
> there is race condition, sometimes will cause panic.

But what data is being accessed at the same time to cause a crash?
How is data being added into the buffer at the same time in two different places into the same queue? What userspace programs are causing this?

> We add the spin_lock to sync the tty_buffer operation, and the issue gone after applied the patch.

So all tty buffer accesses need to be protected by your new lock?

thanks,

greg k-h
This email and any attachments thereto may contain private, confidential, and privileged material for the sole use of the intended recipient. Any review, copying, or distribution of this email (or any attachments thereto) by others is strictly prohibited. If you are not the intended recipient, please contact the sender immediately and permanently delete the original and any copies of this email and any attachments thereto.

此电子邮件及附件所包含内容具有机密性,且仅限于接收人使用。未经允许,禁止第三人阅读、复制或传播该电子邮件中的任何信息。如果您不属于以上电子邮件的目标接收者,请您立即通知发送人并删除原电子邮件及其相关的附件。