]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
serial: sc16is7xx: fix TX fifo corruption
authorHugo Villeneuve <hvilleneuve@dimonoff.com>
Tue, 23 Jul 2024 12:53:00 +0000 (08:53 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 14 Aug 2024 13:34:30 +0000 (15:34 +0200)
commit09cfe05e9907f3276887a20e267cc40e202f4fdd
treeea32773f8797374f4745d67a13f7e8c127161c2f
parent68dc02f319b9ee54dc23caba742a5c754d1cccc8
serial: sc16is7xx: fix TX fifo corruption

commit 133f4c00b8b2bfcacead9b81e7e8edfceb4b06c4 upstream.

Sometimes, when a packet is received on channel A at almost the same time
as a packet is about to be transmitted on channel B, we observe with a
logic analyzer that the received packet on channel A is transmitted on
channel B. In other words, the Tx buffer data on channel B is corrupted
with data from channel A.

The problem appeared since commit 4409df5866b7 ("serial: sc16is7xx: change
EFR lock to operate on each channels"), which changed the EFR locking to
operate on each channel instead of chip-wise.

This commit has introduced a regression, because the EFR lock is used not
only to protect the EFR registers access, but also, in a very obscure and
undocumented way, to protect access to the data buffer, which is shared by
the Tx and Rx handlers, but also by each channel of the IC.

Fix this regression first by switching to kfifo_out_linear_ptr() in
sc16is7xx_handle_tx() to eliminate the need for a shared Rx/Tx buffer.

Secondly, replace the chip-wise Rx buffer with a separate Rx buffer for
each channel.

Fixes: 4409df5866b7 ("serial: sc16is7xx: change EFR lock to operate on each channels")
Cc: stable@vger.kernel.org
Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com>
Link: https://lore.kernel.org/r/20240723125302.1305372-2-hugo@hugovil.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/sc16is7xx.c