[PATCH v7 02/12] serial: 8250: widen RX trigger byte counts to 16 bits

From: James Hilliard

Date: Tue Nov 03 2026 - 16:43:19 EST


DesignWare UARTs can have 2048-byte FIFOs, with receive thresholds as
large as 2046 bytes. The byte-sized threshold tables, setter argument and
sysfs parser cannot represent these values.

Use u16 for the threshold tables and byte counts throughout the 8250
conversion and sysfs paths, including the uart_port callback interface.
Keep the FCR encoding byte-sized and preserve the existing threshold
selection. The Moxa setter continues to validate against its 128-byte
FIFO before writing the byte-sized trigger register.

Signed-off-by: James Hilliard <james.hilliard1@xxxxxxxxx>
---
drivers/tty/serial/8250/8250.h | 2 +-
drivers/tty/serial/8250/8250_mxpcie.c | 2 +-
drivers/tty/serial/8250/8250_port.c | 12 ++++++------
include/linux/serial_core.h | 2 +-
4 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 21ed9c41b751..939b7d4209f1 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -69,7 +69,7 @@ struct serial8250_config {
unsigned short fifo_size;
unsigned short tx_loadsz;
unsigned char fcr;
- unsigned char rxtrig_bytes[UART_FCR_R_TRIG_MAX_STATE];
+ u16 rxtrig_bytes[UART_FCR_R_TRIG_MAX_STATE];
unsigned int flags;
};

diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c
index 4935a5d1c1a3..4f0b881b4f83 100644
--- a/drivers/tty/serial/8250/8250_mxpcie.c
+++ b/drivers/tty/serial/8250/8250_mxpcie.c
@@ -257,7 +257,7 @@ static int mxpcie8250_get_rxtrig(struct uart_port *port)
return serial_port_in(port, MOXA_PUART_RTL);
}

-static int mxpcie8250_set_rxtrig(struct uart_port *port, unsigned char bytes)
+static int mxpcie8250_set_rxtrig(struct uart_port *port, u16 bytes)
{
struct mxpcie8250 *priv = dev_get_drvdata(port->dev);

diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 36b2b0a2c05c..452851815ffc 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3008,14 +3008,14 @@ static int serial8250_request_port(struct uart_port *port)
static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
{
const struct serial8250_config *conf_type = &uart_config[up->port.type];
- unsigned char bytes;
+ u16 bytes;

bytes = conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)];

return bytes ? bytes : -EOPNOTSUPP;
}

-static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, unsigned char bytes)
+static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes)
{
const struct serial8250_config *conf_type = &uart_config[up->port.type];
int i;
@@ -3073,7 +3073,7 @@ static ssize_t rx_trig_bytes_show(struct device *dev,
return sysfs_emit(buf, "%d\n", rxtrig_bytes);
}

-static int do_set_rxtrig(struct tty_port *port, unsigned char bytes)
+static int do_set_rxtrig(struct tty_port *port, u16 bytes)
{
struct uart_state *state = container_of(port, struct uart_state, port);
struct uart_port *uport = state->uart_port;
@@ -3094,7 +3094,7 @@ static int do_set_rxtrig(struct tty_port *port, unsigned char bytes)
return 0;
}

-static int do_serial8250_set_rxtrig(struct tty_port *port, unsigned char bytes)
+static int do_serial8250_set_rxtrig(struct tty_port *port, u16 bytes)
{
int ret;

@@ -3111,13 +3111,13 @@ static ssize_t rx_trig_bytes_store(struct device *dev,
struct tty_port *port = dev_get_drvdata(dev);
struct uart_state *state = container_of(port, struct uart_state, port);
struct uart_port *uport = state->uart_port;
- unsigned char bytes;
+ u16 bytes;
int ret;

if (!count)
return -EINVAL;

- ret = kstrtou8(buf, 10, &bytes);
+ ret = kstrtou16(buf, 10, &bytes);
if (ret < 0)
return ret;

diff --git a/include/linux/serial_core.h b/include/linux/serial_core.h
index 4eeb8253752a..97301ef66af0 100644
--- a/include/linux/serial_core.h
+++ b/include/linux/serial_core.h
@@ -461,7 +461,7 @@ struct uart_port {
unsigned int quot,
unsigned int quot_frac);
int (*get_rxtrig)(struct uart_port *port);
- int (*set_rxtrig)(struct uart_port *port, unsigned char bytes);
+ int (*set_rxtrig)(struct uart_port *port, u16 bytes);
int (*startup)(struct uart_port *port);
void (*shutdown)(struct uart_port *port);
void (*throttle)(struct uart_port *port);

--
2.53.0