[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMuHMdWv-+gWkH2K0r740BaKLwnTm7RdOTd71DkWMDR0A52qEA@mail.gmail.com>
Date: Thu, 19 Dec 2024 10:46:42 +0100
From: Geert Uytterhoeven <geert@...ux-m68k.org>
To: Claudiu <claudiu.beznea@...on.dev>
Cc: gregkh@...uxfoundation.org, jirislaby@...nel.org,
wsa+renesas@...g-engineering.com, prabhakar.mahadev-lad.rj@...renesas.com,
lethal@...ux-sh.org, g.liakhovetski@....de, groeck@...omium.org,
mka@...omium.org, ulrich.hecht+renesas@...il.com, ysato@...rs.sourceforge.jp,
linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
linux-renesas-soc@...r.kernel.org,
Claudiu Beznea <claudiu.beznea.uj@...renesas.com>, stable@...r.kernel.org
Subject: Re: [PATCH RFT 1/6] serial: sh-sci: Check if TX data was written to
device in .tx_empty()
Hi Claudiu,
On Wed, Dec 4, 2024 at 4:58 PM Claudiu <claudiu.beznea@...on.dev> wrote:
> From: Claudiu Beznea <claudiu.beznea.uj@...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@...r.kernel.org
> Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@...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?
>
> port->icount.tx++;
Which brings me to the real reason for replying to this patch:
apparently port->icount.tx is updated only for PIO, not for DMA...
> } while (--count > 0);
> @@ -2247,6 +2275,7 @@ static int sci_startup(struct uart_port *port)
>
> dev_dbg(port->dev, "%s(%d)\n", __func__, port->line);
>
> + s->tx_occurred = false;
> sci_request_dma(port);
>
> ret = sci_request_irq(s);
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-m68k.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
Powered by blists - more mailing lists