From: Alastair D'Silva <alastair@d-silva.org>
To: Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com>
Cc: linux-serial@vger.kernel.org, gregkh@linuxfoundation.org,
jirislaby@kernel.org, robh@kernel.org, krzk+dt@kernel.org,
conor+dt@kernel.org, andriy.shevchenko@linux.intel.com,
ilpo.jarvinen@linux.intel.com, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-sunxi@lists.linux.dev,
Andre Przywara <andre.przywara@arm.com>,
Chen-Yu Tsai <wens@kernel.org>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Samuel Holland <samuel@sholland.org>,
Enzo Adriano <enzo.adriano.code@gmail.com>,
Alastair D'Silva <alastair@d-silva.org>
Subject: Re: [PATCH v2 2/4] serial: 8250_dw: Only accept a contiguous DLF readback
Date: Fri, 27 Nov 2026 22:25:58 +1100 [thread overview]
Message-ID: <20261127112558.2585489-1-alastair@d-silva.org> (raw)
In-Reply-To: <a79114e72d029732db6764935dde12aa5d497706.1792439398.git.vinicius.eduardo.pedrosa@gmail.com>
On Mon, 19 Oct 2026 17:06:11 -0300, Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com> wrote:
> dw8250_setup_port() writes all ones to offset 0xc0 and treats any
> nonzero readback as the DLF register. DLF is a bit field starting at
> bit 0, so a real one reads back as a contiguous 2^n - 1 mask. On some
> Allwinner SoCs offset 0xc0 is the RS485 control register instead
> (UART_485_CTL in the A733 User Manual), whose implemented bits are not
> contiguous. The probe still takes its readback for a DLF of fls(readback)
> bits, and every later divisor change writes the fractional divisor into
> the RS485 control register.
>
> Only accept a readback of the form 2^n - 1.
>
> The probe itself is unchanged: it still writes all ones to offset 0xc0
> and then restores the old value, so this only changes how the readback
> is interpreted.
>
> The A733 reads back 0x19f, and Andre Przywara observed 0x9f on the
> A523. Without this check the A733 RS485 control register reads 0xb after
> boot; with it, the register stays 0 across 300 termios toggle and
> restore cycles.
>
> Suggested-by: Andre Przywara <andre.przywara@arm.com>
> Signed-off-by: Vinicius Pedrosa <vinicius.eduardo.pedrosa@gmail.com>
> ---
> drivers/tty/serial/8250/8250_dwlib.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_dwlib.c b/drivers/tty/serial/8250/8250_dwlib.c
> index 325793f20256..1b0192efe162 100644
> --- a/drivers/tty/serial/8250/8250_dwlib.c
> +++ b/drivers/tty/serial/8250/8250_dwlib.c
> @@ -225,7 +225,11 @@ void dw8250_setup_port(struct uart_port *p)
> reg = dw8250_readl_ext(p, DW_UART_DLF);
> dw8250_writel_ext(p, DW_UART_DLF, old_dlf);
>
> - if (reg) {
> + /*
> + * DLF is a bit field starting at bit 0, so a real one reads back as
> + * 2^n - 1. Any other value means this offset is something else.
> + */
> + if (reg && !(reg & (reg + 1))) {
> pd->dlf_size = fls(reg);
> p->get_divisor = dw8250_get_divisor;
> /* Keep a hook the driver has already installed */
Tested on Xunlong OrangePi 4 Pro (Allwinner A733):
- UART0 (2500000.serial, ttyS0, base_baud = 1500000) boots to shell and
echoes interactive console input at 115200 baud.
Reviewed-by: Alastair D'Silva <alastair@d-silva.org>
Tested-by: Alastair D'Silva <alastair@d-silva.org> # OrangePi 4 Pro
next prev parent reply other threads:[~2026-11-27 11:26 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-19 20:06 [PATCH v2 0/4] serial: 8250_dw: Allwinner A733 UART support Vinicius Pedrosa
2026-10-19 20:06 ` [PATCH v2 1/4] serial: 8250_dw: Keep the BUSY-safe divisor hook when DLF is present Vinicius Pedrosa
2026-10-20 8:30 ` Andy Shevchenko
2026-10-20 8:51 ` Andy Shevchenko
2026-10-20 10:47 ` Vinicius Pedrosa
2026-10-21 6:42 ` Andy Shevchenko
2026-10-21 10:00 ` Vinicius Pedrosa
2026-10-21 13:45 ` Andy Shevchenko
2026-10-21 15:37 ` Vinicius Pedrosa
2026-10-21 16:37 ` Andy Shevchenko
2026-10-21 17:04 ` Vinicius Pedrosa
2026-10-21 17:21 ` Andy Shevchenko
2026-10-21 18:07 ` Vinicius Pedrosa
2026-11-27 11:25 ` Alastair D'Silva
2026-10-19 20:06 ` [PATCH v2 2/4] serial: 8250_dw: Only accept a contiguous DLF readback Vinicius Pedrosa
2026-10-20 6:11 ` Jiri Slaby
2026-10-20 8:31 ` Andy Shevchenko
2026-10-20 11:50 ` Ilpo Järvinen
2026-10-20 12:27 ` Vinicius Pedrosa
2026-10-20 13:02 ` Ilpo Järvinen
2026-10-21 6:43 ` Andy Shevchenko
2026-10-20 10:47 ` Vinicius Pedrosa
2026-11-27 11:25 ` Alastair D'Silva [this message]
2026-10-19 20:06 ` [PATCH v2 3/4] dt-bindings: serial: snps-dw-apb-uart: Add Allwinner A733 Vinicius Pedrosa
2026-10-21 14:54 ` Andre Przywara
2026-10-21 17:58 ` Vinicius Pedrosa
2026-11-30 16:30 ` Andre Przywara
2026-11-27 11:26 ` Alastair D'Silva
2026-11-30 16:17 ` Andre Przywara
2026-10-19 20:06 ` [PATCH v2 4/4] serial: 8250_dw: Add Allwinner A733 UART Vinicius Pedrosa
2026-11-27 11:26 ` Alastair D'Silva
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=20261127112558.2585489-1-alastair@d-silva.org \
--to=alastair@d-silva.org \
--cc=andre.przywara@arm.com \
--cc=andriy.shevchenko@linux.intel.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=enzo.adriano.code@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=jernej.skrabec@gmail.com \
--cc=jirislaby@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=linux-sunxi@lists.linux.dev \
--cc=robh@kernel.org \
--cc=samuel@sholland.org \
--cc=vinicius.eduardo.pedrosa@gmail.com \
--cc=wens@kernel.org \
/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®