Imagination_BXM-4-64

HWPerf and Firmware Trace Buffer (hwperf-trace)

This document describes the two shared telemetry mechanisms between firmware and host on the SpacemiT K3 (36.56.104.183): the FW Trace Buffer (structured event logs) and HWPerf V2B (timestamped event stream and hardware performance counters).


1. Firmware Circular Trace Buffer (struct rogue_fwif_tracebuf) ([P][D])

The mainline driver (pvr_fw_trace.c / pvr_fw_trace.h) exposes firmware logs via debugfs by reading a circular ring of dwords in shared memory:

Field Description
log_type (u32) Bitmask of enabled log groups (updatable at runtime via KCCB_CMD_LOGTYPE_UPDATE) + ROGUE_FWIF_LOG_TYPE_TRACE flag
tracebuf_space[0].trace_pointer (u32) Current write index (0 .. ROGUE_FW_TRACE_BUF_DEFAULT_SIZE_IN_DWORDS - 1)
tracebuf_space[0].trace_buffer_fw_addr fw_addr of the 12,000-dword (48,000-byte) buffer for MIPS thread 0

Format of Each Entry in the Trace Buffer ([P])

Each message written by the firmware consists of 3 + N 32-bit words (N = 0..20, parameter count encoded in the SF ID):

Word Content
0 String Format ID (sf_id): 0x70000000 \| (N << 16) \| (group_id << 12) \| seq_id (see trace-ids.md)
1 Timestamp Low (CR_TIMER bits [31:0])
2 Timestamp High (CR_TIMER bits [47:32] in bits [15:0]) + 16 bits of metadata/debug in bits [31:16]
3 .. 3+N-1 The N u32 arguments corresponding to the format string in pvr_rogue_fwif_sf.h

2. HWPerf V2B Stream ([P][O][D])

HWPerf provides high-resolution tracing of firmware events (HW0/HW1 start/end), hardware events (TA, 3D, PR, 3D-TQ, CDM kicks and completions), CSW events (store/resume), power/clock transitions, and performance counter samples.

Control via KCCB ([P])

The 6 Counter Mux Blocks of the BXM-4-64 (36.56.104.183) ([O])

Validated on the SpacemiT K3 Pico ITX board (capture of 830 continuous periods):

# Mux Block Measured Domain
1 TA_Blk Geometry / Tiling Engine / VDM
2 RASTER_Blk Rasterization / ISP (6 pipes)
3 HUB_Blk Memory Hub / BIF / PM
4 TPU_MCU_ALL Texture Processing Unit (TPU) and MCU
5 USC_ALL Unified Shading Cluster (shader ALU / cycles / slots)
6 PBE_ALL Pixel Back-End (render target writes / compression)

Main HWPerf Packet Categories Emitted by Firmware ([P][D])


3. Clean-Room Implementation Recommendations


Counter Blocks and Mux Programming ([O])

The BXM-4-64 exposes 6 counter blocks with mux registers in broadcast space (plus 5 ID-only blocks without mux registers):

Block sel base (mux) counter enable
TA_BLK 0x7600 0x7608 —
RASTER_BLK 0x7700 0x7708 —
HUB_BLK (BIF/PMCACHE) 0x7800 0x7808 —
TPU_MCU_ALL 0x7900 0x7908 0x8028
USC_ALL 0x8100 0x8108 0x8030
PBE_ALL 0x83D8 0x8478 —

Five ID-only blocks: TORNADO, JONES, TEXAS0, RASTER0, BLACKPEARL0.

Programming (per enabled block)

if enable exists:  BCAST[enable_off] = (block group)
for i in 0 .. num_mux-1:
    addr = BCAST[mux_base + (i << shift)]        # shift = 3, 8 B per mux
    if (mask & (1 << i)): *(u64 *)addr = mux_value[i]
    else:                 *(u64 *)addr = 0
BCAST[sel] = mask << 1
BCAST[sel] = (enable != 0)

After all blocks: counts active blocks, performs D-cache flush + fence + dynamic TLB invalidation, and, if HWPerf logging is enabled, emits the “mux configured” packet.

PBE detail: the 4th mux is at 0x84A0 (not 0x8498) — a documented exception for this block.

Per-Block Enable

Individual enabling is dispatched by block_id (0..0x6F). The value written to enable/disable counters is always 1 and requires no poll.