KMD Logging Mechanism
This page describes how firmware log records are forwarded to the host kernel
module (KMD) through the tt_pcie_log backend.
Overview
The mechanism has two paths:
Control path: KMD sends setup and release messages over the ARC message queue (message ID
TT_SMC_MSG_TT_PCIE_LOG/0xC7).Data path: firmware writes framed log batches into a host DMA buffer and raises a PCIe MSI interrupt so KMD can consume them.
On firmware side, the implementation lives in
lib/tenstorrent/bh_arc/tt_pcie_log.c and is enabled by
CONFIG_TT_PCIE_LOG_BACKEND.
If the CONFIG is not enabled, FW logs will not be sent to host, but FW will enumerate and operate. Other logging backends may be used in conjunction with this backend.
Handshake: Setup And Release
KMD uses sub-commands in tt_pcie_log_rqst:
SETUP (subcmd 1): KMD allocates a coherent DMA buffer and sends DMA
address (low/high 32-bit words) plus buffer size to firmware. Firmware
validates size, configures NOC2AXI access, initializes the header, and starts
periodic flush.
RELEASE (subcmd 2): KMD asks firmware to stop host logging. Firmware
stops the flush timer and returns to local buffering only.
If host is not set up, firmware still formats logs into a local staging buffer. Once setup succeeds, subsequent flushes transfer staged data to host memory.
Data Flow
Zephyr logging calls the backend
processcallback for each message.Firmware writes an entry header plus formatted text into a local framed buffer.
Flush occurs periodically (timer + work queue) or when near local capacity.
During flush: - firmware validates host
magic- firmware checksowneris0(previous batch consumed) - firmware copies bytes to host DMA buffer after the 16-byte buffer header - firmware updateswrite_offset- firmware setsowner = 1(handoff to host) - firmware triggers MSI so KMD can process promptlyKMD interrupt handler schedules work, parses entries, prints them to kernel log with level mapping, then clears
ownerback to0.
Current Behavior Notes
Firmware batches data and sends only when host is ready.
If host has not yet consumed the previous batch, firmware drops the pending local batch for forward progress.
If local staged data exceeds available host payload space, firmware truncates to fit.
Data is currently copied as a contiguous batch (not a true host-side circular producer/consumer protocol yet).
Configuration
Relevant Kconfig options:
CONFIG_TT_PCIE_LOG_BACKEND: enable host logging backend.CONFIG_TT_PCIE_LOG_BACKEND_BUFFER_SIZE: local firmware staging size (default4096bytes).
This backend uses Zephyr text formatting. Other formatters are not supported.
Minimum practical requirement for setup is host buffer size >=
sizeof(fw_log_buffer_header) + sizeof(fw_log_entry_header) + 1.
Troubleshooting
Setup rejected by firmware: check host-provided buffer size and DMA address validity.
No host logs appearing: ensure
CONFIG_TT_PCIE_LOG_BACKEND=yin firmware build and confirm KMD successfully sent setup message and enabled logging.Gaps or dropped records: if host processing is slower than firmware production, batches can be dropped by design. Reduce firmware log volume or increase host consumption responsiveness.
Ensure the KMD version supports the feature