* [PATCH v10 01/11] serial: 8250_dw: allow port setup to report errors
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 02/11] serial: 8250_dw: select port setup through platform data James Hilliard
` (9 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
Return a status from dw8250_setup_port() and propagate failures through
the DW and LPSS probe paths before registering the UART. Use the existing
LPSS cleanup path to release board resources and IRQ vectors on failure.
Keep the current setup behavior by returning zero on both successful
paths. This separates error propagation from the configuration validation
that will use it.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dw.c | 4 +++-
drivers/tty/serial/8250/8250_dwlib.c | 6 ++++--
drivers/tty/serial/8250/8250_dwlib.h | 2 +-
drivers/tty/serial/8250/8250_lpss.c | 4 +++-
4 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index e9bb1df45e33..7d2920106f58 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -766,7 +766,9 @@ static int dw8250_probe(struct platform_device *pdev)
dw8250_setup_dma_filter(p, data);
if (!data->skip_autocfg)
- dw8250_setup_port(p);
+ err = dw8250_setup_port(p);
+ if (err)
+ return err;
/* Use the BUSY-safe sequence for both integer and fractional divisors. */
p->set_divisor = dw8250_set_divisor;
diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index 91b3607b64e6..4a06dec6e263 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -208,7 +208,7 @@ static const struct serial_rs485 dw8250_rs485_supported = {
SER_RS485_ADDR_DEST,
};
-void dw8250_setup_port(struct uart_port *p)
+int dw8250_setup_port(struct uart_port *p)
{
struct dw8250_port_data *pd = p->private_data;
struct uart_8250_port *up = up_to_u8250p(p);
@@ -250,7 +250,7 @@ void dw8250_setup_port(struct uart_port *p)
dev_dbg(p->dev, "CPR is not available, using 0x%08x instead\n", reg);
}
if (!reg)
- return;
+ return 0;
/* Select the type based on FIFO */
if (reg & DW_UART_CPR_FIFO_MODE) {
@@ -270,5 +270,7 @@ void dw8250_setup_port(struct uart_port *p)
pd->srbr = DW_UART_SRBR_0;
else
pd->srbr = UART_RX;
+
+ return 0;
}
EXPORT_SYMBOL_GPL(dw8250_setup_port);
diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h
index 7191cabfb086..4d32651956ab 100644
--- a/drivers/tty/serial/8250/8250_dwlib.h
+++ b/drivers/tty/serial/8250/8250_dwlib.h
@@ -100,7 +100,7 @@ struct dw8250_port_data {
unsigned int dw8250_get_divisor_dlf(struct uart_port *p, unsigned int baud, unsigned int *frac);
void dw8250_set_divisor_dlf(struct uart_port *p, unsigned int quot_frac);
void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old);
-void dw8250_setup_port(struct uart_port *p);
+int dw8250_setup_port(struct uart_port *p);
static inline u32 dw8250_readl_ext(struct uart_port *p, int offset)
{
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index fc9ac24340e6..db8b685b77db 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -353,7 +353,9 @@ static int lpss8250_probe(struct pci_dev *pdev, const struct pci_device_id *id)
if (ret)
return ret;
- dw8250_setup_port(&uart.port);
+ ret = dw8250_setup_port(&uart.port);
+ if (ret)
+ goto err_exit;
ret = lpss8250_dma_setup(lpss, &uart);
if (ret)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 02/11] serial: 8250_dw: select port setup through platform data
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
2026-12-04 10:28 ` [PATCH v10 01/11] serial: 8250_dw: allow port setup to report errors James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 03/11] serial: 8250: widen RX trigger byte counts to 16 bits James Hilliard
` (8 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
Select feature discovery and DMA attachment through a platform-data setup
callback. The generic callback probes the optional registers and attaches
DMA when a FIFO size is available. Integrations with a fixed configuration
can supply their own setup before the port is registered. Allow setup to
return an error so integrations can reject invalid configuration before
registration.
Replace skip_autocfg with the Octeon setup selection. Octeon is a 64-bit
platform and continues to skip optional-register probing while preserving
its existing conditional DMA attachment. Select the DMA setup helper
directly for this integration. Keep generic setup for devices without
matched platform data as well.
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dw.c | 44 +++++++++++++++++++++++++++++----------
1 file changed, 33 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 7d2920106f58..a20adb38e046 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -64,6 +64,7 @@ struct dw8250_platform_data {
u8 usr_reg;
u32 cpr_value;
unsigned int quirks;
+ int (*setup)(struct uart_port *p);
};
struct dw8250_data {
@@ -76,7 +77,6 @@ struct dw8250_data {
struct clk *pclk;
struct reset_control *rst;
- unsigned int skip_autocfg:1;
unsigned int uart_16550_compatible:1;
unsigned int in_idle:1;
@@ -596,7 +596,6 @@ static void dw8250_quirks(struct uart_port *p, struct dw8250_data *data)
p->serial_out = dw8250_serial_outq;
p->flags = UPF_SKIP_TEST | UPF_SHARE_IRQ | UPF_FIXED_TYPE;
p->type = PORT_OCTEON;
- data->skip_autocfg = true;
}
#endif
@@ -631,6 +630,33 @@ static void dw8250_shutdown(struct uart_port *port)
d->no_int_count = 0;
}
+static int dw8250_setup_dma(struct uart_port *p)
+{
+ struct dw8250_data *data = to_dw8250_data(p->private_data);
+ struct uart_8250_port *up = up_to_u8250p(p);
+
+ /* DMA setup requires a FIFO */
+ if (!p->fifosize)
+ return 0;
+
+ data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
+ data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
+ up->dma = &data->data.dma;
+
+ return 0;
+}
+
+static int dw8250_setup(struct uart_port *p)
+{
+ int ret;
+
+ ret = dw8250_setup_port(p);
+ if (ret)
+ return ret;
+
+ return dw8250_setup_dma(p);
+}
+
static int dw8250_probe(struct platform_device *pdev)
{
struct uart_8250_port uart = {}, *up = &uart;
@@ -765,21 +791,16 @@ static int dw8250_probe(struct platform_device *pdev)
dw8250_setup_dma_filter(p, data);
- if (!data->skip_autocfg)
- err = dw8250_setup_port(p);
+ if (data->pdata && data->pdata->setup)
+ err = data->pdata->setup(p);
+ else
+ err = dw8250_setup(p);
if (err)
return err;
/* Use the BUSY-safe sequence for both integer and fractional divisors. */
p->set_divisor = dw8250_set_divisor;
- /* If we have a valid fifosize, try hooking up DMA */
- if (p->fifosize) {
- data->data.dma.rxconf.src_maxburst = p->fifosize / 4;
- data->data.dma.txconf.dst_maxburst = p->fifosize / 4;
- up->dma = &data->data.dma;
- }
-
data->data.uport = serial8250_register_8250_port(up);
if (IS_ERR(data->data.uport))
return PTR_ERR(data->data.uport);
@@ -862,6 +883,7 @@ static const struct dw8250_platform_data dw8250_dw_apb = {
static const struct dw8250_platform_data dw8250_octeon_3860_data = {
.usr_reg = OCTEON_UART_USR,
.quirks = DW_UART_QUIRK_OCTEON,
+ .setup = dw8250_setup_dma,
};
static const struct dw8250_platform_data dw8250_armada_38x_data = {
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 03/11] serial: 8250: widen RX trigger byte counts to 16 bits
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
2026-12-04 10:28 ` [PATCH v10 01/11] serial: 8250_dw: allow port setup to report errors James Hilliard
2026-12-04 10:28 ` [PATCH v10 02/11] serial: 8250_dw: select port setup through platform data James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:46 ` sashiko-bot
2026-12-04 10:28 ` [PATCH v10 04/11] serial: 8250: share the RX trigger conversion helper James Hilliard
` (7 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
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@gmail.com>
---
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 0a3fb63991c1..eff164339611 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
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v10 03/11] serial: 8250: widen RX trigger byte counts to 16 bits
2026-12-04 10:28 ` [PATCH v10 03/11] serial: 8250: widen RX trigger byte counts to 16 bits James Hilliard
@ 2026-12-04 10:46 ` sashiko-bot
0 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-12-04 10:46 UTC (permalink / raw)
To: James Hilliard; +Cc: linux-serial, devicetree, linux-sunxi, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] serial: 8250_mxpcie: u16-to-u8 truncation in
mxpcie8250_set_rxtrig()
--
commit c0bd87c22f5fd195b99868bf224819efdd25bf4c
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250: widen RX trigger byte counts to 16 bits
This commit widens the 8250 RX trigger threshold tables, sysfs parser,
and uart_port set_rxtrig callback from unsigned char to u16 to support
UARTs with larger FIFOs.
> diff --git a/drivers/tty/serial/8250/8250_mxpcie.c b/drivers/tty/serial/8250/8250_mxpcie.c
> index 0a3fb63991c1c..eff1643396110 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);
[Severity: Low]
Can mxpcie8250_set_rxtrig() silently truncate bytes when writing
MOXA_PUART_RTL and rx_trig_level?
mxpcie8250_set_rxtrig() only checks bytes > port->fifosize, but
TIOCSSERIAL allows CAP_SYS_ADMIN to overwrite uport->fifosize via
uart_set_info() without serial8250_verify_port() validating
xmit_fifo_size, even with UPF_FIXED_TYPE set.
With rx_trig_bytes_store() now using kstrtou16(), values above 255 can
pass the fifosize check and get truncated modulo 256 when written to the
8-bit MOXA_PUART_RTL register and stored in u8 rx_trig_level (e.g.
writing 256 programs 0) while returning success.
Bounding bytes against U8_MAX (or the hardware 128-byte FIFO limit) in
mxpcie8250_set_rxtrig() would avoid the truncation.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com?part=3
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v10 04/11] serial: 8250: share the RX trigger conversion helper
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (2 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 03/11] serial: 8250: widen RX trigger byte counts to 16 bits James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 05/11] serial: 8250: expose RX trigger controls for custom callbacks James Hilliard
` (6 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
Drivers can supply receive-trigger thresholds through the RX trigger
callbacks without adding a legacy port type to uart_config[]. Extract the
threshold search into serial8250_bytes_to_fcr() so those drivers can use
the same conversion as the generic 8250 implementation.
Keep the implementation in 8250_port.c and share it within 8250_base.
Include the unsupported-table check and preserve the existing nearest-lower
selection and highest-encoding fallback.
Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250.h | 2 ++
drivers/tty/serial/8250/8250_port.c | 14 ++++++++++----
2 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/tty/serial/8250/8250.h b/drivers/tty/serial/8250/8250.h
index 939b7d4209f1..8729619160ea 100644
--- a/drivers/tty/serial/8250/8250.h
+++ b/drivers/tty/serial/8250/8250.h
@@ -73,6 +73,8 @@ struct serial8250_config {
unsigned int flags;
};
+int serial8250_bytes_to_fcr(const u16 *rxtrig_bytes, u16 bytes);
+
enum uart_port_type {
/* Internal 8250 only */
UART_PORT_AIROHA = 124,
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 452851815ffc..73bc9e7ab703 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3015,16 +3015,15 @@ static int fcr_get_rxtrig_bytes(struct uart_8250_port *up)
return bytes ? bytes : -EOPNOTSUPP;
}
-static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes)
+int serial8250_bytes_to_fcr(const u16 *rxtrig_bytes, u16 bytes)
{
- const struct serial8250_config *conf_type = &uart_config[up->port.type];
int i;
- if (!conf_type->rxtrig_bytes[UART_FCR_R_TRIG_BITS(UART_FCR_R_TRIG_00)])
+ if (!rxtrig_bytes[UART_FCR_R_TRIG_BITS(UART_FCR_R_TRIG_00)])
return -EOPNOTSUPP;
for (i = 1; i < UART_FCR_R_TRIG_MAX_STATE; i++) {
- if (bytes < conf_type->rxtrig_bytes[i])
+ if (bytes < rxtrig_bytes[i])
/* Use the nearest lower value */
return (--i) << UART_FCR_R_TRIG_SHIFT;
}
@@ -3032,6 +3031,13 @@ static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes)
return UART_FCR_R_TRIG_11;
}
+static int bytes_to_fcr_rxtrig(struct uart_8250_port *up, u16 bytes)
+{
+ const struct serial8250_config *conf_type = &uart_config[up->port.type];
+
+ return serial8250_bytes_to_fcr(conf_type->rxtrig_bytes, bytes);
+}
+
static int do_get_rxtrig(struct tty_port *port)
{
struct uart_state *state = container_of(port, struct uart_state, port);
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 05/11] serial: 8250: expose RX trigger controls for custom callbacks
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (3 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 04/11] serial: 8250: share the RX trigger conversion helper James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 06/11] serial: 8250_dw: derive RX trigger thresholds from the FIFO depth James Hilliard
` (5 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
The rx_trig_bytes attribute dispatches to a port's get_rxtrig and
set_rxtrig callbacks when present, but the attribute group is registered
only when the port type has a static receive-trigger table.
Allow a port that supplies both callbacks to expose the attribute without
a static table. This lets integrations such as Octeon provide their
FIFO-relative thresholds through callbacks while retaining their existing
port type. Require both callbacks because the attribute is read/write;
ports with a static table continue to use the existing fallback handlers.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_port.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_port.c b/drivers/tty/serial/8250/8250_port.c
index 73bc9e7ab703..d87e2b852c3c 100644
--- a/drivers/tty/serial/8250/8250_port.c
+++ b/drivers/tty/serial/8250/8250_port.c
@@ -3152,7 +3152,8 @@ static void register_dev_spec_attr_grp(struct uart_8250_port *up)
{
const struct serial8250_config *conf_type = &uart_config[up->port.type];
- if (conf_type->rxtrig_bytes[0])
+ if (conf_type->rxtrig_bytes[0] ||
+ (up->port.get_rxtrig && up->port.set_rxtrig))
up->port.attr_group = &serial8250_dev_attr_group;
}
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 06/11] serial: 8250_dw: derive RX trigger thresholds from the FIFO depth
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (4 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 05/11] serial: 8250: expose RX trigger controls for custom callbacks James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:52 ` sashiko-bot
2026-12-04 10:28 ` [PATCH v10 07/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner H616 James Hilliard
` (4 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
DW_apb_uart uses receive thresholds of one byte, one quarter full,
one half full and two bytes below full. The generic 16550A table describes
these encodings only for a 16-byte FIFO. For example, the half-full setting
on a 64-byte DW FIFO is reported as eight bytes instead of 32, and a sysfs
request for 32 bytes selects the 62-byte encoding.
Build a per-port threshold table from the discovered FIFO depth in dwlib
and install receive-trigger callbacks for CPR-described FIFOs, including
LPSS ports. Keep the setup helper available to integrations which obtain
the depth without probing the optional DW registers. Validate that each
threshold is positive and representable before constructing the table.
Serialize FCR updates with termios and the port lock, acquire a runtime PM
reference before accessing the device, and propagate resume errors without
changing the shadow or hardware. Update only the trigger field so changing
the threshold preserves the FIFO contents.
The FCR mapping is documented in the DW_apb_uart databook, section 6,
FIFO Control Register. The existing default FCR encoding is unchanged.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dwlib.c | 87 ++++++++++++++++++++++++++++++++++++
drivers/tty/serial/8250/8250_dwlib.h | 2 +
2 files changed, 89 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
index 4a06dec6e263..6cfb7674ac11 100644
--- a/drivers/tty/serial/8250/8250_dwlib.c
+++ b/drivers/tty/serial/8250/8250_dwlib.c
@@ -1,18 +1,27 @@
// SPDX-License-Identifier: GPL-2.0+
/* Synopsys DesignWare 8250 library. */
+#include <linux/array_size.h>
#include <linux/bitops.h>
#include <linux/bitfield.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/kernel.h>
+#include <linux/limits.h>
#include <linux/math.h>
+#include <linux/mutex.h>
+#include <linux/pm_runtime.h>
#include <linux/property.h>
#include <linux/serial_8250.h>
#include <linux/serial_core.h>
#include "8250_dwlib.h"
+/* DesignWare FIFO-relative receive thresholds */
+#define DW_UART_RXTRIG_QUARTER_DIV 4
+#define DW_UART_RXTRIG_HALF_DIV 2
+#define DW_UART_RXTRIG_FULL_MARGIN 2
+
/*
* divisor = div(I) + div(F)
* "I" means integer, "F" means fractional
@@ -208,11 +217,85 @@ static const struct serial_rs485 dw8250_rs485_supported = {
SER_RS485_ADDR_DEST,
};
+/* The trigger is the masked FCR receive trigger field, in register position */
+static unsigned int dw8250_rxtrig_bytes(struct uart_port *p, unsigned int trigger)
+{
+ switch (trigger) {
+ case UART_FCR_TRIGGER_1:
+ return 1;
+ case UART_FCR_TRIGGER_4:
+ return p->fifosize / DW_UART_RXTRIG_QUARTER_DIV;
+ case UART_FCR_TRIGGER_8:
+ return p->fifosize / DW_UART_RXTRIG_HALF_DIV;
+ default:
+ return p->fifosize - DW_UART_RXTRIG_FULL_MARGIN;
+ }
+}
+
+static int dw8250_get_rxtrig(struct uart_port *p)
+{
+ struct dw8250_port_data *pd = p->private_data;
+ struct uart_8250_port *up = up_to_u8250p(p);
+
+ guard(uart_port_lock_irqsave)(p);
+
+ return pd->rxtrig_bytes[UART_FCR_R_TRIG_BITS(up->fcr)];
+}
+
+static int dw8250_set_rxtrig(struct uart_port *p, u16 bytes)
+{
+ struct dw8250_port_data *pd = p->private_data;
+ struct uart_8250_port *up = up_to_u8250p(p);
+ int fcr, ret;
+
+ fcr = serial8250_bytes_to_fcr(pd->rxtrig_bytes, bytes);
+ if (fcr < 0)
+ return fcr;
+
+ guard(mutex)(&p->state->port.mutex);
+
+ PM_RUNTIME_ACQUIRE_IF_ENABLED(p->dev, pm);
+ ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
+ if (ret)
+ return ret;
+
+ guard(uart_port_lock_irqsave)(p);
+
+ FIELD_MODIFY(UART_FCR_TRIGGER_MASK, &up->fcr, UART_FCR_R_TRIG_BITS(fcr));
+ /* Changing the trigger alone preserves the FIFO contents */
+ serial_port_out(p, UART_FCR, up->fcr);
+
+ return 0;
+}
+
+int dw8250_setup_rxtrig(struct uart_port *p)
+{
+ struct dw8250_port_data *pd = p->private_data;
+
+ /* Each FIFO-relative threshold must be positive and fit in the table */
+ if (p->fifosize < DW_UART_RXTRIG_QUARTER_DIV ||
+ p->fifosize - DW_UART_RXTRIG_FULL_MARGIN > U16_MAX)
+ return dev_err_probe(p->dev, -EINVAL,
+ "invalid FIFO size %u\n", p->fifosize);
+
+ for (unsigned int i = 0; i < ARRAY_SIZE(pd->rxtrig_bytes); i++) {
+ unsigned int trigger = FIELD_PREP(UART_FCR_TRIGGER_MASK, i);
+
+ pd->rxtrig_bytes[i] = dw8250_rxtrig_bytes(p, trigger);
+ }
+ p->get_rxtrig = dw8250_get_rxtrig;
+ p->set_rxtrig = dw8250_set_rxtrig;
+
+ return 0;
+}
+EXPORT_SYMBOL_NS_GPL(dw8250_setup_rxtrig, "SERIAL_8250");
+
int dw8250_setup_port(struct uart_port *p)
{
struct dw8250_port_data *pd = p->private_data;
struct uart_8250_port *up = up_to_u8250p(p);
u32 reg, old_dlf;
+ int ret;
pd->hw_rs485_support = dw8250_detect_rs485_hw(p);
if (pd->hw_rs485_support) {
@@ -258,6 +341,10 @@ int dw8250_setup_port(struct uart_port *p)
p->flags |= UPF_FIXED_TYPE;
p->fifosize = DW_UART_CPR_FIFO_SIZE(reg);
up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT;
+
+ ret = dw8250_setup_rxtrig(p);
+ if (ret)
+ return ret;
}
if (reg & DW_UART_CPR_AFCE_MODE)
diff --git a/drivers/tty/serial/8250/8250_dwlib.h b/drivers/tty/serial/8250/8250_dwlib.h
index 4d32651956ab..b896dd9bebb7 100644
--- a/drivers/tty/serial/8250/8250_dwlib.h
+++ b/drivers/tty/serial/8250/8250_dwlib.h
@@ -86,6 +86,7 @@ struct dw8250_port_data {
struct uart_8250_dma dma;
/* Hardware configuration */
+ u16 rxtrig_bytes[UART_FCR_R_TRIG_MAX_STATE];
u32 cpr_value;
u8 dlf_size;
@@ -100,6 +101,7 @@ struct dw8250_port_data {
unsigned int dw8250_get_divisor_dlf(struct uart_port *p, unsigned int baud, unsigned int *frac);
void dw8250_set_divisor_dlf(struct uart_port *p, unsigned int quot_frac);
void dw8250_do_set_termios(struct uart_port *p, struct ktermios *termios, const struct ktermios *old);
+int dw8250_setup_rxtrig(struct uart_port *p);
int dw8250_setup_port(struct uart_port *p);
static inline u32 dw8250_readl_ext(struct uart_port *p, int offset)
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v10 06/11] serial: 8250_dw: derive RX trigger thresholds from the FIFO depth
2026-12-04 10:28 ` [PATCH v10 06/11] serial: 8250_dw: derive RX trigger thresholds from the FIFO depth James Hilliard
@ 2026-12-04 10:52 ` sashiko-bot
0 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-12-04 10:52 UTC (permalink / raw)
To: James Hilliard; +Cc: linux-serial, devicetree, linux-sunxi, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] serial: 8250_dw: PM_RUNTIME_ACQUIRE_IF_ENABLED() fails in
dw8250_probe()
--
commit 145c679556b4e6a2b08dcfe78019d88beee1eeb1
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250_dw: derive RX trigger thresholds from the FIFO depth
This commit derives per-port RX trigger threshold tables from the
discovered FIFO depth in 8250_dwlib and installs get_rxtrig/set_rxtrig
callbacks for CPR-described FIFOs.
> diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
> index 4a06dec6e263b..6cfb7674ac119 100644
> --- a/drivers/tty/serial/8250/8250_dwlib.c
> +++ b/drivers/tty/serial/8250/8250_dwlib.c
[ ... ]
> +static int dw8250_set_rxtrig(struct uart_port *p, u16 bytes)
> +{
> + struct dw8250_port_data *pd = p->private_data;
> + struct uart_8250_port *up = up_to_u8250p(p);
> + int fcr, ret;
> +
> + fcr = serial8250_bytes_to_fcr(pd->rxtrig_bytes, bytes);
> + if (fcr < 0)
> + return fcr;
> +
> + guard(mutex)(&p->state->port.mutex);
> +
> + PM_RUNTIME_ACQUIRE_IF_ENABLED(p->dev, pm);
> + ret = PM_RUNTIME_ACQUIRE_ERR(&pm);
> + if (ret)
> + return ret;
[Severity: Medium]
Can PM_RUNTIME_ACQUIRE_IF_ENABLED() fail with -EACCES during initial
dw8250_probe()?
In dw8250_probe(), pm_runtime_set_active() updates runtime_status to
RPM_ACTIVE while disable_depth stays 1 and last_status remains
RPM_INVALID. The probe path then registers the port and publishes the
rx_trig_bytes sysfs attribute before calling pm_runtime_enable().
CPU0 CPU1
dw8250_probe()
pm_runtime_set_active(dev)
(disable_depth=1,
last_status=RPM_INVALID)
serial8250_register_8250_port()
... (publishes rx_trig_bytes)
rx_trig_bytes_store()
dw8250_set_rxtrig()
PM_RUNTIME_ACQUIRE_IF_ENABLED()
rpm_resume() <-- -EACCES
pm_runtime_enable(dev)
Because PM_RUNTIME_ACQUIRE_IF_ENABLED() does not set RPM_TRANSPARENT,
rpm_resume() rejects the call while disable_depth > 0 and last_status is
not RPM_ACTIVE:
drivers/base/power/runtime.c:rpm_resume() {
...
} else if (dev->power.disable_depth > 0) {
if (dev->power.runtime_status == RPM_ACTIVE &&
dev->power.last_status == RPM_ACTIVE)
retval = 1;
else if (rpmflags & RPM_TRANSPARENT)
goto out;
else
retval = -EACCES;
}
...
}
A udev rule or userspace write to rx_trig_bytes reacting to the KOBJ_ADD
uevent in that window fails with -EACCES even though the UART is already
active and clocked, leaving the trigger threshold unconfigured. Using
PM_RUNTIME_ACQUIRE(p->dev, pm) instead passes RPM_TRANSPARENT while still
holding a usage reference until runtime PM is enabled.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com?part=6
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v10 07/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner H616
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (5 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 06/11] serial: 8250_dw: derive RX trigger thresholds from the FIFO depth James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 08/11] serial: 8250_dw: configure the Allwinner H616 UART James Hilliard
` (3 subsequent siblings)
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard, Krzysztof Kozlowski
The H616 UART has 256-byte transmit and receive FIFOs, but its DesignWare
component parameter register does not report the FIFO depth. Its optional
register layout also differs from the generic DesignWare integration.
Add a specific compatible to identify this fixed configuration, retaining
snps,dw-apb-uart as a fallback.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
index e2ca126d58ba..fc1289073241 100644
--- a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
@@ -60,6 +60,7 @@ properties:
- const: renesas,rzn1-uart
- items:
- enum:
+ - allwinner,sun50i-h616-uart
- anlogic,dr1v90-uart
- brcm,bcm11351-dw-apb-uart
- brcm,bcm21664-dw-apb-uart
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 08/11] serial: 8250_dw: configure the Allwinner H616 UART
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (6 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 07/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner H616 James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:50 ` sashiko-bot
2026-12-04 10:28 ` [PATCH v10 09/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner A523 James Hilliard
` (2 subsequent siblings)
10 siblings, 1 reply; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
H616 has 256-byte transmit and receive FIFOs, but its optional DesignWare
component parameter register reads as zero. Generic 16550 probing leaves
the port using the 16-byte FIFO configuration and its trigger-level table.
Keep PORT_16550A and supply the fixed FIFO depth through platform data.
The 8250 core derives the transmit load from that depth. Use the shared
DesignWare receive-trigger setup to describe the 1, 64, 128 and 254-byte
thresholds, with the normal half-full FCR setting selecting 128 bytes.
Advertise automatic flow control so CRTSCTS enables MCR.AFCE, matching the
DesignWare termios path for hardware CTS handling.
Select this configuration through the platform setup callback. H616
has debug-divisor and RS485 control registers overlapping the optional
DesignWare feature probes. Use the fixed configuration with BUSY-safe
integer divisor programming and software RS485 handling.
Keep the UART clock enabled during termios changes with SKIP_SET_RATE.
Its clock is a gate on the shared APB2 source rather than an independent
baud-rate generator.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dw.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index a20adb38e046..7695755666bc 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -63,6 +63,7 @@
struct dw8250_platform_data {
u8 usr_reg;
u32 cpr_value;
+ unsigned int fifo_size;
unsigned int quirks;
int (*setup)(struct uart_port *p);
};
@@ -657,6 +658,31 @@ static int dw8250_setup(struct uart_port *p)
return dw8250_setup_dma(p);
}
+static int dw8250_sunxi_setup(struct uart_port *p)
+{
+ struct dw8250_data *data = to_dw8250_data(p->private_data);
+ struct uart_8250_port *up = up_to_u8250p(p);
+ int ret;
+
+ p->type = PORT_16550A;
+ p->flags |= UPF_FIXED_TYPE;
+ p->fifosize = data->pdata->fifo_size;
+
+ up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT | UART_CAP_AFE;
+
+ ret = dw8250_setup_rxtrig(p);
+ if (ret)
+ return ret;
+
+ /* Use software RS485 with the Allwinner register layout */
+ p->rs485_config = serial8250_em485_config;
+ p->rs485_supported = serial8250_em485_supported;
+ up->rs485_start_tx = serial8250_em485_start_tx;
+ up->rs485_stop_tx = serial8250_em485_stop_tx;
+
+ return 0;
+}
+
static int dw8250_probe(struct platform_device *pdev)
{
struct uart_8250_port uart = {}, *up = &uart;
@@ -880,6 +906,13 @@ static const struct dw8250_platform_data dw8250_dw_apb = {
.usr_reg = DW_UART_USR,
};
+static const struct dw8250_platform_data dw8250_h616_data = {
+ .usr_reg = DW_UART_USR,
+ .fifo_size = 256,
+ .quirks = DW_UART_QUIRK_SKIP_SET_RATE,
+ .setup = dw8250_sunxi_setup,
+};
+
static const struct dw8250_platform_data dw8250_octeon_3860_data = {
.usr_reg = OCTEON_UART_USR,
.quirks = DW_UART_QUIRK_OCTEON,
@@ -931,6 +964,7 @@ static const struct dw8250_platform_data dw8250_tda54 = {
static const struct of_device_id dw8250_of_match[] = {
{ .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb },
+ { .compatible = "allwinner,sun50i-h616-uart", .data = &dw8250_h616_data },
{ .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data },
{ .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data },
{ .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data },
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* Re: [PATCH v10 08/11] serial: 8250_dw: configure the Allwinner H616 UART
2026-12-04 10:28 ` [PATCH v10 08/11] serial: 8250_dw: configure the Allwinner H616 UART James Hilliard
@ 2026-12-04 10:50 ` sashiko-bot
0 siblings, 0 replies; 15+ messages in thread
From: sashiko-bot @ 2026-12-04 10:50 UTC (permalink / raw)
To: James Hilliard; +Cc: linux-serial, devicetree, linux-sunxi, robh, conor+dt
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] serial: 8250_dw: undocumented omission of DMA setup in
dw8250_sunxi_setup()
--
commit 750893605157ada7473d330ea8fa77963781e099
Author: James Hilliard <james.hilliard1@gmail.com>
serial: 8250_dw: configure the Allwinner H616 UART
This commit adds Allwinner H616 platform data and a dw8250_sunxi_setup()
callback to configure the 256-byte FIFO, RX trigger thresholds, automatic
flow control, software RS485, and SKIP_SET_RATE quirk.
> diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
> index a20adb38e0466..7695755666bcb 100644
> --- a/drivers/tty/serial/8250/8250_dw.c
> +++ b/drivers/tty/serial/8250/8250_dw.c
[ ... ]
> @@ -657,6 +658,31 @@ static int dw8250_setup(struct uart_port *p)
> return dw8250_setup_dma(p);
> }
>
> +static int dw8250_sunxi_setup(struct uart_port *p)
> +{
> + struct dw8250_data *data = to_dw8250_data(p->private_data);
> + struct uart_8250_port *up = up_to_u8250p(p);
> + int ret;
> +
> + p->type = PORT_16550A;
> + p->flags |= UPF_FIXED_TYPE;
> + p->fifosize = data->pdata->fifo_size;
> +
> + up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT | UART_CAP_AFE;
> +
> + ret = dw8250_setup_rxtrig(p);
> + if (ret)
> + return ret;
> +
> + /* Use software RS485 with the Allwinner register layout */
> + p->rs485_config = serial8250_em485_config;
> + p->rs485_supported = serial8250_em485_supported;
> + up->rs485_start_tx = serial8250_em485_start_tx;
> + up->rs485_stop_tx = serial8250_em485_stop_tx;
> +
> + return 0;
> +}
[Severity: Low]
Should dw8250_sunxi_setup() or the commit message note that DMA setup is
intentionally omitted?
Other setup paths in 8250_dw.c call dw8250_setup_dma(), and the H616 UART
nodes in sun50i-h616.dtsi declare DMA channels. Without a brief comment
explaining that sunxi stays in PIO mode, a later change could mistake
this for an oversight and attach 8250_dma.
Enabling DMA against sun6i-dma would break H616 UART RX:
sun6i_dma_tx_status() never returns DMA_PAUSED after sun6i_dma_pause(),
causing serial8250_rx_dma_flush() to drop RX data, and a 256-byte FIFO
yields maxburst = 64, which hits an out-of-range shift in find_burst_size().
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-submit-h616-uart-fifo-v1-v10-0-1a9fb4f79635@gmail.com?part=8
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH v10 09/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner A523
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (7 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 08/11] serial: 8250_dw: configure the Allwinner H616 UART James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 10/11] serial: 8250_dw: discover Allwinner A523 FIFO depths through FCC James Hilliard
2026-12-04 10:28 ` [PATCH v10 11/11] serial: 8250_dw: configure RX trigger thresholds for Octeon James Hilliard
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard, Krzysztof Kozlowski
The A523 UART integration has different FIFO depths across its controllers
and reports each controller's depth in the FIFO Clock Control register.
The receive thresholds follow the standard DesignWare FIFO-relative
mapping, while the optional-register layout differs from the generic
DesignWare integration.
Add a compatible for this integration, also used by A527 and T527, with
snps,dw-apb-uart as a fallback.
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
index fc1289073241..ea6ce99178e3 100644
--- a/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
+++ b/Documentation/devicetree/bindings/serial/snps-dw-apb-uart.yaml
@@ -61,6 +61,7 @@ properties:
- items:
- enum:
- allwinner,sun50i-h616-uart
+ - allwinner,sun55i-a523-uart
- anlogic,dr1v90-uart
- brcm,bcm11351-dw-apb-uart
- brcm,bcm21664-dw-apb-uart
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 10/11] serial: 8250_dw: discover Allwinner A523 FIFO depths through FCC
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (8 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 09/11] dt-bindings: serial: snps-dw-apb-uart: add Allwinner A523 James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
2026-12-04 10:28 ` [PATCH v10 11/11] serial: 8250_dw: configure RX trigger thresholds for Octeon James Hilliard
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
The A523 UART integration, also used by A527 and T527, has 64-byte FIFOs
on UART0 and 128-byte FIFOs on UART1 through UART7. Each controller reports
its TX/RX FIFO depth in bits 31:8 of the FIFO Clock Control register at
offset 0xf0. The field holds a byte count, not a logarithmic encoding.
Read this field in the sunxi setup callback when platform data does not
provide a fixed FIFO size. A fixed size takes precedence, so H616 retains
its 256-byte configuration without accessing FCC. The probe has already
enabled the clocks and deasserted reset before invoking the callback.
Leave the FIFO clock-control bits untouched.
Use the shared DesignWare trigger setup to validate the depth and build
the FIFO-relative threshold table. Invalid depths fail probe before
registration instead of producing zero or truncated thresholds. The 8250
core derives the transmit load from the discovered depth.
Select this setup for the A523 compatible. Like H616, this integration
has Allwinner-specific debug-divisor and RS485 registers overlapping the
generic DesignWare feature probes. Use the common sunxi PIO setup,
BUSY-safe integer divisor programming and software RS485 handling. Keep
the APB clock gate enabled during termios updates with SKIP_SET_RATE.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dw.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 7695755666bc..466fafa0bddb 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -44,6 +44,10 @@
#define RZN1_UART_xDMACR_8_WORD_BURST (2 << 1)
#define RZN1_UART_xDMACR_BLK_SZ(x) ((x) << 3)
+/* Allwinner FIFO Clock Control register */
+#define SUNXI_UART_FCC 0xf0
+#define SUNXI_UART_FCC_FIFO_DEPTH GENMASK(31, 8)
+
/* Quirks */
#define DW_UART_QUIRK_OCTEON BIT(0)
#define DW_UART_QUIRK_ARMADA_38X BIT(1)
@@ -63,6 +67,7 @@
struct dw8250_platform_data {
u8 usr_reg;
u32 cpr_value;
+ /* Fixed FIFO depth; zero selects discovery during setup */
unsigned int fifo_size;
unsigned int quirks;
int (*setup)(struct uart_port *p);
@@ -666,7 +671,15 @@ static int dw8250_sunxi_setup(struct uart_port *p)
p->type = PORT_16550A;
p->flags |= UPF_FIXED_TYPE;
- p->fifosize = data->pdata->fifo_size;
+
+ /* Apply given FIFO size or try to autodetect it */
+ if (data->pdata->fifo_size) {
+ p->fifosize = data->pdata->fifo_size;
+ } else {
+ u32 fcc = dw8250_readl_ext(p, SUNXI_UART_FCC);
+
+ p->fifosize = FIELD_GET(SUNXI_UART_FCC_FIFO_DEPTH, fcc);
+ }
up->capabilities = UART_CAP_FIFO | UART_CAP_NOTEMT | UART_CAP_AFE;
@@ -913,6 +926,12 @@ static const struct dw8250_platform_data dw8250_h616_data = {
.setup = dw8250_sunxi_setup,
};
+static const struct dw8250_platform_data dw8250_a523_data = {
+ .usr_reg = DW_UART_USR,
+ .quirks = DW_UART_QUIRK_SKIP_SET_RATE,
+ .setup = dw8250_sunxi_setup,
+};
+
static const struct dw8250_platform_data dw8250_octeon_3860_data = {
.usr_reg = OCTEON_UART_USR,
.quirks = DW_UART_QUIRK_OCTEON,
@@ -965,6 +984,7 @@ static const struct dw8250_platform_data dw8250_tda54 = {
static const struct of_device_id dw8250_of_match[] = {
{ .compatible = "snps,dw-apb-uart", .data = &dw8250_dw_apb },
{ .compatible = "allwinner,sun50i-h616-uart", .data = &dw8250_h616_data },
+ { .compatible = "allwinner,sun55i-a523-uart", .data = &dw8250_a523_data },
{ .compatible = "cavium,octeon-3860-uart", .data = &dw8250_octeon_3860_data },
{ .compatible = "marvell,armada-38x-uart", .data = &dw8250_armada_38x_data },
{ .compatible = "renesas,rzn1-uart", .data = &dw8250_renesas_rzn1_data },
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread* [PATCH v10 11/11] serial: 8250_dw: configure RX trigger thresholds for Octeon
2026-12-04 10:28 [PATCH v10 00/11] serial: 8250_dw: share RX trigger setup and describe Allwinner UARTs James Hilliard
` (9 preceding siblings ...)
2026-12-04 10:28 ` [PATCH v10 10/11] serial: 8250_dw: discover Allwinner A523 FIFO depths through FCC James Hilliard
@ 2026-12-04 10:28 ` James Hilliard
10 siblings, 0 replies; 15+ messages in thread
From: James Hilliard @ 2026-12-04 10:28 UTC (permalink / raw)
To: Andy Shevchenko, Ilpo Järvinen, Greg Kroah-Hartman,
Jiri Slaby, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Chen-Yu Tsai, Jernej Skrabec, Samuel Holland
Cc: linux-kernel, linux-serial, devicetree, linux-arm-kernel,
linux-sunxi, James Hilliard
Octeon uses the DesignWare receive-trigger mapping with a 64-byte FIFO,
giving thresholds of 1, 16, 32 and 62 bytes. Its setup bypasses
dw8250_setup_port(), so it does not install the common trigger callbacks.
PORT_OCTEON also has no static trigger table, so rx_trig_bytes is not
exposed.
Supply the fixed depth from platform data when firmware has not provided
one and initialize the common trigger table before port registration.
This makes rx_trig_bytes available while preserving the Octeon port type
and register accessors.
Select DMA before filling in the default depth, as before when the 8250
core supplied that default during registration. Thus the new trigger
setup preserves which ports attach DMA and their existing burst sizes.
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
drivers/tty/serial/8250/8250_dw.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_dw.c b/drivers/tty/serial/8250/8250_dw.c
index 466fafa0bddb..3ca5567a707b 100644
--- a/drivers/tty/serial/8250/8250_dw.c
+++ b/drivers/tty/serial/8250/8250_dw.c
@@ -663,6 +663,21 @@ static int dw8250_setup(struct uart_port *p)
return dw8250_setup_dma(p);
}
+static int dw8250_octeon_setup(struct uart_port *p)
+{
+ struct dw8250_data *data = to_dw8250_data(p->private_data);
+ int ret;
+
+ /* Preserve DMA selection before supplying the fixed FIFO depth */
+ ret = dw8250_setup_dma(p);
+ if (ret)
+ return ret;
+
+ p->fifosize = p->fifosize ?: data->pdata->fifo_size;
+
+ return dw8250_setup_rxtrig(p);
+}
+
static int dw8250_sunxi_setup(struct uart_port *p)
{
struct dw8250_data *data = to_dw8250_data(p->private_data);
@@ -934,8 +949,9 @@ static const struct dw8250_platform_data dw8250_a523_data = {
static const struct dw8250_platform_data dw8250_octeon_3860_data = {
.usr_reg = OCTEON_UART_USR,
+ .fifo_size = 64,
.quirks = DW_UART_QUIRK_OCTEON,
- .setup = dw8250_setup_dma,
+ .setup = dw8250_octeon_setup,
};
static const struct dw8250_platform_data dw8250_armada_38x_data = {
--
2.53.0
^ permalink raw reply related [flat|nested] 15+ messages in thread