Skip to content

Fix transmit handling on SCI/RSCI ports

Diogo Ivo linux-renesas-soc linux-serial lkml stable 5 versions – In review

Get series with b4
b4 am [email protected] change-id 20261020-g2ul_sci-b610606ea5b5

Versions newest first

  1. v5 Latest7 patches 1 replyIn review
  2. v47 patches 2 repliesSuperseded
  3. v34 patches 10 repliesSuperseded
Earlier versions · 2
VersionPostedPatchesRepliesStatus
v24 patches2 repliesSuperseded inferred link
v14 patches4 repliesSuperseded

Changes in v5 from the cover letter

* Patch 2:
- 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.
- Link to v4: https://patch.msgid.link/[email protected]

Patches in v5 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/7serial: sh-sci: Drop TE disable at end of transmission on SCIdrivers/tty/serial/sh-sci.c+0 -70 replies
2/7serial: sh-sci: Keep TX enabled on TEI while data is pendingdrivers/tty/serial/rsci.c drivers/tty/serial/sh-sci-common.h drivers/tty/serial/sh-sci.c+38 -130 replies
3/7serial: rsci: Enable transmit end interrupt in rsci_stop_tx()drivers/tty/serial/rsci.c+2 -00 replies
4/7serial: sh-sci: Do not kick TX from sci_er_interrupt() on RSCIdrivers/tty/serial/sh-sci.c+1 -10 replies
5/7serial: sh-sci: Skip TDxE clear when hardware clears it automaticallydrivers/tty/serial/sh-sci-common.h drivers/tty/serial/sh-sci.c+9 -20 replies
6/7serial: sh-sci: Toggle TE when restoring SCSCR in console write on SCIdrivers/tty/serial/sh-sci.c+6 -20 replies
7/7serial: rsci: Simplify rsci_transmit_chars()drivers/tty/serial/rsci.c+4 -150 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v5 yet.

Read the v5 thread

Cover letter [PATCH v5 0/7] Fix transmit handling on SCI/RSCI ports

Hi all,

This is v5 of the SCI/RSCI transmit fixes originally posted by Biju Das. Patches 1, 5 and 6 retain the v3 code and descriptions from Biju and Au Dang, patch 2 is updated to address v4 review feedback, and patches 3, 4 and 7 incorporate additional RSCI fixes.

The series addresses transmit stalls, duplicated output and spurious interrupts on the SCI (PORT_SCI) and RSCI ports of the sh-sci driver:

- Patch 1 removes the code that disables TE at the end of a transmission on SCI, which the hardware manual does not describe.
- Patch 2 stops the TEI handler from turning the transmitter off while hardware or software TX data is still pending, which could stall or cut off output. It also covers the TE handling that patch 1 no longer does in sci_transmit_chars().
- Patch 3 enables TEIE in rsci_stop_tx() when TE is set, allowing transmit-end handling to clear TE after the hardware FIFO drains.
- Patch 4 avoids kicking RSCI transmission from the receive-error handler, which could otherwise cause spurious TEI interrupts or leave the transmitter in a state that stalls later output.
- Patch 5 skips the software clear of the TDxE flag on SCI, since hardware clears it on a TDR write and the extra clear caused a spurious TXI and a duplicated last character.
- Patch 6 forces a TE toggle when restoring SCSCR in the console write path on SCI, so the TXI that restarts an interrupted drain is generated. Without it the RZ/G2UL console can hang during boot.
- Patch 7 simplifies rsci_transmit_chars() now that the receive-error handler no longer invokes it, and reuses rsci_stop_tx().

OpenCode (GPT-6.1 Sol and Gemini 4 Argon) assisted with reviewing the previous discussion, preparing and reordering this series, updating trailers and recipients, and drafting this cover letter, as well as helping debug the various edge cases and proposing code changes.

Changes in v5:
* Patch 2:
- 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.
- Link to v4: https://patch.msgid.link/[email protected]

Changes in v4:
* Trim unrelated x86/TDX recipients identified in the v3 discussion.
* Keep the code and descriptions of the four v3 patches unchanged.
* Add patch 3 to enable transmit-end interrupts in rsci_stop_tx().
* Add patch 4 to avoid kicking RSCI TX from the receive-error handler.
* Add patch 7 to simplify rsci_transmit_chars().
* Group patches with Fixes tags first (patches 1-4) and mark them for
stable.
* Base the combined series on next-20261019.
- Link to v3: https://lore.kernel.org/all/[email protected]/

Changes in v3:
* Updated commit description for patch#2
* When the port is stopped with data still queued, the transmit_chars() paths (sci_transmit_chars() and rsci_transmit_chars()) now also swap
TIE for TEIE, as they already did for an empty kfifo. Without this, TIE would keep firing with nothing the driver is allowed to send, and TEI would never be raised to complete the transmission.
* Replaced sci_tx_interrupt() with port's transmit_chars() to avoid
lock drop race in sci_tx_end_interrupt() before TX handoff.
* Added missing has_tdxe_auto_clear init in scix_early_console_setup().
* Replaced to_sci_port(port)->type with sci_port->type in serial_console_write().
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
* Updated commit header and description for patch#2 and #3.
* Take the port lock before reading the control register, so the read-modify-write in sci_tx_end_interrupt() is protected.
* Extended the pending-data check in sci_tx_end_interrupt() to cover x_char and a stopped port, not only a non-empty xmit kfifo.
* Replaced the PORT_SCI check with a has_tdxe_auto_clear flag in
struct sci_port, set from the new tdxe_auto_clear field in
struct sci_of_data.
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Au Dang (2):
serial: sh-sci: Skip TDxE clear when hardware clears it automatically
serial: sh-sci: Toggle TE when restoring SCSCR in console write on SCI

Biju Das (2):
serial: sh-sci: Drop TE disable at end of transmission on SCI
serial: sh-sci: Keep TX enabled on TEI while data is pending

Diogo Ivo (3):
serial: rsci: Enable transmit end interrupt in rsci_stop_tx()
serial: sh-sci: Do not kick TX from sci_er_interrupt() on RSCI
serial: rsci: Simplify rsci_transmit_chars()

 drivers/tty/serial/rsci.c          | 23 +++++-------
 drivers/tty/serial/sh-sci-common.h |  4 +++
 drivers/tty/serial/sh-sci.c        | 71 +++++++++++++++++++++++++-------------
 3 files changed, 59 insertions(+), 39 deletions(-)

---
base-commit: 3d229ce89862b8e82d71a9e11d6f840ca272a6d6
change-id: 20261020-g2ul_sci-b610606ea5b5

Best regards,

Signature · 1 line
Diogo Ivo <[email protected]>