From: neil.armstrong@linaro.org
To: Stephan Gerhold <stephan.gerhold@linaro.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jiri Slaby <jirislaby@kernel.org>
Cc: Stephen Boyd <sboyd@kernel.org>,
linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-serial@vger.kernel.org, Sam Day <me@samcday.com>
Subject: Re: [PATCH] serial: msm: Configure correct working mode before starting earlycon
Date: Wed, 9 Apr 2025 14:37:35 +0200 [thread overview]
Message-ID: <d8a0f3a2-03ed-48be-8ca2-dfed622554ee@linaro.org> (raw)
In-Reply-To: <20250408-msm-serial-earlycon-v1-1-429080127530@linaro.org>
On 08/04/2025 19:22, Stephan Gerhold wrote:
> The MSM UART DM controller supports different working modes, e.g. DMA or
> the "single-character mode", where all reads/writes operate on a single
> character rather than 4 chars (32-bit) at once. When using earlycon,
> __msm_console_write() always writes 4 characters at a time, but we don't
> know which mode the bootloader was using and we don't set the mode either.
>
> This causes garbled output if the bootloader was using the single-character
> mode, because only every 4th character appears in the serial console, e.g.
>
> "[ 00oni pi 000xf0[ 00i s 5rm9(l)l s 1 1 SPMTA 7:C 5[ 00A ade k d[
> 00ano:ameoi .Q1B[ 00ac _idaM00080oo'"
>
> If the bootloader was using the DMA ("DM") mode, output would likely fail
> entirely. Later, when the full serial driver probes, the port is
> re-initialized and output works as expected.
>
> Fix this also for earlycon by clearing the DMEN register and
> reset+re-enable the transmitter to apply the change. This ensures the
> transmitter is in the expected state before writing any output.
>
> Cc: stable@vger.kernel.org
> Fixes: 0efe72963409 ("tty: serial: msm: Add earlycon support")
> Signed-off-by: Stephan Gerhold <stephan.gerhold@linaro.org>
> ---
> drivers/tty/serial/msm_serial.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
> index 1b137e06844425584afe5d3f647e9537c6e2d658..3449945493ceb42369d2acafca925350fccc4f82 100644
> --- a/drivers/tty/serial/msm_serial.c
> +++ b/drivers/tty/serial/msm_serial.c
> @@ -1746,6 +1746,12 @@ msm_serial_early_console_setup_dm(struct earlycon_device *device,
> if (!device->port.membase)
> return -ENODEV;
>
> + /* Disable DM / single-character modes */
> + msm_write(&device->port, 0, UARTDM_DMEN);
> + msm_write(&device->port, MSM_UART_CR_CMD_RESET_RX, MSM_UART_CR);
> + msm_write(&device->port, MSM_UART_CR_CMD_RESET_TX, MSM_UART_CR);
> + msm_write(&device->port, MSM_UART_CR_TX_ENABLE, MSM_UART_CR);
> +
> device->con->write = msm_serial_early_write_dm;
> return 0;
> }
>
> ---
> base-commit: 0af2f6be1b4281385b618cb86ad946eded089ac8
> change-id: 20250408-msm-serial-earlycon-4c5dfa782496
>
> Best regards,
I think it's safe the sanitize the mode in earlycon.
Reviewed-by: Neil Armstrong <neil.armstrong@linaro.org>
Thanks
Neil
next prev parent reply other threads:[~2025-04-09 12:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-08 17:22 [PATCH] serial: msm: Configure correct working mode before starting earlycon Stephan Gerhold
2025-04-09 10:00 ` Mukesh Kumar Savaliya
2025-04-09 12:36 ` Stephan Gerhold
2025-04-09 12:37 ` neil.armstrong [this message]
2025-04-09 18:11 ` Stephen Boyd
2025-04-09 19:01 ` Stephan Gerhold
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=d8a0f3a2-03ed-48be-8ca2-dfed622554ee@linaro.org \
--to=neil.armstrong@linaro.org \
--cc=gregkh@linuxfoundation.org \
--cc=jirislaby@kernel.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=me@samcday.com \
--cc=sboyd@kernel.org \
--cc=stephan.gerhold@linaro.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