From: Greg KH <gregkh@linuxfoundation.org>
To: Claudiu <claudiu.beznea@tuxon.dev>
Cc: stable@vger.kernel.org
Subject: Re: [PATCH 5.10.y 1/4] serial: sh-sci: Check if TX data was written to device in .tx_empty()
Date: Wed, 4 Jun 2025 15:27:10 +0200 [thread overview]
Message-ID: <2025060448-puzzle-equator-c99b@gregkh> (raw)
In-Reply-To: <20250603093701.3928327-2-claudiu.beznea.uj@bp.renesas.com>
On Tue, Jun 03, 2025 at 12:36:58PM +0300, Claudiu wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>
> commit 7cc0e0a43a91052477c2921f924a37d9c3891f0c upstream.
>
> On the Renesas RZ/G3S, when doing suspend to RAM, the uart_suspend_port()
> is called. The uart_suspend_port() calls 3 times the
> struct uart_port::ops::tx_empty() before shutting down the port.
>
> According to the documentation, the struct uart_port::ops::tx_empty()
> API tests whether the transmitter FIFO and shifter for the port is
> empty.
>
> The Renesas RZ/G3S SCIFA IP reports the number of data units stored in the
> transmit FIFO through the FDR (FIFO Data Count Register). The data units
> in the FIFOs are written in the shift register and transmitted from there.
> The TEND bit in the Serial Status Register reports if the data was
> transmitted from the shift register.
>
> In the previous code, in the tx_empty() API implemented by the sh-sci
> driver, it is considered that the TX is empty if the hardware reports the
> TEND bit set and the number of data units in the FIFO is zero.
>
> According to the HW manual, the TEND bit has the following meaning:
>
> 0: Transmission is in the waiting state or in progress.
> 1: Transmission is completed.
>
> It has been noticed that when opening the serial device w/o using it and
> then switch to a power saving mode, the tx_empty() call in the
> uart_port_suspend() function fails, leading to the "Unable to drain
> transmitter" message being printed on the console. This is because the
> TEND=0 if nothing has been transmitted and the FIFOs are empty. As the
> TEND=0 has double meaning (waiting state, in progress) we can't
> determined the scenario described above.
>
> Add a software workaround for this. This sets a variable if any data has
> been sent on the serial console (when using PIO) or if the DMA callback has
> been called (meaning something has been transmitted). In the tx_empty()
> API the status of the DMA transaction is also checked and if it is
> completed or in progress the code falls back in checking the hardware
> registers instead of relying on the software variable.
>
> Fixes: 73a19e4c0301 ("serial: sh-sci: Add DMA support.")
> Cc: stable@vger.kernel.org
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> Link: https://lore.kernel.org/r/20241125115856.513642-1-claudiu.beznea.uj@bp.renesas.com
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> [claudiu.beznea: fixed conflict by:
> - keeping serial_port_out() instead of sci_port_out() in
> sci_transmit_chars()
> - keeping !uart_circ_empty(xmit) condition in sci_dma_tx_complete(),
> after s->tx_occurred = true; assignement]
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
> ---
> drivers/tty/serial/sh-sci.c | 29 +++++++++++++++++++++++++++++
> 1 file changed, 29 insertions(+)
For obvious reasons, we can't take patches ONLY for older stable
kernels, and not newer ones. Otherwise you would have kernel releases
without any fixes and get a regression when moving to a newer tree,
which you yourself don't want to have happen :)
So can you resend these patches for all of the needed branches,
including this one, as I'll drop this from my review queue now.
thanks,
greg k-h
next prev parent reply other threads:[~2025-06-04 13:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-03 9:36 [PATCH 5.10.y 0/4] serial: sh-sci: Backport fixes Claudiu
2025-06-03 9:36 ` [PATCH 5.10.y 1/4] serial: sh-sci: Check if TX data was written to device in .tx_empty() Claudiu
2025-06-03 19:04 ` Sasha Levin
2025-06-04 13:27 ` Greg KH [this message]
2025-06-03 9:36 ` [PATCH 5.10.y 2/4] serial: sh-sci: Move runtime PM enable to sci_probe_single() Claudiu
2025-06-03 18:36 ` Sasha Levin
2025-06-03 9:37 ` [PATCH 5.10.y 3/4] serial: sh-sci: Clean sci_ports[0] after at earlycon exit Claudiu
2025-06-03 18:35 ` Sasha Levin
2025-06-03 9:37 ` [PATCH 5.10.y 4/4] serial: sh-sci: Increment the runtime usage counter for the earlycon device Claudiu
2025-06-03 18:36 ` Sasha Levin
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=2025060448-puzzle-equator-c99b@gregkh \
--to=gregkh@linuxfoundation.org \
--cc=claudiu.beznea@tuxon.dev \
--cc=stable@vger.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