Repository navigation
Conversation
…ounded TX wait Found during a debug session chasing "no output on COM1". The output loss turned out to be a capture-timing error (attaching to the serial socket after the monitor had already printed), NOT a broken port: with a reader attached before boot, COM1 emits the full boot stream. These are the real defects that session uncovered, none of which required the port to be broken. 1. Serial device paths were given a fabricated I/O address. classify_device_path set `found_serial` if ANY node in a composite path was a serial node, then stamped the device with a hardcoded 0x3F8 when no address had been found. In practice 26 unrelated handles were classified as serial ports, all claiming the same address. The UEFI UART node type carries baud/framing only (baud_rate, data_bits, parity, stop_bits) and no I/O base, so the correct behaviour is to set the address only when the TERMINAL node is serial, and to leave serial-in-the-middle paths address-less instead of inventing one. The 0x3F8 fallback is retained for the terminal-node case with an explicit TODO(serial-discovery): it is an assumption (conventional COM1), not a discovery result, and would program the wrong port on hardware with a non-standard UART base. Proper resolution: ACPI SPCR or the serial device's _CRS I/O resource, or EFI_SERIAL_IO_MODE/MMIO configuration. 2. The driver manager could bind the same class repeatedly. SerialDriver keeps process-wide state in SERIAL_STATE, so binding a second DeviceClass::Serial device overwrote the first while leaving it unowned. The manager now binds single-instance classes (currently Serial) at most once, snapshotted before the mutable device loop. Marked TODO(single-instance-binding): dedupe by physical resource (I/O base, MMIO range, PCI BDF) so genuinely distinct ports can each bind, and define the ownership rule for multi-port hardware. 3. Transmit polling was unbounded inside a lock. SerialPort::write_buffer spun `while line_status() & 0x20 == 0` with SERIAL_STATE held. On a port that never reports THRE that wedges the console permanently, silently, and inside a mutex. The wait is now bounded (wait_transmit_ready) and write_bytes_direct returns Err instead of an unconditional Ok, so callers fall back rather than believing a dropped write succeeded. Verification: - Build clean (pinned nightly-2026-02-18). - Boot with a reader attached to the persistent relay before QEMU starts: 1429 bytes on COM1, 0 page/GP faults, monitor reaches idle loop. - LSR reads 0x60 (THRE set) throughout, confirming the transmitter itself is healthy and that early captures were measuring a quiet period. Docs: - AGENTS.md: replaced the one-line relay note with a channel table (serial/monitor/debugcon/QMP, both ends), the attach-before-boot rule, the headless debugcon-only default, and per-channel proof guidance, so a dev session starts with the right debugging model. - hardware-and-drivers.md: documented both open assumptions, the bounded-wait rationale, and a "never poll hardware unbounded while holding a lock" rule. No root-cause fiction: nothing here claims to have fixed silent COM1 output.
This was referenced Nov 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three real defects found while chasing "no output on COM1". The output loss itself was a measurement error, not a bug — see Root cause was capture timing below. These are the genuine problems that session uncovered, and none of them required the port to be broken.
Root cause was capture timing (not a bug)
The original symptom was 0 bytes on COM1 with debugcon working. That was wrong: I attached
socatto the serial socket after QEMU had booted, so the monitor's one-shot banner had already been written and discarded with no reader attached.Attaching to the persistent relay before launching QEMU proves the port works:
→ 1429 bytes on COM1, 0 faults.
LSR reads
0x60(THRE set) throughout, so the transmitter was healthy the whole time. This PR deliberately does not claim to have fixed silent COM1 output, because there was nothing to fix there.Defects actually fixed
1. Serial device paths got a fabricated I/O address
classify_device_pathsetfound_serialif any node in a composite path was a serial node, then stamped the device with a hardcoded0x3F8when no address had been found. In practice 26 unrelated handles were classified as serial ports, all claiming the same address.The UEFI UART node type carries baud/framing only (
baud_rate,data_bits,parity,stop_bits) — no I/O base. Correct behaviour is to set the address only when the terminal node is serial, and leave serial-in-the-middle paths address-less instead of inventing one.The
0x3F8fallback is retained for the terminal-node case behind an explicitTODO(serial-discovery): it is an assumption (conventional COM1), not a discovery result, and would program the wrong port on hardware with a non-standard UART base.2. The driver manager could bind the same class repeatedly
SerialDriverkeeps process-wide state inSERIAL_STATE, so binding a secondDeviceClass::Serialdevice overwrote the first while leaving it unowned. The manager now binds single-instance classes (currently Serial) at most once, snapshotted before the mutable device loop.Marked
TODO(single-instance-binding): dedupe by physical resource (I/O base, MMIO range, PCI BDF) so genuinely distinct ports can each bind, and define the ownership rule for multi-port hardware.3. Transmit polling was unbounded inside a lock
SerialPort::write_bufferspunwhile line_status() & 0x20 == 0withSERIAL_STATEheld. On a port that never reports THRE that wedges the console permanently, silently, and inside a mutex — turning one dead device into a dead subsystem with no error.The wait is now bounded (
wait_transmit_ready), andwrite_bytes_directreturnsErrinstead of an unconditionalOk, so callers fall back rather than believing a dropped write succeeded.Docs
AGENTS.md— replaced the one-line relay note with a channel table (serial/monitor/debugcon/QMP, both ends), the attach-before-boot rule, the headless debugcon-only default, per-channel proof guidance, and the "don't poll hardware unbounded under a lock" rule. This is the file read at the start of a dev session, so the debugging model is now stated where it will be seen.docs/hardware-and-drivers.md— documented both open assumptions, the bounded-wait rationale, and a new safety rule.Verification
nightly-2026-02-18).Open assumptions
Tracked as a repo issue; the
TODO(serial-discovery)andTODO(single-instance-binding)comments point at the same work:0x3F8rather than being read from ACPI (SPCR /_CRS) orEFI_SERIAL_IO_MODE.