From: Claudiu Beznea <claudiu.beznea@tuxon.dev>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: gregkh@linuxfoundation.org, jirislaby@kernel.org,
wsa+renesas@sang-engineering.com,
prabhakar.mahadev-lad.rj@bp.renesas.com, lethal@linux-sh.org,
g.liakhovetski@gmx.de, groeck@chromium.org, mka@chromium.org,
ulrich.hecht+renesas@gmail.com, ysato@users.sourceforge.jp,
linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>,
stable@vger.kernel.org
Subject: Re: [PATCH RFT 1/6] serial: sh-sci: Check if TX data was written to device in .tx_empty()
Date: Sat, 21 Dec 2024 11:16:19 +0200 [thread overview]
Message-ID: <316408fc-156d-4c80-b62e-bcf1c4bd3c08@tuxon.dev> (raw)
In-Reply-To: <CAMuHMdWv-+gWkH2K0r740BaKLwnTm7RdOTd71DkWMDR0A52qEA@mail.gmail.com>
Hi, Geert,
On 19.12.2024 11:46, Geert Uytterhoeven wrote:
> Hi Claudiu,
>
> On Wed, Dec 4, 2024 at 4:58 PM Claudiu <claudiu.beznea@tuxon.dev> wrote:
>> From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
>>
>> 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>
> Thanks for your patch, which is now commit 7cc0e0a43a910524 ("serial:
> sh-sci: Check if TX data was written to device in .tx_empty()") in
> v6.13-rc3.
>
>> --- a/drivers/tty/serial/sh-sci.c
>> +++ b/drivers/tty/serial/sh-sci.c
>> @@ -885,6 +887,7 @@ static void sci_transmit_chars(struct uart_port *port)
>> }
>>
>> sci_serial_out(port, SCxTDR, c);
>> + s->tx_occurred = true;
> And you cannot use the existing port->icount.tx below, as that is not
> reset to zero on sci_startup(), right?
I missed that the driver is incrementing the port->icount.tx . I'm not sure
we can use it though, as it is not reset on sci_startup(), as you pointed out.
Thank you,
Claudiu
next prev parent reply other threads:[~2024-12-21 9:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 15:58 [PATCH RFT 0/6] serial: sh-sci: Fixes for earlycon and keep_bootcon Claudiu
2024-12-04 15:58 ` [PATCH RFT 1/6] serial: sh-sci: Check if TX data was written to device in .tx_empty() Claudiu
2024-12-19 9:46 ` Geert Uytterhoeven
2024-12-21 9:16 ` Claudiu Beznea [this message]
2024-12-04 15:58 ` [PATCH RFT 2/6] serial: sh-sci: Drop __initdata macro for port_cfg Claudiu
2024-12-19 9:55 ` Geert Uytterhoeven
2024-12-04 15:58 ` [PATCH RFT 3/6] serial: sh-sci: Move runtime PM enable to sci_probe_single() Claudiu
2024-12-19 10:18 ` Geert Uytterhoeven
2024-12-21 9:20 ` Claudiu Beznea
2024-12-04 15:58 ` [PATCH RFT 4/6] serial: sh-sci: Do not probe the serial port if its slot in sci_ports[] is in use Claudiu
2024-12-19 14:21 ` Geert Uytterhoeven
2024-12-04 15:58 ` [PATCH RFT 5/6] serial: sh-sci: Clean sci_ports[0] after at earlycon exit Claudiu
2024-12-19 14:26 ` Geert Uytterhoeven
2024-12-21 9:39 ` Claudiu Beznea
2024-12-04 15:58 ` [PATCH RFT 6/6] serial: sh-sci: Increment the runtime usage counter for the earlycon device Claudiu
2024-12-19 14:30 ` Geert Uytterhoeven
2024-12-21 9:40 ` Claudiu Beznea
2025-01-02 17:57 ` Claudiu Beznea
2024-12-04 21:38 ` [PATCH RFT 0/6] serial: sh-sci: Fixes for earlycon and keep_bootcon Wolfram Sang
2024-12-05 8:39 ` Claudiu Beznea
2024-12-05 8:51 ` Claudiu Beznea
2024-12-19 15:11 ` Geert Uytterhoeven
2024-12-21 9:54 ` Claudiu Beznea
2025-01-03 11:48 ` Claudiu Beznea
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=316408fc-156d-4c80-b62e-bcf1c4bd3c08@tuxon.dev \
--to=claudiu.beznea@tuxon.dev \
--cc=claudiu.beznea.uj@bp.renesas.com \
--cc=g.liakhovetski@gmx.de \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=groeck@chromium.org \
--cc=jirislaby@kernel.org \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mka@chromium.org \
--cc=prabhakar.mahadev-lad.rj@bp.renesas.com \
--cc=stable@vger.kernel.org \
--cc=ulrich.hecht+renesas@gmail.com \
--cc=wsa+renesas@sang-engineering.com \
--cc=ysato@users.sourceforge.jp \
/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®