* [PATCH v5 1/7] serial: sh-sci: Drop TE disable at end of transmission on SCI
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 2/7] serial: sh-sci: Keep TX enabled on TEI while data is pending Diogo Ivo
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
stable, Diogo Ivo
From: Biju Das <biju.das.jz@bp.renesas.com>
Commit f06c2a9000eb ("tty: serial: sh-sci: Fix end of transmission on
SCI") made sci_transmit_chars() clear SCSCR.TE and return early on
PORT_SCI once the transmit FIFO is empty.
The hardware manual does not describe disabling the transmitter to end
a transmission, so this special case has no basis in the documented
programming sequence. Remove it and let SCI follow the same path as the
other port types. A plain revert no longer applies because the driver
now uses a kfifo, so the code is removed by hand.
Fixes: f06c2a9000eb ("tty: serial: sh-sci: Fix end of transmission on SCI")
Cc: stable@vger.kernel.org
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/sh-sci.c | 7 -------
1 file changed, 7 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index bd58bbfa65aa..9eb297dbc901 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -1036,13 +1036,6 @@ static void sci_transmit_chars(struct uart_port *port)
c = port->x_char;
port->x_char = 0;
} else if (stopped || !kfifo_get(&tport->xmit_fifo, &c)) {
- if (s->type == PORT_SCI &&
- kfifo_is_empty(&tport->xmit_fifo)) {
- ctrl = sci_serial_in(port, SCSCR);
- ctrl &= ~SCSCR_TE;
- sci_serial_out(port, SCSCR, ctrl);
- return;
- }
break;
}
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 2/7] serial: sh-sci: Keep TX enabled on TEI while data is pending
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 1/7] serial: sh-sci: Drop TE disable at end of transmission on SCI Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 3/7] serial: rsci: Enable transmit end interrupt in rsci_stop_tx() Diogo Ivo
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
stable, Diogo Ivo
From: Biju Das <biju.das.jz@bp.renesas.com>
sci_tx_end_interrupt() clears TE and TEIE unconditionally on SCI and
RSCI ports. If new data was queued or transmission restarted before the
TEI handler runs, disabling the transmitter stalls or truncates output.
To fix truncations, verify that poll_sent_bits are set, and address
stalls by checking for pending data (while the port is not suspended)
before clearing TE and TEIE. The existing TE/TEIE teardown path only
runs once nothing is left to send and we are sure that we are not still
sending data.
While at it, make sure to also stop TX when the port is stopped with data
queued.
Fixes: d61ae331d6f3 ("tty: serial: sh-sci: Add support for tx end interrupt handling")
Cc: stable@vger.kernel.org
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Co-developed-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
Changes in v5:
- Make the commit message more succinct.
- Drop unused tie and teie initializers from sci_scif_port_params_bits.
- Enable SCSCR.TEIE in sci_stop_tx() on PORT_SCI and call
sci_stop_tx() in sci_transmit_chars() when empty or stopped.
- Check poll_sent_bits in sci_tx_end_interrupt() before acting on TEI.
- Prevent sci_tx_end_interrupt() from restarting TX during suspend.
---
drivers/tty/serial/rsci.c | 4 +++-
drivers/tty/serial/sh-sci-common.h | 2 ++
drivers/tty/serial/sh-sci.c | 45 ++++++++++++++++++++++++++++----------
3 files changed, 38 insertions(+), 13 deletions(-)
diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index 40db9daa4272..0391111db8ae 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -465,7 +465,7 @@ static void rsci_transmit_chars(struct uart_port *port)
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
uart_write_wakeup(port);
- if (kfifo_is_empty(&tport->xmit_fifo)) {
+ if (kfifo_is_empty(&tport->xmit_fifo) || stopped) {
ctrl = rsci_serial_in(port, CCR0);
ctrl &= ~CCR0_TIE;
ctrl |= CCR0_TEIE;
@@ -627,6 +627,8 @@ static const struct sci_port_params_bits rsci_port_param_bits = {
.rxtx_enable = CCR0_RE | CCR0_TE,
.te_clear = CCR0_TE | CCR0_TEIE,
.poll_sent_bits = CSR_TDRE | CSR_TEND,
+ .tie = CCR0_TIE,
+ .teie = CCR0_TEIE
};
static const struct sci_port_params rsci_rzg3e_port_params = {
diff --git a/drivers/tty/serial/sh-sci-common.h b/drivers/tty/serial/sh-sci-common.h
index 01ff9fced803..273856fbc20b 100644
--- a/drivers/tty/serial/sh-sci-common.h
+++ b/drivers/tty/serial/sh-sci-common.h
@@ -56,6 +56,8 @@ struct sci_port_params_bits {
unsigned int rxtx_enable;
unsigned int te_clear;
unsigned int poll_sent_bits;
+ unsigned int tie;
+ unsigned int teie;
};
struct sci_common_regs {
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 9eb297dbc901..c2de7e7faab6 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -261,7 +261,9 @@ static bool sci_uart_earlycon_dev_probing;
static const struct sci_port_params_bits sci_sci_port_params_bits = {
.rxtx_enable = SCSCR_RE | SCSCR_TE,
.te_clear = SCSCR_TE | SCSCR_TEIE,
- .poll_sent_bits = SCI_TDRE | SCI_TEND
+ .poll_sent_bits = SCI_TDRE | SCI_TEND,
+ .tie = SCSCR_TIE,
+ .teie = SCSCR_TEIE
};
static const struct sci_port_params_bits sci_scif_port_params_bits = {
@@ -810,6 +812,9 @@ static void sci_stop_tx(struct uart_port *port)
ctrl &= ~SCSCR_TIE;
+ if (s->type == PORT_SCI && (ctrl & SCSCR_TE))
+ ctrl |= SCSCR_TEIE;
+
sci_serial_out(port, SCSCR, ctrl);
#ifdef CONFIG_SERIAL_SH_SCI_DMA
@@ -1049,16 +1054,9 @@ static void sci_transmit_chars(struct uart_port *port)
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
uart_write_wakeup(port);
- if (kfifo_is_empty(&tport->xmit_fifo)) {
- if (s->type == PORT_SCI) {
- ctrl = sci_serial_in(port, SCSCR);
- ctrl &= ~SCSCR_TIE;
- ctrl |= SCSCR_TEIE;
- sci_serial_out(port, SCSCR, ctrl);
- }
+ if (kfifo_is_empty(&tport->xmit_fifo) || stopped)
sci_stop_tx(port);
- }
}
static void sci_receive_chars(struct uart_port *port)
@@ -2012,17 +2010,40 @@ static irqreturn_t sci_tx_end_interrupt(int irq, void *ptr)
{
struct uart_port *port = ptr;
struct sci_port *s = to_sci_port(port);
+ struct tty_port *tport = &port->state->port;
+ const struct sci_port_params_bits *bits = s->params->param_bits;
const struct sci_common_regs *regs = s->params->common_regs;
unsigned long flags;
- u32 ctrl;
+ u32 ctrl, status;
if (s->type != PORT_SCI && !sci_is_rsci_type(s->type))
return sci_tx_interrupt(irq, ptr);
uart_port_lock_irqsave(port, &flags);
- ctrl = s->ops->read_reg(port, regs->control) &
- ~(s->params->param_bits->te_clear);
+
+ /*
+ * We may be sending data while we service this TEI. If so,
+ * bail out so we don't stop an ongoing TX.
+ */
+ status = s->ops->read_reg(port, regs->status);
+ if ((status & bits->poll_sent_bits) != bits->poll_sent_bits)
+ goto out_unlock;
+
+ ctrl = s->ops->read_reg(port, regs->control);
+
+ if (!port->suspended &&
+ (port->x_char ||
+ (!kfifo_is_empty(&tport->xmit_fifo) && !uart_tx_stopped(port)))) {
+ ctrl &= ~bits->teie;
+ ctrl |= bits->tie;
+ s->ops->write_reg(port, regs->control, ctrl);
+ s->ops->transmit_chars(port);
+ goto out_unlock;
+ }
+
+ ctrl &= ~bits->te_clear;
s->ops->write_reg(port, regs->control, ctrl);
+out_unlock:
uart_port_unlock_irqrestore(port, flags);
return IRQ_HANDLED;
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 3/7] serial: rsci: Enable transmit end interrupt in rsci_stop_tx()
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 1/7] serial: sh-sci: Drop TE disable at end of transmission on SCI Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 2/7] serial: sh-sci: Keep TX enabled on TEI while data is pending Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 4/7] serial: sh-sci: Do not kick TX from sci_er_interrupt() on RSCI Diogo Ivo
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
stable, Diogo Ivo
Currently, rsci_stop_tx() clears CCR0.TIE without enabling CCR0.TEIE.
If transmission is stopped while CCR0.TE is set (for example, via
TCOOFF), the hardware FIFO drains and sets CSR.TDRE while CCR0.TIE is 0,
and no TEI (Transmit End) interrupt is generated to clear CCR0.TE.
However, on RSCI setting TIE while TE is already set does not generate a
TXI interrupt. Thus, if transmission is later resumed via rsci_start_tx(),
setting CCR0.TIE while CCR0.TE and CSR.TDRE are already 1 fails to call
into rsci_transmit_chars(), permanently stalling subsequent transmissions.
Fix this by setting CCR0.TEIE in rsci_stop_tx() whenever CCR0.TE is
set, ensuring sci_tx_end_interrupt() fires once the hardware finishes
shifting out in-flight data and clears CCR0.TE.
Fixes: 0666e3fe95ab ("serial: sh-sci: Add support for RZ/T2H SCI")
Cc: stable@vger.kernel.org
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/rsci.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index 0391111db8ae..05703bb31afd 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -409,6 +409,8 @@ static void rsci_stop_tx(struct uart_port *port)
ctrl = rsci_serial_in(port, CCR0);
ctrl &= ~CCR0_TIE;
+ if (ctrl & CCR0_TE)
+ ctrl |= CCR0_TEIE;
rsci_serial_out(port, CCR0, ctrl);
}
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 4/7] serial: sh-sci: Do not kick TX from sci_er_interrupt() on RSCI
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
` (2 preceding siblings ...)
2026-11-17 23:40 ` [PATCH v5 3/7] serial: rsci: Enable transmit end interrupt in rsci_stop_tx() Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 5/7] serial: sh-sci: Skip TDxE clear when hardware clears it automatically Diogo Ivo
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
stable, Diogo Ivo
On RSCI, the receive error interrupt (ERI) has its own dedicated
interrupt line and status flags cleared via the write-only CFCLR
register, with no hardware interaction with transmission.
Calling sci_tx_interrupt() from sci_er_interrupt() on RSCI is
unnecessary and causes rsci_transmit_chars() to run in invalid TX
states:
- If an RX error occurs while TX is idle (CCR0.TE == 0 and CSR.TDRE == 1)
and xmit_fifo is empty, rsci_transmit_chars() sets CCR0.TEIE while
CSR.TEND is 1, triggering a spurious TEI interrupt.
- If an RX error occurs while the hardware TX FIFO is draining
(CSR.TDRE == 0) after xmit_fifo was flushed, rsci_transmit_chars()
clears CCR0.TIE without setting CCR0.TEIE, leaving CCR0.TE set after
the hardware FIFO drains and stalling subsequent transmissions.
Skip calling sci_tx_interrupt() in sci_er_interrupt() for RSCI ports.
Fixes: 0666e3fe95ab ("serial: sh-sci: Add support for RZ/T2H SCI")
Cc: stable@vger.kernel.org
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/sh-sci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index c2de7e7faab6..2b6847f0ea72 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -2099,7 +2099,7 @@ static irqreturn_t sci_er_interrupt(int irq, void *ptr)
s->ops->clear_SCxSR(port, SCxSR_ERROR_CLEAR(port));
/* Kick the transmission */
- if (!s->chan_tx)
+ if (!s->chan_tx && !sci_is_rsci_type(s->type))
sci_tx_interrupt(irq, ptr);
return IRQ_HANDLED;
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 5/7] serial: sh-sci: Skip TDxE clear when hardware clears it automatically
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
` (3 preceding siblings ...)
2026-11-17 23:40 ` [PATCH v5 4/7] serial: sh-sci: Do not kick TX from sci_er_interrupt() on RSCI Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 6/7] serial: sh-sci: Toggle TE when restoring SCSCR in console write on SCI Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 7/7] serial: rsci: Simplify rsci_transmit_chars() Diogo Ivo
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
Diogo Ivo
From: Au Dang <au.dang.jx@renesas.com>
On some SCI variants, the TDxE (Transmit Data Empty) flag in SCxSR is
cleared by hardware when data is written to TDR. Clearing it again from
software via clear_SCxSR() generates a spurious TXI interrupt, causing
the last character to be transmitted twice.
Add a tdxe_auto_clear flag to struct sci_of_data, propagate it to struct
sci_port as has_tdxe_auto_clear, and skip the clear_SCxSR() call in
sci_transmit_chars() and sci_poll_put_char() when it is set. Enable the
flag for the PORT_SCI (of_sci_sci) variant.
Signed-off-by: Au Dang <au.dang.jx@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/sh-sci-common.h | 2 ++
drivers/tty/serial/sh-sci.c | 9 +++++++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sh-sci-common.h b/drivers/tty/serial/sh-sci-common.h
index 273856fbc20b..b75e5e1d3075 100644
--- a/drivers/tty/serial/sh-sci-common.h
+++ b/drivers/tty/serial/sh-sci-common.h
@@ -108,6 +108,7 @@ struct sci_of_data {
const struct sci_port_ops *ops;
unsigned short regtype;
unsigned short type;
+ bool tdxe_auto_clear;
};
struct sci_port {
@@ -163,6 +164,7 @@ struct sci_port {
bool has_rtscts;
bool autorts;
bool tx_occurred;
+ bool has_tdxe_auto_clear;
};
#define to_sci_port(uart) container_of((uart), struct sci_port, port)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 2b6847f0ea72..93440fd8c2bf 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -914,7 +914,8 @@ static void sci_poll_put_char(struct uart_port *port, unsigned char c)
} while (!(status & SCxSR_TDxE(port)));
sci_serial_out(port, SCxTDR, c);
- s->ops->clear_SCxSR(port, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port));
+ if (!s->has_tdxe_auto_clear)
+ s->ops->clear_SCxSR(port, SCxSR_TDxE_CLEAR(port) & ~SCxSR_TEND(port));
}
#endif /* CONFIG_CONSOLE_POLL || CONFIG_SERIAL_SH_SCI_CONSOLE ||
CONFIG_SERIAL_SH_SCI_EARLYCON */
@@ -1050,7 +1051,8 @@ static void sci_transmit_chars(struct uart_port *port)
port->icount.tx++;
} while (--count > 0);
- s->ops->clear_SCxSR(port, SCxSR_TDxE_CLEAR(port));
+ if (!s->has_tdxe_auto_clear)
+ s->ops->clear_SCxSR(port, SCxSR_TDxE_CLEAR(port));
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
uart_write_wakeup(port);
@@ -3660,6 +3662,7 @@ static const struct sci_of_data of_sci_sci = {
.ops = &sci_port_ops,
.uart_ops = &sci_uart_ops,
.params = &sci_port_params[SCIx_SCI_REGTYPE],
+ .tdxe_auto_clear = true,
};
static const struct of_device_id of_sci_match[] __maybe_unused = {
@@ -3798,6 +3801,7 @@ static struct plat_sci_port *sci_parse_dt(struct platform_device *pdev,
sp->ops = data->ops;
sp->port.ops = data->uart_ops;
sp->params = data->params;
+ sp->has_tdxe_auto_clear = data->tdxe_auto_clear;
sp->has_rtscts = of_property_read_bool(np, "uart-has-rtscts");
@@ -4084,6 +4088,7 @@ int __init scix_early_console_setup(struct earlycon_device *device,
sci_ports[0].params = data->params;
sci_ports[0].ops = data->ops;
sci_ports[0].port.ops = data->uart_ops;
+ sci_ports[0].has_tdxe_auto_clear = data->tdxe_auto_clear;
sci_uart_earlycon = true;
regs = sci_ports[0].params->common_regs;
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 6/7] serial: sh-sci: Toggle TE when restoring SCSCR in console write on SCI
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
` (4 preceding siblings ...)
2026-11-17 23:40 ` [PATCH v5 5/7] serial: sh-sci: Skip TDxE clear when hardware clears it automatically Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
2026-11-17 23:40 ` [PATCH v5 7/7] serial: rsci: Simplify rsci_transmit_chars() Diogo Ivo
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
Diogo Ivo
From: Au Dang <au.dang.jx@renesas.com>
When SCI0 (PORT_SCI) is the system console on RZ/G2UL, the board can
hang at the serial console output stage during boot.
ftrace shows the following sequence:
1. sci_transmit_chars() is draining the TX kfifo through TXI
interrupts with SCSCR=0xf0 (TE=1, TIE=1, RE=1, RIE=1).
2. serial_console_write() runs in the middle of that drain. It saves
SCSCR=0xf0, switches to polling by writing SCSCR=0x30 (TE=1, TIE=0)
and outputs the characters with sci_poll_put_char().
3. It then restores SCSCR=0xf0 in a single write. TE is 1 both before
and after, so there is no TE transition.
4. sci_start_tx() is then called repeatedly with SCSCR unchanged, but
no TXI is ever raised again, so the drain never resumes and the
console hangs.
The RZ/G2UL User's Manual (section 23.3.6, "SCI Initialization") notes
that changing SCR.TE from 1 to 0 or from 0 to 1 while SCR.TIE is 1
generates a TXI interrupt request. Without a TE transition, the TXI
that would restart the drain is never generated.
For PORT_SCI, restore SCSCR in two steps: first with TE cleared, then
with the full saved value. This forces the TE 1->0->1 transition while
TIE is being re-enabled, so TXI fires and the interrupted drain
resumes.
Signed-off-by: Au Dang <au.dang.jx@renesas.com>
Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/sh-sci.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/serial/sh-sci.c b/drivers/tty/serial/sh-sci.c
index 93440fd8c2bf..f5194cfa3364 100644
--- a/drivers/tty/serial/sh-sci.c
+++ b/drivers/tty/serial/sh-sci.c
@@ -3452,10 +3452,14 @@ static void serial_console_write(struct console *co, const char *s,
cpu_relax();
/* restore the SCSCR */
- if (sci_port->ops->finish_console_write)
+ if (sci_port->ops->finish_console_write) {
sci_port->ops->finish_console_write(port, ctrl);
- else
+ } else {
+ if (sci_port->type == PORT_SCI)
+ sci_port->ops->write_reg(port, regs->control, ctrl & ~SCSCR_TE);
+
sci_port->ops->write_reg(port, regs->control, ctrl);
+ }
if (locked)
uart_port_unlock_irqrestore(port, flags);
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH v5 7/7] serial: rsci: Simplify rsci_transmit_chars()
2026-11-17 23:40 [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports Diogo Ivo
` (5 preceding siblings ...)
2026-11-17 23:40 ` [PATCH v5 6/7] serial: sh-sci: Toggle TE when restoring SCSCR in console write on SCI Diogo Ivo
@ 2026-11-17 23:40 ` Diogo Ivo
6 siblings, 0 replies; 8+ messages in thread
From: Diogo Ivo @ 2026-11-17 23:40 UTC (permalink / raw)
To: Greg Kroah-Hartman, Jiri Slaby
Cc: linux-serial, linux-kernel, linux-renesas-soc, Biju Das, Au Dang,
Geert Uytterhoeven, Wolfram Sang, Lad Prabhakar, Thierry Bultel,
Diogo Ivo
Now that sci_er_interrupt() no longer calls sci_tx_interrupt() on RSCI
ports, rsci_transmit_chars() is only invoked when CSR.TDRE and CCR0.TE
are set.
Drop the redundant CCR0.TIE manipulation in the !CSR_TDRE guard and
call rsci_stop_tx() instead of open-coding the CCR0.TIE/CCR0.TEIE
update when transmission stops.
Signed-off-by: Diogo Ivo <diogo.ivo.sx@renesas.com>
---
drivers/tty/serial/rsci.c | 19 ++++---------------
1 file changed, 4 insertions(+), 15 deletions(-)
diff --git a/drivers/tty/serial/rsci.c b/drivers/tty/serial/rsci.c
index 05703bb31afd..80087be11808 100644
--- a/drivers/tty/serial/rsci.c
+++ b/drivers/tty/serial/rsci.c
@@ -432,19 +432,12 @@ static void rsci_transmit_chars(struct uart_port *port)
{
unsigned int stopped = uart_tx_stopped(port);
struct tty_port *tport = &port->state->port;
- u32 status, ctrl;
+ u32 status;
int count;
status = rsci_serial_in(port, CSR);
- if (!(status & CSR_TDRE)) {
- ctrl = rsci_serial_in(port, CCR0);
- if (kfifo_is_empty(&tport->xmit_fifo))
- ctrl &= ~CCR0_TIE;
- else
- ctrl |= CCR0_TIE;
- rsci_serial_out(port, CCR0, ctrl);
+ if (!(status & CSR_TDRE))
return;
- }
count = rsci_txroom(port);
@@ -467,12 +460,8 @@ static void rsci_transmit_chars(struct uart_port *port)
if (kfifo_len(&tport->xmit_fifo) < WAKEUP_CHARS)
uart_write_wakeup(port);
- if (kfifo_is_empty(&tport->xmit_fifo) || stopped) {
- ctrl = rsci_serial_in(port, CCR0);
- ctrl &= ~CCR0_TIE;
- ctrl |= CCR0_TEIE;
- rsci_serial_out(port, CCR0, ctrl);
- }
+ if (kfifo_is_empty(&tport->xmit_fifo) || stopped)
+ rsci_stop_tx(port);
}
static void rsci_receive_chars(struct uart_port *port)
--
2.56.1
^ permalink raw reply [flat|nested] 8+ messages in thread