This document details the Data Masters (DMs) present on the SpacemiT K3 (36.56.104.183) and the exact allocation algorithm for the 8 BIF catalogue banks (BIF_CAT_BASE0..7) used before each hardware kick.
36.56.104.183) ([P][O])| DM Index | Mainline Enum | Status on K3 | Associated Physical Units | EVENT_STATUS (0x0130) Event |
MTS Enable |
|---|---|---|---|---|---|
0 |
PVR_FWIF_DM_GP |
Active | General control, MMU Fault, USC trigger, Slave req | 0x200 (b9), 0x1000 (b12), 0x8000 (b15), 0x80000 (b19) |
0x0B58 = 0x89200 |
1 |
PVR_FWIF_DM_TDM |
Absent | (No 2D/TLA/TDM engine on K3) | — | Unused |
2 |
PVR_FWIF_DM_GEOM |
Active | VDM, TE, PPP, PM (ctx 0), TPU/USC (vertex) | 0x20 (TA_FINISHED, b5), 0x80 (PM_OOM, b7) |
0x0B68 = 0xA0 |
3 |
PVR_FWIF_DM_FRAG |
Active | ISP (6 pipes), PBE (8 MRTs / 3 MRTs in 3D-TQ), ZLS, PM (ctx 1), TPU/USC (pixel) | 0x08 (PIXELBE_END_RENDER, b3); auxiliary 0x100 (PM_3D_MEM_FREE, b8), 0x4000 (ISP_ZLS_END, b14) |
0x0B70 = 0x08 |
4 |
PVR_FWIF_DM_CDM |
Active | CDM, PDS, USC (compute), TPU (0x1858) |
0x04 (COMPUTE_FINISHED, b2) |
0x0B78 = 0x04 |
5 |
PVR_FWIF_DM_RAY |
Absent | (No Ray Tracing on K3) | — | Unused |
BIF_CAT_BASE0..7) ([P][D])The GPU internal bus interface (BIF/MMU) has 8 64-bit Page Catalogue base registers (ROGUE_CR_BIF_CAT_BASE0 .. ROGUE_CR_BIF_CAT_BASE7), spaced 8 bytes apart starting at 0x1200:
| BIF Bank | MMIO Offset (Unicast / Broadcast) | Usage on K3 (36.56.104.183) |
|---|---|---|
| Bank 0 | 0x1200 / BCAST[0x1200] |
Reserved for Firmware / OSID 0 (configured by host; never reused for user contexts!) |
| Bank 1 | 0x1208 / BCAST[0x1208] |
Dynamic slot 0 (user memory contexts) |
| Bank 2 | 0x1210 / BCAST[0x1210] |
Dynamic slot 1 |
| Bank 3 | 0x1218 / BCAST[0x1218] |
Dynamic slot 2 |
| Bank 4 | 0x1220 / BCAST[0x1220] |
Dynamic slot 3 |
| Bank 5 | 0x1228 / BCAST[0x1228] |
Dynamic slot 4 |
| Bank 6 | 0x1230 / BCAST[0x1230] |
Dynamic slot 5 |
| Bank 7 | 0x1238 / BCAST[0x1238] |
Dynamic slot 6 |
BIF_CAT_BASEn register receives the 36-bit physical address of the Page Catalogue (fwmemcontext.pc_dev_paddr, 4 KiB-aligned: bits [31:12] in the low word and bits [7:0] in the high word → 36 physical bits).1..7 to use through the 64-bit BIF_CAT_BASE_INDEX (0x1240) register, replicated per core (base = core * 0x80000, for core = 0 .. CR[0xF308] - 1):| Requester / DM | Word of 0x1240 |
Field (bits) | Write Scope |
|---|---|---|---|
DM0 / GP (req = 0) |
High (+0x04, 0x1244) |
[2:0] (bank & 0x7) |
All cores (0 .. CR[0xF308] - 1) |
DM2 / GEOM (req = 2 or 6) |
Low (+0x00, 0x1240) |
[2:0] (bank & 0x7) |
Active core (core_id * 0x80000) |
DM3 / FRAG (req = 3) |
Low (+0x00, 0x1240) |
[10:8] ((bank & 0x7) << 8) |
All cores (0 .. CR[0xF308] - 1) |
DM4 / CDM (req = 4) |
Low (+0x00, 0x1240) |
[18:16] ((bank & 0x7) << 16) |
All cores (0 .. CR[0xF308] - 1) |
0x1240 / 0x1244 via read-modify-write (clear the target DM’s 3-bit mask before inserting the new bank).MemCtx Activation and Deactivation Algorithm ([D])The firmware maintains a small reference-counted LRU table for the 7 dynamic slots (idx = 0..6, corresponding to physical banks 1..7) (a 1-byte counter per slot + eviction cursor):
idx = memctx->page_cat_base_reg_set and pc_paddr = memctx->pc_dev_paddr.idx < 7 and the current content of CR[0x1208 + idx*8] matches pc_paddr (low word masked with 0xFFFFF000 and high word masked with 0xFF).BIF_CAT_BASE reprogramming is needed.refcount) is 0.refcount == 0 (all 7 banks simultaneously in use — rare since there are only 3 user DMs + PM), returns failure and defers the kick.memctx->page_cat_base_reg_set = idx.sync) and performs MMU invalidation with mask 0x1C (ROGUE_CR_BIF_CTRL_INVAL, BCAST[0x12A0] = 0x1C, followed by polling until 0x12A0 == 0).pc_paddr into BCAST[0x1208 + idx*8] (lo at +0, hi at +4).memctx->flags indicates an active breakpoint (bit 3), configures the breakpoint register for that context.bank = idx + 1 (1..7) into the corresponding field of BIF_CAT_BASE_INDEX (0x1240/0x1244) per the table above.refcount[idx] was 0, removes idx from the evictable (LRU) list.refcount[idx].refcount[0..6] without overwriting adjacent state/cursor fields.HW1)refcount[idx] of the slot associated with memctx.refcount[idx] reaches 0, returns idx to the tail of the LRU list (keeping BIF_CAT_BASE populated to maximize cache hits on subsequent kicks from the same context!).KCCB_CMD_CLEANUP for an fwmemcontext or after an HWR reset, invalidates the slot entry (page_cat_base_reg_set = 0xFFFFFFFF) and clears all counters on HWR reset.[P][D])The two invalidation primitives used on the K3 (36.56.104.183):
| Operation | Register Sequence | Mandatory Poll |
|---|---|---|
| MMU Cache Invalidation (BIF) | BCAST[0x12A0] = mask (e.g., 0x1C for PC/PD/PT in BIF, or flags & 0xF via KCCB_CMD_MMUCACHE) |
Poll CR[0x12A0] until == 0 |
| SLC Flush/Invalidation | BCAST[0x3818] = op (0x10 = global flush+inval or per-DM bits in ROGUE_CR_SLC_CTRL_FLUSH_INVAL) |
Poll ROGUE_CR_SLC_STATUS0 (CR[0x3820]) until completion |
| PM/BIF Memory Flush/Invalidation | If (flags & 0x10) in KCCB_CMD_MMUCACHE: BCAST[0x1348] = 1 |
Poll CR[0x1348] bit 0 == 0 |
| Post-Kick DM Cache Invalidation | Full per-DM sequence in §4.1 (not a single register) | Explicit polls in §4.1 |
[D])The firmware uses three sibling routines (one per user DM) called in the completion handler before retiring the cCCB command (hence before any UFO/Sync Checkpoint UPDATE that releases the host). The skeleton is shared; what differs is the value written to each register and one extra block that runs only for DM3.
| Step | GEOM (DM2) | FRAG/3D (DM3) | CDM (DM4) |
|---|---|---|---|
| 1. unified store / drain | BCAST[0x4000] = 1 |
BCAST[0x4000] = 1 |
BCAST[0x4000] = 1 |
| 2. per-core cache trigger | CR[core*0x80000+0x0688] = 1 |
= 2 |
= 4 |
| 3. poll step 2 | 0x0688 == 0 (core bit) |
same | same |
| 4. DM cache block | BCAST[0x0668] = 5 |
BCAST[0x0668] = 3 |
BCAST[0x0668] = 9 |
| 5. poll step 4 | 0x0668 bit 0 == 0 |
same | same |
| 6. TPU/USC block | BCAST[0x1608] = 0x10001 |
BCAST[0x1608] = 0x38001 |
BCAST[0x1608] = 0x10001 |
| 7. poll step 6 | 0x1608 bit 0 == 0 |
same | same |
| 8. DM3 only: internal caches | — | BCAST[0x1480] = 1, BCAST[0x1470] = 1, BCAST[0x1478] = 1; poll 0x1470 and 0x1478 (bit 0 == 0) |
— |
| 9. final invalidate | BCAST[0x1488] = 1 |
same | same |
| 10. write filter | BCAST[0x1744] = 0x80 |
= 0x180 |
= 0x280 |
| 11. MCU fence | BCAST[0x1740] = 0 (ROGUE_CR_MCU_FENCE) |
same | same |
| 12. clean trigger | BCAST[0x1720] = 7 (GP context) / 0x27 (others) |
= 0xb / 0x2b |
= 0x13 / 0x33 |
| 13. poll step 12 | BCAST[0x1728] bit 0 == 0 |
same | same |
| 14. wrapper barrier | only when DM is not GP: 0xBFC01800 = 1, ehb, sync |
same | same |
| 15. SLC flush/inval | BCAST[0x3818] = 2 (DM_TA) |
= 6 (DM_TA \| DM_PIXEL) |
= 8 (DM_COMPUTE) |
| 16. SLC poll | ROGUE_CR_SLC_STATUS0 (0x3820) bit 2 == 0, per core |
same | same |
Implementation notes:
BCAST = block broadcast alias (0xCFA00000); the firmware writes equivalently to the per-core bank (0xCF800000 + core*0x80000 + offset). In step 2 the register is per-core, so the poll routine takes the core mask.context == NULL) is the global flush path: it writes BCAST[0x3818] = 2/6/8 according to the DM and polls the SLC without a core mask.EVENT_STATUS event that triggers the routine is cleared before it (BCAST[0x0138] = DM bit), and the command is retired after — guaranteeing that the host never observes the fence before data reaches DRAM.SLC_CTRL_FLUSH_INVAL primitive accepts any register mask; for DM2 it uses the per-core path (value 2 in the core bank), and for the others it uses broadcast with the supplied value.