Imagination_BXM-4-64

Client CCB (cCCB — Per-Context Work Queues)

Each submission context (struct rogue_fwif_fwcommoncontext for GEOM, FRAG, or CDM) has its own variable-size circular command ring called the cCCB (Client Command Control Buffer), where the Linux driver (pvr_cccb.c) writes synchronization sequences (UFOs / Sync Checkpoints) and hardware kick commands.


1. Ring Pointers (struct rogue_fwif_cccb_ctl, 32 bytes) ([P])

Field Written By Role
write_offset (Woff) Host (and/or updated via KCCB_CMD_KICK) Next free byte for host writes
read_offset (Roff) Firmware Start of the command currently executing or awaiting retirement
dep_offset (Doff) Firmware Advances past dependency commands (fences/UFO checks) already evaluated
wrap_mask Host (fixed) cccb_size - 1 (power-of-2 alignment)
read_offset2..4 Firmware Auxiliary tracking/prefetch pointers

2. cCCB Command Header (struct rogue_fwif_ccb_cmd_header) — 40 bytes ([P])

Verified by pvr_rogue_fwif_client_check.h:

Offset Type Field Description
0x00 u32 cmd_type Command type (ROGUE_FWIF_CCB_CMD_TYPE_*, with marker 0x2ABC0000 in bits [31:16])
0x04 u32 cmd_size Payload size (in bytes, excluding the 40 B header)
0x08 u32 ext_job_ref External job reference (used in HWR and HWPerf)
0x0C u32 int_job_ref Driver internal sequential job reference
0x10..0x27 struct work_est_kick_data struct rogue_fwif_workest_kick_data (return_data_index, cycles_prediction, deadline — total header size: 40 bytes)

3. cCCB Command Type Catalog ([P])

The values match pvr_rogue_fwif.h exactly (with ROGUE_CMD_MAGIC_DWORD_SHIFTED = 0x2ABC0000 and ROGUE_CCB_TYPE_TASK = BIT(15) = 0x8000). Commands are divided into GPU task commands (TASK, bit 15 set) — which occupy a physical Data Master — and generic / control commands — executed directly by the MIPS core without occupying a DM:

Task Commands (0x2ABC8000 | id)

Public Type (ROGUE_FWIF_CCB_CMD_TYPE_*) Value DM Description
GEOM 0x2ABC80C9 (201) DM2 (GEOM/TA) Geometry / Tiling kick (struct rogue_fwif_cmd_geom)
TQ_3D 0x2ABC80CA (202) DM3 (3D-TQ) Transfer via 3D pipeline (struct rogue_fwif_cmd_transfer)
FRAG 0x2ABC80CB (203) DM3 (FRAG/3D) 3D fragment rendering kick (struct rogue_fwif_cmd_frag)
FRAG_PR 0x2ABC80CC (204) DM3 (PR) Partial Render (SPM) associated with HWRTData
CDM 0x2ABC80CD (205) DM4 (CDM) Compute kick (struct rogue_fwif_cmd_compute)
FBSC_INVALIDATE 0x2ABC80CF (207) — FBSC cache invalidation (when applicable)
PRE_TIMESTAMP 0x2ABC80D1 (209) Any DM Records pre-task timestamp
NULL 0x2ABC80D2 (210) Any DM KickSync Null: does not trigger hardware; immediately advances to retirement and executes UFO/Sync updates (used for pure barriers)
ABORT 0x2ABC80D3 (211) Any DM Aborts pending sequence

K3 Note: TQ_TDM (206) and TQ_2D (208) do not exist on silicon 36.56.104.183.

Generic Commands (0x2ABC0000 | id — Synchronization and Control)

Public Type (ROGUE_FWIF_CCB_CMD_TYPE_*) Value Purpose Firmware Action
FENCE 0x2ABC00D4 (212) List of struct rogue_fwif_ufo (addr, value) Blocks the context while any *(u32 *)ufo.addr != ufo.value
UPDATE 0x2ABC00D5 (213) List of struct rogue_fwif_ufo Writes *(u32 *)ufo.addr = ufo.value for each entry and signals host IRQ
RMW_UPDATE 0x2ABC00D6 (214) Read-Modify-Write update Atomically modifies a UFO word
FENCE_PR 0x2ABC00D7 (215) List of UFOs (partial fence) Used before PR commands / geometry dependency
PRIORITY 0x2ABC00D8 (216) u32 priority Updates dynamic priority of the common context
POST_TIMESTAMP 0x2ABC00D9 (217) Post-task timestamp Records timestamp after completion
UNFENCED_UPDATE 0x2ABC00DA (218) List of struct rogue_fwif_ufo Same as UPDATE, emitted after completion without an extra barrier
UNFENCED_RMW_UPDATE 0x2ABC00DB (219) Unfenced RMW Non-blocking RMW update
PADDING 0x2ABC00DD (221) Wrap-around padding Ignored immediately; advances Roff to 0

4. UFOs and Sync Checkpoints ([P][D])

The mainline drm/imagination driver (pvr_sync.c) implements dma_fence on top of two mechanisms that the firmware handles uniformly via fw_addr addresses:

  1. Classic UFOs (struct rogue_fwif_ufo):
    • Mandatory 32-bit width ([D]): all reads and writes to ufo.addr (FENCE, FENCE_PR, UPDATE, UNFENCED_UPDATE, RMW_UPDATE, UNFENCED_RMW_UPDATE) must be 32-bit (u32). Truncating accesses to 16 bits corrupts the upper half of synchronization counters/states and causes hangs in multi-stage pipelines.
    • Fence (FENCE, 0x2ABC00D4): condition satisfied when *(volatile u32 *)addr == value.
    • Fence PR (FENCE_PR, 0x2ABC00D7): uses a wrap-around-safe signed comparison ((int32_t)(*(volatile u32 *)addr - value) >= 0), allowing the fence to pass when the counter has already advanced past the expected value.
    • Update (UPDATE / UNFENCED_UPDATE): writes *(volatile u32 *)addr = value.
    • Per-command limit ([D]): a fence/update command supports at most 64 UFOs (cnt <= 0x40); commands exceeding this limit must be rejected/logged as an error.
  2. Sync Checkpoints (32-bit public states + bit-0 tag convention) ([P][D]):
    • PVR_SYNC_CHECKPOINT_ACTIVE = 0x00000AC1 (pending — blocks fences waiting for signaling)
    • PVR_SYNC_CHECKPOINT_SIGNALLED = 0x00000519 (completed normally)
    • PVR_SYNC_CHECKPOINT_ERRORED = 0x00000EFF (completed with error — e.g., after HWR)
    • Tagged addressing (bit 0 = 1): when ufo.addr & 1 != 0, the address points to a Sync Checkpoint structure whose aligned base is base = ufo.addr & 0xC1FFFFFC (within the FW Heap):
      • *(volatile u32 *)(base + 0x00): state word (0xAC1 / 0x519 / 0xEFF).
      • *(volatile u32 *)(base + 0x04): reference/signal counter (fw_ref_count), incremented on UPDATE when signaling the checkpoint and, when enabled, on FENCE when consuming the checkpoint.
    • Important error rule: A fence waiting for 0x519 is also unblocked if the checkpoint transitions to 0xEFF (error), preventing cascading deadlocks after an HWR; it is up to the firmware to propagate or allow controlled draining of dependent commands according to the reset policy.
  3. Edge-case rules in cCCB processing ([D]):
    • Last unsatisfied UFO cache: when blocking on a FENCE, the firmware may record (addr, expected) in fwcommoncontext.last_failed_ufo and re-test only that entry upon wake-up, clearing it as soon as it is satisfied (avoiding rescanning the entire UFO array on every interrupt).
    • Empty UPDATE (cmd_size == 0, 0 UFOs): must still advance Roff by the header size, mark update activity, and advance Doff if Doff == Roff.
    • Post-fence rescheduling: when unblocking a context after a FENCE, re-enqueue the corresponding DM (mapping internal geometry/TA type 6 to DM2/GEOM) and signal CR[0x0B00] (MTS_SCHEDULE).

5. Lifecycle of a Job in the cCCB ([D])

For a typical GPU job (for example, a 3D render or Compute dispatch), the host writes the following sequence into the cCCB:

[ FENCE (check inputs) ] → [ TASK (GEOM / FRAG / CDM / TQ_3D) ] → [ UPDATE (signal outputs) ]

The firmware processes this sequence in two phases:

  1. Dispatch Phase (BG Context, HW0):
    • Consumes PADDING and PRIORITY immediately (advancing Roff and Doff).
    • Evaluates FENCE / FENCE_PR:
      • If any UFO is not satisfied: the context remains on the DM waiting queue (waiting_list) without advancing Roff; it will be re-evaluated whenever any other DM executes an UPDATE or a new kick arrives.
      • If all UFOs are satisfied: advances Roff and Doff to the next command.
    • Upon encountering a TASK command:
      • If it is CCB_CMD_TYPE_NULL: retires it immediately and proceeds to the following UPDATEs.
      • If it is GEOM, FRAG, CDM, or TQ_3D: if the corresponding DM is idle, activates MemCtx in the BIF, programs the DM registers, and triggers the hardware. Roff remains pointing to the TASK command while it is executing (to allow CSW or HWR diagnostics).
  2. Retirement Phase (IRQ Context, HW1 → BG reschedule):
    • When the completion interrupt arrives (TA_FINISHED, PIXELBE_END_RENDER, COMPUTE_FINISHED) and it was not a CSW pause:
    • Executes the DM completion flush (exact sequence in data-masters.md §4.1; happens before UPDATE/retirement), increments cleanup_ctl.executed_commands of referenced objects (HWRTData, Context), and advances Roff past the TASK command.
    • Immediately processes all subsequent UPDATE / UNFENCED_UPDATE / PADDING commands up to the next FENCE or TASK (or until Roff == Woff).
    • Ensures the visibility barrier (0xBFC01800 = 1, ehb, sync) and triggers a host IRQ (hwirq 75).
    • Writes to ROGUE_CR_MTS_SCHEDULE (CR[0x0B00] = 0) to wake BG and re-evaluate contexts that were waiting on the newly signaled UFOs.