Skip to content

Commit 2ca40d0

Browse files
taha-auclaude
andcommitted
devices: serial: assert THRE when the TX interrupt is enabled
A real 16550 raises the THRE (transmit-holding-register-empty) interrupt the moment it is enabled while the THR is empty. CH flushes TX synchronously, so the THR is always empty, but it only signalled THRE on register writes, never on IER enable. Interrupt-driven TX drivers (Windows serial.sys) that enable the interrupt and wait for THRE before writing the first byte therefore deadlocked: the write timed out and no bytes ever reached the host serial log. Assert thr_empty() on the IER enable path so the first interrupt fires and TX progresses. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 026c1ff commit 2ca40d0

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

devices/src/legacy/serial.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,15 @@ impl Serial {
259259
self.thr_empty()?;
260260
}
261261
}
262-
IER => self.interrupt_enable = v & IER_FIFO_BITS,
262+
IER => {
263+
self.interrupt_enable = v & IER_FIFO_BITS;
264+
// A real 16550 asserts the THRE interrupt as soon as it is enabled
265+
// while the THR is empty. CH flushes TX synchronously so the THR is
266+
// always empty; without this, interrupt-driven TX drivers (Windows
267+
// serial.sys) that enable the interrupt and wait before writing the
268+
// first byte deadlock (write times out, no bytes emitted).
269+
self.thr_empty()?;
270+
}
263271
LCR => self.line_control = v,
264272
MCR => self.modem_control = v,
265273
SCR => self.scratch = v,

0 commit comments

Comments
 (0)