From: John Ogness <john.ogness@linutronix.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jirislaby@kernel.org>,
Esben Haabendal <esben@geanix.com>,
linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org,
Petr Mladek <pmladek@suse.com>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Arnd Bergmann <arnd@arndb.de>, Tony Lindgren <tony@atomide.com>,
Kevin Hilman <khilman@baylibre.com>,
Markus Schneider-Pargmann <msp@baylibre.com>,
Udit Kumar <u-kumar1@ti.com>,
Griffin Kroah-Hartman <griffin@kroah.com>,
Rengarajan S <rengarajan.s@microchip.com>,
Guenter Roeck <linux@roeck-us.net>,
Jeff Johnson <quic_jjohnson@quicinc.com>,
Niklas Schnelle <schnelle@linux.ibm.com>,
Serge Semin <fancer.lancer@gmail.com>,
Lino Sanfilippo <l.sanfilippo@kunbus.com>,
Peter Collingbourne <pcc@google.com>
Subject: [PATCH tty-next v1 3/4] serial: 8250: Never adjust UART_LSR_DR in @read_status_mask
Date: Mon, 16 Dec 2024 18:18:43 +0106 [thread overview]
Message-ID: <20241216171244.12783-4-john.ogness@linutronix.de> (raw)
In-Reply-To: <20241216171244.12783-1-john.ogness@linutronix.de>
The CREAD feature of termios is implemented by setting/clearing
UART_LSR_DR within @ignore_status_mask. For this feature to
function correctly, it requires that UART_LSR_DR is never
masked (unset) in @read_status_mask so that uart_insert_char()
can properly drop the character if CREAD is disabled.
Currently there are code paths that clear/set UART_LSR_DR from
@read_status_mask at times. This appears to be a relic from
Linux 1.1.60, where @read_status_mask could be used to mask
all UART_LSR reading. However, since Linux 2.1.8 that is no
longer the case. Now if UART_LSR_DR is cleared from
@read_status_mask, received characters may not be dropped
even though CREAD is disabled.
This can be seen when:
- CREAD is disabled (UART_LSR_DR is set in @ignore_status_mask)
- LSR has an error bit set from UART_LSR_BRK_ERROR_BITS
(and that error is not ignored via @ignore_status_mask)
- UART_LSR_DR is cleared in @read_status_mask
In this case characters will be inserted into the tty buffer
even though they should be ignored.
Remove all setting/clearing of UART_LSR_DR for
@read_status_mask except for its initialization.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
drivers/tty/serial/8250/8250_core.c | 1 -
drivers/tty/serial/8250/8250_omap.c | 1 -
drivers/tty/serial/8250/8250_port.c | 1 -
3 files changed, 3 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_core.c b/drivers/tty/serial/8250/8250_core.c
index 5f9f06911795..2b70e82dffeb 100644
--- a/drivers/tty/serial/8250/8250_core.c
+++ b/drivers/tty/serial/8250/8250_core.c
@@ -675,7 +675,6 @@ static void serial_8250_overrun_backoff_work(struct work_struct *work)
uart_port_lock_irqsave(port, &flags);
up->ier |= UART_IER_RLSI | UART_IER_RDI;
- up->port.read_status_mask |= UART_LSR_DR;
serial_out(up, UART_IER, up->ier);
uart_port_unlock_irqrestore(port, flags);
}
diff --git a/drivers/tty/serial/8250/8250_omap.c b/drivers/tty/serial/8250/8250_omap.c
index 5290aed76a5e..10144fcc0363 100644
--- a/drivers/tty/serial/8250/8250_omap.c
+++ b/drivers/tty/serial/8250/8250_omap.c
@@ -838,7 +838,6 @@ static void omap_8250_unthrottle(struct uart_port *port)
if (up->dma)
up->dma->rx_dma(up);
up->ier |= UART_IER_RLSI | UART_IER_RDI;
- port->read_status_mask |= UART_LSR_DR;
serial_out(up, UART_IER, up->ier);
uart_port_unlock_irqrestore(port, flags);
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index a5c1b069c67b..3b9dc2bb06eb 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -1390,7 +1390,6 @@ static void serial8250_stop_rx(struct uart_port *port)
serial8250_rpm_get(up);
up->ier &= ~(UART_IER_RLSI | UART_IER_RDI);
- up->port.read_status_mask &= ~UART_LSR_DR;
serial_port_out(port, UART_IER, up->ier);
serial8250_rpm_put(up);
--
2.39.5
next prev parent reply other threads:[~2024-12-16 17:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 17:12 [PATCH tty-next v1 0/4] serial: 8250: Fix LSR masking John Ogness
2024-12-16 17:12 ` [PATCH tty-next v1 1/4] serial: 8250: Use @ier bits to determine if Rx is stopped John Ogness
2024-12-16 20:31 ` Andy Shevchenko
2024-12-16 20:43 ` Andy Shevchenko
2024-12-20 11:50 ` John Ogness
2024-12-24 15:59 ` Andy Shevchenko
2024-12-16 17:12 ` [PATCH tty-next v1 2/4] serial: 8250: Do not set UART_LSR_THRE in @read_status_mask John Ogness
2024-12-16 20:36 ` Andy Shevchenko
2024-12-16 17:12 ` John Ogness [this message]
2024-12-16 17:12 ` [PATCH tty-next v1 4/4] serial: 8250: Explain the role of @read_status_mask John Ogness
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241216171244.12783-4-john.ogness@linutronix.de \
--to=john.ogness@linutronix.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=arnd@arndb.de \
--cc=esben@geanix.com \
--cc=fancer.lancer@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=griffin@kroah.com \
--cc=jirislaby@kernel.org \
--cc=khilman@baylibre.com \
--cc=l.sanfilippo@kunbus.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=msp@baylibre.com \
--cc=pcc@google.com \
--cc=pmladek@suse.com \
--cc=quic_jjohnson@quicinc.com \
--cc=rengarajan.s@microchip.com \
--cc=schnelle@linux.ibm.com \
--cc=tony@atomide.com \
--cc=u-kumar1@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®